diff --git a/ChangeLog b/ChangeLog index 95a3ff20bb..eecdc72fa9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2001-02-10 Dekel Tsur + + * src/insets/insettext.C (LocalDispatch): Restore the language + if the inset becomes empty. + + * src/text.C (PrepareToPrint): Fix for RTL text in tabulars. + + * src/paragraph.C (GetUChar): New method. + (String): Use GetUChar. + + * src/buffer.C (asciiParagraph): Use GetUChar. + 2001-02-02 Dekel Tsur * LaTeX.C (scanAuxFile): A rewrite of this method. It now returns diff --git a/src/buffer.C b/src/buffer.C index af5236fefc..34eccdc561 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1496,7 +1496,7 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, } else { islatex = 0; } - c = par->GetChar(i); + c = par->GetUChar(params, i); if (islatex) continue; switch (c) { diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 1e83755a5e..20d2862ba5 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1102,6 +1102,15 @@ InsetText::LocalDispatch(BufferView * bv, result = UNDISPATCHED; break; } + + /// If the action has deleted all text in the inset, we need to change the + // language to the language to the surronding text. + if (par->Last() == 0 && !par->next) { + LyXFont font(LyXFont::ALL_IGNORE); + font.setLanguage(bv->getParentLanguage(this)); + SetFont(bv, font, false); + } + if (result != FINISHED) { ShowInsetCursor(bv); } else diff --git a/src/lyxparagraph.h b/src/lyxparagraph.h index 98e73a11ec..69e956f2f0 100644 --- a/src/lyxparagraph.h +++ b/src/lyxparagraph.h @@ -441,6 +441,8 @@ public: LyXFont const getFont(BufferParams const &, size_type pos) const; /// value_type GetChar(size_type pos) const; + /// + value_type GetUChar(BufferParams const &, size_type pos) const; /// The position must already exist. void SetChar(size_type pos, value_type c) { #ifndef HAVE_ROPE diff --git a/src/paragraph.C b/src/paragraph.C index e6ab4c8774..30483ca859 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1018,6 +1018,47 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const } +LyXParagraph::value_type +LyXParagraph::GetUChar(BufferParams const & bparams, + LyXParagraph::size_type pos) const +{ + value_type c = GetChar(pos); + if (!lyxrc.rtl_support) + return c; + + value_type uc = c; + switch (c) { + case '(': + uc = ')'; + break; + case ')': + uc = '('; + break; + case '[': + uc = ']'; + break; + case ']': + uc = '['; + break; + case '{': + uc = '}'; + break; + case '}': + uc = '{'; + break; + case '<': + uc = '>'; + break; + case '>': + uc = '<'; + break; + } + if (uc != c && GetFontSettings(bparams, pos).isRightToLeft()) + return uc; + else + return c; +} + // return an string of the current word, and the end of the word in lastpos. string const LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const { @@ -3991,7 +4032,7 @@ string const LyXParagraph::String(Buffer const * buffer, s += labelstring + ' '; for (LyXParagraph::size_type i = beg; i < end; ++i) { - value_type c = GetChar(i); + value_type c = GetUChar(buffer->params, i); if (IsPrintable(c)) s += c; else if (c == META_INSET) { diff --git a/src/text.C b/src/text.C index b493a5498a..64fa5b2615 100644 --- a/src/text.C +++ b/src/text.C @@ -2196,21 +2196,18 @@ void LyXText::PrepareToPrint(BufferView * bview, bool const is_rtl = row->par()->isRightToLeftPar(bview->buffer()->params); -#ifndef NEW_INSETS - if (is_rtl) { - x = RightMargin(bview->buffer(), row); + x = (workWidth(bview) > 0) + ? RightMargin(bview->buffer(), row) : 0; +#ifndef NEW_INSETS if (row->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) { LyXFont font(LyXFont::ALL_SANE); font.setSize(LyXFont::SIZE_SMALL); x += lyxfont::width("Mwide-figM", font); } - } else #endif - if (workWidth(bview) > 0) - x = LeftMargin(bview, row); - else - x = 0; + } else + x = (workWidth(bview) > 0) ? LeftMargin(bview, row) : 0; // is there a manual margin with a manual label if (textclasslist.Style(bview->buffer()->params.textclass,