This is a continuation of r21128, r21244
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21448
a592a061-630c-0410-9148-
cb99ea01b6c8
14 files changed:
if (inset) {
if (inset->isActive()) {
Cursor tmpcur = cur;
if (inset) {
if (inset->isActive()) {
Cursor tmpcur = cur;
- tmpcur.pushLeft(*inset);
+ tmpcur.pushBackward(*inset);
inset->dispatch(tmpcur, tmpcmd);
if (tmpcur.result().dispatched()) {
cur.dispatched();
inset->dispatch(tmpcur, tmpcmd);
if (tmpcur.result().dispatched()) {
cur.dispatched();
-void Cursor::pushLeft(Inset & p)
+void Cursor::pushBackward(Inset & p)
{
BOOST_ASSERT(!empty());
{
BOOST_ASSERT(!empty());
- //lyxerr << "Entering inset " << t << " left" << endl;
+ //lyxerr << "Entering inset " << t << " front" << endl;
push(p);
p.idxFirst(*this);
}
push(p);
p.idxFirst(*this);
}
+bool Cursor::popBackward()
{
BOOST_ASSERT(!empty());
{
BOOST_ASSERT(!empty());
- //lyxerr << "Leaving inset to the left" << endl;
+ //lyxerr << "Leaving inset from in front" << endl;
inset().notifyCursorLeaves(*this);
if (depth() == 1)
return false;
inset().notifyCursorLeaves(*this);
if (depth() == 1)
return false;
+bool Cursor::popForward()
{
BOOST_ASSERT(!empty());
{
BOOST_ASSERT(!empty());
- //lyxerr << "Leaving inset to the right" << endl;
+ //lyxerr << "Leaving inset from in back" << endl;
const pos_type lp = (depth() > 1) ? (*this)[depth() - 2].lastpos() : 0;
inset().notifyCursorLeaves(*this);
if (depth() == 1)
const pos_type lp = (depth() > 1) ? (*this)[depth() - 2].lastpos() : 0;
inset().notifyCursorLeaves(*this);
if (depth() == 1)
+bool Cursor::posBackward()
{
if (pos() == 0)
return false;
{
if (pos() == 0)
return false;
+bool Cursor::posForward()
{
if (pos() == lastpos())
return false;
{
if (pos() == lastpos())
return false;
plainInsert(t);
// enter the new inset and move the contents of the selection if possible
if (t->isActive()) {
plainInsert(t);
// enter the new inset and move the contents of the selection if possible
if (t->isActive()) {
- posLeft();
- // be careful here: don't use 'pushLeft(t)' as this we need to
+ posBackward();
+ // be careful here: don't use 'pushBackward(t)' as this we need to
// push the clone, not the original
// push the clone, not the original
- pushLeft(*nextInset());
+ pushBackward(*nextInset());
// We may not use niceInsert here (recursion)
MathData ar;
asArray(safe, ar);
// We may not use niceInsert here (recursion)
MathData ar;
asArray(safe, ar);
if (pos() == 0) {
// If empty cell, and not part of a big cell
if (lastpos() == 0 && inset().nargs() == 1) {
if (pos() == 0) {
// If empty cell, and not part of a big cell
if (lastpos() == 0 && inset().nargs() == 1) {
// Directly delete empty cell: [|[]] => [|]
if (inMathed()) {
plainErase();
// Directly delete empty cell: [|[]] => [|]
if (inMathed()) {
plainErase();
if (inMathed())
pullArg();
else
if (inMathed())
pullArg();
else
if (pos() == lastpos()) {
bool one_cell = inset().nargs() == 1;
if (one_cell && lastpos() == 0) {
if (pos() == lastpos()) {
bool one_cell = inset().nargs() == 1;
if (one_cell && lastpos() == 0) {
// Directly delete empty cell: [|[]] => [|]
if (inMathed()) {
plainErase();
// Directly delete empty cell: [|[]] => [|]
if (inMathed()) {
plainErase();
MathAtom t = a;
asArray(cap::grabAndEraseSelection(*this), t.nucleus()->cell(c));
insert(t);
MathAtom t = a;
asArray(cap::grabAndEraseSelection(*this), t.nucleus()->cell(c));
insert(t);
- posLeft();
- pushLeft(*nextInset());
+ posBackward();
+ pushBackward(*nextInset());
{
// FIXME: Look here
MathData ar = cell();
{
// FIXME: Look here
MathData ar = cell();
- if (popLeft() && inMathed()) {
+ if (popBackward() && inMathed()) {
plainErase();
cell().insert(pos(), ar);
resetAnchor();
plainErase();
cell().insert(pos(), ar);
resetAnchor();
}
// any improvement going just out of inset?
}
// any improvement going just out of inset?
- if (popLeft() && inMathed()) {
- //lyxerr << "updown: popLeft succeeded" << endl;
+ if (popBackward() && inMathed()) {
+ //lyxerr << "updown: popBackward succeeded" << endl;
int xnew;
int ynew;
getPos(xnew, ynew);
int xnew;
int ynew;
getPos(xnew, ynew);
// something left in the cell
if (pos() == 0) {
// cursor in first position
// something left in the cell
if (pos() == 0) {
// cursor in first position
} else if (pos() == lastpos()) {
// cursor in last position
} else if (pos() == lastpos()) {
// cursor in last position
} else {
// cursor in between. split cell
MathData::iterator bt = cell().begin();
MathAtom at = createInsetMath(from_utf8(font));
at.nucleus()->cell(0) = MathData(bt, bt + pos());
cell().erase(bt, bt + pos());
} else {
// cursor in between. split cell
MathData::iterator bt = cell().begin();
MathAtom at = createInsetMath(from_utf8(font));
at.nucleus()->cell(0) = MathData(bt, bt + pos());
cell().erase(bt, bt + pos());
plainInsert(at);
}
} else {
plainInsert(at);
}
} else {
DispatchResult result() const;
/// add a new cursor slice
void push(Inset & inset);
DispatchResult result() const;
/// add a new cursor slice
void push(Inset & inset);
- /// add a new cursor slice, place cursor on left end
- void pushLeft(Inset & inset);
+ /// add a new cursor slice, place cursor at front (move backwards)
+ void pushBackward(Inset & inset);
/// pop one level off the cursor
void pop();
/// pop one level off the cursor
void pop();
- /// pop one slice off the cursor stack and go left
- bool popLeft();
- /// pop one slice off the cursor stack and go right
- bool popRight();
+ /// pop one slice off the cursor stack and go backwards
+ bool popBackward();
+ /// pop one slice off the cursor stack and go forward
+ bool popForward();
/// make sure we are outside of given inset
void leaveInset(Inset const & inset);
/// sets cursor part
/// make sure we are outside of given inset
void leaveInset(Inset const & inset);
/// sets cursor part
- /// move one step to the left
- bool posLeft();
- /// move one step to the right
- bool posRight();
+ /// move one step backwards
+ bool posBackward();
+ /// move one step forward
+ bool posForward();
/// insert an inset
void insert(Inset *);
/// insert an inset
void insert(Inset *);
&& (inset_code == NO_CODE
|| inset_code == it->lyxCode())) {
Cursor tmpcur = cur;
&& (inset_code == NO_CODE
|| inset_code == it->lyxCode())) {
Cursor tmpcur = cur;
+ tmpcur.pushBackward(*it);
it->dispatch(tmpcur, fr);
}
}
it->dispatch(tmpcur, fr);
}
}
ParagraphList plist;
if (cur.lastpit() != 0 || cur.lastpos() != 0)
plist = paragraphs();
ParagraphList plist;
if (cur.lastpit() != 0 || cur.lastpos() != 0)
plist = paragraphs();
// store cursor offset
if (spit == 0)
spos += cur.pos();
// store cursor offset
if (spit == 0)
spos += cur.pos();
cur.recordUndo();
cap::replaceSelection(cur);
cur.insert(new InsetSpecialChar(kind));
cur.recordUndo();
cap::replaceSelection(cur);
cur.insert(new InsetSpecialChar(kind));
cur.recordUndo();
cap::replaceSelection(cur);
cur.insert(new InsetNewline);
cur.recordUndo();
cap::replaceSelection(cur);
cur.insert(new InsetNewline);
moveCursor(cur, false);
}
break;
moveCursor(cur, false);
}
break;
if (cur.selection())
cutSelection(cur, true, false);
insertInset(cur, inset);
if (cur.selection())
cutSelection(cur, true, false);
insertInset(cur, inset);
insertChar(cur, ' ');
else {
doInsertInset(cur, this, cmd, false, false);
insertChar(cur, ' ');
else {
doInsertInset(cur, this, cmd, false, false);
}
moveCursor(cur, false);
break;
}
moveCursor(cur, false);
break;
cur.insert(new InsetQuotes(c,
bufparams.quotes_language,
InsetQuotes::DoubleQ));
cur.insert(new InsetQuotes(c,
bufparams.quotes_language,
InsetQuotes::DoubleQ));
}
else
lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
}
else
lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
static_cast<InsetInfo *>(inset)->setInfo(to_utf8(ds));
}
insertInset(cur, inset);
static_cast<InsetInfo *>(inset)->setInfo(to_utf8(ds));
}
insertInset(cur, inset);
// Open the inset, and move the current selection
// inside it.
doInsertInset(cur, this, cmd, true, true);
// Open the inset, and move the current selection
// inside it.
doInsertInset(cur, this, cmd, true, true);
// These insets are numbered.
updateLabels(bv->buffer());
break;
// These insets are numbered.
updateLabels(bv->buffer());
break;
// Open the inset, and move the current selection
// inside it.
doInsertInset(cur, this, cmd, true, true);
// Open the inset, and move the current selection
// inside it.
doInsertInset(cur, this, cmd, true, true);
break;
case LFUN_TABULAR_INSERT:
// if there were no arguments, just open the dialog
if (doInsertInset(cur, this, cmd, false, true))
break;
case LFUN_TABULAR_INSERT:
// if there were no arguments, just open the dialog
if (doInsertInset(cur, this, cmd, false, true))
else
bv->showDialog("tabularcreate");
else
bv->showDialog("tabularcreate");
bool content = cur.selection(); // will some text be moved into the inset?
doInsertInset(cur, this, cmd, true, true);
bool content = cur.selection(); // will some text be moved into the inset?
doInsertInset(cur, this, cmd, true, true);
ParagraphList & pars = cur.text()->paragraphs();
TextClass const & tclass = bv->buffer().params().getTextClass();
ParagraphList & pars = cur.text()->paragraphs();
TextClass const & tclass = bv->buffer().params().getTextClass();
case LFUN_INDEX_INSERT:
doInsertInset(cur, this, cmd, true, true);
case LFUN_INDEX_INSERT:
doInsertInset(cur, this, cmd, true, true);
break;
case LFUN_NOMENCL_INSERT: {
break;
case LFUN_NOMENCL_INSERT: {
// description entry still needs to be filled in.
if (cmd.action == LFUN_NOMENCL_INSERT)
inset->edit(cur, true);
// description entry still needs to be filled in.
if (cmd.action == LFUN_NOMENCL_INSERT)
inset->edit(cur, true);
case LFUN_CLEARDOUBLEPAGE_INSERT:
// do nothing fancy
doInsertInset(cur, this, cmd, false, false);
case LFUN_CLEARDOUBLEPAGE_INSERT:
// do nothing fancy
doInsertInset(cur, this, cmd, false, false);
break;
case LFUN_DEPTH_DECREMENT:
break;
case LFUN_DEPTH_DECREMENT:
ParagraphParameters p;
setParagraphs(cur, p);
insertInset(cur, new InsetFloatList(to_utf8(cmd.argument())));
ParagraphParameters p;
setParagraphs(cur, p);
insertInset(cur, new InsetFloatList(to_utf8(cmd.argument())));
} else {
lyxerr << "Non-existent float type: "
<< to_utf8(cmd.argument()) << endl;
} else {
lyxerr << "Non-existent float type: "
<< to_utf8(cmd.argument()) << endl;
// when layout is set; when material is pasted.
int const moveCursor = par.checkBiblio(buffer.params().trackChanges);
if (moveCursor > 0)
// when layout is set; when material is pasted.
int const moveCursor = par.checkBiblio(buffer.params().trackChanges);
if (moveCursor > 0)
- const_cast<Cursor &>(bv_->cursor()).posRight();
+ const_cast<Cursor &>(bv_->cursor()).posForward();
else if (moveCursor < 0) {
Cursor & cursor = const_cast<Cursor &>(bv_->cursor());
if (cursor.pos() >= -moveCursor)
else if (moveCursor < 0) {
Cursor & cursor = const_cast<Cursor &>(bv_->cursor());
if (cursor.pos() >= -moveCursor)
}
// Optimisation: this is used in the next two loops
}
// Optimisation: this is used in the next two loops
/// Move one physical cell down
virtual bool idxPrev(Cursor &) const { return false; }
/// Move one physical cell down
virtual bool idxPrev(Cursor &) const { return false; }
- /// Target pos when we enter the inset from the left by pressing "Right"
+ /// Target pos when we enter the inset while moving forward
virtual bool idxFirst(Cursor &) const { return false; }
virtual bool idxFirst(Cursor &) const { return false; }
- /// Target pos when we enter the inset from the right by pressing "Left"
+ /// Target pos when we enter the inset while moving backwards
virtual bool idxLast(Cursor &) const { return false; }
/// Delete a cell and move cursor
virtual bool idxLast(Cursor &) const { return false; }
/// Delete a cell and move cursor
-void InsetMathHull::edit(Cursor & cur, bool left)
+void InsetMathHull::edit(Cursor & cur, bool front)
- left ? idxFirst(cur) : idxLast(cur);
+ front ? idxFirst(cur) : idxLast(cur);
// The inset formula dimension is not necessarily the same as the
// one of the instant preview image, so we have to indicate to the
// BufferView that a metrics update is needed.
// The inset formula dimension is not necessarily the same as the
// one of the instant preview image, so we have to indicate to the
// BufferView that a metrics update is needed.
///
EDITABLE editable() const { return HIGHLY_EDITABLE; }
///
///
EDITABLE editable() const { return HIGHLY_EDITABLE; }
///
- void edit(Cursor & cur, bool left);
+ void edit(Cursor & cur, bool front);
///
Inset * editXY(Cursor & cur, int x, int y);
///
///
Inset * editXY(Cursor & cur, int x, int y);
///
cur.clearTargetX();
cur.macroModeClose();
if (cur.pos() != cur.lastpos() && cur.openable(cur.nextAtom())) {
cur.clearTargetX();
cur.macroModeClose();
if (cur.pos() != cur.lastpos() && cur.openable(cur.nextAtom())) {
- cur.pushLeft(*cur.nextAtom().nucleus());
+ cur.pushBackward(*cur.nextAtom().nucleus());
cur.inset().idxFirst(cur);
cur.inset().idxFirst(cur);
- } else if (cur.posRight() || idxRight(cur)
- || cur.popRight() || cur.selection())
+ } else if (cur.posForward() || idxRight(cur)
+ || cur.popForward() || cur.selection())
;
else {
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
;
else {
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
cur.clearTargetX();
cur.macroModeClose();
if (cur.pos() != 0 && cur.openable(cur.prevAtom())) {
cur.clearTargetX();
cur.macroModeClose();
if (cur.pos() != 0 && cur.openable(cur.prevAtom())) {
cur.push(*cur.nextAtom().nucleus());
cur.inset().idxLast(cur);
cur.push(*cur.nextAtom().nucleus());
cur.inset().idxLast(cur);
- } else if (cur.posLeft() || idxLeft(cur)
- || cur.popLeft() || cur.selection())
+ } else if (cur.posBackward() || idxLeft(cur)
+ || cur.popBackward() || cur.selection())
;
else {
cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
;
else {
cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
case LFUN_INSET_TOGGLE:
cur.recordUndo();
lock(!lock());
case LFUN_INSET_TOGGLE:
cur.recordUndo();
lock(!lock());
break;
case LFUN_SELF_INSERT:
break;
case LFUN_SELF_INSERT:
&& cur.macroModeClose()) {
MathAtom const atom = cur.prevAtom();
if (atom->asNestInset() && atom->isActive()) {
&& cur.macroModeClose()) {
MathAtom const atom = cur.prevAtom();
if (atom->asNestInset() && atom->isActive()) {
- cur.posLeft();
- cur.pushLeft(*cur.nextInset());
+ cur.posBackward();
+ cur.pushBackward(*cur.nextInset());
}
} else if (!interpretChar(cur, cmd.argument()[0])) {
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
}
} else if (!interpretChar(cur, cmd.argument()[0])) {
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
selClearOrDel(cur);
//cur.plainInsert(MathAtom(new InsetMathMBox(cur.bv())));
cur.plainInsert(MathAtom(new InsetMathBox(from_ascii("mbox"))));
selClearOrDel(cur);
//cur.plainInsert(MathAtom(new InsetMathMBox(cur.bv())));
cur.plainInsert(MathAtom(new InsetMathBox(from_ascii("mbox"))));
- cur.posLeft();
- cur.pushLeft(*cur.nextInset());
+ cur.posBackward();
+ cur.pushBackward(*cur.nextInset());
cur.niceInsert(save_selection);
#else
if (currentMode() == Inset::TEXT_MODE) {
cur.niceInsert(save_selection);
#else
if (currentMode() == Inset::TEXT_MODE) {
+ if (cur.popForward()) {
// FIXME: we have to enable full redraw here because of the
// visual box corners that define the inset. If we know for
// sure that we stay within the same cell we can optimize for
// FIXME: we have to enable full redraw here because of the
// visual box corners that define the inset. If we know for
// sure that we stay within the same cell we can optimize for
/// move one physical cell down
bool idxPrev(Cursor &) const;
/// move one physical cell down
bool idxPrev(Cursor &) const;
- /// target pos when we enter the inset from the left by pressing "Right"
+ /// target pos when we enter the inset while moving forward
bool idxFirst(Cursor &) const;
bool idxFirst(Cursor &) const;
- /// target pos when we enter the inset from the right by pressing "Left"
+ /// target pos when we enter the inset while moving backwards
bool idxLast(Cursor &) const;
/// number of cells currently governed by us
bool idxLast(Cursor &) const;
/// number of cells currently governed by us
bool idxRight(Cursor & cur) const;
/// move cursor up or down
bool idxUpDown(Cursor & cur, bool up) const;
bool idxRight(Cursor & cur) const;
/// move cursor up or down
bool idxUpDown(Cursor & cur, bool up) const;
- /// Target pos when we enter the inset from the left by pressing "Right"
+ /// Target pos when we enter the inset while moving forward
bool idxFirst(Cursor & cur) const;
bool idxFirst(Cursor & cur) const;
- /// Target pos when we enter the inset from the right by pressing "Left"
+ /// Target pos when we enter the inset while moving backwards
bool idxLast(Cursor & cur) const;
/// write LaTeX and Lyx code
bool idxLast(Cursor & cur) const;
/// write LaTeX and Lyx code
///
Inset * editXY(Cursor & cur, int x, int y);
///
Inset * editXY(Cursor & cur, int x, int y);
- /// target pos when we enter the inset from the left by pressing "Right"
+ /// target pos when we enter the inset while moving forward
bool idxFirst(Cursor &) const;
bool idxFirst(Cursor &) const;
- /// target pos when we enter the inset from the right by pressing "Left"
+ /// target pos when we enter the inset while moving backwards
bool idxLast(Cursor &) const;
///
bool idxLast(Cursor &) const;
///