commit 96692bdbb0189b71803e83dbb18a2e3f006e7bf5 Author: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Thu Jul 16 11:55:45 2015 +0200
Move some functions out of Bidi.* The functions reverseDirectionNeeded() and reverseDirectionNeeded() do not rely on the Bidi class. The first one is changed into a Cursor method, and the second one is replaced with explicit code. diff --git a/src/Bidi.cpp b/src/Bidi.cpp index 3b598a4..c06b08a 100644 --- a/src/Bidi.cpp +++ b/src/Bidi.cpp @@ -215,23 +215,4 @@ bool Bidi::isBoundary(Buffer const & buf, Paragraph const & par, return rtl != rtl2; } - -bool reverseDirectionNeeded(Cursor const & cur) -{ - /* - * We determine the directions based on the direction of the - * bottom() --- i.e., outermost --- paragraph, because that is - * the only way to achieve consistency of the arrow's movements - * within a paragraph, and thus avoid situations in which the - * cursor gets stuck. - */ - return cur.bottom().paragraph().isRTL(cur.bv().buffer().params()); -} - - -bool isWithinRtlParagraph(Cursor const & cur) -{ - return cur.innerParagraph().isRTL(cur.bv().buffer().params()); -} - } // namespace lyx diff --git a/src/Bidi.h b/src/Bidi.h index c406a7a..1b7e4f3 100644 --- a/src/Bidi.h +++ b/src/Bidi.h @@ -75,12 +75,6 @@ private: pos_type end_; }; -/// Should interpretation of the arrow keys be reversed? -bool reverseDirectionNeeded(Cursor const & cur); - -/// Is current paragraph in RTL mode? -bool isWithinRtlParagraph(Cursor const & cur); - } // namespace lyx #endif // BIDI_H diff --git a/src/Cursor.cpp b/src/Cursor.cpp index fff5025..c89db5d 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -1156,6 +1156,19 @@ void Cursor::posVisToRowExtremity(bool left) } +bool Cursor::reverseDirectionNeeded() const +{ + /* + * We determine the directions based on the direction of the + * bottom() --- i.e., outermost --- paragraph, because that is + * the only way to achieve consistency of the arrow's movements + * within a paragraph, and thus avoid situations in which the + * cursor gets stuck. + */ + return bottom().paragraph().isRTL(bv().buffer().params()); +} + + CursorSlice Cursor::normalAnchor() const { if (!selection()) @@ -1843,7 +1856,7 @@ bool Cursor::upDownInMath(bool up) // handling when the cursor is at the end of line: Use the new // x-target only if the old one was before the end of line // or the old one was after the beginning of the line - bool inRTL = isWithinRtlParagraph(*this); + bool inRTL = innerParagraph().isRTL(bv().buffer().params()); bool left; bool right; if (inRTL) { @@ -1985,7 +1998,7 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded) // end of line: Use the new x-target only if the old // one was before the end of line or the old one was // after the beginning of the line - bool inRTL = isWithinRtlParagraph(*this); + bool inRTL = innerParagraph().isRTL(bv().buffer().params()); bool left; bool right; if (inRTL) { diff --git a/src/Cursor.h b/src/Cursor.h index 739d228..4ca5f31 100644 --- a/src/Cursor.h +++ b/src/Cursor.h @@ -268,6 +268,8 @@ public: bool posVisToNewRow(bool movingLeft); /// move to right or left extremity of the current row void posVisToRowExtremity(bool left); + /// Should interpretation of the arrow keys be reversed? + bool reverseDirectionNeeded() const; /// insert an inset void insert(Inset *); diff --git a/src/Text2.cpp b/src/Text2.cpp index 5a41761..fb6bd70 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -22,7 +22,6 @@ #include "Text.h" -#include "Bidi.h" #include "Buffer.h" #include "buffer_funcs.h" #include "BufferList.h" diff --git a/src/Text3.cpp b/src/Text3.cpp index 252279a..47a91b5 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -17,7 +17,6 @@ #include "Text.h" -#include "Bidi.h" #include "BranchList.h" #include "FloatList.h" #include "FuncStatus.h" @@ -710,7 +709,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cmd = FuncRequest(LFUN_FINISHED_LEFT); } } else { - if (reverseDirectionNeeded(cur)) { + if (cur.reverseDirectionNeeded()) { cmd.setAction(cmd.action() == LFUN_CHAR_LEFT_SELECT ? LFUN_CHAR_FORWARD_SELECT : LFUN_CHAR_FORWARD); } else { @@ -734,7 +733,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cmd = FuncRequest(LFUN_FINISHED_RIGHT); } } else { - if (reverseDirectionNeeded(cur)) { + if (cur.reverseDirectionNeeded()) { cmd.setAction(cmd.action() == LFUN_CHAR_RIGHT_SELECT ? LFUN_CHAR_BACKWARD_SELECT : LFUN_CHAR_BACKWARD); } else { @@ -846,7 +845,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cmd = FuncRequest(LFUN_FINISHED_RIGHT); } } else { - if (reverseDirectionNeeded(cur)) { + if (cur.reverseDirectionNeeded()) { cmd.setAction(cmd.action() == LFUN_WORD_RIGHT_SELECT ? LFUN_WORD_BACKWARD_SELECT : LFUN_WORD_BACKWARD); } else { @@ -898,7 +897,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cmd = FuncRequest(LFUN_FINISHED_LEFT); } } else { - if (reverseDirectionNeeded(cur)) { + if (cur.reverseDirectionNeeded()) { cmd.setAction(cmd.action() == LFUN_WORD_LEFT_SELECT ? LFUN_WORD_FORWARD_SELECT : LFUN_WORD_FORWARD); } else { diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 392e1ff..133c336 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -38,7 +38,6 @@ #include "MathStream.h" #include "MathSupport.h" -#include "Bidi.h" #include "Buffer.h" #include "BufferParams.h" #include "BufferView.h" @@ -670,7 +669,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd) else { bool right = (act == LFUN_CHAR_RIGHT_SELECT || act == LFUN_CHAR_RIGHT); - if (lyxrc.visual_cursor || !reverseDirectionNeeded(cur)) + if (lyxrc.visual_cursor || !cur.reverseDirectionNeeded()) forward = right; else forward = !right;