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/formula.C
src/mathed/formulamacro.C
src/mathed/math_cursor.C
src/MenuBackend.C
src/minibuffer.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>
* 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>
* 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)
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

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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: