more dispatchresult changes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8013 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-11-01 15:45:19 +00:00
parent eeb6a77860
commit cc719fe0ce
41 changed files with 341 additions and 318 deletions

View File

@ -1279,7 +1279,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
break;
default:
return bv_->getLyXText()->dispatch(FuncRequest(ev, bv_)) >= DispatchResult(DISPATCHED);
return bv_->getLyXText()->dispatch(FuncRequest(ev, bv_)).dispatched();
} // end of switch
return true;

View File

@ -1,3 +1,14 @@
2003-11-01 Lars Gullik Bjønnes <larsbj@gullik.net>
* text3.C:
* lyxfunc.C:
* cursor.C (dispatch):
* BufferView_pimpl.C (dispatch): adjust for DispatchResult changes
* dispatchresult.h: remove UNDISPATCHED, DISPATCHED and
DISPATCHED_NOUPDATE from dispatch_result_t, add NONE. Add a
contructor, add a class function dispatched. Remove operator>=
2003-11-01 Lars Gullik Bjønnes <larsbj@gullik.net>
* debug.C: only use the default constructor for debugstream

View File

@ -32,17 +32,16 @@ DispatchResult Cursor::dispatch(FuncRequest const & cmd)
DispatchResult res = data_[i].inset_->dispatch(cmd);
lyxerr << " result: " << res.val() << endl;
if (res == DispatchResult(DISPATCHED)) {
//update();
return DispatchResult(DISPATCHED);
if (res.dispatched()) {
if (res.val() != NOUPDATE) {
//update();
}
return DispatchResult(true);
}
if (res == DispatchResult(DISPATCHED_NOUPDATE))
return DispatchResult(DISPATCHED);
lyxerr << "# unhandled result: " << res.val() << endl;
}
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}

View File

@ -14,24 +14,23 @@
#define DISPATCH_RESULT_H
/** Dispatch result codes
DISPATCHED = the inset catched the action
DISPATCHED_NOUPDATE = the inset catched the action and no update
is needed here to redraw the inset
DISPATCHED = the inset caught the action
DISPATCHED_NOUPDATE = the inset caught the action and no update
is needed to redraw the inset
FINISHED = the inset must be unlocked as a result
of the action
FINISHED_RIGHT = FINISHED, but put the cursor to the RIGHT of
FINISHED_RIGHT = FINISHED, but move the cursor RIGHT from
the inset.
FINISHED_UP = FINISHED, but put the cursor UP of
FINISHED_UP = FINISHED, but move the cursor UP from
the inset.
FINISHED_DOWN = FINISHED, but put the cursor DOWN of
FINISHED_DOWN = FINISHED, but move the cursor DOWN from
the inset.
UNDISPATCHED = the action was not catched, it should be
dispatched by lower level insets
*/
enum dispatch_result_t {
UNDISPATCHED = 0,
DISPATCHED,
DISPATCHED_NOUPDATE,
NONE = 0,
NOUPDATE,
FINISHED,
FINISHED_RIGHT,
FINISHED_UP,
@ -45,11 +44,18 @@ enum dispatch_result_t {
class DispatchResult {
public:
DispatchResult()
: val_(UNDISPATCHED) {}
: dispatched_(false), val_(NONE) {}
explicit
DispatchResult(dispatch_result_t val) : val_(val) {}
DispatchResult(bool dis)
: dispatched_(dis), val_(NONE) {}
DispatchResult(bool dis, dispatch_result_t val)
: dispatched_(dis), val_(val) {}
dispatch_result_t val() const { return val_; }
bool dispatched() const {
return dispatched_;
}
private:
bool dispatched_;
dispatch_result_t val_;
};
@ -57,7 +63,7 @@ private:
inline
bool operator==(DispatchResult const & lhs, DispatchResult const & rhs)
{
return lhs.val() == rhs.val();
return lhs.dispatched() == rhs.dispatched() && lhs.val() == rhs.val();
}
@ -67,13 +73,4 @@ bool operator!=(DispatchResult const & lhs, DispatchResult const & rhs)
return !(lhs == rhs);
}
// This operator is temporary, will be removed with the introduction of
// a status field in DispatchResult.
inline
bool operator>=(DispatchResult const & lhs, DispatchResult const & rhs)
{
return lhs.val() >= rhs.val();
}
#endif // DISPATCH_RESULT_H

View File

@ -1,12 +1,16 @@
2003-11-01 Lars Gullik Bjønnes <larsbj@gullik.net>
* insets: adjust for DispatchResult changes.
2003-11-01 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* insetpagebreak.C: fix screen representation & ascii output.
2003-11-01 Alfredo Braunstein <abraunst@libero.it>
* inset.[Ch]:
* insettext.[Ch]:
* insettabular.[Ch]:
* inset.[Ch]:
* insettext.[Ch]:
* insettabular.[Ch]:
* insetcollapsable.[Ch]: bool haveParagraphs() -> int numParagraphs()
2003-10-31 José Matos <jamatos@lyx.org>

View File

@ -33,5 +33,5 @@ InsetBase::dispatch(FuncRequest const & f)
DispatchResult
InsetBase::priv_dispatch(FuncRequest const &, idx_type &, pos_type &)
{
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}

View File

@ -67,17 +67,17 @@ InsetBibitem::priv_dispatch(FuncRequest const & cmd,
case LFUN_INSET_EDIT:
InsetCommandMailer("bibitem", *this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p);
if (p.getCmdName().empty())
return DispatchResult(DISPATCHED);
return DispatchResult(true);
setParams(p);
cmd.view()->updateInset(this);
cmd.view()->fitCursor();
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
default:

View File

@ -96,19 +96,19 @@ InsetBibtex::priv_dispatch(FuncRequest const & cmd,
case LFUN_INSET_DIALOG_SHOW:
InsetCommandMailer("bibtex", *this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_RELEASE:
if (button().box().contains(cmd.x, cmd.y))
InsetCommandMailer("bibtex", *this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p);
if (p.getCmdName().empty())
return DispatchResult(DISPATCHED);
return DispatchResult(true);
setParams(p);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
default:

View File

@ -177,16 +177,16 @@ InsetBox::priv_dispatch(FuncRequest const & cmd,
InsetBoxMailer::string2params(cmd.argument, params_);
setButtonLabel();
bv->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_INSET_DIALOG_UPDATE:
InsetBoxMailer(*this).updateDialog(bv);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_RELEASE:
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
InsetBoxMailer(*this).showDialog(bv);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
// fallthrough:

View File

@ -130,20 +130,20 @@ InsetBranch::priv_dispatch(FuncRequest const & cmd,
params_.branch = params.branch;
setButtonLabel();
bv->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_INSET_EDIT:
if (cmd.button() != mouse_button::button3)
return InsetCollapsable::priv_dispatch(cmd, idx, pos);
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
case LFUN_INSET_DIALOG_UPDATE:
InsetBranchMailer("branch", *this).updateDialog(bv);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_RELEASE:
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
InsetBranchMailer("branch", *this).showDialog(bv);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
// fallthrough:
default:

View File

@ -316,7 +316,7 @@ InsetCitation::priv_dispatch(FuncRequest const & cmd,
switch (cmd.action) {
case LFUN_INSET_EDIT:
InsetCommandMailer("citation", *this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
return InsetCommand::priv_dispatch(cmd, idx, pos);

View File

@ -234,7 +234,7 @@ void InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
bv->updateInset(this);
bv->buffer()->markDirty();
} else if (!collapsed_ && cmd.y > button_dim.y2) {
ret = inset.dispatch(adjustCommand(cmd)) == DispatchResult(DISPATCHED);
ret = inset.dispatch(adjustCommand(cmd)) == DispatchResult(true);
}
if (cmd.button() == mouse_button::button3 && !ret)
showInsetDialog(bv);
@ -310,14 +310,14 @@ InsetCollapsable::priv_dispatch(FuncRequest const & cmd,
if (bv->lockInset(this))
inset.dispatch(cmd);
}
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
#ifdef WITH_WARNINGS
#warning Fix this properly in BufferView_pimpl::workAreaButtonRelease
#endif
if (cmd.button() == mouse_button::button3)
return DispatchResult(DISPATCHED);
return DispatchResult(true);
UpdatableInset::priv_dispatch(cmd, idx, pos);
@ -327,13 +327,13 @@ InsetCollapsable::priv_dispatch(FuncRequest const & cmd,
// it was already collapsed!
first_after_edit = true;
if (!bv->lockInset(this))
return DispatchResult(DISPATCHED);
return DispatchResult(true);
bv->updateInset(this);
bv->buffer()->markDirty();
inset.dispatch(cmd);
} else {
if (!bv->lockInset(this))
return DispatchResult(DISPATCHED);
return DispatchResult(true);
if (cmd.y <= button_dim.y2) {
FuncRequest cmd1 = cmd;
cmd1.y = 0;
@ -341,26 +341,26 @@ InsetCollapsable::priv_dispatch(FuncRequest const & cmd,
} else
inset.dispatch(adjustCommand(cmd));
}
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_MOUSE_PRESS:
if (!collapsed_ && cmd.y > button_dim.y2)
inset.dispatch(adjustCommand(cmd));
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_MOTION:
if (!collapsed_ && cmd.y > button_dim.y2)
inset.dispatch(adjustCommand(cmd));
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_RELEASE:
lfunMouseRelease(cmd);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
DispatchResult result = inset.dispatch(cmd);
if (result >= DispatchResult(FINISHED))
DispatchResult const result = inset.dispatch(cmd);
if (result.val() >= FINISHED)
bv->unlockInset(this);
first_after_edit = false;
return result;

View File

@ -96,22 +96,22 @@ InsetCommand::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p);
if (p.getCmdName().empty())
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
setParams(p);
cmd.view()->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_INSET_DIALOG_UPDATE:
InsetCommandMailer(cmd.argument, *this).updateDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_RELEASE:
return dispatch(FuncRequest(cmd.view(), LFUN_INSET_EDIT));
default:
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}
}

View File

@ -429,7 +429,7 @@ DispatchResult
InsetERT::priv_dispatch(FuncRequest const & cmd,
idx_type & idx, pos_type & pos)
{
DispatchResult result = DispatchResult(UNDISPATCHED);
DispatchResult result = DispatchResult(false);
BufferView * bv = cmd.view();
if (inset.paragraphs.begin()->empty()) {
@ -466,28 +466,28 @@ InsetERT::priv_dispatch(FuncRequest const & cmd,
*/
inset.getLyXText(cmd.view())->fullRebreak();
bv->updateInset(this);
result = DispatchResult(DISPATCHED);
result = DispatchResult(true);
}
break;
case LFUN_MOUSE_PRESS:
lfunMousePress(cmd);
result = DispatchResult(DISPATCHED);
result = DispatchResult(true);
break;
case LFUN_MOUSE_MOTION:
lfunMouseMotion(cmd);
result = DispatchResult(DISPATCHED);
result = DispatchResult(true);
break;
case LFUN_MOUSE_RELEASE:
lfunMouseRelease(cmd);
result = DispatchResult(DISPATCHED);
result = DispatchResult(true);
break;
case LFUN_LAYOUT:
bv->owner()->setLayout(inset.paragraphs.begin()->layout()->name());
result = DispatchResult(DISPATCHED_NOUPDATE);
result = DispatchResult(true, NOUPDATE);
break;
default:

View File

@ -439,7 +439,7 @@ InsetExternal::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
InsetExternalParams p;
InsetExternalMailer::string2params(cmd.argument, buffer, p);
external::editExternal(p, buffer);
return DispatchResult(DISPATCHED_NOUPDATE);
return DispatchResult(true, NOUPDATE);
}
case LFUN_INSET_MODIFY: {
@ -450,20 +450,20 @@ InsetExternal::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
InsetExternalMailer::string2params(cmd.argument, buffer, p);
setParams(p, buffer);
cmd.view()->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_INSET_DIALOG_UPDATE:
InsetExternalMailer(*this).updateDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_RELEASE:
case LFUN_INSET_EDIT:
InsetExternalMailer(*this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}
}

View File

@ -176,12 +176,12 @@ InsetFloat::priv_dispatch(FuncRequest const & cmd,
wide(params_.wide, cmd.view()->buffer()->params());
cmd.view()->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_INSET_DIALOG_UPDATE: {
InsetFloatMailer(*this).updateDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
default:

View File

@ -127,11 +127,11 @@ InsetFloatList::priv_dispatch(FuncRequest const & cmd,
case LFUN_MOUSE_RELEASE:
if (button().box().contains(cmd.x, cmd.y))
InsetCommandMailer("toc", *this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_INSET_DIALOG_SHOW:
InsetCommandMailer("toc", *this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
return InsetCommand::priv_dispatch(cmd, idx, pos);

View File

@ -203,20 +203,20 @@ InsetGraphics::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
setParams(p);
cmd.view()->updateInset(this);
}
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_INSET_DIALOG_UPDATE:
InsetGraphicsMailer(*this).updateDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_INSET_EDIT:
case LFUN_MOUSE_RELEASE:
InsetGraphicsMailer(*this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}
}

View File

@ -120,24 +120,24 @@ InsetInclude::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
set(p, *cmd.view()->buffer());
cmd.view()->updateInset(this);
}
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_INSET_DIALOG_UPDATE:
InsetIncludeMailer(*this).updateDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_RELEASE:
if (button_.box().contains(cmd.x, cmd.y))
InsetIncludeMailer(*this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_INSET_DIALOG_SHOW:
InsetIncludeMailer(*this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}
}

View File

@ -68,7 +68,7 @@ InsetIndex::priv_dispatch(FuncRequest const & cmd,
switch (cmd.action) {
case LFUN_INSET_EDIT:
InsetCommandMailer("index", *this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
return InsetCommand::priv_dispatch(cmd, idx, pos);

View File

@ -68,14 +68,14 @@ InsetLabel::priv_dispatch(FuncRequest const & cmd,
case LFUN_INSET_EDIT:
InsetCommandMailer("label", *this).showDialog(bv);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
break;
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p);
if (p.getCmdName().empty())
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
bool clean = true;
if (bv && p.getContents() != params().getContents()) {
@ -85,7 +85,7 @@ InsetLabel::priv_dispatch(FuncRequest const & cmd,
setParams(p);
bv->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
default:

View File

@ -112,12 +112,12 @@ InsetMinipage::priv_dispatch(FuncRequest const & cmd,
* with ugliness like this ... */
inset.getLyXText(cmd.view())->fullRebreak();
cmd.view()->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_INSET_DIALOG_UPDATE:
InsetMinipageMailer(*this).updateDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
return InsetCollapsable::priv_dispatch(cmd, idx, pos);

View File

@ -142,22 +142,22 @@ InsetNote::priv_dispatch(FuncRequest const & cmd,
InsetNoteMailer::string2params(cmd.argument, params_);
setButtonLabel();
bv->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_INSET_EDIT:
if (cmd.button() == mouse_button::button3)
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
return InsetCollapsable::priv_dispatch(cmd, idx, pos);
case LFUN_INSET_DIALOG_UPDATE:
InsetNoteMailer("note", *this).updateDialog(bv);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_RELEASE:
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
InsetNoteMailer("note", *this).showDialog(bv);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
// fallthrough:

View File

@ -58,7 +58,7 @@ InsetRef::priv_dispatch(FuncRequest const & cmd,
dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
else
InsetCommandMailer("ref", *this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
return InsetCommand::priv_dispatch(cmd, idx, pos);

View File

@ -599,18 +599,18 @@ void InsetTabular::lfunMousePress(FuncRequest const & cmd)
bool InsetTabular::lfunMouseRelease(FuncRequest const & cmd)
{
DispatchResult ret = DispatchResult(UNDISPATCHED);
DispatchResult ret(false);
if (the_locking_inset) {
FuncRequest cmd1 = cmd;
cmd1.x -= inset_x;
cmd1.y -= inset_y;
ret = the_locking_inset->dispatch(cmd1);
}
if (cmd.button() == mouse_button::button3 && ret == DispatchResult(UNDISPATCHED)) {
if (cmd.button() == mouse_button::button3 && ret == DispatchResult(false)) {
InsetTabularMailer(*this).showDialog(cmd.view());
return true;
}
return ret >= DispatchResult(DISPATCHED);
return ret.dispatched() || ret.val() > FINISHED;
}
@ -680,7 +680,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
if (!bv->lockInset(this)) {
lyxerr << "InsetTabular::Cannot lock inset" << endl;
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
finishUndo();
@ -716,34 +716,34 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
activateCellInset(bv, cmd.x - inset_x, cmd.y - inset_y, cmd.button());
}
}
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
if (result == DispatchResult(DISPATCHED) || result == DispatchResult(DISPATCHED_NOUPDATE)) {
if (result.dispatched()) {
resetPos(bv);
return result;
}
if (cmd.action < 0 && cmd.argument.empty())
return DispatchResult(FINISHED);
return DispatchResult(false, FINISHED);
bool hs = hasSelection();
result = DispatchResult(DISPATCHED);
result = DispatchResult(true);
// this one have priority over the locked InsetText, if we're not already
// inside another tabular then that one get's priority!
if (getFirstLockingInsetOfType(InsetOld::TABULAR_CODE) == this) {
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
lfunMousePress(cmd);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_MOTION:
lfunMouseMotion(cmd);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_RELEASE:
return lfunMouseRelease(cmd) ? DispatchResult(DISPATCHED) : DispatchResult(UNDISPATCHED);
return DispatchResult(lfunMouseRelease(cmd));
case LFUN_CELL_BACKWARD:
case LFUN_CELL_FORWARD:
@ -756,7 +756,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
if (hs)
updateLocal(bv);
if (!the_locking_inset)
return DispatchResult(DISPATCHED_NOUPDATE);
return DispatchResult(true, NOUPDATE);
return result;
// this to avoid compiler warnings.
default:
@ -768,33 +768,35 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
string arg = cmd.argument;
if (the_locking_inset) {
result = the_locking_inset->dispatch(cmd);
if (result == DispatchResult(DISPATCHED_NOUPDATE)) {
int sc = scroll();
resetPos(bv);
if (sc != scroll()) { // inset has been scrolled
if (result.dispatched()) {
if (result.val() == NOUPDATE) {
int const sc = scroll();
resetPos(bv);
if (sc != scroll()) {
// inset has been scrolled
updateLocal(bv);
}
} else {
updateLocal(bv);
}
return result;
} else if (result == DispatchResult(DISPATCHED)) {
updateLocal(bv);
return result;
} else if (result == DispatchResult(FINISHED_UP)) {
} else if (result.val() == FINISHED_UP) {
action = LFUN_UP;
// Make sure to reset status message after
// exiting, e.g. math inset
bv->owner()->clearMessage();
} else if (result == DispatchResult(FINISHED_DOWN)) {
} else if (result.val() == FINISHED_DOWN) {
action = LFUN_DOWN;
bv->owner()->clearMessage();
} else if (result == DispatchResult(FINISHED_RIGHT)) {
} else if (result.val() == FINISHED_RIGHT) {
action = LFUN_RIGHT;
bv->owner()->clearMessage();
} else if (result == DispatchResult(FINISHED)) {
} else if (result.val() == FINISHED) {
bv->owner()->clearMessage();
}
}
result = DispatchResult(DISPATCHED);
result = DispatchResult(true);
switch (action) {
// --- Cursor Movements ----------------------------------
case LFUN_RIGHTSEL: {
@ -960,7 +962,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
break;
case LFUN_TABULAR_FEATURE:
if (!tabularFeatures(bv, arg))
result = DispatchResult(UNDISPATCHED);
result = DispatchResult(false);
break;
// insert file functions
case LFUN_FILE_INSERT_ASCII_PARA:
@ -972,7 +974,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
if (insertAsciiString(bv, tmpstr, false))
updateLocal(bv);
else
result = DispatchResult(UNDISPATCHED);
result = DispatchResult(false);
break;
}
// cut and paste functions
@ -1073,7 +1075,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
default:
// handle font changing stuff on selection before we lock the inset
// in the default part!
result = DispatchResult(UNDISPATCHED);
result = DispatchResult(false);
if (hs) {
switch(action) {
case LFUN_LANGUAGE:
@ -1087,7 +1089,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
case LFUN_UNDERLINE:
case LFUN_FONT_SIZE:
if (bv->dispatch(FuncRequest(bv, action, arg)))
result = DispatchResult(DISPATCHED);
result = DispatchResult(true);
break;
default:
break;
@ -1095,15 +1097,15 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
}
// we try to activate the actual inset and put this event down to
// the insets dispatch function.
if (result == DispatchResult(DISPATCHED) || the_locking_inset)
if (result.dispatched() || the_locking_inset)
break;
if (activateCellInset(bv)) {
result = the_locking_inset->dispatch(FuncRequest(bv, action, arg));
if (result == DispatchResult(UNDISPATCHED) || result >= DispatchResult(FINISHED)) {
if (!result.dispatched()) {
unlockInsetInInset(bv, the_locking_inset);
// we need to update if this was requested before
updateLocal(bv);
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}
if (hs)
clearSelection();
@ -1112,11 +1114,12 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
}
break;
}
if (!(result >= DispatchResult(FINISHED))) {
if (!the_locking_inset && bv->fitCursor())
updateLocal(bv);
} else
if (result.val() >= FINISHED)
bv->unlockInset(this);
else if (!the_locking_inset && bv->fitCursor())
updateLocal(bv);
return result;
}
@ -1404,17 +1407,17 @@ DispatchResult InsetTabular::moveRight(BufferView * bv, bool lock)
{
if (lock && !old_locking_inset) {
if (activateCellInset(bv))
return DispatchResult(DISPATCHED);
return DispatchResult(true);
} else {
bool moved = isRightToLeft(bv)
? movePrevCell(bv) : moveNextCell(bv);
if (!moved)
return DispatchResult(FINISHED_RIGHT);
return DispatchResult(false, FINISHED_RIGHT);
if (lock && activateCellInset(bv))
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
resetPos(bv);
return DispatchResult(DISPATCHED_NOUPDATE);
return DispatchResult(true, NOUPDATE);
}
@ -1422,12 +1425,12 @@ DispatchResult InsetTabular::moveLeft(BufferView * bv, bool lock)
{
bool moved = isRightToLeft(bv) ? moveNextCell(bv) : movePrevCell(bv);
if (!moved)
return DispatchResult(FINISHED);
return DispatchResult(false, FINISHED);
// behind the inset
if (lock && activateCellInset(bv, 0, 0, mouse_button::none, true))
return DispatchResult(DISPATCHED);
return DispatchResult(true);
resetPos(bv);
return DispatchResult(DISPATCHED_NOUPDATE);
return DispatchResult(true, NOUPDATE);
}
@ -1436,7 +1439,7 @@ DispatchResult InsetTabular::moveUp(BufferView * bv, bool lock)
int const ocell = actcell;
actcell = tabular.getCellAbove(actcell);
if (actcell == ocell) // we moved out of the inset
return DispatchResult(FINISHED_UP);
return DispatchResult(false, FINISHED_UP);
resetPos(bv);
if (lock) {
int x = 0;
@ -1446,9 +1449,9 @@ DispatchResult InsetTabular::moveUp(BufferView * bv, bool lock)
x -= cursorx_ + tabular.getBeginningOfTextInCell(actcell);
}
if (activateCellInset(bv, x, 0))
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
return DispatchResult(DISPATCHED_NOUPDATE);
return DispatchResult(true, NOUPDATE);
}
@ -1457,7 +1460,7 @@ DispatchResult InsetTabular::moveDown(BufferView * bv, bool lock)
int const ocell = actcell;
actcell = tabular.getCellBelow(actcell);
if (actcell == ocell) // we moved out of the inset
return DispatchResult(FINISHED_DOWN);
return DispatchResult(false, FINISHED_DOWN);
resetPos(bv);
if (lock) {
int x = 0;
@ -1467,9 +1470,9 @@ DispatchResult InsetTabular::moveDown(BufferView * bv, bool lock)
x -= cursorx_ + tabular.getBeginningOfTextInCell(actcell);
}
if (activateCellInset(bv, x, 0))
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
return DispatchResult(DISPATCHED_NOUPDATE);
return DispatchResult(true, NOUPDATE);
}

View File

@ -546,8 +546,11 @@ bool InsetText::lfunMouseRelease(FuncRequest const & cmd)
cmd1.y -= inset_y;
no_selection = true;
if (the_locking_inset)
return the_locking_inset->dispatch(cmd1) >= DispatchResult(DISPATCHED);
if (the_locking_inset) {
DispatchResult const res = the_locking_inset->dispatch(cmd1);
return res.dispatched() || res.val() >= NOUPDATE;
}
int tmp_x = cmd.x;
int tmp_y = cmd.y + dim_.asc - bv->top_y();
@ -557,7 +560,8 @@ bool InsetText::lfunMouseRelease(FuncRequest const & cmd)
// We still need to deal properly with the whole relative vs.
// absolute mouse co-ords thing in a realiable, sensible way
bool ret = inset->dispatch(cmd1) >= DispatchResult(DISPATCHED);
DispatchResult const res = inset->dispatch(cmd1);
bool const ret = res.dispatched() || res.val() >= NOUPDATE;
updateLocal(bv, false);
return ret;
}
@ -601,7 +605,7 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
if (!bv->lockInset(this)) {
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
locked = true;
@ -649,19 +653,19 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
updateLocal(bv, false);
// Tell the paragraph dialog that we've entered an insettext.
bv->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_MOUSE_PRESS:
lfunMousePress(cmd);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_MOTION:
lfunMouseMotion(cmd);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_RELEASE:
return lfunMouseRelease(cmd) ? DispatchResult(DISPATCHED) : DispatchResult(UNDISPATCHED);
return DispatchResult(lfunMouseRelease(cmd));
default:
break;
@ -671,51 +675,50 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
no_selection = false;
DispatchResult result = UpdatableInset::priv_dispatch(cmd, idx, pos);
if (result != DispatchResult(UNDISPATCHED))
return DispatchResult(DISPATCHED);
if (result.dispatched())
return DispatchResult(true);
result = DispatchResult(DISPATCHED);
result = DispatchResult(true);
if (cmd.action < 0 && cmd.argument.empty())
return DispatchResult(FINISHED);
return DispatchResult(false, FINISHED);
if (the_locking_inset) {
result = the_locking_inset->dispatch(cmd);
if (result == DispatchResult(DISPATCHED_NOUPDATE))
return result;
if (result == DispatchResult(DISPATCHED)) {
updateLocal(bv, false);
if (result.dispatched()) {
if (result.val() != NOUPDATE)
updateLocal(bv, false);
return result;
}
if (result >= DispatchResult(FINISHED)) {
switch (result.val()) {
case FINISHED_RIGHT:
moveRightIntern(bv, false, false);
result = DispatchResult(DISPATCHED);
break;
case FINISHED_UP:
result = moveUp(bv);
if (result >= DispatchResult(FINISHED)) {
updateLocal(bv, false);
bv->unlockInset(this);
}
break;
case FINISHED_DOWN:
result = moveDown(bv);
if (result >= DispatchResult(FINISHED)) {
updateLocal(bv, false);
bv->unlockInset(this);
}
break;
default:
result = DispatchResult(DISPATCHED);
break;
switch (result.val()) {
case FINISHED_RIGHT:
moveRightIntern(bv, false, false);
result = DispatchResult(true);
break;
case FINISHED_UP:
result = moveUp(bv);
if (result.val() >= FINISHED) {
updateLocal(bv, false);
bv->unlockInset(this);
}
the_locking_inset = 0;
updateLocal(bv, false);
// make sure status gets reset immediately
bv->owner()->clearMessage();
return result;
break;
case FINISHED_DOWN:
result = moveDown(bv);
if (result.val() >= FINISHED) {
updateLocal(bv, false);
bv->unlockInset(this);
}
break;
default:
result = DispatchResult(true);
break;
}
the_locking_inset = 0;
updateLocal(bv, false);
// make sure status gets reset immediately
bv->owner()->clearMessage();
return result;
}
bool updflag = false;
@ -749,7 +752,7 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
}
text_.selection.cursor = text_.cursor;
updflag = true;
result = DispatchResult(DISPATCHED_NOUPDATE);
result = DispatchResult(true, NOUPDATE);
break;
// cursor movements that need special handling
@ -773,21 +776,21 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
case LFUN_PRIOR:
if (crow() == text_.firstRow())
result = DispatchResult(FINISHED_UP);
result = DispatchResult(false, FINISHED_UP);
else {
text_.cursorPrevious();
text_.clearSelection();
result = DispatchResult(DISPATCHED_NOUPDATE);
result = DispatchResult(true, NOUPDATE);
}
break;
case LFUN_NEXT:
if (crow() == text_.lastRow())
result = DispatchResult(FINISHED_DOWN);
result = DispatchResult(false, FINISHED_DOWN);
else {
text_.cursorNext();
text_.clearSelection();
result = DispatchResult(DISPATCHED_NOUPDATE);
result = DispatchResult(true, NOUPDATE);
}
break;
@ -832,7 +835,7 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
case LFUN_BREAKPARAGRAPH:
if (!autoBreakRows_) {
result = DispatchResult(DISPATCHED);
result = DispatchResult(true);
} else {
replaceSelection(bv->getLyXText());
text_.breakParagraph(paragraphs, 0);
@ -842,7 +845,7 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
if (!autoBreakRows_) {
result = DispatchResult(DISPATCHED);
result = DispatchResult(true);
} else {
replaceSelection(bv->getLyXText());
text_.breakParagraph(paragraphs, 1);
@ -852,7 +855,7 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
case LFUN_BREAKLINE: {
if (!autoBreakRows_) {
result = DispatchResult(DISPATCHED);
result = DispatchResult(true);
} else {
replaceSelection(bv->getLyXText());
text_.insertInset(new InsetNewline);
@ -901,7 +904,7 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
default:
if (!bv->dispatch(cmd))
result = DispatchResult(UNDISPATCHED);
result = DispatchResult(false);
break;
}
@ -916,11 +919,11 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
setFont(bv, font, false);
}
if (result >= DispatchResult(FINISHED))
if (result.val() >= FINISHED)
bv->unlockInset(this);
if (result == DispatchResult(DISPATCHED_NOUPDATE))
result = DispatchResult(DISPATCHED);
if (result.val() == NOUPDATE)
result = DispatchResult(true);
return result;
}
@ -1043,13 +1046,13 @@ InsetText::moveRightIntern(BufferView * bv, bool front,
ParagraphList::iterator c_par = cpar();
if (boost::next(c_par) == paragraphs.end() && cpos() >= c_par->size())
return DispatchResult(FINISHED_RIGHT);
return DispatchResult(false, FINISHED_RIGHT);
if (activate_inset && checkAndActivateInset(bv, front))
return DispatchResult(DISPATCHED);
return DispatchResult(true);
text_.cursorRight(bv);
if (!selecting)
text_.clearSelection();
return DispatchResult(DISPATCHED_NOUPDATE);
return DispatchResult(true, NOUPDATE);
}
@ -1058,33 +1061,33 @@ InsetText::moveLeftIntern(BufferView * bv, bool front,
bool activate_inset, bool selecting)
{
if (cpar() == paragraphs.begin() && cpos() <= 0)
return DispatchResult(FINISHED);
return DispatchResult(false, FINISHED);
text_.cursorLeft(bv);
if (!selecting)
text_.clearSelection();
if (activate_inset && checkAndActivateInset(bv, front))
return DispatchResult(DISPATCHED);
return DispatchResult(DISPATCHED_NOUPDATE);
return DispatchResult(true);
return DispatchResult(true, NOUPDATE);
}
DispatchResult InsetText::moveUp(BufferView * bv)
{
if (crow() == text_.firstRow())
return DispatchResult(FINISHED_UP);
return DispatchResult(false, FINISHED_UP);
text_.cursorUp(bv);
text_.clearSelection();
return DispatchResult(DISPATCHED_NOUPDATE);
return DispatchResult(true, NOUPDATE);
}
DispatchResult InsetText::moveDown(BufferView * bv)
{
if (crow() == text_.lastRow())
return DispatchResult(FINISHED_DOWN);
return DispatchResult(false, FINISHED_DOWN);
text_.cursorDown(bv);
text_.clearSelection();
return DispatchResult(DISPATCHED_NOUPDATE);
return DispatchResult(true, NOUPDATE);
}

View File

@ -82,11 +82,11 @@ InsetTOC::priv_dispatch(FuncRequest const & cmd,
case LFUN_MOUSE_RELEASE:
if (button().box().contains(cmd.x, cmd.y))
InsetCommandMailer("toc", *this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_INSET_DIALOG_SHOW:
InsetCommandMailer("toc", *this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
return InsetCommand::priv_dispatch(cmd, idx, pos);

View File

@ -51,7 +51,7 @@ InsetUrl::priv_dispatch(FuncRequest const & cmd,
switch (cmd.action) {
case LFUN_INSET_EDIT:
InsetCommandMailer("url", *this).showDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
return InsetCommand::priv_dispatch(cmd, idx, pos);
}

View File

@ -98,12 +98,12 @@ InsetWrap::priv_dispatch(FuncRequest const & cmd,
params_.width = params.width;
cmd.view()->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_INSET_DIALOG_UPDATE:
InsetWrapMailer(*this).updateDialog(cmd.view());
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
return InsetCollapsable::priv_dispatch(cmd, idx, pos);

View File

@ -113,7 +113,7 @@ DispatchResult
UpdatableInset::priv_dispatch(FuncRequest const & ev, idx_type &, pos_type &)
{
if (ev.action == LFUN_MOUSE_RELEASE)
return (editable() == IS_EDITABLE) ? DispatchResult(DISPATCHED) : DispatchResult(UNDISPATCHED);
return DispatchResult(editable() == IS_EDITABLE);
if (!ev.argument.empty() && ev.action == LFUN_SCROLL_INSET) {
if (ev.argument.find('.') != ev.argument.npos) {
@ -125,9 +125,9 @@ UpdatableInset::priv_dispatch(FuncRequest const & ev, idx_type &, pos_type &)
}
ev.view()->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}

View File

@ -885,11 +885,11 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
{
Cursor cursor;
buildCursor(cursor, *view());
if (cursor.dispatch(FuncRequest(func, view())) == DispatchResult(DISPATCHED)) {
if (cursor.dispatch(FuncRequest(func, view())).dispatched()) {
lyxerr << "dispatched by Cursor::dispatch()\n";
goto exit_with_message;
}
lyxerr << "### NOT DispatchResult(DISPATCHED) BY Cursor::dispatch() ###\n";
lyxerr << "### NOT DispatchResult(true) BY Cursor::dispatch() ###\n";
}
#endif
@ -933,27 +933,27 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
// Hand-over to inset's own dispatch:
result = inset->dispatch(FuncRequest(view(), action, argument));
if (result == DispatchResult(DISPATCHED) || result == DispatchResult(DISPATCHED_NOUPDATE)) {
if (result.dispatched()) {
goto exit_with_message;
}
// If DispatchResult(UNDISPATCHED), just soldier on
if (result == DispatchResult(FINISHED)) {
// If DispatchResult(false), just soldier on
if (result.val() == FINISHED) {
owner->clearMessage();
goto exit_with_message;
// We do not need special RTL handling here:
// DispatchResult(FINISHED) means that the cursor should be
// FINISHED means that the cursor should be
// one position after the inset.
}
if (result == DispatchResult(FINISHED_RIGHT)) {
if (result.val() == FINISHED_RIGHT) {
view()->text->cursorRight(view());
moveCursorUpdate();
owner->clearMessage();
goto exit_with_message;
}
if (result == DispatchResult(FINISHED_UP)) {
if (result.val() == FINISHED_UP) {
LyXText * text = view()->text;
ParagraphList::iterator pit = text->cursorPar();
Row const & row = *pit->getRow(text->cursor.pos());
@ -975,7 +975,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
goto exit_with_message;
}
if (result == DispatchResult(FINISHED_DOWN)) {
if (result.val() == FINISHED_DOWN) {
LyXText * text = view()->text;
ParagraphList::iterator pit = text->cursorPar();
Row const & row = *pit->getRow(text->cursor.pos());

View File

@ -1,3 +1,7 @@
2003-11-01 Lars Gullik Bjřnnes <larsbj@gullik.net>
* adjust for DispatchResult changes
2003-10-31 José Matos <jamatos@lyx.org>
* formula.[Ch] (ascii, linuxdoc, docbook):
@ -9,13 +13,13 @@
2003-10-29 Lars Gullik Bjønnes <larsbj@gullik.net>
* math_scriptinset.C (priv_dispatch):
* math_nestinset.C (priv_dispatch):
* math_hullinset.C (priv_dispatch):
* math_gridinset.C (priv_dispatch):
* math_cursor.C (dispatch):
* formulabase.C (lfunMouseRelease, lfunMousePress)
(lfunMouseMotion, priv_dispatch):
* math_scriptinset.C (priv_dispatch):
* math_nestinset.C (priv_dispatch):
* math_hullinset.C (priv_dispatch):
* math_gridinset.C (priv_dispatch):
* math_cursor.C (dispatch):
* formulabase.C (lfunMouseRelease, lfunMousePress)
(lfunMouseMotion, priv_dispatch):
* command_inset.C (priv_dispatch): explict DispatchResult ctor fallout.
2003-10-29 Lars Gullik Bjønnes <larsbj@gullik.net>

View File

@ -62,7 +62,7 @@ CommandInset::priv_dispatch(FuncRequest const & cmd,
default:
return MathNestInset::priv_dispatch(cmd, idx, pos);
}
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}

View File

@ -215,7 +215,7 @@ void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
DispatchResult InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
{
if (!mathcursor)
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
BufferView * bv = cmd.view();
bv->updateInset(this);
@ -223,12 +223,12 @@ DispatchResult InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
if (cmd.button() == mouse_button::button3) {
// try to dispatch to enclosed insets first
if (mathcursor->dispatch(cmd) == DispatchResult(UNDISPATCHED)) {
if (!mathcursor->dispatch(cmd).dispatched()) {
// launch math panel for right mouse button
lyxerr << "lfunMouseRelease: undispatched: " << cmd.button() << endl;
bv->owner()->getDialogs().show("mathpanel");
}
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
if (cmd.button() == mouse_button::button2) {
@ -238,7 +238,7 @@ DispatchResult InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
mathcursor->insert(ar);
bv->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
if (cmd.button() == mouse_button::button1) {
@ -250,10 +250,10 @@ DispatchResult InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
//mathcursor = new MathCursor(this, x == 0);
//metrics(bv);
//mathcursor->setPos(x + xo_, y + yo_);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}
@ -272,7 +272,7 @@ DispatchResult InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
if (cmd.button() == mouse_button::button3) {
mathcursor->dispatch(cmd);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
if (cmd.button() == mouse_button::button1) {
@ -281,28 +281,28 @@ DispatchResult InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
mathcursor->selClear();
mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
mathcursor->dispatch(cmd);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
bv->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
DispatchResult InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
{
if (!mathcursor)
return DispatchResult(DISPATCHED);
return DispatchResult(true);
if (mathcursor->dispatch(FuncRequest(cmd)) != DispatchResult(UNDISPATCHED))
return DispatchResult(DISPATCHED);
if (mathcursor->dispatch(FuncRequest(cmd)).dispatched())
return DispatchResult(true);
// only select with button 1
if (cmd.button() != mouse_button::button1)
return DispatchResult(DISPATCHED);
return DispatchResult(true);
if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
return DispatchResult(DISPATCHED);
return DispatchResult(true);
first_x = cmd.x;
first_y = cmd.y;
@ -313,7 +313,7 @@ DispatchResult InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
BufferView * bv = cmd.view();
mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
bv->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
@ -349,7 +349,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
// if that is removed, we won't get the magenta box when entering an
// inset for the first time
bv->updateInset(this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MOUSE_PRESS:
//lyxerr << "Mouse single press" << endl;
@ -368,10 +368,10 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
}
if (!mathcursor)
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
string argument = cmd.argument;
DispatchResult result = DispatchResult(DISPATCHED);
DispatchResult result(true);
bool sel = false;
bool was_macro = mathcursor->inMacroMode();
bool was_selection = mathcursor->selection();
@ -400,7 +400,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
case LFUN_RIGHTSEL:
sel = true; // fall through...
case LFUN_RIGHT:
result = mathcursor->right(sel) ? DispatchResult(DISPATCHED) : DispatchResult(FINISHED_RIGHT);
result = mathcursor->right(sel) ? DispatchResult(true) : DispatchResult(false, FINISHED_RIGHT);
//lyxerr << "calling scroll 20" << endl;
//scroll(bv, 20);
// write something to the minibuffer
@ -410,19 +410,19 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
case LFUN_LEFTSEL:
sel = true; // fall through
case LFUN_LEFT:
result = mathcursor->left(sel) ? DispatchResult(DISPATCHED) : DispatchResult(FINISHED);
result = mathcursor->left(sel) ? DispatchResult(true) : DispatchResult(true, FINISHED);
break;
case LFUN_UPSEL:
sel = true; // fall through
case LFUN_UP:
result = mathcursor->up(sel) ? DispatchResult(DISPATCHED) : DispatchResult(FINISHED_UP);
result = mathcursor->up(sel) ? DispatchResult(true) : DispatchResult(false, FINISHED_UP);
break;
case LFUN_DOWNSEL:
sel = true; // fall through
case LFUN_DOWN:
result = mathcursor->down(sel) ? DispatchResult(DISPATCHED) : DispatchResult(FINISHED_DOWN);
result = mathcursor->down(sel) ? DispatchResult(true) : DispatchResult(false, FINISHED_DOWN);
break;
case LFUN_WORDSEL:
@ -434,7 +434,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
case LFUN_UP_PARAGRAPH:
case LFUN_DOWN_PARAGRAPHSEL:
case LFUN_DOWN_PARAGRAPH:
result = DispatchResult(FINISHED);
result = DispatchResult(true, FINISHED);
break;
case LFUN_HOMESEL:
@ -442,7 +442,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
sel = true; // fall through
case LFUN_HOME:
case LFUN_WORDLEFT:
result = mathcursor->home(sel) ? DispatchResult(DISPATCHED) : DispatchResult(FINISHED);
result = mathcursor->home(sel) ? DispatchResult(true) : DispatchResult(true, FINISHED);
break;
case LFUN_ENDSEL:
@ -450,21 +450,21 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
sel = true; // fall through
case LFUN_END:
case LFUN_WORDRIGHT:
result = mathcursor->end(sel) ? DispatchResult(DISPATCHED) : DispatchResult(FINISHED_RIGHT);
result = mathcursor->end(sel) ? DispatchResult(true) : DispatchResult(false, FINISHED_RIGHT);
break;
case LFUN_PRIORSEL:
case LFUN_PRIOR:
case LFUN_BEGINNINGBUFSEL:
case LFUN_BEGINNINGBUF:
result = DispatchResult(FINISHED);
result = DispatchResult(true, FINISHED);
break;
case LFUN_NEXTSEL:
case LFUN_NEXT:
case LFUN_ENDBUFSEL:
case LFUN_ENDBUF:
result = DispatchResult(FINISHED_RIGHT);
result = DispatchResult(false, FINISHED_RIGHT);
break;
case LFUN_CELL_FORWARD:
@ -479,7 +479,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
case LFUN_BACKSPACE:
recordUndo(bv, Undo::ATOMIC);
if (!mathcursor->backspace()) {
result = DispatchResult(FINISHED);
result = DispatchResult(true, FINISHED);
remove_inset = true;
}
break;
@ -488,7 +488,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
case LFUN_DELETE:
recordUndo(bv, Undo::ATOMIC);
if (!mathcursor->erase()) {
result = DispatchResult(FINISHED);
result = DispatchResult(true, FINISHED);
remove_inset = true;
}
break;
@ -641,7 +641,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
case LFUN_EXEC_COMMAND:
result = DispatchResult(UNDISPATCHED);
result = DispatchResult(false);
break;
case LFUN_INSET_ERT:
@ -669,7 +669,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
if (!argument.empty()) {
recordUndo(bv, Undo::ATOMIC);
if (argument.size() == 1)
result = mathcursor->interpret(argument[0]) ? DispatchResult(DISPATCHED) : DispatchResult(FINISHED_RIGHT);
result = mathcursor->interpret(argument[0]) ? DispatchResult(true) : DispatchResult(false, FINISHED_RIGHT);
else
mathcursor->insert(argument);
}
@ -679,7 +679,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
if (mathcursor->selection())
mathcursor->selClear();
else
result = DispatchResult(UNDISPATCHED);
result = DispatchResult(false);
break;
case LFUN_INSET_TOGGLE:
@ -687,7 +687,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
break;
case LFUN_DIALOG_SHOW:
result = DispatchResult(UNDISPATCHED);
result = DispatchResult(false);
break;
case LFUN_DIALOG_SHOW_NEW_INSET: {
@ -699,7 +699,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
}
if (data.empty())
result = DispatchResult(UNDISPATCHED);
result = DispatchResult(false);
else {
bv->owner()->getDialogs().show(name, data, 0);
}
@ -718,19 +718,19 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
MathArray ar;
if (createMathInset_fromDialogStr(cmd.argument, ar)) {
mathcursor->insert(ar);
result = DispatchResult(DISPATCHED);
result = DispatchResult(true);
} else {
result = DispatchResult(UNDISPATCHED);
result = DispatchResult(false);
}
}
}
break;
default:
result = DispatchResult(UNDISPATCHED);
result = DispatchResult(false);
}
if (result == DispatchResult(DISPATCHED))
if (result == DispatchResult(true))
bv->updateInset(this);
mathcursor->normalize();
@ -741,8 +741,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
if (mathcursor->selection() || was_selection)
toggleInsetSelection(bv);
if (result == DispatchResult(DISPATCHED) || result == DispatchResult(DISPATCHED_NOUPDATE) ||
result == DispatchResult(UNDISPATCHED)) {
if (result.val() <= NOUPDATE) {
fitInsetCursor(bv);
revealCodes(bv);
cmd.view()->stuffClipboard(mathcursor->grabSelection());

View File

@ -1417,17 +1417,19 @@ DispatchResult MathCursor::dispatch(FuncRequest const & cmd)
case LFUN_MOUSE_RELEASE:
case LFUN_MOUSE_DOUBLE: {
CursorPos & pos = Cursor_.back();
DispatchResult res = DispatchResult(UNDISPATCHED);
int x = 0, y = 0;
int x = 0;
int y = 0;
getPos(x, y);
if (x < cmd.x && hasPrevAtom()) {
res = prevAtom().nucleus()->dispatch(cmd, pos.idx_, pos.pos_);
if (res != DispatchResult(UNDISPATCHED))
DispatchResult const res =
prevAtom().nucleus()->dispatch(cmd, pos.idx_, pos.pos_);
if (res.dispatched())
return res;
}
if (x > cmd.x && hasNextAtom()) {
res = nextAtom().nucleus()->dispatch(cmd, pos.idx_, pos.pos_);
if (res != DispatchResult(UNDISPATCHED))
DispatchResult const res =
nextAtom().nucleus()->dispatch(cmd, pos.idx_, pos.pos_);
if (res.dispatched())
return res;
}
}
@ -1437,16 +1439,17 @@ DispatchResult MathCursor::dispatch(FuncRequest const & cmd)
for (int i = Cursor_.size() - 1; i >= 0; --i) {
CursorPos & pos = Cursor_[i];
DispatchResult res = pos.inset_->dispatch(cmd, pos.idx_, pos.pos_);
if (res != DispatchResult(UNDISPATCHED)) {
if (res == DispatchResult(FINISHED)) {
DispatchResult const res =
pos.inset_->dispatch(cmd, pos.idx_, pos.pos_);
if (res.dispatched()) {
if (res.val() == FINISHED) {
Cursor_.shrink(i + 1);
selClear();
}
return res;
}
}
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}

View File

@ -1050,13 +1050,13 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
case LFUN_MOUSE_RELEASE:
//if (cmd.button() == mouse_button::button3) {
// GridInsetMailer(*this).showDialog();
// return DispatchResult(DISPATCHED);
// return DispatchResult(true);
//}
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
case LFUN_INSET_DIALOG_UPDATE:
GridInsetMailer(*this).updateDialog(cmd.view());
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
// insert file functions
case LFUN_DELETE_LINE_FORWARD:
@ -1072,12 +1072,12 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
idx = nargs() - 1;
if (pos > cell(idx).size())
pos = cell(idx).size();
return DispatchResult(FINISHED);
return DispatchResult(true, FINISHED);
case LFUN_CELL_SPLIT:
//recordUndo(bv, Undo::ATOMIC);
splitCell(idx, pos);
return DispatchResult(FINISHED);
return DispatchResult(true, FINISHED);
case LFUN_BREAKLINE: {
//recordUndo(bv, Undo::INSERT);
@ -1096,7 +1096,7 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
pos = cell(idx).size();
//mathcursor->normalize();
return DispatchResult(FINISHED);
return DispatchResult(true, FINISHED);
}
case LFUN_TABULAR_FEATURE: {
@ -1151,9 +1151,9 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
else if (s == "swap-column")
swapCol(col(idx));
else
return DispatchResult(UNDISPATCHED);
lyxerr << "returning DispatchResult(FINISHED)" << endl;
return DispatchResult(FINISHED);
return DispatchResult(false);
lyxerr << "returning DispatchResult(true, FINISHED)" << endl;
return DispatchResult(true, FINISHED);
}
case LFUN_PASTE: {
@ -1184,7 +1184,7 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
for (col_type c = 0; c < grid.ncols(); ++c)
cell(i).append(grid.cell(grid.index(r, c)));
}
return DispatchResult(FINISHED);
return DispatchResult(true, FINISHED);
}
default:

View File

@ -782,7 +782,7 @@ DispatchResult MathHullInset::priv_dispatch
mutate("eqnarray");
idx = 1;
pos = 0;
return DispatchResult(FINISHED);
return DispatchResult(true, FINISHED);
}
return MathGridInset::priv_dispatch(cmd, idx, pos);
@ -798,7 +798,7 @@ DispatchResult MathHullInset::priv_dispatch
numbered(row, !old);
//bv->owner()->message(old ? _("No number") : _("Number"));
}
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_MATH_NONUMBER:
if (display()) {
@ -808,7 +808,7 @@ DispatchResult MathHullInset::priv_dispatch
//bv->owner()->message(old ? _("No number") : _("Number"));
numbered(r, !old);
}
return DispatchResult(DISPATCHED);
return DispatchResult(true);
case LFUN_INSERT_LABEL: {
row_type r = (type_ == "multline") ? nrows() - 1 : row(idx);
@ -822,7 +822,7 @@ DispatchResult MathHullInset::priv_dispatch
? Alert::askForText(_("Enter new label to insert:"), default_label)
: Alert::askForText(_("Enter label:"), old_label);
if (!res.first)
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
new_label = trim(res.second);
}
@ -832,12 +832,12 @@ DispatchResult MathHullInset::priv_dispatch
if (!new_label.empty())
numbered(r, true);
label(r, new_label);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_MATH_EXTERN:
doExtern(cmd, idx, pos);
return DispatchResult(FINISHED);
return DispatchResult(true, FINISHED);
case LFUN_MATH_MUTATE: {
lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
@ -849,14 +849,14 @@ DispatchResult MathHullInset::priv_dispatch
idx = nargs() - 1;
if (pos > cell(idx).size())
pos = cell(idx).size();
return DispatchResult(FINISHED);
return DispatchResult(true, FINISHED);
}
case LFUN_MATH_DISPLAY: {
mutate(type_ == "simple" ? "equation" : "simple");
idx = 0;
pos = cell(idx).size();
return DispatchResult(FINISHED);
return DispatchResult(true, FINISHED);
}
default:

View File

@ -299,7 +299,7 @@ MathNestInset::priv_dispatch(FuncRequest const & cmd,
mathed_parse_cell(ar, cmd.argument);
cell(idx).insert(pos, ar);
pos += ar.size();
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
case LFUN_PASTESELECTION:
@ -310,7 +310,7 @@ MathNestInset::priv_dispatch(FuncRequest const & cmd,
case LFUN_MOUSE_PRESS:
if (cmd.button() == mouse_button::button2)
return priv_dispatch(FuncRequest(bv, LFUN_PASTESELECTION), idx, pos);
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
default:
return MathInset::priv_dispatch(cmd, idx, pos);

View File

@ -528,7 +528,7 @@ MathScriptInset::priv_dispatch(FuncRequest const & cmd,
limits_ = (hasLimits()) ? -1 : 1;
else
limits_ = 0;
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
return MathNestInset::priv_dispatch(cmd, idx, pos);

View File

@ -62,18 +62,18 @@ RefInset::priv_dispatch(FuncRequest const & cmd,
if (cmd.getArg(0) == "ref") {
MathArray ar;
if (!createMathInset_fromDialogStr(cmd.argument, ar))
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
*this = *ar[0].nucleus()->asRefInset();
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
break;
case LFUN_MOUSE_RELEASE:
if (cmd.button() == mouse_button::button3) {
lyxerr << "trying to goto ref" << cell(0) << endl;
cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
if (cmd.button() == mouse_button::button1) {
// Eventually trigger dialog with button 3
@ -81,18 +81,18 @@ RefInset::priv_dispatch(FuncRequest const & cmd,
string const data = createDialogStr("ref");
cmd.view()->owner()->getDialogs().
show("ref", data, this);
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}
break;
case LFUN_MOUSE_PRESS:
case LFUN_MOUSE_MOTION:
// eat other mouse commands
return DispatchResult(DISPATCHED);
return DispatchResult(true);
default:
return CommandInset::priv_dispatch(cmd, idx, pos);
}
// not our business
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}

View File

@ -982,14 +982,14 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_BEGINNINGBUFSEL:
if (inset_owner)
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
cursorTop();
finishChange(bv, true);
break;
case LFUN_ENDBUFSEL:
if (inset_owner)
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
cursorBottom();
finishChange(bv, true);
break;
@ -1534,8 +1534,8 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
break;
default:
return DispatchResult(UNDISPATCHED);
return DispatchResult(false);
}
return DispatchResult(DISPATCHED);
return DispatchResult(true);
}