From ddd82f7aa4f124da045f1d9ddd723598b0d39402 Mon Sep 17 00:00:00 2001 From: Dov Feldstern Date: Mon, 5 Nov 2007 19:41:16 +0000 Subject: [PATCH] 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 --- src/BufferView.cpp | 2 +- src/Cursor.cpp | 44 ++++++++++++++++++------------------ src/Cursor.h | 20 ++++++++-------- src/LyXFunc.cpp | 2 +- src/Text.cpp | 2 +- src/Text3.cpp | 28 +++++++++++------------ src/TextMetrics.cpp | 4 ++-- src/insets/Inset.h | 4 ++-- src/mathed/InsetMathHull.cpp | 4 ++-- src/mathed/InsetMathHull.h | 2 +- src/mathed/InsetMathNest.cpp | 24 ++++++++++---------- src/mathed/InsetMathNest.h | 4 ++-- src/mathed/InsetMathScript.h | 4 ++-- src/mathed/MathMacro.h | 4 ++-- 14 files changed, 74 insertions(+), 74 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index b538fc0649..5275791927 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -1320,7 +1320,7 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd) if (inset) { if (inset->isActive()) { Cursor tmpcur = cur; - tmpcur.pushLeft(*inset); + tmpcur.pushBackward(*inset); inset->dispatch(tmpcur, tmpcmd); if (tmpcur.result().dispatched()) { cur.dispatched(); diff --git a/src/Cursor.cpp b/src/Cursor.cpp index a64381b018..791c2602bb 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -370,19 +370,19 @@ void Cursor::push(Inset & p) } -void Cursor::pushLeft(Inset & p) +void Cursor::pushBackward(Inset & p) { BOOST_ASSERT(!empty()); - //lyxerr << "Entering inset " << t << " left" << endl; + //lyxerr << "Entering inset " << t << " front" << endl; push(p); p.idxFirst(*this); } -bool Cursor::popLeft() +bool Cursor::popBackward() { 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; @@ -391,10 +391,10 @@ bool Cursor::popLeft() } -bool Cursor::popRight() +bool Cursor::popForward() { 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) @@ -440,7 +440,7 @@ void Cursor::resetAnchor() -bool Cursor::posLeft() +bool Cursor::posBackward() { if (pos() == 0) return false; @@ -449,7 +449,7 @@ bool Cursor::posLeft() } -bool Cursor::posRight() +bool Cursor::posForward() { if (pos() == lastpos()) return false; @@ -772,10 +772,10 @@ void Cursor::niceInsert(MathAtom const & t) 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 - pushLeft(*nextInset()); + pushBackward(*nextInset()); // We may not use niceInsert here (recursion) MathData ar; asArray(safe, ar); @@ -806,7 +806,7 @@ bool Cursor::backspace() if (pos() == 0) { // If empty cell, and not part of a big cell if (lastpos() == 0 && inset().nargs() == 1) { - popLeft(); + popBackward(); // Directly delete empty cell: [|[]] => [|] if (inMathed()) { plainErase(); @@ -819,7 +819,7 @@ bool Cursor::backspace() if (inMathed()) pullArg(); else - popLeft(); + popBackward(); return true; } } @@ -865,7 +865,7 @@ bool Cursor::erase() if (pos() == lastpos()) { bool one_cell = inset().nargs() == 1; if (one_cell && lastpos() == 0) { - popLeft(); + popBackward(); // Directly delete empty cell: [|[]] => [|] if (inMathed()) { plainErase(); @@ -967,8 +967,8 @@ void Cursor::handleNest(MathAtom const & a, int c) MathAtom t = a; asArray(cap::grabAndEraseSelection(*this), t.nucleus()->cell(c)); insert(t); - posLeft(); - pushLeft(*nextInset()); + posBackward(); + pushBackward(*nextInset()); } @@ -1019,7 +1019,7 @@ void Cursor::pullArg() { // FIXME: Look here MathData ar = cell(); - if (popLeft() && inMathed()) { + if (popBackward() && inMathed()) { plainErase(); cell().insert(pos(), ar); resetAnchor(); @@ -1161,8 +1161,8 @@ bool Cursor::upDownInMath(bool up) } // 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); @@ -1303,17 +1303,17 @@ void Cursor::handleFont(string const & font) // something left in the cell if (pos() == 0) { // cursor in first position - popLeft(); + popBackward(); } else if (pos() == lastpos()) { // cursor in last position - popRight(); + popForward(); } 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()); - popLeft(); + popBackward(); plainInsert(at); } } else { diff --git a/src/Cursor.h b/src/Cursor.h index 1ee104cd52..a275260bf8 100644 --- a/src/Cursor.h +++ b/src/Cursor.h @@ -48,14 +48,14 @@ public: 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 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 @@ -112,10 +112,10 @@ public: // // common 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 *); diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index f917369253..89bcdf1728 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -1841,7 +1841,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) && (inset_code == NO_CODE || inset_code == it->lyxCode())) { Cursor tmpcur = cur; - tmpcur.pushLeft(*it); + tmpcur.pushBackward(*it); it->dispatch(tmpcur, fr); } } diff --git a/src/Text.cpp b/src/Text.cpp index d7745e4203..fce891497d 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -1053,7 +1053,7 @@ bool Text::dissolveInset(Cursor & cur) { ParagraphList plist; if (cur.lastpit() != 0 || cur.lastpos() != 0) plist = paragraphs(); - cur.popLeft(); + cur.popBackward(); // store cursor offset if (spit == 0) spos += cur.pos(); diff --git a/src/Text3.cpp b/src/Text3.cpp index 887e9bd050..b04b475ca1 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -179,7 +179,7 @@ static void specialChar(Cursor & cur, InsetSpecialChar::Kind kind) cur.recordUndo(); cap::replaceSelection(cur); cur.insert(new InsetSpecialChar(kind)); - cur.posRight(); + cur.posForward(); } @@ -558,7 +558,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cur.recordUndo(); cap::replaceSelection(cur); cur.insert(new InsetNewline); - cur.posRight(); + cur.posForward(); moveCursor(cur, false); } break; @@ -714,7 +714,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) if (cur.selection()) cutSelection(cur, true, false); insertInset(cur, inset); - cur.posRight(); + cur.posForward(); } break; } @@ -732,7 +732,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) insertChar(cur, ' '); else { doInsertInset(cur, this, cmd, false, false); - cur.posRight(); + cur.posForward(); } moveCursor(cur, false); break; @@ -936,7 +936,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cur.insert(new InsetQuotes(c, bufparams.quotes_language, InsetQuotes::DoubleQ)); - cur.posRight(); + cur.posForward(); } else lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\"")); @@ -1156,7 +1156,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) static_cast(inset)->setInfo(to_utf8(ds)); } insertInset(cur, inset); - cur.posRight(); + cur.posForward(); break; } #if 0 @@ -1168,7 +1168,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // Open the inset, and move the current selection // inside it. doInsertInset(cur, this, cmd, true, true); - cur.posRight(); + cur.posForward(); // These insets are numbered. updateLabels(bv->buffer()); break; @@ -1185,13 +1185,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // Open the inset, and move the current selection // inside it. doInsertInset(cur, this, cmd, true, true); - cur.posRight(); + cur.posForward(); break; case LFUN_TABULAR_INSERT: // if there were no arguments, just open the dialog if (doInsertInset(cur, this, cmd, false, true)) - cur.posRight(); + cur.posForward(); else 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? doInsertInset(cur, this, cmd, true, true); - cur.posRight(); + cur.posForward(); ParagraphList & pars = cur.text()->paragraphs(); TextClass const & tclass = bv->buffer().params().getTextClass(); @@ -1242,7 +1242,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INDEX_INSERT: doInsertInset(cur, this, cmd, true, true); - cur.posRight(); + cur.posForward(); break; case LFUN_NOMENCL_INSERT: { @@ -1260,7 +1260,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // description entry still needs to be filled in. if (cmd.action == LFUN_NOMENCL_INSERT) inset->edit(cur, true); - cur.posRight(); + cur.posForward(); break; } @@ -1274,7 +1274,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_CLEARDOUBLEPAGE_INSERT: // do nothing fancy doInsertInset(cur, this, cmd, false, false); - cur.posRight(); + cur.posForward(); break; case LFUN_DEPTH_DECREMENT: @@ -1516,7 +1516,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) ParagraphParameters p; setParagraphs(cur, p); insertInset(cur, new InsetFloatList(to_utf8(cmd.argument()))); - cur.posRight(); + cur.posForward(); } else { lyxerr << "Non-existent float type: " << to_utf8(cmd.argument()) << endl; diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 1e317ba6e5..6efe804f0b 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -369,11 +369,11 @@ bool TextMetrics::redoParagraph(pit_type const pit) // when layout is set; when material is pasted. int const moveCursor = par.checkBiblio(buffer.params().trackChanges); if (moveCursor > 0) - const_cast(bv_->cursor()).posRight(); + const_cast(bv_->cursor()).posForward(); else if (moveCursor < 0) { Cursor & cursor = const_cast(bv_->cursor()); if (cursor.pos() >= -moveCursor) - cursor.posLeft(); + cursor.posBackward(); } // Optimisation: this is used in the next two loops diff --git a/src/insets/Inset.h b/src/insets/Inset.h index d7fdbd1439..e432a6406b 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -180,9 +180,9 @@ public: /// 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; } - /// 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 diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index f344cc1e3c..daa89e1bb1 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -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); - 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. diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index b69b55f75e..e866874bcf 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -196,7 +196,7 @@ public: /// 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); /// diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index f85f6d872f..810dfaa275 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -507,10 +507,10 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd) 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); - } 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); @@ -526,11 +526,11 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd) cur.clearTargetX(); cur.macroModeClose(); if (cur.pos() != 0 && cur.openable(cur.prevAtom())) { - cur.posLeft(); + cur.posBackward(); 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); @@ -729,7 +729,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_TOGGLE: cur.recordUndo(); lock(!lock()); - cur.popRight(); + cur.popForward(); break; case LFUN_SELF_INSERT: @@ -760,8 +760,8 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd) && 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); @@ -881,8 +881,8 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd) 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) { @@ -1463,7 +1463,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type c) return true; } - if (cur.popRight()) { + 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 diff --git a/src/mathed/InsetMathNest.h b/src/mathed/InsetMathNest.h index db4cfa7414..3b54b3a8af 100644 --- a/src/mathed/InsetMathNest.h +++ b/src/mathed/InsetMathNest.h @@ -62,9 +62,9 @@ public: /// 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; - /// 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 diff --git a/src/mathed/InsetMathScript.h b/src/mathed/InsetMathScript.h index 68a4572d73..ad6b1f5c5e 100644 --- a/src/mathed/InsetMathScript.h +++ b/src/mathed/InsetMathScript.h @@ -47,9 +47,9 @@ public: 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; - /// 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 diff --git a/src/mathed/MathMacro.h b/src/mathed/MathMacro.h index 050abe1849..dc90e10304 100644 --- a/src/mathed/MathMacro.h +++ b/src/mathed/MathMacro.h @@ -49,9 +49,9 @@ public: /// 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; - /// 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; /// -- 2.39.2