]> git.lyx.org Git - lyx.git/blobdiff - src/rowpainter.cpp
* Call metrics of the parameters with the correct font in MathMacros, for example
[lyx.git] / src / rowpainter.cpp
index 7d391a68ae58e9a6c7ea6aadc601d42a94ec299c..0a097ed9f257edd0308bae09e473db4025b64e4d 100644 (file)
@@ -242,10 +242,11 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font,
        FontSpan const font_span = par_.fontSpan(pos);
        // Track-change status.
        Change const & change_running = par_.lookupChange(pos);
-               
+
        // selected text?
        bool const selection = pos >= row_.sel_beg && pos < row_.sel_end;
 
+       char_type prev_char = ' ';
        // collect as much similar chars as we can
        for (++vpos ; vpos < end ; ++vpos) {
                pos = bidi_.vis2log(vpos);
@@ -264,6 +265,11 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font,
 
                char_type c = par_.getChar(pos);
 
+               if (c == '\t' || prev_char == '\t') {
+                       prev_char = c;
+                       break;
+               }
+
                if (!isPrintableNonspace(c))
                        break;
 
@@ -308,6 +314,9 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font,
 
        docstring s(&str[0], str.size());
 
+       if (s[0] == '\t')
+               s.replace(0,1,from_ascii("    "));
+
        if (!selection && !change_running.changed()) {
                x_ += pi_.pain.text(int(x_), yo_, s, font);
                return;
@@ -603,19 +612,19 @@ void RowPainter::paintLast()
 
        Change const & change = par_.lookupChange(par_.size());
        if (change.changed()) {
-               FontMetrics const & fm = 
+               FontMetrics const & fm =
                        theFontMetrics(pi_.base.bv->buffer().params().getFont());
                int const length = fm.maxAscent() / 2;
                ColorCode col = change.color();
 
                pi_.pain.line(int(x_) + 1, yo_ + 2, int(x_) + 1, yo_ + 2 - length, col,
                           Painter::line_solid, Painter::line_thick);
-               
+
                if (change.deleted()) {
-                       pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 1 + length, 
+                       pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 1 + length,
                                yo_ + 2, col, Painter::line_solid, Painter::line_thick);
                } else {
-                       pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 1, 
+                       pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 1,
                                yo_ + 2, col, Painter::line_solid, Painter::line_thick);
                }
 
@@ -698,7 +707,7 @@ void RowPainter::paintText()
 
        Change change_running;
        int change_last_x = 0;
-       
+
        // check for possible inline completion
        DocIterator const & inlineCompletionPos = pi_.base.bv->inlineCompletionPos();
        pos_type inlineCompletionVPos = -1;
@@ -767,22 +776,22 @@ void RowPainter::paintText()
 
                // If we reach the end of a change or if the author changes, paint it.
                // We also don't paint across things like tables
-               if (change_running.changed() && (highly_editable_inset 
+               if (change_running.changed() && (highly_editable_inset
                        || !change.changed() || !change_running.isSimilarTo(change))) {
                        // Calculate 1/3 height of the buffer's default font
                        FontMetrics const & fm
                                = theFontMetrics(pi_.base.bv->buffer().params().getFont());
-                       int const y_bar = change_running.deleted() ? 
+                       int const y_bar = change_running.deleted() ?
                                yo_ - fm.maxAscent() / 3 : yo_ + fm.maxAscent() / 6;
                        pi_.pain.line(change_last_x, y_bar, int(x_), y_bar,
-                               change_running.color(), Painter::line_solid, 
+                               change_running.color(), Painter::line_solid,
                                Painter::line_thin);
-                       
+
                        // Change might continue with a different author or type
                        if (change.changed() && !highly_editable_inset) {
                                change_running = change;
                                change_last_x = int(x_);
-                       } else 
+                       } else
                                change_running.setUnchanged();
                }
 
@@ -826,7 +835,7 @@ void RowPainter::paintText()
        if (change_running.changed()) {
                FontMetrics const & fm
                        = theFontMetrics(pi_.base.bv->buffer().params().getFont());
-               int const y_bar = change_running.deleted() ? 
+               int const y_bar = change_running.deleted() ?
                                yo_ - fm.maxAscent() / 3 : yo_ + fm.maxAscent() / 6;
                pi_.pain.line(change_last_x, y_bar, int(x_), y_bar,
                        change_running.color(), Painter::line_solid, Painter::line_thin);