Getting rid of LTR bias --- part 3/4

This is a continuation of r21128, r21244


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21448 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dov Feldstern 2007-11-05 19:41:16 +00:00
parent c888185ffc
commit ddd82f7aa4
14 changed files with 74 additions and 74 deletions

View File

@ -1320,7 +1320,7 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
if (inset) { if (inset) {
if (inset->isActive()) { if (inset->isActive()) {
Cursor tmpcur = cur; Cursor tmpcur = cur;
tmpcur.pushLeft(*inset); tmpcur.pushBackward(*inset);
inset->dispatch(tmpcur, tmpcmd); inset->dispatch(tmpcur, tmpcmd);
if (tmpcur.result().dispatched()) { if (tmpcur.result().dispatched()) {
cur.dispatched(); cur.dispatched();

View File

@ -370,19 +370,19 @@ void Cursor::push(Inset & p)
} }
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); push(p);
p.idxFirst(*this); p.idxFirst(*this);
} }
bool Cursor::popLeft() 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); inset().notifyCursorLeaves(*this);
if (depth() == 1) if (depth() == 1)
return false; return false;
@ -391,10 +391,10 @@ bool Cursor::popLeft()
} }
bool Cursor::popRight() 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; const pos_type lp = (depth() > 1) ? (*this)[depth() - 2].lastpos() : 0;
inset().notifyCursorLeaves(*this); inset().notifyCursorLeaves(*this);
if (depth() == 1) if (depth() == 1)
@ -440,7 +440,7 @@ void Cursor::resetAnchor()
bool Cursor::posLeft() bool Cursor::posBackward()
{ {
if (pos() == 0) if (pos() == 0)
return false; return false;
@ -449,7 +449,7 @@ bool Cursor::posLeft()
} }
bool Cursor::posRight() bool Cursor::posForward()
{ {
if (pos() == lastpos()) if (pos() == lastpos())
return false; return false;
@ -772,10 +772,10 @@ void Cursor::niceInsert(MathAtom const & t)
plainInsert(t); plainInsert(t);
// enter the new inset and move the contents of the selection if possible // enter the new inset and move the contents of the selection if possible
if (t->isActive()) { if (t->isActive()) {
posLeft(); posBackward();
// be careful here: don't use 'pushLeft(t)' as this we need to // 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) // We may not use niceInsert here (recursion)
MathData ar; MathData ar;
asArray(safe, ar); asArray(safe, ar);
@ -806,7 +806,7 @@ bool Cursor::backspace()
if (pos() == 0) { if (pos() == 0) {
// If empty cell, and not part of a big cell // If empty cell, and not part of a big cell
if (lastpos() == 0 && inset().nargs() == 1) { if (lastpos() == 0 && inset().nargs() == 1) {
popLeft(); popBackward();
// Directly delete empty cell: [|[]] => [|] // Directly delete empty cell: [|[]] => [|]
if (inMathed()) { if (inMathed()) {
plainErase(); plainErase();
@ -819,7 +819,7 @@ bool Cursor::backspace()
if (inMathed()) if (inMathed())
pullArg(); pullArg();
else else
popLeft(); popBackward();
return true; return true;
} }
} }
@ -865,7 +865,7 @@ bool Cursor::erase()
if (pos() == lastpos()) { if (pos() == lastpos()) {
bool one_cell = inset().nargs() == 1; bool one_cell = inset().nargs() == 1;
if (one_cell && lastpos() == 0) { if (one_cell && lastpos() == 0) {
popLeft(); popBackward();
// Directly delete empty cell: [|[]] => [|] // Directly delete empty cell: [|[]] => [|]
if (inMathed()) { if (inMathed()) {
plainErase(); plainErase();
@ -967,8 +967,8 @@ void Cursor::handleNest(MathAtom const & a, int c)
MathAtom t = a; MathAtom t = a;
asArray(cap::grabAndEraseSelection(*this), t.nucleus()->cell(c)); asArray(cap::grabAndEraseSelection(*this), t.nucleus()->cell(c));
insert(t); insert(t);
posLeft(); posBackward();
pushLeft(*nextInset()); pushBackward(*nextInset());
} }
@ -1019,7 +1019,7 @@ void Cursor::pullArg()
{ {
// FIXME: Look here // FIXME: Look here
MathData ar = cell(); MathData ar = cell();
if (popLeft() && inMathed()) { if (popBackward() && inMathed()) {
plainErase(); plainErase();
cell().insert(pos(), ar); cell().insert(pos(), ar);
resetAnchor(); resetAnchor();
@ -1161,8 +1161,8 @@ bool Cursor::upDownInMath(bool up)
} }
// any improvement going just out of inset? // any improvement going just out of inset?
if (popLeft() && inMathed()) { if (popBackward() && inMathed()) {
//lyxerr << "updown: popLeft succeeded" << endl; //lyxerr << "updown: popBackward succeeded" << endl;
int xnew; int xnew;
int ynew; int ynew;
getPos(xnew, ynew); getPos(xnew, ynew);
@ -1303,17 +1303,17 @@ void Cursor::handleFont(string const & font)
// something left in the cell // something left in the cell
if (pos() == 0) { if (pos() == 0) {
// cursor in first position // cursor in first position
popLeft(); popBackward();
} else if (pos() == lastpos()) { } else if (pos() == lastpos()) {
// cursor in last position // cursor in last position
popRight(); popForward();
} else { } else {
// cursor in between. split cell // cursor in between. split cell
MathData::iterator bt = cell().begin(); MathData::iterator bt = cell().begin();
MathAtom at = createInsetMath(from_utf8(font)); MathAtom at = createInsetMath(from_utf8(font));
at.nucleus()->cell(0) = MathData(bt, bt + pos()); at.nucleus()->cell(0) = MathData(bt, bt + pos());
cell().erase(bt, bt + pos()); cell().erase(bt, bt + pos());
popLeft(); popBackward();
plainInsert(at); plainInsert(at);
} }
} else { } else {

View File

@ -48,14 +48,14 @@ public:
DispatchResult result() const; DispatchResult result() const;
/// add a new cursor slice /// add a new cursor slice
void push(Inset & inset); void push(Inset & inset);
/// add a new cursor slice, place cursor on left end /// add a new cursor slice, place cursor at front (move backwards)
void pushLeft(Inset & inset); void pushBackward(Inset & inset);
/// pop one level off the cursor /// pop one level off the cursor
void pop(); void pop();
/// pop one slice off the cursor stack and go left /// pop one slice off the cursor stack and go backwards
bool popLeft(); bool popBackward();
/// pop one slice off the cursor stack and go right /// pop one slice off the cursor stack and go forward
bool popRight(); bool popForward();
/// make sure we are outside of given inset /// make sure we are outside of given inset
void leaveInset(Inset const & inset); void leaveInset(Inset const & inset);
/// sets cursor part /// sets cursor part
@ -112,10 +112,10 @@ public:
// //
// common part // common part
// //
/// move one step to the left /// move one step backwards
bool posLeft(); bool posBackward();
/// move one step to the right /// move one step forward
bool posRight(); bool posForward();
/// insert an inset /// insert an inset
void insert(Inset *); void insert(Inset *);

View File

@ -1841,7 +1841,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
&& (inset_code == NO_CODE && (inset_code == NO_CODE
|| inset_code == it->lyxCode())) { || inset_code == it->lyxCode())) {
Cursor tmpcur = cur; Cursor tmpcur = cur;
tmpcur.pushLeft(*it); tmpcur.pushBackward(*it);
it->dispatch(tmpcur, fr); it->dispatch(tmpcur, fr);
} }
} }

View File

@ -1053,7 +1053,7 @@ bool Text::dissolveInset(Cursor & cur) {
ParagraphList plist; ParagraphList plist;
if (cur.lastpit() != 0 || cur.lastpos() != 0) if (cur.lastpit() != 0 || cur.lastpos() != 0)
plist = paragraphs(); plist = paragraphs();
cur.popLeft(); cur.popBackward();
// store cursor offset // store cursor offset
if (spit == 0) if (spit == 0)
spos += cur.pos(); spos += cur.pos();

View File

@ -179,7 +179,7 @@ static void specialChar(Cursor & cur, InsetSpecialChar::Kind kind)
cur.recordUndo(); cur.recordUndo();
cap::replaceSelection(cur); cap::replaceSelection(cur);
cur.insert(new InsetSpecialChar(kind)); cur.insert(new InsetSpecialChar(kind));
cur.posRight(); cur.posForward();
} }
@ -558,7 +558,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
cur.recordUndo(); cur.recordUndo();
cap::replaceSelection(cur); cap::replaceSelection(cur);
cur.insert(new InsetNewline); cur.insert(new InsetNewline);
cur.posRight(); cur.posForward();
moveCursor(cur, false); moveCursor(cur, false);
} }
break; break;
@ -714,7 +714,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
if (cur.selection()) if (cur.selection())
cutSelection(cur, true, false); cutSelection(cur, true, false);
insertInset(cur, inset); insertInset(cur, inset);
cur.posRight(); cur.posForward();
} }
break; break;
} }
@ -732,7 +732,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
insertChar(cur, ' '); insertChar(cur, ' ');
else { else {
doInsertInset(cur, this, cmd, false, false); doInsertInset(cur, this, cmd, false, false);
cur.posRight(); cur.posForward();
} }
moveCursor(cur, false); moveCursor(cur, false);
break; break;
@ -936,7 +936,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
cur.insert(new InsetQuotes(c, cur.insert(new InsetQuotes(c,
bufparams.quotes_language, bufparams.quotes_language,
InsetQuotes::DoubleQ)); InsetQuotes::DoubleQ));
cur.posRight(); cur.posForward();
} }
else else
lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\"")); lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
@ -1156,7 +1156,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
static_cast<InsetInfo *>(inset)->setInfo(to_utf8(ds)); static_cast<InsetInfo *>(inset)->setInfo(to_utf8(ds));
} }
insertInset(cur, inset); insertInset(cur, inset);
cur.posRight(); cur.posForward();
break; break;
} }
#if 0 #if 0
@ -1168,7 +1168,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// Open the inset, and move the current selection // Open the inset, and move the current selection
// inside it. // inside it.
doInsertInset(cur, this, cmd, true, true); doInsertInset(cur, this, cmd, true, true);
cur.posRight(); cur.posForward();
// These insets are numbered. // These insets are numbered.
updateLabels(bv->buffer()); updateLabels(bv->buffer());
break; break;
@ -1185,13 +1185,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// Open the inset, and move the current selection // Open the inset, and move the current selection
// inside it. // inside it.
doInsertInset(cur, this, cmd, true, true); doInsertInset(cur, this, cmd, true, true);
cur.posRight(); cur.posForward();
break; break;
case LFUN_TABULAR_INSERT: case LFUN_TABULAR_INSERT:
// if there were no arguments, just open the dialog // if there were no arguments, just open the dialog
if (doInsertInset(cur, this, cmd, false, true)) if (doInsertInset(cur, this, cmd, false, true))
cur.posRight(); cur.posForward();
else else
bv->showDialog("tabularcreate"); bv->showDialog("tabularcreate");
@ -1203,7 +1203,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
bool content = cur.selection(); // will some text be moved into the inset? bool content = cur.selection(); // will some text be moved into the inset?
doInsertInset(cur, this, cmd, true, true); doInsertInset(cur, this, cmd, true, true);
cur.posRight(); cur.posForward();
ParagraphList & pars = cur.text()->paragraphs(); ParagraphList & pars = cur.text()->paragraphs();
TextClass const & tclass = bv->buffer().params().getTextClass(); TextClass const & tclass = bv->buffer().params().getTextClass();
@ -1242,7 +1242,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_INDEX_INSERT: case LFUN_INDEX_INSERT:
doInsertInset(cur, this, cmd, true, true); doInsertInset(cur, this, cmd, true, true);
cur.posRight(); cur.posForward();
break; break;
case LFUN_NOMENCL_INSERT: { case LFUN_NOMENCL_INSERT: {
@ -1260,7 +1260,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// description entry still needs to be filled in. // description entry still needs to be filled in.
if (cmd.action == LFUN_NOMENCL_INSERT) if (cmd.action == LFUN_NOMENCL_INSERT)
inset->edit(cur, true); inset->edit(cur, true);
cur.posRight(); cur.posForward();
break; break;
} }
@ -1274,7 +1274,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_CLEARDOUBLEPAGE_INSERT: case LFUN_CLEARDOUBLEPAGE_INSERT:
// do nothing fancy // do nothing fancy
doInsertInset(cur, this, cmd, false, false); doInsertInset(cur, this, cmd, false, false);
cur.posRight(); cur.posForward();
break; break;
case LFUN_DEPTH_DECREMENT: case LFUN_DEPTH_DECREMENT:
@ -1516,7 +1516,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
ParagraphParameters p; ParagraphParameters p;
setParagraphs(cur, p); setParagraphs(cur, p);
insertInset(cur, new InsetFloatList(to_utf8(cmd.argument()))); insertInset(cur, new InsetFloatList(to_utf8(cmd.argument())));
cur.posRight(); cur.posForward();
} else { } else {
lyxerr << "Non-existent float type: " lyxerr << "Non-existent float type: "
<< to_utf8(cmd.argument()) << endl; << to_utf8(cmd.argument()) << endl;

View File

@ -369,11 +369,11 @@ bool TextMetrics::redoParagraph(pit_type const pit)
// when layout is set; when material is pasted. // when layout is set; when material is pasted.
int const moveCursor = par.checkBiblio(buffer.params().trackChanges); int const moveCursor = par.checkBiblio(buffer.params().trackChanges);
if (moveCursor > 0) if (moveCursor > 0)
const_cast<Cursor &>(bv_->cursor()).posRight(); const_cast<Cursor &>(bv_->cursor()).posForward();
else if (moveCursor < 0) { else if (moveCursor < 0) {
Cursor & cursor = const_cast<Cursor &>(bv_->cursor()); Cursor & cursor = const_cast<Cursor &>(bv_->cursor());
if (cursor.pos() >= -moveCursor) if (cursor.pos() >= -moveCursor)
cursor.posLeft(); cursor.posBackward();
} }
// Optimisation: this is used in the next two loops // Optimisation: this is used in the next two loops

View File

@ -180,9 +180,9 @@ public:
/// Move one physical cell down /// Move one physical cell down
virtual bool idxPrev(Cursor &) const { return false; } 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; } virtual bool idxLast(Cursor &) const { return false; }
/// Delete a cell and move cursor /// Delete a cell and move cursor

View File

@ -1308,10 +1308,10 @@ void InsetMathHull::handleFont2(Cursor & cur, docstring const & arg)
} }
void InsetMathHull::edit(Cursor & cur, bool left) void InsetMathHull::edit(Cursor & cur, bool front)
{ {
cur.push(*this); cur.push(*this);
left ? idxFirst(cur) : idxLast(cur); front ? idxFirst(cur) : idxLast(cur);
// The inset formula dimension is not necessarily the same as the // The inset formula dimension is not necessarily the same as the
// one of the instant preview image, so we have to indicate to the // one of the instant preview image, so we have to indicate to the
// BufferView that a metrics update is needed. // BufferView that a metrics update is needed.

View File

@ -196,7 +196,7 @@ public:
/// ///
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);
/// ///

View File

@ -507,10 +507,10 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
cur.clearTargetX(); cur.clearTargetX();
cur.macroModeClose(); cur.macroModeClose();
if (cur.pos() != cur.lastpos() && cur.openable(cur.nextAtom())) { 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) } else if (cur.posForward() || idxRight(cur)
|| cur.popRight() || cur.selection()) || cur.popForward() || cur.selection())
; ;
else { else {
cmd = FuncRequest(LFUN_FINISHED_FORWARD); cmd = FuncRequest(LFUN_FINISHED_FORWARD);
@ -526,11 +526,11 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
cur.clearTargetX(); cur.clearTargetX();
cur.macroModeClose(); cur.macroModeClose();
if (cur.pos() != 0 && cur.openable(cur.prevAtom())) { if (cur.pos() != 0 && cur.openable(cur.prevAtom())) {
cur.posLeft(); cur.posBackward();
cur.push(*cur.nextAtom().nucleus()); cur.push(*cur.nextAtom().nucleus());
cur.inset().idxLast(cur); cur.inset().idxLast(cur);
} else if (cur.posLeft() || idxLeft(cur) } else if (cur.posBackward() || idxLeft(cur)
|| cur.popLeft() || cur.selection()) || cur.popBackward() || cur.selection())
; ;
else { else {
cmd = FuncRequest(LFUN_FINISHED_BACKWARD); cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
@ -729,7 +729,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_INSET_TOGGLE: case LFUN_INSET_TOGGLE:
cur.recordUndo(); cur.recordUndo();
lock(!lock()); lock(!lock());
cur.popRight(); cur.popForward();
break; break;
case LFUN_SELF_INSERT: case LFUN_SELF_INSERT:
@ -760,8 +760,8 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
&& cur.macroModeClose()) { && cur.macroModeClose()) {
MathAtom const atom = cur.prevAtom(); MathAtom const atom = cur.prevAtom();
if (atom->asNestInset() && atom->isActive()) { if (atom->asNestInset() && atom->isActive()) {
cur.posLeft(); cur.posBackward();
cur.pushLeft(*cur.nextInset()); cur.pushBackward(*cur.nextInset());
} }
} else if (!interpretChar(cur, cmd.argument()[0])) { } else if (!interpretChar(cur, cmd.argument()[0])) {
cmd = FuncRequest(LFUN_FINISHED_FORWARD); cmd = FuncRequest(LFUN_FINISHED_FORWARD);
@ -881,8 +881,8 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
selClearOrDel(cur); selClearOrDel(cur);
//cur.plainInsert(MathAtom(new InsetMathMBox(cur.bv()))); //cur.plainInsert(MathAtom(new InsetMathMBox(cur.bv())));
cur.plainInsert(MathAtom(new InsetMathBox(from_ascii("mbox")))); cur.plainInsert(MathAtom(new InsetMathBox(from_ascii("mbox"))));
cur.posLeft(); cur.posBackward();
cur.pushLeft(*cur.nextInset()); cur.pushBackward(*cur.nextInset());
cur.niceInsert(save_selection); cur.niceInsert(save_selection);
#else #else
if (currentMode() == Inset::TEXT_MODE) { if (currentMode() == Inset::TEXT_MODE) {
@ -1463,7 +1463,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type c)
return true; return true;
} }
if (cur.popRight()) { if (cur.popForward()) {
// FIXME: we have to enable full redraw here because of the // FIXME: we have to enable full redraw here because of the
// visual box corners that define the inset. If we know for // visual box corners that define the inset. If we know for
// sure that we stay within the same cell we can optimize for // sure that we stay within the same cell we can optimize for

View File

@ -62,9 +62,9 @@ public:
/// move one physical cell down /// move one physical cell down
bool idxPrev(Cursor &) const; 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; bool idxLast(Cursor &) const;
/// number of cells currently governed by us /// number of cells currently governed by us

View File

@ -47,9 +47,9 @@ public:
bool idxRight(Cursor & cur) const; bool idxRight(Cursor & cur) const;
/// move cursor up or down /// move cursor up or down
bool idxUpDown(Cursor & cur, bool up) const; 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; bool idxLast(Cursor & cur) const;
/// write LaTeX and Lyx code /// write LaTeX and Lyx code

View File

@ -49,9 +49,9 @@ public:
/// ///
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;
/// ///