Finishing up the LTR bias removal

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Finishing up the LTR bias removal

Dov Feldstern
Hi!

Attached find the final patch (at least for now) which gets rid of LTR
bias in the code. I will commit in the next few days if there are no
objections.

The only non-trivial change (i.e., more than just changing function
names) is that I merged idxLeft into idxPrev, and idxRight into idxNext.
Does this seem OK?

Other than that, just make sure the names I chose are OK.

As this entire series, behavior should remain unchanged by this patch.

Thanks!
Dov


diff -r 7537ce89f78b src/BufferView.cpp
--- a/src/BufferView.cpp Sat Nov 03 19:12:52 2007 +0100
+++ b/src/BufferView.cpp Sun Nov 04 00:48:34 2007 +0200
@@ -1320,7 +1320,7 @@ Update::flags BufferView::dispatch(FuncR
  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 -r 7537ce89f78b src/Cursor.cpp
--- a/src/Cursor.cpp Sat Nov 03 19:12:52 2007 +0100
+++ b/src/Cursor.cpp Sun Nov 04 00:48:34 2007 +0200
@@ -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 back" << 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 front" << 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 &
  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 &
  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 & f
  // 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 -r 7537ce89f78b src/Cursor.h
--- a/src/Cursor.h Sat Nov 03 19:12:52 2007 +0100
+++ b/src/Cursor.h Sun Nov 04 00:48:34 2007 +0200
@@ -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 -r 7537ce89f78b src/LyXFunc.cpp
--- a/src/LyXFunc.cpp Sat Nov 03 19:12:52 2007 +0100
+++ b/src/LyXFunc.cpp Sun Nov 04 00:48:34 2007 +0200
@@ -1841,7 +1841,7 @@ void LyXFunc::dispatch(FuncRequest const
     && (inset_code == NO_CODE
     || inset_code == it->lyxCode())) {
  Cursor tmpcur = cur;
- tmpcur.pushLeft(*it);
+ tmpcur.pushBackward(*it);
  it->dispatch(tmpcur, fr);
  }
  }
diff -r 7537ce89f78b src/Text.cpp
--- a/src/Text.cpp Sat Nov 03 19:12:52 2007 +0100
+++ b/src/Text.cpp Sun Nov 04 00:48:34 2007 +0200
@@ -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 -r 7537ce89f78b src/Text3.cpp
--- a/src/Text3.cpp Sat Nov 03 19:12:52 2007 +0100
+++ b/src/Text3.cpp Sun Nov 04 00:48:34 2007 +0200
@@ -179,7 +179,7 @@ static void specialChar(Cursor & cur, In
  cur.recordUndo();
  cap::replaceSelection(cur);
  cur.insert(new InsetSpecialChar(kind));
- cur.posRight();
+ cur.posForward();
 }
 
 
@@ -558,7 +558,7 @@ void Text::dispatch(Cursor & cur, FuncRe
  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, FuncRe
  if (cur.selection())
  cutSelection(cur, true, false);
  insertInset(cur, inset);
- cur.posRight();
+ cur.posForward();
  }
  break;
  }
@@ -732,7 +732,7 @@ void Text::dispatch(Cursor & cur, FuncRe
  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, FuncRe
  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, FuncRe
  static_cast<InsetInfo *>(inset)->setInfo(to_utf8(ds));
  }
  insertInset(cur, inset);
- cur.posRight();
+ cur.posForward();
  break;
  }
 #if 0
@@ -1168,7 +1168,7 @@ void Text::dispatch(Cursor & cur, FuncRe
  // 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, FuncRe
  // 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, FuncRe
  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, FuncRe
 
  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, FuncRe
  // 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, FuncRe
  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, FuncRe
  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 -r 7537ce89f78b src/TextMetrics.cpp
--- a/src/TextMetrics.cpp Sat Nov 03 19:12:52 2007 +0100
+++ b/src/TextMetrics.cpp Sun Nov 04 00:48:34 2007 +0200
@@ -369,11 +369,11 @@ bool TextMetrics::redoParagraph(pit_type
  // 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)
- cursor.posLeft();
+ cursor.posBackward();
  }
 
  // Optimisation: this is used in the next two loops
diff -r 7537ce89f78b src/insets/Inset.h
--- a/src/insets/Inset.h Sat Nov 03 19:12:52 2007 +0100
+++ b/src/insets/Inset.h Sun Nov 04 00:48:34 2007 +0200
@@ -170,19 +170,14 @@ public:
  virtual bool isActive() const { return nargs() > 0; }
  /// Where should we go when we press the up or down cursor key?
  virtual bool idxUpDown(Cursor & cur, bool up) const;
- /// Move one cell to the left
- virtual bool idxLeft(Cursor &) const { return false; }
- /// Move one cell to the right
- virtual bool idxRight(Cursor &) const { return false; }
-
- /// Move one physical cell up
+ /// Move one physical cell forward
  virtual bool idxNext(Cursor &) const { return false; }
- /// Move one physical cell down
+ /// Move one physical cell backwards
  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 -r 7537ce89f78b src/mathed/InsetMathFrac.cpp
--- a/src/mathed/InsetMathFrac.cpp Sat Nov 03 19:12:52 2007 +0100
+++ b/src/mathed/InsetMathFrac.cpp Sun Nov 04 00:48:34 2007 +0200
@@ -79,7 +79,7 @@ InsetMathFrac const * InsetMathFrac::asF
 }
 
 
-bool InsetMathFrac::idxRight(Cursor & cur) const
+bool InsetMathFrac::idxNext(Cursor & cur) const
 {
  InsetMath::idx_type target = 0;
  if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
@@ -97,7 +97,7 @@ bool InsetMathFrac::idxRight(Cursor & cu
 }
 
 
-bool InsetMathFrac::idxLeft(Cursor & cur) const
+bool InsetMathFrac::idxPrev(Cursor & cur) const
 {
  InsetMath::idx_type target = 0;
  if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
diff -r 7537ce89f78b src/mathed/InsetMathFrac.h
--- a/src/mathed/InsetMathFrac.h Sat Nov 03 19:12:52 2007 +0100
+++ b/src/mathed/InsetMathFrac.h Sun Nov 04 00:48:34 2007 +0200
@@ -26,9 +26,9 @@ public:
  ///
  bool idxUpDown(Cursor &, bool up) const;
  ///
- bool idxLeft(Cursor &) const { return false; }
- ///
- bool idxRight(Cursor &) const { return false; }
+ bool idxPrev(Cursor &) const { return false; }
+ ///
+ bool idxNext(Cursor &) const { return false; }
 };
 
 
@@ -49,9 +49,9 @@ public:
  ///
  explicit InsetMathFrac(Kind kind = FRAC, idx_type ncells = 2);
  ///
- bool idxRight(Cursor &) const;
- ///
- bool idxLeft(Cursor &) const;
+ bool idxNext(Cursor &) const;
+ ///
+ bool idxPrev(Cursor &) const;
  ///
  void metrics(MetricsInfo & mi, Dimension & dim) const;
  ///
diff -r 7537ce89f78b src/mathed/InsetMathGrid.cpp
--- a/src/mathed/InsetMathGrid.cpp Sat Nov 03 19:12:52 2007 +0100
+++ b/src/mathed/InsetMathGrid.cpp Sun Nov 04 00:48:34 2007 +0200
@@ -830,7 +830,7 @@ bool InsetMathGrid::idxUpDown(Cursor & c
 }
 
 
-bool InsetMathGrid::idxLeft(Cursor & cur) const
+bool InsetMathGrid::idxPrev(Cursor & cur) const
 {
  // leave matrix if on the left hand edge
  if (cur.col() == 0)
@@ -841,9 +841,9 @@ bool InsetMathGrid::idxLeft(Cursor & cur
 }
 
 
-bool InsetMathGrid::idxRight(Cursor & cur) const
-{
- // leave matrix if on the right hand edge
+bool InsetMathGrid::idxNext(Cursor & cur) const
+{
+ // leave matrix if at the end
  if (cur.col() + 1 == ncols())
  return false;
  ++cur.idx();
diff -r 7537ce89f78b src/mathed/InsetMathGrid.h
--- a/src/mathed/InsetMathGrid.h Sat Nov 03 19:12:52 2007 +0100
+++ b/src/mathed/InsetMathGrid.h Sun Nov 04 00:48:34 2007 +0200
@@ -155,9 +155,9 @@ public:
  ///
  bool idxUpDown(Cursor &, bool up) const;
  ///
- bool idxLeft(Cursor &) const;
- ///
- bool idxRight(Cursor &) const;
+ bool idxPrev(Cursor &) const;
+ ///
+ bool idxNext(Cursor &) const;
  ///
  bool idxFirst(Cursor &) const;
  ///
diff -r 7537ce89f78b src/mathed/InsetMathHull.cpp
--- a/src/mathed/InsetMathHull.cpp Sat Nov 03 19:12:52 2007 +0100
+++ b/src/mathed/InsetMathHull.cpp Sun Nov 04 00:48:34 2007 +0200
@@ -1308,10 +1308,10 @@ void InsetMathHull::handleFont2(Cursor &
 }
 
 
-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 -r 7537ce89f78b src/mathed/InsetMathHull.h
--- a/src/mathed/InsetMathHull.h Sat Nov 03 19:12:52 2007 +0100
+++ b/src/mathed/InsetMathHull.h Sun Nov 04 00:48:34 2007 +0200
@@ -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 -r 7537ce89f78b src/mathed/InsetMathNest.cpp
--- a/src/mathed/InsetMathNest.cpp Sat Nov 03 19:12:52 2007 +0100
+++ b/src/mathed/InsetMathNest.cpp Sun Nov 04 00:48:34 2007 +0200
@@ -164,12 +164,6 @@ bool InsetMathNest::idxNext(Cursor & cur
 }
 
 
-bool InsetMathNest::idxRight(Cursor & cur) const
-{
- return idxNext(cur);
-}
-
-
 bool InsetMathNest::idxPrev(Cursor & cur) const
 {
  BOOST_ASSERT(&cur.inset() == this);
@@ -178,12 +172,6 @@ bool InsetMathNest::idxPrev(Cursor & cur
  --cur.idx();
  cur.pos() = cur.lastpos();
  return true;
-}
-
-
-bool InsetMathNest::idxLeft(Cursor & cur) const
-{
- return idxPrev(cur);
 }
 
 
@@ -507,10 +495,10 @@ void InsetMathNest::doDispatch(Cursor &
  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() || idxNext(cur)
+ || cur.popForward() || cur.selection())
  ;
  else {
  cmd = FuncRequest(LFUN_FINISHED_FORWARD);
@@ -526,11 +514,11 @@ void InsetMathNest::doDispatch(Cursor &
  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() || idxPrev(cur)
+ || cur.popBackward() || cur.selection())
  ;
  else {
  cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
@@ -729,7 +717,7 @@ void InsetMathNest::doDispatch(Cursor &
  case LFUN_INSET_TOGGLE:
  cur.recordUndo();
  lock(!lock());
- cur.popRight();
+ cur.popForward();
  break;
 
  case LFUN_SELF_INSERT:
@@ -760,8 +748,8 @@ void InsetMathNest::doDispatch(Cursor &
     && 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 +869,8 @@ void InsetMathNest::doDispatch(Cursor &
  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 +1451,7 @@ bool InsetMathNest::interpretChar(Cursor
  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 -r 7537ce89f78b src/mathed/InsetMathNest.h
--- a/src/mathed/InsetMathNest.h Sat Nov 03 19:12:52 2007 +0100
+++ b/src/mathed/InsetMathNest.h Sun Nov 04 00:48:35 2007 +0200
@@ -52,19 +52,14 @@ public:
  ///
  Inset * editXY(Cursor & cur, int x, int y);
 
- /// order of movement through the cells when pressing the left key
- bool idxLeft(Cursor &) const;
- /// order of movement through the cells when pressing the right key
- bool idxRight(Cursor &) const;
-
- /// move one physical cell up
+ /// move one physical cell forward
  bool idxNext(Cursor &) const;
- /// move one physical cell down
+ /// move one physical cell backwards
  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 -r 7537ce89f78b src/mathed/InsetMathScript.cpp
--- a/src/mathed/InsetMathScript.cpp Sat Nov 03 19:12:52 2007 +0100
+++ b/src/mathed/InsetMathScript.cpp Sun Nov 04 00:48:35 2007 +0200
@@ -468,13 +468,13 @@ Inset::idx_type InsetMathScript::idxOfSc
 }
 
 
-bool InsetMathScript::idxRight(Cursor &) const
+bool InsetMathScript::idxNext(Cursor &) const
 {
  return false;
 }
 
 
-bool InsetMathScript::idxLeft(Cursor &) const
+bool InsetMathScript::idxPrev(Cursor &) const
 {
  return false;
 }
diff -r 7537ce89f78b src/mathed/InsetMathScript.h
--- a/src/mathed/InsetMathScript.h Sat Nov 03 19:12:52 2007 +0100
+++ b/src/mathed/InsetMathScript.h Sun Nov 04 00:48:35 2007 +0200
@@ -41,15 +41,15 @@ public:
  ///
  void drawT(TextPainter & pi, int x, int y) const;
 
- /// move cursor left
- bool idxLeft(Cursor & cur) const;
- /// move cursor right
- bool idxRight(Cursor & cur) const;
+ /// move cursor backwards
+ bool idxPrev(Cursor & cur) const;
+ /// move cursor forward
+ bool idxNext(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 -r 7537ce89f78b src/mathed/MathMacro.h
--- a/src/mathed/MathMacro.h Sat Nov 03 19:12:52 2007 +0100
+++ b/src/mathed/MathMacro.h Sun Nov 04 00:48:35 2007 +0200
@@ -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;
 
  ///
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Finishing up the LTR bias removal

Martin Vermeer-2
On Sun, Nov 04, 2007 at 12:56:40AM +0200, Dov Feldstern wrote:

> Hi!
>
> Attached find the final patch (at least for now) which gets rid of LTR
> bias in the code. I will commit in the next few days if there are no
> objections.
>
> The only non-trivial change (i.e., more than just changing function
> names) is that I merged idxLeft into idxPrev, and idxRight into idxNext.
> Does this seem OK?
>
> Other than that, just make sure the names I chose are OK.
>
> As this entire series, behavior should remain unchanged by this patch.
>
> Thanks!
> Dov
>

> diff -r 7537ce89f78b src/BufferView.cpp
> --- a/src/BufferView.cpp Sat Nov 03 19:12:52 2007 +0100
> +++ b/src/BufferView.cpp Sun Nov 04 00:48:34 2007 +0200
> @@ -1320,7 +1320,7 @@ Update::flags BufferView::dispatch(FuncR
>   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 -r 7537ce89f78b src/Cursor.cpp
> --- a/src/Cursor.cpp Sat Nov 03 19:12:52 2007 +0100
> +++ b/src/Cursor.cpp Sun Nov 04 00:48:34 2007 +0200
> @@ -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;

OK

>   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 back" << endl;

This feels wrong. Are you sure?

>   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 front" << endl;

Same here

- Martin

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Finishing up the LTR bias removal

Martin Vermeer-2
In reply to this post by Dov Feldstern
On Sun, Nov 04, 2007 at 12:56:40AM +0200, Dov Feldstern wrote:
> Hi!
>
> Attached find the final patch (at least for now) which gets rid of LTR
> bias in the code. I will commit in the next few days if there are no
> objections.
>
> The only non-trivial change (i.e., more than just changing function
> names) is that I merged idxLeft into idxPrev, and idxRight into idxNext.
> Does this seem OK?

Hmmm... this is only for math, right?

Aren't math formulas always written in LtR order (or more correctly, in
the same order that we Latins do it), also within Hebrew/Arabic
documents?

I am a bit apprehensive about this, because math thinking is very
visual. There, left is left and right is right, like on a blackboard
(all gifted mathematicians have a "mental blackboard" on which they also
play chess etc.)

You may notice also that the idxLeft/idxRight functions are bound to the
leftarrow/rightarrow cursor keys, which we earlier agreed (IIRC) were
hardwired to physical left and right motion.

- Martin
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Finishing up the LTR bias removal

Andre Poenitz-3
In reply to this post by Dov Feldstern
On Sun, Nov 04, 2007 at 12:56:40AM +0200, Dov Feldstern wrote:
> Hi!
>
> Attached find the final patch (at least for now) which gets rid of LTR bias
> in the code. I will commit in the next few days if there are no objections.
>
> The only non-trivial change (i.e., more than just changing function names)
> is that I merged idxLeft into idxPrev, and idxRight into idxNext. Does this
> seem OK?

No. If you are in the first column of a math array, idxPrev moves to the
last column of the preivous line whereas idxLeft leaves the array to the
left.

Andre'
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Finishing up the LTR bias removal

Dov Feldstern
In reply to this post by Martin Vermeer-2
Martin Vermeer wrote:
> On Sun, Nov 04, 2007 at 12:56:40AM +0200, Dov Feldstern wrote:
>> -bool Cursor::popLeft()
>> +bool Cursor::popBackward()
>>  {
>>   BOOST_ASSERT(!empty());
>> - //lyxerr << "Leaving inset to the left" << endl;
>> + //lyxerr << "Leaving inset from in back" << endl;
>
> This feels wrong. Are you sure?

My mistake, good catch!

>
>>   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 front" << endl;
>
> Same here

And here ;) Thanks!

>
> - Martin
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Finishing up the LTR bias removal

Dov Feldstern
In reply to this post by Martin Vermeer-2
Martin Vermeer wrote:

> On Sun, Nov 04, 2007 at 12:56:40AM +0200, Dov Feldstern wrote:
>> Hi!
>>
>> Attached find the final patch (at least for now) which gets rid of LTR
>> bias in the code. I will commit in the next few days if there are no
>> objections.
>>
>> The only non-trivial change (i.e., more than just changing function
>> names) is that I merged idxLeft into idxPrev, and idxRight into idxNext.
>> Does this seem OK?
>
> Hmmm... this is only for math, right?

Yes, except that the idxFoo methods are also declared in Inset.h


OK, thanks for the feedback below. And Andre' has pointed out
specifically why idxLeft and idxPrev are *not* synonymous. So I will
rework the whole idxFoo methods part.

>
> Aren't math formulas always written in LtR order (or more correctly, in
> the same order that we Latins do it), also within Hebrew/Arabic
> documents?
>

Yes, this is correct.

> I am a bit apprehensive about this, because math thinking is very
> visual. There, left is left and right is right, like on a blackboard
> (all gifted mathematicians have a "mental blackboard" on which they also
> play chess etc.)
>

Yes, this is also correct (well, except for the chess part maybe, I'm
not sure about that one ;) ).

> You may notice also that the idxLeft/idxRight functions are bound to the
> leftarrow/rightarrow cursor keys,

Actually, I don't see this. Where is this binding?

> which we earlier agreed (IIRC) were
> hardwired to physical left and right motion.
>

Not exactly. In the earlier stages of this patch series, I've organized
things so that now left really binds to the left LFUN, and right to
right. However, what the LFUNs actually do still depends on a few things:

*) if the mode is visual, then left will move visually left, and right
will move visually right. This mode does not yet exist, though.

*) if the mode is logical (the only mode which currently exists),
behavior is as follows:
   - only the direction of the *paragraph* (let's call it parDir) is
used to determine the actual motion (this is necessary in order to avoid
situations in which the cursor "gets stuck" in the middle of a paragraph).
   - if parDir == LTR, then left moves logically backwards, right moves
logically forward
   - if parDir == RTL, then left moves logically forward, right moves
logically backward

So it's still slightly more complicated.

However, as I said, I will think this part over.

> - Martin
>  
>

Again, thanks for the input,
Dov
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Finishing up the LTR bias removal

Dov Feldstern
Dov Feldstern wrote:
> Martin Vermeer wrote:
>> On Sun, Nov 04, 2007 at 12:56:40AM +0200, Dov Feldstern wrote:
>>> Hi!
>>>
>>> Attached find the final patch (at least for now) which gets rid of
>>> LTR bias in the code. I will commit in the next few days if there are
>>> no objections.
>>>

Attached is a newer version of this patch --- after getting feedback
from Martin and Andre' --- in two parts. p3 is basically the same as the
previous patch, sans the idxFoo stuff. p4 is a new treatment of the
idxFoo methods: I just renamed the idxLeft and idxRight to idxBackward
and idxForward, respectively. So now, there should be absolutely no
change in behavior, the entire patch consists only of renames and
comments (unless I made a mistake somewhere).

Martin, I decided to change the idxFoo stuff even though it's only used
in math, which is entirely LTR, for the following reasons:

*) the methods *do* appear in Inset.h, so they could potentially be used
outside of math
*) forward and backward are no less correct than left and right (even if
it is a tad less, well, visual)
*) there are places in the code which now read "posBackward &&
idxBackward", which I think is slightly better than "posBackward && idxLeft"

I hope you don't mind this too much...

Dov

diff -r 8a5c2505808e src/BufferView.cpp
--- a/src/BufferView.cpp Sat Nov 03 21:52:09 2007 +0100
+++ b/src/BufferView.cpp Sun Nov 04 19:35:43 2007 +0200
@@ -1320,7 +1320,7 @@ Update::flags BufferView::dispatch(FuncR
  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 -r 8a5c2505808e src/Cursor.cpp
--- a/src/Cursor.cpp Sat Nov 03 21:52:09 2007 +0100
+++ b/src/Cursor.cpp Sun Nov 04 19:35:43 2007 +0200
@@ -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 &
  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 &
  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 & f
  // 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 -r 8a5c2505808e src/Cursor.h
--- a/src/Cursor.h Sat Nov 03 21:52:09 2007 +0100
+++ b/src/Cursor.h Sun Nov 04 19:35:43 2007 +0200
@@ -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 -r 8a5c2505808e src/LyXFunc.cpp
--- a/src/LyXFunc.cpp Sat Nov 03 21:52:09 2007 +0100
+++ b/src/LyXFunc.cpp Sun Nov 04 19:35:43 2007 +0200
@@ -1841,7 +1841,7 @@ void LyXFunc::dispatch(FuncRequest const
     && (inset_code == NO_CODE
     || inset_code == it->lyxCode())) {
  Cursor tmpcur = cur;
- tmpcur.pushLeft(*it);
+ tmpcur.pushBackward(*it);
  it->dispatch(tmpcur, fr);
  }
  }
diff -r 8a5c2505808e src/Text.cpp
--- a/src/Text.cpp Sat Nov 03 21:52:09 2007 +0100
+++ b/src/Text.cpp Sun Nov 04 19:35:43 2007 +0200
@@ -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 -r 8a5c2505808e src/Text3.cpp
--- a/src/Text3.cpp Sat Nov 03 21:52:09 2007 +0100
+++ b/src/Text3.cpp Sun Nov 04 19:35:43 2007 +0200
@@ -179,7 +179,7 @@ static void specialChar(Cursor & cur, In
  cur.recordUndo();
  cap::replaceSelection(cur);
  cur.insert(new InsetSpecialChar(kind));
- cur.posRight();
+ cur.posForward();
 }
 
 
@@ -558,7 +558,7 @@ void Text::dispatch(Cursor & cur, FuncRe
  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, FuncRe
  if (cur.selection())
  cutSelection(cur, true, false);
  insertInset(cur, inset);
- cur.posRight();
+ cur.posForward();
  }
  break;
  }
@@ -732,7 +732,7 @@ void Text::dispatch(Cursor & cur, FuncRe
  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, FuncRe
  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, FuncRe
  static_cast<InsetInfo *>(inset)->setInfo(to_utf8(ds));
  }
  insertInset(cur, inset);
- cur.posRight();
+ cur.posForward();
  break;
  }
 #if 0
@@ -1168,7 +1168,7 @@ void Text::dispatch(Cursor & cur, FuncRe
  // 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, FuncRe
  // 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, FuncRe
  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, FuncRe
 
  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, FuncRe
  // 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, FuncRe
  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, FuncRe
  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 -r 8a5c2505808e src/TextMetrics.cpp
--- a/src/TextMetrics.cpp Sat Nov 03 21:52:09 2007 +0100
+++ b/src/TextMetrics.cpp Sun Nov 04 19:35:43 2007 +0200
@@ -369,11 +369,11 @@ bool TextMetrics::redoParagraph(pit_type
  // 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)
- cursor.posLeft();
+ cursor.posBackward();
  }
 
  // Optimisation: this is used in the next two loops
diff -r 8a5c2505808e src/insets/Inset.h
--- a/src/insets/Inset.h Sat Nov 03 21:52:09 2007 +0100
+++ b/src/insets/Inset.h Sun Nov 04 19:35:43 2007 +0200
@@ -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 -r 8a5c2505808e src/mathed/InsetMathHull.cpp
--- a/src/mathed/InsetMathHull.cpp Sat Nov 03 21:52:09 2007 +0100
+++ b/src/mathed/InsetMathHull.cpp Sun Nov 04 19:35:43 2007 +0200
@@ -1308,10 +1308,10 @@ void InsetMathHull::handleFont2(Cursor &
 }
 
 
-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 -r 8a5c2505808e src/mathed/InsetMathHull.h
--- a/src/mathed/InsetMathHull.h Sat Nov 03 21:52:09 2007 +0100
+++ b/src/mathed/InsetMathHull.h Sun Nov 04 19:35:43 2007 +0200
@@ -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 -r 8a5c2505808e src/mathed/InsetMathNest.cpp
--- a/src/mathed/InsetMathNest.cpp Sat Nov 03 21:52:09 2007 +0100
+++ b/src/mathed/InsetMathNest.cpp Sun Nov 04 19:35:43 2007 +0200
@@ -507,10 +495,10 @@ void InsetMathNest::doDispatch(Cursor &
  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 +514,11 @@ void InsetMathNest::doDispatch(Cursor &
  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 +717,7 @@ void InsetMathNest::doDispatch(Cursor &
  case LFUN_INSET_TOGGLE:
  cur.recordUndo();
  lock(!lock());
- cur.popRight();
+ cur.popForward();
  break;
 
  case LFUN_SELF_INSERT:
@@ -760,8 +748,8 @@ void InsetMathNest::doDispatch(Cursor &
     && 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 +869,8 @@ void InsetMathNest::doDispatch(Cursor &
  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 +1451,7 @@ bool InsetMathNest::interpretChar(Cursor
  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 -r 8a5c2505808e src/mathed/InsetMathNest.h
--- a/src/mathed/InsetMathNest.h Sat Nov 03 21:52:09 2007 +0100
+++ b/src/mathed/InsetMathNest.h Sun Nov 04 19:35:43 2007 +0200
@@ -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 -r 8a5c2505808e src/mathed/InsetMathScript.h
--- a/src/mathed/InsetMathScript.h Sat Nov 03 21:52:09 2007 +0100
+++ b/src/mathed/InsetMathScript.h Sun Nov 04 19:35:43 2007 +0200
@@ -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 -r 8a5c2505808e src/mathed/MathMacro.h
--- a/src/mathed/MathMacro.h Sat Nov 03 21:52:09 2007 +0100
+++ b/src/mathed/MathMacro.h Sun Nov 04 19:35:43 2007 +0200
@@ -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;
 
  ///

diff -r 2acba83fd845 src/insets/Inset.h
--- a/src/insets/Inset.h Sun Nov 04 19:51:53 2007 +0200
+++ b/src/insets/Inset.h Sun Nov 04 22:10:05 2007 +0200
@@ -170,14 +170,14 @@ public:
  virtual bool isActive() const { return nargs() > 0; }
  /// Where should we go when we press the up or down cursor key?
  virtual bool idxUpDown(Cursor & cur, bool up) const;
- /// Move one cell to the left
- virtual bool idxLeft(Cursor &) const { return false; }
- /// Move one cell to the right
- virtual bool idxRight(Cursor &) const { return false; }
-
- /// Move one physical cell up
+ /// Move one cell backwards
+ virtual bool idxBackward(Cursor &) const { return false; }
+ /// Move one cell forward
+ virtual bool idxForward(Cursor &) const { return false; }
+
+ /// Move to the next cell
  virtual bool idxNext(Cursor &) const { return false; }
- /// Move one physical cell down
+ /// Move to the previous cell
  virtual bool idxPrev(Cursor &) const { return false; }
 
  /// Target pos when we enter the inset while moving forward
diff -r 2acba83fd845 src/mathed/InsetMathFrac.cpp
--- a/src/mathed/InsetMathFrac.cpp Sun Nov 04 19:51:53 2007 +0200
+++ b/src/mathed/InsetMathFrac.cpp Sun Nov 04 22:10:05 2007 +0200
@@ -79,7 +79,7 @@ InsetMathFrac const * InsetMathFrac::asF
 }
 
 
-bool InsetMathFrac::idxRight(Cursor & cur) const
+bool InsetMathFrac::idxForward(Cursor & cur) const
 {
  InsetMath::idx_type target = 0;
  if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
@@ -97,7 +97,7 @@ bool InsetMathFrac::idxRight(Cursor & cu
 }
 
 
-bool InsetMathFrac::idxLeft(Cursor & cur) const
+bool InsetMathFrac::idxBackward(Cursor & cur) const
 {
  InsetMath::idx_type target = 0;
  if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
diff -r 2acba83fd845 src/mathed/InsetMathFrac.h
--- a/src/mathed/InsetMathFrac.h Sun Nov 04 19:51:53 2007 +0200
+++ b/src/mathed/InsetMathFrac.h Sun Nov 04 22:10:05 2007 +0200
@@ -26,9 +26,9 @@ public:
  ///
  bool idxUpDown(Cursor &, bool up) const;
  ///
- bool idxLeft(Cursor &) const { return false; }
- ///
- bool idxRight(Cursor &) const { return false; }
+ bool idxBackward(Cursor &) const { return false; }
+ ///
+ bool idxForward(Cursor &) const { return false; }
 };
 
 
@@ -49,9 +49,9 @@ public:
  ///
  explicit InsetMathFrac(Kind kind = FRAC, idx_type ncells = 2);
  ///
- bool idxRight(Cursor &) const;
- ///
- bool idxLeft(Cursor &) const;
+ bool idxForward(Cursor &) const;
+ ///
+ bool idxBackward(Cursor &) const;
  ///
  void metrics(MetricsInfo & mi, Dimension & dim) const;
  ///
diff -r 2acba83fd845 src/mathed/InsetMathGrid.cpp
--- a/src/mathed/InsetMathGrid.cpp Sun Nov 04 19:51:53 2007 +0200
+++ b/src/mathed/InsetMathGrid.cpp Sun Nov 04 22:10:05 2007 +0200
@@ -830,9 +830,9 @@ bool InsetMathGrid::idxUpDown(Cursor & c
 }
 
 
-bool InsetMathGrid::idxLeft(Cursor & cur) const
-{
- // leave matrix if on the left hand edge
+bool InsetMathGrid::idxBackward(Cursor & cur) const
+{
+ // leave matrix if at the front edge
  if (cur.col() == 0)
  return false;
  --cur.idx();
@@ -841,9 +841,9 @@ bool InsetMathGrid::idxLeft(Cursor & cur
 }
 
 
-bool InsetMathGrid::idxRight(Cursor & cur) const
-{
- // leave matrix if on the right hand edge
+bool InsetMathGrid::idxForward(Cursor & cur) const
+{
+ // leave matrix if at the back edge
  if (cur.col() + 1 == ncols())
  return false;
  ++cur.idx();
diff -r 2acba83fd845 src/mathed/InsetMathGrid.h
--- a/src/mathed/InsetMathGrid.h Sun Nov 04 19:51:53 2007 +0200
+++ b/src/mathed/InsetMathGrid.h Sun Nov 04 22:10:05 2007 +0200
@@ -155,9 +155,9 @@ public:
  ///
  bool idxUpDown(Cursor &, bool up) const;
  ///
- bool idxLeft(Cursor &) const;
- ///
- bool idxRight(Cursor &) const;
+ bool idxBackward(Cursor &) const;
+ ///
+ bool idxForward(Cursor &) const;
  ///
  bool idxFirst(Cursor &) const;
  ///
diff -r 2acba83fd845 src/mathed/InsetMathNest.cpp
--- a/src/mathed/InsetMathNest.cpp Sun Nov 04 19:51:53 2007 +0200
+++ b/src/mathed/InsetMathNest.cpp Sun Nov 04 22:10:05 2007 +0200
@@ -164,7 +164,7 @@ bool InsetMathNest::idxNext(Cursor & cur
 }
 
 
-bool InsetMathNest::idxRight(Cursor & cur) const
+bool InsetMathNest::idxForward(Cursor & cur) const
 {
  return idxNext(cur);
 }
@@ -181,7 +181,7 @@ bool InsetMathNest::idxPrev(Cursor & cur
 }
 
 
-bool InsetMathNest::idxLeft(Cursor & cur) const
+bool InsetMathNest::idxBackward(Cursor & cur) const
 {
  return idxPrev(cur);
 }
@@ -509,7 +509,7 @@ void InsetMathNest::doDispatch(Cursor &
  if (cur.pos() != cur.lastpos() && cur.openable(cur.nextAtom())) {
  cur.pushBackward(*cur.nextAtom().nucleus());
  cur.inset().idxFirst(cur);
- } else if (cur.posForward() || idxRight(cur)
+ } else if (cur.posForward() || idxForward(cur)
  || cur.popForward() || cur.selection())
  ;
  else {
@@ -529,7 +529,7 @@ void InsetMathNest::doDispatch(Cursor &
  cur.posBackward();
  cur.push(*cur.nextAtom().nucleus());
  cur.inset().idxLast(cur);
- } else if (cur.posBackward() || idxLeft(cur)
+ } else if (cur.posBackward() || idxBackward(cur)
  || cur.popBackward() || cur.selection())
  ;
  else {
diff -r 2acba83fd845 src/mathed/InsetMathNest.h
--- a/src/mathed/InsetMathNest.h Sun Nov 04 19:51:53 2007 +0200
+++ b/src/mathed/InsetMathNest.h Sun Nov 04 22:10:05 2007 +0200
@@ -52,14 +52,14 @@ public:
  ///
  Inset * editXY(Cursor & cur, int x, int y);
 
- /// order of movement through the cells when pressing the left key
- bool idxLeft(Cursor &) const;
- /// order of movement through the cells when pressing the right key
- bool idxRight(Cursor &) const;
+ /// order of movement through the cells when moving backwards
+ bool idxBackward(Cursor &) const;
+ /// order of movement through the cells when moving forward
+ bool idxForward(Cursor &) const;
 
- /// move one physical cell up
+ /// move to next cell
  bool idxNext(Cursor &) const;
- /// move one physical cell down
+ /// move to previous cell
  bool idxPrev(Cursor &) const;
 
  /// target pos when we enter the inset while moving forward
diff -r 2acba83fd845 src/mathed/InsetMathScript.cpp
--- a/src/mathed/InsetMathScript.cpp Sun Nov 04 19:51:53 2007 +0200
+++ b/src/mathed/InsetMathScript.cpp Sun Nov 04 22:10:05 2007 +0200
@@ -468,13 +468,13 @@ Inset::idx_type InsetMathScript::idxOfSc
 }
 
 
-bool InsetMathScript::idxRight(Cursor &) const
+bool InsetMathScript::idxForward(Cursor &) const
 {
  return false;
 }
 
 
-bool InsetMathScript::idxLeft(Cursor &) const
+bool InsetMathScript::idxBackward(Cursor &) const
 {
  return false;
 }
diff -r 2acba83fd845 src/mathed/InsetMathScript.h
--- a/src/mathed/InsetMathScript.h Sun Nov 04 19:51:53 2007 +0200
+++ b/src/mathed/InsetMathScript.h Sun Nov 04 22:10:05 2007 +0200
@@ -41,10 +41,10 @@ public:
  ///
  void drawT(TextPainter & pi, int x, int y) const;
 
- /// move cursor left
- bool idxLeft(Cursor & cur) const;
- /// move cursor right
- bool idxRight(Cursor & cur) const;
+ /// move cursor backwards
+ bool idxBackward(Cursor & cur) const;
+ /// move cursor forward
+ bool idxForward(Cursor & cur) const;
  /// move cursor up or down
  bool idxUpDown(Cursor & cur, bool up) const;
  /// Target pos when we enter the inset while moving forward
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Finishing up the LTR bias removal

Martin Vermeer-2
On Sun, Nov 04, 2007 at 11:00:54PM +0200, Dov Feldstern wrote:

> Dov Feldstern wrote:
> >Martin Vermeer wrote:
> >>On Sun, Nov 04, 2007 at 12:56:40AM +0200, Dov Feldstern wrote:
> >>>Hi!
> >>>
> >>>Attached find the final patch (at least for now) which gets rid of
> >>>LTR bias in the code. I will commit in the next few days if there are
> >>>no objections.
> >>>
>
> Attached is a newer version of this patch --- after getting feedback
> from Martin and Andre' --- in two parts. p3 is basically the same as the
> previous patch, sans the idxFoo stuff. p4 is a new treatment of the
> idxFoo methods: I just renamed the idxLeft and idxRight to idxBackward
> and idxForward, respectively. So now, there should be absolutely no
> change in behavior, the entire patch consists only of renames and
> comments (unless I made a mistake somewhere).
>
> Martin, I decided to change the idxFoo stuff even though it's only used
> in math, which is entirely LTR, for the following reasons:
>
> *) the methods *do* appear in Inset.h, so they could potentially be used
> outside of math
> *) forward and backward are no less correct than left and right (even if
> it is a tad less, well, visual)
> *) there are places in the code which now read "posBackward &&
> idxBackward", which I think is slightly better than "posBackward && idxLeft"
>
> I hope you don't mind this too much...
>
> Dov

Looks OK...

- Martin

Loading...