mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Fix cursor movement inside insets by Dov Feldstern.
* Bidi.[h,cpp]: new helper function reverseDirectionNeeded() * Cursor::isRTL(): delete unused method git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18350 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6277ba63ab
commit
55a26d72d4
15
src/Bidi.cpp
15
src/Bidi.cpp
@ -12,6 +12,7 @@
|
||||
|
||||
#include "Bidi.h"
|
||||
#include "Buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "Font.h"
|
||||
#include "Row.h"
|
||||
#include "LyXRC.h"
|
||||
@ -209,4 +210,18 @@ bool Bidi::isBoundary(Buffer const & buf, Paragraph const & par,
|
||||
}
|
||||
|
||||
|
||||
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().isRightToLeftPar(
|
||||
cur.bv().buffer()->params());
|
||||
}
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -13,6 +13,7 @@
|
||||
#define BIDI_H
|
||||
|
||||
#include "support/types.h"
|
||||
#include "Cursor.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
@ -65,6 +66,8 @@ private:
|
||||
pos_type end_;
|
||||
};
|
||||
|
||||
/// Should interpretation of the arrow keys be reversed?
|
||||
bool reverseDirectionNeeded(Cursor const & cur);
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
|
@ -1339,10 +1339,4 @@ void Cursor::fixIfBroken()
|
||||
}
|
||||
|
||||
|
||||
bool Cursor::isRTL() const
|
||||
{
|
||||
return innerParagraph().isRightToLeftPar(bv().buffer()->params());
|
||||
}
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -307,8 +307,6 @@ public:
|
||||
Encoding const * getEncoding() const;
|
||||
/// font at cursor position
|
||||
Font getFont() const;
|
||||
///
|
||||
bool isRTL() const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -433,7 +433,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
//lyxerr << BOOST_CURRENT_FUNCTION
|
||||
// << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
|
||||
needsUpdate |= cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
|
||||
if (isRTL(*cur.bv().buffer(), cur.paragraph()))
|
||||
if (reverseDirectionNeeded(cur))
|
||||
needsUpdate |= cursorLeft(cur);
|
||||
else
|
||||
needsUpdate |= cursorRight(cur);
|
||||
@ -451,7 +451,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
case LFUN_CHAR_BACKWARD_SELECT:
|
||||
//lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
|
||||
needsUpdate |= cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
|
||||
if (isRTL(*cur.bv().buffer(), cur.paragraph()))
|
||||
if (reverseDirectionNeeded(cur))
|
||||
needsUpdate |= cursorRight(cur);
|
||||
else
|
||||
needsUpdate |= cursorLeft(cur);
|
||||
@ -557,7 +557,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
case LFUN_WORD_FORWARD:
|
||||
case LFUN_WORD_FORWARD_SELECT:
|
||||
needsUpdate |= cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
|
||||
if (isRTL(*cur.bv().buffer(), cur.paragraph()))
|
||||
if (reverseDirectionNeeded(cur))
|
||||
needsUpdate |= cursorLeftOneWord(cur);
|
||||
else
|
||||
needsUpdate |= cursorRightOneWord(cur);
|
||||
@ -568,7 +568,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
case LFUN_WORD_BACKWARD:
|
||||
case LFUN_WORD_BACKWARD_SELECT:
|
||||
needsUpdate |= cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
|
||||
if (isRTL(*cur.bv().buffer(), cur.paragraph()))
|
||||
if (reverseDirectionNeeded(cur))
|
||||
needsUpdate |= cursorRightOneWord(cur);
|
||||
else
|
||||
needsUpdate |= cursorLeftOneWord(cur);
|
||||
@ -1434,11 +1434,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
|
||||
case LFUN_FINISHED_LEFT:
|
||||
LYXERR(Debug::DEBUG) << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
|
||||
if (reverseDirectionNeeded(cur))
|
||||
++cur.pos();
|
||||
break;
|
||||
|
||||
case LFUN_FINISHED_RIGHT:
|
||||
LYXERR(Debug::DEBUG) << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
|
||||
++cur.pos();
|
||||
if (!reverseDirectionNeeded(cur))
|
||||
++cur.pos();
|
||||
break;
|
||||
|
||||
case LFUN_FINISHED_UP:
|
||||
|
@ -492,7 +492,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
cur.autocorrect() = false;
|
||||
cur.clearTargetX();
|
||||
cur.macroModeClose();
|
||||
if (cur.isRTL() )
|
||||
if (reverseDirectionNeeded(cur))
|
||||
goto goto_char_backwards;
|
||||
|
||||
goto_char_forwards:
|
||||
@ -515,7 +515,7 @@ goto_char_forwards:
|
||||
cur.autocorrect() = false;
|
||||
cur.clearTargetX();
|
||||
cur.macroModeClose();
|
||||
if (cur.isRTL())
|
||||
if (reverseDirectionNeeded(cur))
|
||||
goto goto_char_forwards;
|
||||
|
||||
goto_char_backwards:
|
||||
|
Loading…
Reference in New Issue
Block a user