]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettext.C
* In the process of fixing the math background color bug, this commit transfer backgr...
[lyx.git] / src / insets / insettext.C
index 23096b7ae41bd3f389197040d2fae0efca39e026..a782cc56f53775d01e80dda54da0ce27fc52dc2c 100644 (file)
@@ -31,6 +31,7 @@
 #include "lyxrc.h"
 #include "lyxtext.h"
 #include "metricsinfo.h"
+#include "outputparams.h"
 #include "output_docbook.h"
 #include "output_latex.h"
 #include "output_plaintext.h"
@@ -197,8 +198,9 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
                int const w = tm.width() + 2 * border_;
                int const a = tm.ascent() + border_;
                int const h = a + tm.descent() + border_;
-               pi.pain.rectangle(x, y - a, (wide() ? tm.maxWidth() : w), h,
-                       frameColor());
+               pi.pain.rectangle(x, y - a,
+                                 ((wide() || hasFixedWidth()) ? tm.maxWidth() : w),
+                                 h, frameColor());
        }
 }
 
@@ -210,8 +212,9 @@ void InsetText::drawSelection(PainterInfo & pi, int x, int y) const
        int const w = tm.width() + 2 * border_;
        int const a = tm.ascent() + border_;
        int const h = a + tm.descent() + border_;
-       pi.pain.fillRectangle(x, y - a, (wide() ? tm.maxWidth() : w), h,
-               backgroundColor());
+       pi.pain.fillRectangle(x, y - a,
+                             ((wide() || hasFixedWidth()) ? tm.maxWidth() : w),
+                             h, backgroundColor());
        text_.drawSelection(pi, x + border_, y);
 }
 
@@ -253,7 +256,7 @@ InsetBase * InsetText::editXY(LCursor & cur, int x, int y)
 
 void InsetText::doDispatch(LCursor & cur, FuncRequest & cmd)
 {
-       lyxerr[Debug::ACTION] << BOOST_CURRENT_FUNCTION
+       LYXERR(Debug::ACTION) << BOOST_CURRENT_FUNCTION
                             << " [ cmd.action = "
                             << cmd.action << ']' << endl;
        text_.dispatch(cur, cmd);
@@ -290,7 +293,7 @@ void InsetText::rejectChanges(BufferParams const & bparams)
 
 
 int InsetText::latex(Buffer const & buf, odocstream & os,
-                    OutputParams const & runparams) const
+                     OutputParams const & runparams) const
 {
        TexRow texrow;
        latexParagraphs(buf, paragraphs(), os, texrow, runparams);
@@ -299,25 +302,34 @@ int InsetText::latex(Buffer const & buf, odocstream & os,
 
 
 int InsetText::plaintext(Buffer const & buf, odocstream & os,
-                    OutputParams const & runparams) const
+                         OutputParams const & runparams) const
 {
        ParagraphList::const_iterator beg = paragraphs().begin();
        ParagraphList::const_iterator end = paragraphs().end();
        ParagraphList::const_iterator it = beg;
        bool ref_printed = false;
-       odocstringstream oss;
-       for (; it != end; ++it)
+       int len = 0;
+       for (; it != end; ++it) {
+               if (it != beg) {
+                       os << '\n';
+                       if (runparams.linelen > 0)
+                               os << '\n';
+               }
+               odocstringstream oss;
                writePlaintextParagraph(buf, *it, oss, runparams, ref_printed);
+               docstring const str = oss.str();
+               os << str;
+               // FIXME: len is not computed fully correctly; in principle,
+               // we have to count the characters after the last '\n'
+               len = str.size();
+       }
 
-       docstring const str = oss.str();
-       os << str;
-       // Return how many newlines we issued.
-       return int(lyx::count(str.begin(), str.end(), '\n'));
+       return len;
 }
 
 
 int InsetText::docbook(Buffer const & buf, odocstream & os,
-                      OutputParams const & runparams) const
+                       OutputParams const & runparams) const
 {
        docbookParagraphs(paragraphs(), buf, os, runparams);
        return 0;