From 45bd81a203238ef43a026463d6dcf0fd020beedb Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Thu, 16 Aug 2001 08:52:30 +0000 Subject: [PATCH] Added new FINISED states FINISHED_RIGHT, FINISHED_UP, FINISHED_DOWN. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2518 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 1 + src/ChangeLog | 4 ++++ src/insets/ChangeLog | 8 ++++++++ src/insets/inset.h | 21 +++++++++++++------ src/insets/insetcollapsable.C | 6 +++--- src/insets/insettabular.C | 10 ++++----- src/insets/insettext.C | 12 +++++------ src/lyxfunc.C | 38 ++++++++++++++++++++++++++++++----- 8 files changed, 75 insertions(+), 25 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 446fd4dc1d..dc7e9ec132 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -168,6 +168,7 @@ src/LyXView.C src/mathed/formulabase.C src/mathed/formula.C src/mathed/formulamacro.C +src/mathed/math_cursor.C src/MenuBackend.C src/minibuffer.C src/paragraph.C diff --git a/src/ChangeLog b/src/ChangeLog index 2161d93e2d..9c9ab33510 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-08-16 Juergen Vigna + + * lyxfunc.C (dispatch): implemented the new FINISHED states. + 2001-08-14 Dekel Tsur * buffer.C (parseSingleLyXformat2Token): Do not generate errors diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 7cea082331..ce461cfbb5 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,11 @@ +2001-08-16 Juergen Vigna + + * insettext.C: implemented the new FINISHED states. + + * insettabular.C: ditto + + * inset.h: added more FINISHED states for cursor right,up,down + 2001-08-14 Juergen Vigna * insetert.C (edit): forgot to set status_ in edit calls! diff --git a/src/insets/inset.h b/src/insets/inset.h index 2a70ca4d85..82d84034bc 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -355,19 +355,28 @@ public: becomes a bit complex, just two possible results (boolean) are not enough. - DISPATCHED = the inset catched the action + DISPATCHED = the inset catched the action DISPATCHED_NOUPDATE = the inset catched the action and no update is needed here to redraw the inset - FINISHED = the inset must be unlocked as a result - of the action - UNDISPATCHED = the action was not catched, it should be - dispatched by lower level insets + FINISHED = the inset must be unlocked as a result + of the action + FINISHED_RIGHT = FINISHED, but put the cursor to the RIGHT of + the inset. + FINISHED_UP = FINISHED, but put the cursor UP of + the inset. + FINISHED_DOWN = FINISHED, but put the cursor DOWN of + the inset. + UNDISPATCHED = the action was not catched, it should be + dispatched by lower level insets */ enum RESULT { UNDISPATCHED = 0, DISPATCHED, DISPATCHED_NOUPDATE, - FINISHED + FINISHED, + FINISHED_RIGHT, + FINISHED_UP, + FINISHED_DOWN }; /// To convert old binary dispatch results diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index ce43acc582..b1905c679c 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -417,10 +417,10 @@ void InsetCollapsable::update(BufferView * bv, LyXFont const & font, UpdatableInset::RESULT InsetCollapsable::localDispatch(BufferView * bv, kb_action action, - string const & arg) + string const & arg) { UpdatableInset::RESULT result = inset.localDispatch(bv, action, arg); - if (result == FINISHED) + if (result >= FINISHED) bv->unlockInset(this); first_after_edit = false; return result; @@ -436,7 +436,7 @@ bool InsetCollapsable::lockInsetInInset(BufferView * bv, UpdatableInset * in) bool InsetCollapsable::unlockInsetInInset(BufferView * bv, UpdatableInset * in, - bool lr) + bool lr) { if (&inset == in) { bv->unlockInset(this); diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 62ab9682b9..f54ef6e196 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1105,7 +1105,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action, // reset need_update setted in above function! need_update = NONE; result = the_locking_inset->localDispatch(bv, action, arg); - if ((result == UNDISPATCHED) || (result == FINISHED)) { + if ((result == UNDISPATCHED) || (result >= FINISHED)) { unlockInsetInInset(bv, the_locking_inset); nodraw(false); the_locking_inset = 0; @@ -1121,7 +1121,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action, } break; } - if (result!=FINISHED) { + if (result < FINISHED) { if (!the_locking_inset) { showInsetCursor(bv); } @@ -1400,7 +1400,7 @@ UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock) bool moved = isRightToLeft(bv) ? movePrevCell(bv) : moveNextCell(bv); if (!moved) - return FINISHED; + return FINISHED_RIGHT; if (lock && activateCellInset(bv)) return DISPATCHED; } @@ -1428,7 +1428,7 @@ UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv, bool lock) int const ocell = actcell; actcell = tabular->GetCellAbove(actcell); if (actcell == ocell) // we moved out of the inset - return FINISHED; + return FINISHED_UP; resetPos(bv); if (lock) { int x = 0; @@ -1449,7 +1449,7 @@ UpdatableInset::RESULT InsetTabular::moveDown(BufferView * bv, bool lock) int const ocell = actcell; actcell = tabular->GetCellBelow(actcell); if (actcell == ocell) // we moved out of the inset - return FINISHED; + return FINISHED_DOWN; resetPos(bv); if (lock) { int x = 0; diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 1e1da89929..5f030e5b46 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1319,7 +1319,7 @@ InsetText::localDispatch(BufferView * bv, setFont(bv, font, false); } - if (result != FINISHED) { + if (result < FINISHED) { showInsetCursor(bv); } else bv->unlockInset(this); @@ -1499,10 +1499,10 @@ InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting) UpdatableInset::RESULT InsetText::moveRightIntern(BufferView * bv, bool behind, - bool activate_inset, bool selecting) + bool activate_inset, bool selecting) { if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size())) - return FINISHED; + return FINISHED_RIGHT; if (activate_inset && checkAndActivateInset(bv, behind)) return DISPATCHED; getLyXText(bv)->cursorRight(bv); @@ -1514,7 +1514,7 @@ InsetText::moveRightIntern(BufferView * bv, bool behind, UpdatableInset::RESULT InsetText::moveLeftIntern(BufferView * bv, bool behind, - bool activate_inset, bool selecting) + bool activate_inset, bool selecting) { if (!cpar(bv)->previous() && (cpos(bv) <= 0)) return FINISHED; @@ -1531,7 +1531,7 @@ UpdatableInset::RESULT InsetText::moveUp(BufferView * bv) { if (!crow(bv)->previous()) - return FINISHED; + return FINISHED_UP; getLyXText(bv)->cursorUp(bv); return DISPATCHED_NOUPDATE; } @@ -1541,7 +1541,7 @@ UpdatableInset::RESULT InsetText::moveDown(BufferView * bv) { if (!crow(bv)->next()) - return FINISHED; + return FINISHED_DOWN; getLyXText(bv)->cursorDown(bv); return DISPATCHED_NOUPDATE; } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index a95050cc8b..534d64e737 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -866,12 +866,40 @@ string const LyXFunc::dispatch(int ac, inset->edit(owner->view(),slx,sly,0); return string(); } else if (((result=owner->view()->theLockingInset()-> - localDispatch(owner->view(), action, - argument)) == - UpdatableInset::DISPATCHED) || - (result == UpdatableInset::DISPATCHED_NOUPDATE)) + localDispatch(owner->view(), action, argument)) == + UpdatableInset::DISPATCHED) || + (result == UpdatableInset::DISPATCHED_NOUPDATE)) return string(); - else { + else if (result == UpdatableInset::FINISHED) { + if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) { + TEXT()->cursorRight(owner->view()); + moveCursorUpdate(true, false); + owner->showState(); + } + return string(); + } else if (result == UpdatableInset::FINISHED_RIGHT) { + if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) { + TEXT()->cursorRight(owner->view()); + moveCursorUpdate(true, false); + owner->showState(); + } + return string(); + } else if (result == UpdatableInset::FINISHED_UP) { + if (TEXT()->cursor.row()->previous()) { + TEXT()->cursorUp(owner->view()); + moveCursorUpdate(true, false); + owner->showState(); + } + return string(); + } else if (result == UpdatableInset::FINISHED_DOWN) { + if (TEXT()->cursor.row()->next()) + TEXT()->cursorDown(owner->view()); + else + TEXT()->cursorRight(owner->view()); + moveCursorUpdate(true, false); + owner->showState(); + return string(); + } else { //setMessage(N_("Text mode")); switch (action) { case LFUN_UNKNOWN_ACTION: -- 2.39.2