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
This commit is contained in:
Jürgen Vigna 2001-08-16 08:52:30 +00:00
parent da44328c30
commit 45bd81a203
8 changed files with 75 additions and 25 deletions

View File

@ -168,6 +168,7 @@ src/LyXView.C
src/mathed/formulabase.C src/mathed/formulabase.C
src/mathed/formula.C src/mathed/formula.C
src/mathed/formulamacro.C src/mathed/formulamacro.C
src/mathed/math_cursor.C
src/MenuBackend.C src/MenuBackend.C
src/minibuffer.C src/minibuffer.C
src/paragraph.C src/paragraph.C

View File

@ -1,3 +1,7 @@
2001-08-16 Juergen Vigna <jug@sad.it>
* lyxfunc.C (dispatch): implemented the new FINISHED states.
2001-08-14 Dekel Tsur <dekelts@tau.ac.il> 2001-08-14 Dekel Tsur <dekelts@tau.ac.il>
* buffer.C (parseSingleLyXformat2Token): Do not generate errors * buffer.C (parseSingleLyXformat2Token): Do not generate errors

View File

@ -1,3 +1,11 @@
2001-08-16 Juergen Vigna <jug@sad.it>
* 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 <jug@sad.it> 2001-08-14 Juergen Vigna <jug@sad.it>
* insetert.C (edit): forgot to set status_ in edit calls! * insetert.C (edit): forgot to set status_ in edit calls!

View File

@ -355,19 +355,28 @@ public:
becomes a bit complex, just two possible results (boolean) becomes a bit complex, just two possible results (boolean)
are not enough. 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 DISPATCHED_NOUPDATE = the inset catched the action and no update
is needed here to redraw the inset is needed here to redraw the inset
FINISHED = the inset must be unlocked as a result FINISHED = the inset must be unlocked as a result
of the action of the action
UNDISPATCHED = the action was not catched, it should be FINISHED_RIGHT = FINISHED, but put the cursor to the RIGHT of
dispatched by lower level insets 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 { enum RESULT {
UNDISPATCHED = 0, UNDISPATCHED = 0,
DISPATCHED, DISPATCHED,
DISPATCHED_NOUPDATE, DISPATCHED_NOUPDATE,
FINISHED FINISHED,
FINISHED_RIGHT,
FINISHED_UP,
FINISHED_DOWN
}; };
/// To convert old binary dispatch results /// To convert old binary dispatch results

View File

@ -417,10 +417,10 @@ void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
UpdatableInset::RESULT UpdatableInset::RESULT
InsetCollapsable::localDispatch(BufferView * bv, kb_action action, InsetCollapsable::localDispatch(BufferView * bv, kb_action action,
string const & arg) string const & arg)
{ {
UpdatableInset::RESULT result = inset.localDispatch(bv, action, arg); UpdatableInset::RESULT result = inset.localDispatch(bv, action, arg);
if (result == FINISHED) if (result >= FINISHED)
bv->unlockInset(this); bv->unlockInset(this);
first_after_edit = false; first_after_edit = false;
return result; return result;
@ -436,7 +436,7 @@ bool InsetCollapsable::lockInsetInInset(BufferView * bv, UpdatableInset * in)
bool InsetCollapsable::unlockInsetInInset(BufferView * bv, UpdatableInset * in, bool InsetCollapsable::unlockInsetInInset(BufferView * bv, UpdatableInset * in,
bool lr) bool lr)
{ {
if (&inset == in) { if (&inset == in) {
bv->unlockInset(this); bv->unlockInset(this);

View File

@ -1105,7 +1105,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
// reset need_update setted in above function! // reset need_update setted in above function!
need_update = NONE; need_update = NONE;
result = the_locking_inset->localDispatch(bv, action, arg); result = the_locking_inset->localDispatch(bv, action, arg);
if ((result == UNDISPATCHED) || (result == FINISHED)) { if ((result == UNDISPATCHED) || (result >= FINISHED)) {
unlockInsetInInset(bv, the_locking_inset); unlockInsetInInset(bv, the_locking_inset);
nodraw(false); nodraw(false);
the_locking_inset = 0; the_locking_inset = 0;
@ -1121,7 +1121,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
} }
break; break;
} }
if (result!=FINISHED) { if (result < FINISHED) {
if (!the_locking_inset) { if (!the_locking_inset) {
showInsetCursor(bv); showInsetCursor(bv);
} }
@ -1400,7 +1400,7 @@ UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
bool moved = isRightToLeft(bv) bool moved = isRightToLeft(bv)
? movePrevCell(bv) : moveNextCell(bv); ? movePrevCell(bv) : moveNextCell(bv);
if (!moved) if (!moved)
return FINISHED; return FINISHED_RIGHT;
if (lock && activateCellInset(bv)) if (lock && activateCellInset(bv))
return DISPATCHED; return DISPATCHED;
} }
@ -1428,7 +1428,7 @@ UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv, bool lock)
int const ocell = actcell; int const ocell = actcell;
actcell = tabular->GetCellAbove(actcell); actcell = tabular->GetCellAbove(actcell);
if (actcell == ocell) // we moved out of the inset if (actcell == ocell) // we moved out of the inset
return FINISHED; return FINISHED_UP;
resetPos(bv); resetPos(bv);
if (lock) { if (lock) {
int x = 0; int x = 0;
@ -1449,7 +1449,7 @@ UpdatableInset::RESULT InsetTabular::moveDown(BufferView * bv, bool lock)
int const ocell = actcell; int const ocell = actcell;
actcell = tabular->GetCellBelow(actcell); actcell = tabular->GetCellBelow(actcell);
if (actcell == ocell) // we moved out of the inset if (actcell == ocell) // we moved out of the inset
return FINISHED; return FINISHED_DOWN;
resetPos(bv); resetPos(bv);
if (lock) { if (lock) {
int x = 0; int x = 0;

View File

@ -1319,7 +1319,7 @@ InsetText::localDispatch(BufferView * bv,
setFont(bv, font, false); setFont(bv, font, false);
} }
if (result != FINISHED) { if (result < FINISHED) {
showInsetCursor(bv); showInsetCursor(bv);
} else } else
bv->unlockInset(this); bv->unlockInset(this);
@ -1499,10 +1499,10 @@ InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting)
UpdatableInset::RESULT UpdatableInset::RESULT
InsetText::moveRightIntern(BufferView * bv, bool behind, 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())) if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size()))
return FINISHED; return FINISHED_RIGHT;
if (activate_inset && checkAndActivateInset(bv, behind)) if (activate_inset && checkAndActivateInset(bv, behind))
return DISPATCHED; return DISPATCHED;
getLyXText(bv)->cursorRight(bv); getLyXText(bv)->cursorRight(bv);
@ -1514,7 +1514,7 @@ InsetText::moveRightIntern(BufferView * bv, bool behind,
UpdatableInset::RESULT UpdatableInset::RESULT
InsetText::moveLeftIntern(BufferView * bv, bool behind, InsetText::moveLeftIntern(BufferView * bv, bool behind,
bool activate_inset, bool selecting) bool activate_inset, bool selecting)
{ {
if (!cpar(bv)->previous() && (cpos(bv) <= 0)) if (!cpar(bv)->previous() && (cpos(bv) <= 0))
return FINISHED; return FINISHED;
@ -1531,7 +1531,7 @@ UpdatableInset::RESULT
InsetText::moveUp(BufferView * bv) InsetText::moveUp(BufferView * bv)
{ {
if (!crow(bv)->previous()) if (!crow(bv)->previous())
return FINISHED; return FINISHED_UP;
getLyXText(bv)->cursorUp(bv); getLyXText(bv)->cursorUp(bv);
return DISPATCHED_NOUPDATE; return DISPATCHED_NOUPDATE;
} }
@ -1541,7 +1541,7 @@ UpdatableInset::RESULT
InsetText::moveDown(BufferView * bv) InsetText::moveDown(BufferView * bv)
{ {
if (!crow(bv)->next()) if (!crow(bv)->next())
return FINISHED; return FINISHED_DOWN;
getLyXText(bv)->cursorDown(bv); getLyXText(bv)->cursorDown(bv);
return DISPATCHED_NOUPDATE; return DISPATCHED_NOUPDATE;
} }

View File

@ -866,12 +866,40 @@ string const LyXFunc::dispatch(int ac,
inset->edit(owner->view(),slx,sly,0); inset->edit(owner->view(),slx,sly,0);
return string(); return string();
} else if (((result=owner->view()->theLockingInset()-> } else if (((result=owner->view()->theLockingInset()->
localDispatch(owner->view(), action, localDispatch(owner->view(), action, argument)) ==
argument)) == UpdatableInset::DISPATCHED) ||
UpdatableInset::DISPATCHED) || (result == UpdatableInset::DISPATCHED_NOUPDATE))
(result == UpdatableInset::DISPATCHED_NOUPDATE))
return string(); 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")); //setMessage(N_("Text mode"));
switch (action) { switch (action) {
case LFUN_UNKNOWN_ACTION: case LFUN_UNKNOWN_ACTION: