From 94699b586578ef48f2d22ccce4354ac08d337baf Mon Sep 17 00:00:00 2001 From: Edwin Leuven Date: Tue, 1 Apr 2008 17:53:26 +0000 Subject: [PATCH] don't draw selection too wide (esp visible in full screen mode) there is still one issue which is related (or so i think) to the pit is not being updated when extending a selection to a new row with cursor right/left. i left a FIXME in the code i put this in since it is a uniform improvement on the current situation... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24089 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/TextMetrics.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 904c7611a9..765e5bcc77 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -2025,8 +2025,10 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type pit, int x, int y) co if (row_selection) { DocIterator beg = bv_->cursor().selectionBegin(); DocIterator end = bv_->cursor().selectionEnd(); - bool const beg_margin = beg.pit() < pit && i == 0; - bool const end_margin = end.pit() > pit && i == nrows - 1; + // FIXME (not here): pit is not updated when extending + // a selection to a new row with cursor right/left + bool const beg_margin = beg.pit() < pit; + bool const end_margin = end.pit() > pit; beg.pit() = pit; beg.pos() = row.sel_beg; end.pit() = pit; @@ -2082,17 +2084,23 @@ void TextMetrics::drawRowSelection(PainterInfo & pi, int x, Row const & row, // draw the margins if (drawOnBegMargin) { - if (text_->isRTL(buffer, beg.paragraph())) - pi.pain.fillRectangle(x + x1, y1, width() - x1, y2 - y1, Color_selection); - else - pi.pain.fillRectangle(x, y1, x1, y2 - y1, Color_selection); + if (text_->isRTL(buffer, beg.paragraph())) { + int lm = bv_->leftMargin(); + pi.pain.fillRectangle(x + x1, y1, width() - lm - x1, y2 - y1, Color_selection); + } else { + int rm = bv_->rightMargin(); + pi.pain.fillRectangle(rm, y1, x1 - rm, y2 - y1, Color_selection); + } } if (drawOnEndMargin) { - if (text_->isRTL(buffer, beg.paragraph())) - pi.pain.fillRectangle(x, y1, x2, y2 - y1, Color_selection); - else - pi.pain.fillRectangle(x + x2, y1, width() - x2, y2 - y1, Color_selection); + if (text_->isRTL(buffer, beg.paragraph())) { + int rm = bv_->rightMargin(); + pi.pain.fillRectangle(x + rm, y1, x2 - rm, y2 - y1, Color_selection); + } else { + int lm = bv_->leftMargin(); + pi.pain.fillRectangle(x + x2, y1, width() - lm - x2, y2 - y1, Color_selection); + } } // if we are on a boundary from the beginning, it's probably -- 2.39.2