On Wed, Jan 25, 2006 at 11:18:32AM +0200, Martin Vermeer wrote:
> On Tue, Jan 24, 2006 at 11:33:45PM +0100, Helge Hafting wrote:
  
> > A remaining nit:
> > Insert an ERT box, minipage or a table into a document that has a 
> > nondefault doc language.
> > Observe how the curor is L-shaped (i.e. underlined) as if
> > the language is different (from document language) even though it isn't.
> > There will be no stupid underlining when actually typing text, but the
> > cursor indicate otherwise. Perhaps the same fix should be applied to cursor
> > handling as well?

Attached fixes this for all insets except tabular. Tabular is a mystery
to me...  
  
> > Your patchset seems to address most of  the "language silliness" problems
> > now.  This is much better than what we had.  There is still the L-cursor,
> > and the missing underlining in table cells though.
> 
> OK, Helge, thanks a lot for your thorough testing!
> 
> Lars, Jean-Marc, assuming Helge confirms the above applyOuterFont
> sub-fix, shall I prepare a more official looking patch for this? It
> fixes a visually bad regression, and replaces a kludge that didn't work
> properly and wasn't based on any deep understanding of what happens in
> the code, by a solution that does and is. 
 
So here it is, the complete patch, still a bit further polished.

- Martin
 
Index: buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.630
diff -u -p -r1.630 buffer.C
--- buffer.C    29 Nov 2005 15:08:34 -0000      1.630
+++ buffer.C    25 Jan 2006 19:26:42 -0000
@@ -1307,6 +1307,8 @@ void Buffer::changeLanguage(Language con
        for_each(par_iterator_begin(),
                 par_iterator_end(),
                 bind(&Paragraph::changeLanguage, _1, params(), from, to));
+
+       text().real_current_font.setLanguage(to);
 }
 
 
Index: paragraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
retrieving revision 1.418
diff -u -p -r1.418 paragraph.C
--- paragraph.C 30 Dec 2005 19:02:52 -0000      1.418
+++ paragraph.C 25 Jan 2006 19:26:44 -0000
@@ -356,12 +356,12 @@ FontSpan Paragraph::fontSpan(lyx::pos_ty
 
 
 // Gets uninstantiated font setting at position 0
-LyXFont const Paragraph::getFirstFontSettings() const
+LyXFont const Paragraph::getFirstFontSettings(BufferParams const & bparams) 
const
 {
        if (!empty() && !pimpl_->fontlist.empty())
                return pimpl_->fontlist[0].font();
 
-       return LyXFont(LyXFont::ALL_INHERIT);
+       return LyXFont(LyXFont::ALL_INHERIT, bparams.language);
 }
 
 
@@ -1494,7 +1494,7 @@ Language const *
 Paragraph::getParLanguage(BufferParams const & bparams) const
 {
        if (!empty())
-               return getFirstFontSettings().language();
+               return getFirstFontSettings(bparams).language();
 #ifdef WITH_WARNINGS
 #warning FIXME we should check the prev par as well (Lgb)
 #endif
@@ -1513,7 +1513,8 @@ bool Paragraph::isRightToLeftPar(BufferP
 void Paragraph::changeLanguage(BufferParams const & bparams,
                               Language const * from, Language const * to)
 {
-       for (pos_type i = 0; i < size(); ++i) {
+       // <= to catch the dummy font change at end
+       for (pos_type i = 0; i <= size(); ++i) {
                LyXFont font = getFontSettings(bparams, i);
                if (font.language() == from) {
                        font.setLanguage(to);
@@ -1532,7 +1533,8 @@ bool Paragraph::isMultiLingual(BufferPar
        for (; cit != end; ++cit)
                if (cit->font().language() != ignore_language &&
                    cit->font().language() != latex_language &&
-                   cit->font().language() != doc_language)
+                   cit->font().language() != doc_language &&
+                   cit->font().language() != default_language)
                        return true;
        return false;
 }
Index: paragraph.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.h,v
retrieving revision 1.159
diff -u -p -r1.159 paragraph.h
--- paragraph.h 1 Jan 2006 20:28:03 -0000       1.159
+++ paragraph.h 25 Jan 2006 19:26:44 -0000
@@ -273,7 +273,7 @@ public:
        LyXFont const
        getFontSettings(BufferParams const &, lyx::pos_type pos) const;
        ///
-       LyXFont const getFirstFontSettings() const;
+       LyXFont const getFirstFontSettings(BufferParams const & bp = 0) const;
 
        /** Get fully instantiated font. If pos == -1, use the layout
            font attached to this paragraph.
Index: paragraph_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_funcs.C,v
retrieving revision 1.117
diff -u -p -r1.117 paragraph_funcs.C
--- paragraph_funcs.C   16 Jul 2005 12:02:30 -0000      1.117
+++ paragraph_funcs.C   25 Jan 2006 19:26:44 -0000
@@ -157,7 +157,7 @@ void breakParagraph(BufferParams const &
                // Make sure that we keep the language when
                // breaking paragrpah.
                if (tmp->empty()) {
-                       LyXFont changed = tmp->getFirstFontSettings();
+                       LyXFont changed = tmp->getFirstFontSettings(bparams);
                        LyXFont old = par.getFontSettings(bparams, par.size());
                        changed.setLanguage(old.language());
                        tmp->setFont(0, changed);
Index: rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.163
diff -u -p -r1.163 rowpainter.C
--- rowpainter.C        16 Jan 2006 15:17:17 -0000      1.163
+++ rowpainter.C        25 Jan 2006 19:26:45 -0000
@@ -306,7 +322,6 @@ void RowPainter::paintFromPos(pos_type &
 {
        pos_type const pos = text_.bidi.vis2log(vpos);
        LyXFont orig_font = text_.getFont(par_, pos);
-       text_.applyOuterFont(orig_font);
 
        double const orig_x = x_;
 
Index: text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.639
diff -u -p -r1.639 text.C
--- text.C      19 Dec 2005 12:30:33 -0000      1.639
+++ text.C      25 Jan 2006 19:26:47 -0000
@@ -1692,8 +1692,10 @@ bool LyXText::redoParagraph(pit_type con
        // redo insets
        // FIXME: We should always use getFont(), see documentation of
        // noFontChange() in insetbase.h.
-       LyXFont const tclassfont =
+       LyXFont tclassfont =
                bv()->buffer()->params().getLyXTextClass().defaultfont();
+       // Default class font, nevertheless document language:
+       tclassfont.setLanguage(bv()->buffer()->params().language);
        InsetList::iterator ii = par.insetlist.begin();
        InsetList::iterator iend = par.insetlist.end();
        for (; ii != iend; ++ii) {
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.638
diff -u -p -r1.638 text2.C
--- text2.C     23 Jan 2006 10:25:41 -0000      1.638
+++ text2.C     25 Jan 2006 19:26:48 -0000
@@ -222,7 +222,8 @@ void LyXText::applyOuterFont(LyXFont & f
        LyXFont lf(font_);
        lf.reduce(defaultfont_);
        lf.realize(font);
-       lf.setLanguage(font.language());
+       if (font.language() != default_language)
+               lf.setLanguage(font.language());
        font = lf;
 }
 
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.323
diff -u -p -r1.323 text3.C
--- text3.C     31 Dec 2005 11:40:32 -0000      1.323
+++ text3.C     25 Jan 2006 19:26:48 -0000
@@ -1114,12 +1122,6 @@ void LyXText::dispatch(LCursor & cur, Fu
                cur.clearSelection();
                LyXFont const old_font = real_current_font;
 
-               // Prevents language turds in new lyxtexts under non-english
-               BufferParams const & bufparams = cur.buffer().params();
-               Language const * lang = 
cur.paragraph().getParLanguage(bufparams);
-               current_font.setLanguage(lang);
-               real_current_font.setLanguage(lang);
-
                string::const_iterator cit = cmd.argument.begin();
                string::const_iterator end = cmd.argument.end();
                for (; cit != end; ++cit)
Index: insetcharstyle.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcharstyle.C,v
retrieving revision 1.39
diff -u -p -r1.39 insetcharstyle.C
--- insetcharstyle.C    25 Nov 2005 14:40:32 -0000      1.39
+++ insetcharstyle.C    25 Jan 2006 19:37:13 -0000
@@ -135,8 +136,9 @@ void InsetCharStyle::metrics(MetricsInfo
 {
        LyXFont tmpfont = mi.base.font;
        getDrawFont(mi.base.font);
-       mi.base.font.reduce(LyXFont(LyXFont::ALL_SANE));
        mi.base.font.realize(tmpfont);
+       // Needed to propagate doc language (infamous blueline)
+       mi.base.font.setLanguage(tmpfont.language());
        mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
        InsetText::metrics(mi, dim);
        mi.base.font = tmpfont;
Index: insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.623
diff -u -p -r1.623 insettext.C
--- insettext.C 11 Jan 2006 14:22:10 -0000      1.623
+++ insettext.C 25 Jan 2006 19:37:13 -0000
@@ -80,6 +80,9 @@ InsetText::InsetText(BufferParams const 
        paragraphs().back().layout(bp.getLyXTextClass().defaultLayout());
        if (bp.tracking_changes)
                paragraphs().back().trackChanges();
+       // Dispose of the infamous L-shaped cursor. Doesn't work for tabular
+       // though - MV
+       text_.real_current_font.setLanguage(bp.language);
        init();
 }
 

Attachment: pgpcsE9KIdKQq.pgp
Description: PGP signature

Reply via email to