// but for RTL boundaries don't, because: abc|DDEEFFghi -> abcDDEEF|Fghi
if (cur.boundary()) {
cur.boundary(false);
- } else if (bidi.isBoundary(buffer, cur.paragraph(), cur.pos() + 1)) {
+ } else if (isRTLBoundary(buffer, cur.paragraph(), cur.pos() + 1)) {
// in front of RTL boundary -> Stay on this side of the boundary because:
// ab|cDDEEFFghi -> abc|DDEEFFghi
++cur.pos();
bool isRTL(Buffer const &, Paragraph const & par) const;
/// is this position in the paragraph right-to-left?
bool isRTL(Buffer const & buffer, CursorSlice const & sl, bool boundary) const;
+ /// is between pos-1 and pos an RTL<->LTR boundary?
+ bool isRTLBoundary(Buffer const & buffer, Paragraph const & par,
+ pos_type pos) const;
+ /// would be a RTL<->LTR boundary between pos and the given font?
+ bool isRTLBoundary(Buffer const & buffer, Paragraph const & par,
+ pos_type pos, Font const & font) const;
+
///
bool checkAndActivateInset(Cursor & cur, bool front);
real_current_font = getFont(cur.buffer(), par, pos);
if (cur.pos() == cur.lastpos()
- && bidi.isBoundary(cur.buffer(), par, cur.pos())
+ && isRTLBoundary(cur.buffer(), par, cur.pos())
&& !cur.boundary()) {
Language const * lang = par.getParLanguage(bufparams);
current_font.setLanguage(lang);
// if left of boundary -> just jump to right side
// but for RTL boundaries don't, because: abc|DDEEFFghi -> abcDDEEF|Fghi
if (cur.boundary() &&
- !bidi.isBoundary(cur.buffer(), cur.paragraph(), cur.pos()))
+ !isRTLBoundary(cur.buffer(), cur.paragraph(), cur.pos()))
return setCursor(cur, cur.pit(), cur.pos(), true, false);
// next position is left of boundary,
// in front of RTL boundary? Stay on this side of the boundary because:
// ab|cDDEEFFghi -> abc|DDEEFFghi
- if (bidi.isBoundary(cur.buffer(), cur.paragraph(), cur.pos() + 1))
+ if (isRTLBoundary(cur.buffer(), cur.paragraph(), cur.pos() + 1))
return setCursor(cur, cur.pit(), cur.pos() + 1, true, true);
// move right
Font freefont(Font::ALL_IGNORE);
bool toggleall = false;
-
void toggleAndShow(Cursor & cur, Text * text,
Font const & font, bool toggleall = true)
{
if (font.language() != ignore_language ||
font.number() != Font::IGNORE) {
Paragraph & par = cur.paragraph();
- text->bidi.computeTables(par, cur.buffer(), cur.textRow());
- if (cur.boundary() !=
- text->bidi.isBoundary(cur.buffer(), par,
- cur.pos(),
- text->real_current_font))
+ if (cur.boundary() != text->isRTLBoundary(cur.buffer(), par,
+ cur.pos(), text->real_current_font))
text->setCursor(cur, cur.pit(), cur.pos(),
- false, !cur.boundary());
+ false, !cur.boundary());
}
}
bool Text::isRTL(Buffer const & buffer, CursorSlice const & sl, bool boundary) const
{
- if (!sl.text())
+ if (!lyxrc.rtl_support && !sl.text())
return false;
int correction = 0;
}
+bool Text::isRTLBoundary(Buffer const & buffer, Paragraph const & par,
+ pos_type pos) const
+{
+ if (!lyxrc.rtl_support)
+ return false;
+
+ // no RTL boundary at line start
+ if (pos == 0)
+ return false;
+
+ bool left = getFont(buffer, par, pos - 1).isVisibleRightToLeft();
+ bool right;
+ if (pos == par.size())
+ right = par.isRightToLeftPar(buffer.params());
+ else
+ right = getFont(buffer, par, pos).isVisibleRightToLeft();
+ return left != right;
+}
+
+
+bool Text::isRTLBoundary(Buffer const & buffer, Paragraph const & par,
+ pos_type pos, Font const & font) const
+{
+ if (!lyxrc.rtl_support)
+ return false;
+
+ bool left = font.isVisibleRightToLeft();
+ bool right;
+ if (pos == par.size())
+ right = par.isRightToLeftPar(buffer.params());
+ else
+ right = getFont(buffer, par, pos).isVisibleRightToLeft();
+ return left != right;
+}
+
+
void Text::dispatch(Cursor & cur, FuncRequest & cmd)
{
LYXERR(Debug::ACTION) << "Text::dispatch: cmd: " << cmd << endl;
bool const rtl = (text_->bidi.level(c) % 2 == 1);
if (left_side == rtl) {
++c;
- boundary = text_->bidi.isBoundary(buffer, par, c);
+ boundary = text_->isRTLBoundary(buffer, par, c);
}
}