2003-02-26 17:04:10 +00:00
|
|
|
/**
|
2014-07-25 19:55:08 +00:00
|
|
|
* \file RowPainter.cpp
|
2003-02-26 17:04:10 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author various
|
|
|
|
* \author John Levon
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-02-26 17:04:10 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2008-03-17 21:11:17 +00:00
|
|
|
#include <algorithm>
|
2003-02-26 17:04:10 +00:00
|
|
|
|
2014-07-25 19:55:08 +00:00
|
|
|
#include "RowPainter.h"
|
2003-02-26 17:04:10 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Buffer.h"
|
|
|
|
#include "CoordCache.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
#include "Cursor.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "BufferParams.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
#include "BufferView.h"
|
2007-10-18 15:29:51 +00:00
|
|
|
#include "Changes.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Language.h"
|
2007-09-29 20:02:32 +00:00
|
|
|
#include "Layout.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "LyXRC.h"
|
|
|
|
#include "Row.h"
|
|
|
|
#include "MetricsInfo.h"
|
|
|
|
#include "Paragraph.h"
|
2006-12-29 23:54:48 +00:00
|
|
|
#include "ParagraphMetrics.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
#include "ParagraphParameters.h"
|
2006-12-29 23:54:48 +00:00
|
|
|
#include "TextMetrics.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "VSpace.h"
|
2003-02-26 17:04:10 +00:00
|
|
|
|
2006-10-07 16:15:06 +00:00
|
|
|
#include "frontends/FontMetrics.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
#include "frontends/Painter.h"
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "insets/InsetText.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
|
2010-12-22 00:16:51 +00:00
|
|
|
#include "mathed/InsetMath.h"
|
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
2009-07-19 01:41:47 +00:00
|
|
|
#include "support/gettext.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
#include "support/textutils.h"
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2008-04-30 08:26:40 +00:00
|
|
|
#include "support/lassert.h"
|
2005-12-30 19:02:52 +00:00
|
|
|
#include <boost/crc.hpp>
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2004-01-30 11:41:12 +00:00
|
|
|
|
2007-08-28 08:57:13 +00:00
|
|
|
namespace lyx {
|
2003-07-14 17:50:00 +00:00
|
|
|
|
2007-08-28 08:57:13 +00:00
|
|
|
using frontend::Painter;
|
|
|
|
using frontend::FontMetrics;
|
2003-07-28 12:20:42 +00:00
|
|
|
|
2012-10-27 13:45:27 +00:00
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
RowPainter::RowPainter(PainterInfo & pi,
|
2013-10-11 14:12:20 +00:00
|
|
|
Text const & text, pit_type pit, Row const & row, int x, int y)
|
2007-08-30 14:26:52 +00:00
|
|
|
: pi_(pi), text_(text),
|
2007-08-30 13:53:02 +00:00
|
|
|
text_metrics_(pi_.base.bv->textMetrics(&text)),
|
2006-12-29 23:54:48 +00:00
|
|
|
pars_(text.paragraphs()),
|
2004-11-30 01:59:49 +00:00
|
|
|
row_(row), pit_(pit), par_(text.paragraphs()[pit]),
|
2013-10-11 14:12:20 +00:00
|
|
|
pm_(text_metrics_.parMetrics(pit)), change_(pi_.change_),
|
2010-12-15 07:12:42 +00:00
|
|
|
xo_(x), yo_(y), width_(text_metrics_.width()),
|
2015-07-14 15:42:45 +00:00
|
|
|
solid_line_thickness_(1), solid_line_offset_(1),
|
|
|
|
dotted_line_thickness_(1), dotted_line_offset_(2)
|
2003-11-24 16:26:55 +00:00
|
|
|
{
|
2011-02-20 07:50:28 +00:00
|
|
|
if (lyxrc.zoom >= 200) {
|
|
|
|
// derive the line thickness from zoom factor
|
|
|
|
// the zoom is given in percent
|
|
|
|
// (increase thickness at 250%, 450% etc.)
|
2015-07-14 15:42:45 +00:00
|
|
|
solid_line_thickness_ = (lyxrc.zoom + 50) / 200;
|
2011-02-20 07:50:28 +00:00
|
|
|
// adjust line_offset_ too
|
2015-07-14 15:42:45 +00:00
|
|
|
solid_line_offset_ = 1 + solid_line_thickness_ / 2;
|
2011-02-20 07:50:28 +00:00
|
|
|
}
|
2010-12-15 07:12:42 +00:00
|
|
|
if (lyxrc.zoom >= 100) {
|
|
|
|
// derive the line thickness from zoom factor
|
|
|
|
// the zoom is given in percent
|
|
|
|
// (increase thickness at 150%, 250% etc.)
|
2015-07-14 15:42:45 +00:00
|
|
|
dotted_line_thickness_ = (lyxrc.zoom + 50) / 100;
|
2010-12-15 07:12:42 +00:00
|
|
|
// adjust line_offset_ too
|
2015-07-14 15:42:45 +00:00
|
|
|
dotted_line_offset_ = 1 + dotted_line_thickness_ / 2;
|
2010-12-15 07:12:42 +00:00
|
|
|
}
|
2010-12-13 16:18:37 +00:00
|
|
|
|
2014-12-22 09:36:53 +00:00
|
|
|
x_ = row_.left_margin + xo_;
|
2004-08-14 15:55:22 +00:00
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
//lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
|
|
|
|
//row_.dump();
|
|
|
|
|
2013-04-27 21:52:55 +00:00
|
|
|
LBUFERR(pit >= 0);
|
|
|
|
LBUFERR(pit < int(text.paragraphs().size()));
|
2003-11-24 16:26:55 +00:00
|
|
|
}
|
2003-02-26 17:04:10 +00:00
|
|
|
|
|
|
|
|
2008-02-27 23:03:26 +00:00
|
|
|
FontInfo RowPainter::labelFont() const
|
2003-02-26 17:04:10 +00:00
|
|
|
{
|
2010-09-06 14:35:02 +00:00
|
|
|
FontInfo f = text_.labelFont(par_);
|
|
|
|
// selected text?
|
|
|
|
if (row_.begin_margin_sel || pi_.selected)
|
|
|
|
f.setPaintColor(Color_selectiontext);
|
|
|
|
return f;
|
2003-02-26 17:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-03 15:39:58 +00:00
|
|
|
// If you want to debug inset metrics uncomment the following line:
|
2007-08-30 09:01:30 +00:00
|
|
|
//#define DEBUG_METRICS
|
2006-11-03 15:39:58 +00:00
|
|
|
// This draws green lines around each inset.
|
|
|
|
|
|
|
|
|
2015-07-16 21:34:33 +00:00
|
|
|
void RowPainter::paintInset(Inset const * inset, Font const & font,
|
|
|
|
Change const & change,
|
|
|
|
pos_type const pos)
|
2003-02-26 17:04:10 +00:00
|
|
|
{
|
2015-07-16 21:10:44 +00:00
|
|
|
// Handle selection
|
|
|
|
bool const pi_selected = pi_.selected;
|
|
|
|
Cursor const & cur = pi_.base.bv->cursor();
|
|
|
|
if (cur.selection() && cur.text() == &text_
|
|
|
|
&& cur.normalAnchor().text() == &text_)
|
|
|
|
pi_.selected = row_.sel_beg <= pos && row_.sel_end > pos;
|
|
|
|
|
2008-08-24 21:24:21 +00:00
|
|
|
LASSERT(inset, return);
|
2008-01-14 16:24:01 +00:00
|
|
|
// Backup full_repaint status because some insets (InsetTabular)
|
|
|
|
// requires a full repaint
|
2015-05-06 16:39:24 +00:00
|
|
|
bool const pi_full_repaint = pi_.full_repaint;
|
|
|
|
bool const pi_do_spellcheck = pi_.do_spellcheck;
|
2015-07-16 21:34:33 +00:00
|
|
|
Change const pi_change = pi_.change_;
|
2008-01-14 16:24:01 +00:00
|
|
|
|
2011-02-22 19:41:04 +00:00
|
|
|
pi_.base.font = inset->inheritFont() ? font.fontInfo() :
|
|
|
|
pi_.base.bv->buffer().params().getFont().fontInfo();
|
2015-07-16 21:34:33 +00:00
|
|
|
pi_.ltr_pos = !font.isVisibleRightToLeft();
|
|
|
|
pi_.change_ = change_.changed() ? change_ : change;
|
2015-05-06 16:39:24 +00:00
|
|
|
pi_.do_spellcheck &= inset->allowSpellCheck();
|
2009-02-09 21:14:23 +00:00
|
|
|
|
2008-12-22 18:16:05 +00:00
|
|
|
int const x1 = int(x_);
|
|
|
|
pi_.base.bv->coordCache().insets().add(inset, x1, yo_);
|
2007-08-27 14:38:29 +00:00
|
|
|
// insets are painted completely. Recursive
|
2010-11-25 13:08:26 +00:00
|
|
|
// FIXME: it is wrong to completely paint the background
|
|
|
|
// if we want to do single row painting.
|
2008-12-22 18:16:05 +00:00
|
|
|
inset->drawBackground(pi_, x1, yo_);
|
|
|
|
inset->drawSelection(pi_, x1, yo_);
|
|
|
|
inset->draw(pi_, x1, yo_);
|
2007-08-30 09:01:30 +00:00
|
|
|
|
2015-10-12 14:11:58 +00:00
|
|
|
Dimension const & dim = pi_.base.bv->coordCache().insets().dim(inset);
|
2007-08-30 09:01:30 +00:00
|
|
|
|
2007-10-29 08:52:13 +00:00
|
|
|
paintForeignMark(x_, font.language(), dim.descent());
|
2007-09-21 20:39:47 +00:00
|
|
|
|
|
|
|
x_ += dim.width();
|
2007-08-30 09:01:30 +00:00
|
|
|
|
2008-01-14 16:24:01 +00:00
|
|
|
// Restore full_repaint status.
|
|
|
|
pi_.full_repaint = pi_full_repaint;
|
2015-07-16 21:34:33 +00:00
|
|
|
pi_.change_ = pi_change;
|
2015-05-06 16:39:24 +00:00
|
|
|
pi_.do_spellcheck = pi_do_spellcheck;
|
2015-07-16 21:10:44 +00:00
|
|
|
pi_.selected = pi_selected;
|
2008-01-14 16:24:01 +00:00
|
|
|
|
2006-11-03 15:39:58 +00:00
|
|
|
#ifdef DEBUG_METRICS
|
|
|
|
int const x2 = x1 + dim.wid;
|
|
|
|
int const y1 = yo_ + dim.des;
|
|
|
|
int const y2 = yo_ - dim.asc;
|
2007-10-25 12:41:02 +00:00
|
|
|
pi_.pain.line(x1, y1, x1, y2, Color_green);
|
|
|
|
pi_.pain.line(x1, y1, x2, y1, Color_green);
|
|
|
|
pi_.pain.line(x2, y1, x2, y2, Color_green);
|
|
|
|
pi_.pain.line(x1, y2, x2, y2, Color_green);
|
2006-11-03 15:39:58 +00:00
|
|
|
#endif
|
2003-02-26 17:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-14 21:45:41 +00:00
|
|
|
void RowPainter::paintForeignMark(double orig_x, Language const * lang, int desc) const
|
|
|
|
{
|
|
|
|
if (!lyxrc.mark_foreign_language)
|
|
|
|
return;
|
|
|
|
if (lang == latex_language)
|
|
|
|
return;
|
|
|
|
if (lang == pi_.base.bv->buffer().params().language)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int const y = yo_ + solid_line_offset_ + desc + solid_line_thickness_ / 2;
|
|
|
|
pi_.pain.line(int(orig_x), y, int(x_), y, Color_language,
|
|
|
|
Painter::line_solid, solid_line_thickness_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RowPainter::paintMisspelledMark(double const orig_x,
|
2015-07-18 23:22:10 +00:00
|
|
|
Row::Element const & e) const
|
2015-07-14 21:45:41 +00:00
|
|
|
{
|
|
|
|
// if changed the misspelled marker gets placed slightly lower than normal
|
|
|
|
// to avoid drawing at the same vertical offset
|
|
|
|
int const y = yo_ + solid_line_offset_ + solid_line_thickness_
|
2015-07-18 23:22:10 +00:00
|
|
|
+ (e.change.changed() ? solid_line_thickness_ + 1 : 0)
|
2015-07-14 21:45:41 +00:00
|
|
|
+ dotted_line_offset_;
|
|
|
|
|
|
|
|
//FIXME: this could be computed only once, it is probably not costly.
|
|
|
|
// check for cursor position
|
|
|
|
// don't draw misspelled marker for words at cursor position
|
|
|
|
// we don't want to disturb the process of text editing
|
|
|
|
DocIterator const nw = pi_.base.bv->cursor().newWord();
|
|
|
|
pos_type cpos = -1;
|
|
|
|
if (!nw.empty() && par_.id() == nw.paragraph().id()) {
|
|
|
|
cpos = nw.pos();
|
|
|
|
if (cpos > 0 && cpos == par_.size() && !par_.isWordSeparator(cpos-1))
|
|
|
|
--cpos;
|
|
|
|
else if (cpos > 0 && par_.isWordSeparator(cpos))
|
|
|
|
--cpos;
|
|
|
|
}
|
|
|
|
|
2015-07-18 23:22:10 +00:00
|
|
|
pos_type pos = e.pos;
|
|
|
|
while (pos < e.pos + pos_type(e.str.length())) {
|
2015-07-14 21:45:41 +00:00
|
|
|
if (!par_.isMisspelled(pos)) {
|
|
|
|
++pos;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
FontSpan const & range = par_.getSpellRange(pos);
|
|
|
|
|
|
|
|
// Skip element which are being edited
|
|
|
|
if (range.contains(cpos)) {
|
|
|
|
// the range includes the last element
|
|
|
|
pos = range.last + 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-07-18 23:22:10 +00:00
|
|
|
FontMetrics const & fm = theFontMetrics(e.font);
|
|
|
|
int x1 = fm.pos2x(e.str, range.first - e.pos,
|
2015-09-18 14:42:24 +00:00
|
|
|
e.isRTL(), e.extra);
|
2015-07-18 23:22:10 +00:00
|
|
|
int x2 = fm.pos2x(e.str, min(range.last - e.pos + 1,
|
|
|
|
pos_type(e.str.length())),
|
2015-09-18 14:42:24 +00:00
|
|
|
e.isRTL(), e.extra);
|
2015-07-14 21:45:41 +00:00
|
|
|
if (x1 > x2)
|
|
|
|
swap(x1, x2);
|
|
|
|
|
|
|
|
pi_.pain.line(int(orig_x) + x1, y, int(orig_x) + x2, y,
|
|
|
|
Color_error,
|
|
|
|
Painter::line_onoffdash, dotted_line_thickness_);
|
|
|
|
pos = range.last + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-18 23:22:10 +00:00
|
|
|
void RowPainter::paintStringAndSel(Row::Element const & e)
|
2015-07-14 21:45:41 +00:00
|
|
|
{
|
|
|
|
// at least part of text selected?
|
2015-07-18 23:22:10 +00:00
|
|
|
bool const some_sel = (e.endpos >= row_.sel_beg && e.pos < row_.sel_end)
|
2015-07-14 21:45:41 +00:00
|
|
|
|| pi_.selected;
|
|
|
|
// all the text selected?
|
2015-07-18 23:22:10 +00:00
|
|
|
bool const all_sel = (e.pos >= row_.sel_beg && e.endpos < row_.sel_end)
|
2015-07-14 21:45:41 +00:00
|
|
|
|| pi_.selected;
|
|
|
|
|
|
|
|
if (all_sel) {
|
2015-07-18 23:22:10 +00:00
|
|
|
Font copy = e.font;
|
2015-07-14 21:45:41 +00:00
|
|
|
copy.fontInfo().setPaintColor(Color_selectiontext);
|
2015-07-18 23:22:10 +00:00
|
|
|
pi_.pain.text(int(x_), yo_, e.str, copy, e.extra);
|
|
|
|
} else if (e.change.changed()) {
|
|
|
|
Font copy = e.font;
|
|
|
|
copy.fontInfo().setPaintColor(e.change.color());
|
|
|
|
pi_.pain.text(int(x_), yo_, e.str, copy, e.extra);
|
2015-07-14 21:45:41 +00:00
|
|
|
} else if (!some_sel) {
|
2015-07-18 23:22:10 +00:00
|
|
|
pi_.pain.text(int(x_), yo_, e.str, e.font, e.extra);
|
2015-07-14 21:45:41 +00:00
|
|
|
} else {
|
2015-07-18 23:22:10 +00:00
|
|
|
pi_.pain.text(int(x_), yo_, e.str, e.font, Color_selectiontext,
|
|
|
|
max(row_.sel_beg, e.pos) - e.pos,
|
|
|
|
min(row_.sel_end, e.endpos) - e.pos, e.extra);
|
2015-07-14 21:45:41 +00:00
|
|
|
}
|
2015-07-18 23:22:10 +00:00
|
|
|
x_ += e.full_width();
|
2015-07-14 21:45:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-16 21:18:55 +00:00
|
|
|
void RowPainter::paintChange(double orig_x, Font const & font,
|
|
|
|
Change const & change) const
|
|
|
|
{
|
|
|
|
if (!change.changed())
|
|
|
|
return;
|
|
|
|
// Calculate 1/3 height of font
|
|
|
|
FontMetrics const & fm = theFontMetrics(font);
|
|
|
|
int const y_bar = change.deleted() ? yo_ - fm.maxAscent() / 3
|
|
|
|
: yo_ + 2 * solid_line_offset_ + solid_line_thickness_;
|
|
|
|
pi_.pain.line(int(orig_x), y_bar, int(x_), y_bar,
|
|
|
|
change.color(), Painter::line_solid, solid_line_thickness_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-29 14:12:11 +00:00
|
|
|
void RowPainter::paintChangeBar() const
|
2003-02-26 17:04:10 +00:00
|
|
|
{
|
2003-10-23 08:15:57 +00:00
|
|
|
pos_type const start = row_.pos();
|
2006-10-31 20:07:26 +00:00
|
|
|
pos_type end = row_.endpos();
|
|
|
|
|
|
|
|
if (par_.size() == end) {
|
|
|
|
// this is the last row of the paragraph;
|
|
|
|
// thus, we must also consider the imaginary end-of-par character
|
|
|
|
end++;
|
|
|
|
}
|
2003-02-26 17:04:10 +00:00
|
|
|
|
2006-03-13 11:05:07 +00:00
|
|
|
if (start == end || !par_.isChanged(start, end))
|
2003-02-26 17:04:10 +00:00
|
|
|
return;
|
2003-03-04 09:27:27 +00:00
|
|
|
|
2007-09-02 11:27:19 +00:00
|
|
|
int const height = text_metrics_.isLastRow(pit_, row_)
|
2004-11-30 01:59:49 +00:00
|
|
|
? row_.ascent()
|
|
|
|
: row_.height();
|
2003-03-04 09:27:27 +00:00
|
|
|
|
2007-10-25 12:41:02 +00:00
|
|
|
pi_.pain.fillRectangle(5, yo_ - row_.ascent(), 3, height, Color_changebar);
|
2003-02-26 17:04:10 +00:00
|
|
|
}
|
|
|
|
|
2003-03-04 09:27:27 +00:00
|
|
|
|
2015-06-29 14:12:11 +00:00
|
|
|
void RowPainter::paintAppendix() const
|
2003-02-26 17:04:10 +00:00
|
|
|
{
|
2007-07-17 13:35:32 +00:00
|
|
|
// only draw the appendix frame once (for the main text)
|
2009-08-09 15:29:34 +00:00
|
|
|
if (!par_.params().appendix() || !text_.isMainText())
|
2003-03-13 19:55:39 +00:00
|
|
|
return;
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
int y = yo_ - row_.ascent();
|
2003-03-13 19:55:39 +00:00
|
|
|
|
2004-08-15 00:01:45 +00:00
|
|
|
if (par_.params().startOfAppendix())
|
2003-03-13 19:55:39 +00:00
|
|
|
y += 2 * defaultRowHeight();
|
|
|
|
|
2007-10-25 12:41:02 +00:00
|
|
|
pi_.pain.line(1, y, 1, yo_ + row_.height(), Color_appendix);
|
|
|
|
pi_.pain.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), Color_appendix);
|
2003-02-26 17:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-29 14:12:11 +00:00
|
|
|
void RowPainter::paintDepthBar() const
|
2003-02-26 17:04:10 +00:00
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
depth_type const depth = par_.getDepth();
|
2003-02-26 17:04:10 +00:00
|
|
|
|
|
|
|
if (depth <= 0)
|
|
|
|
return;
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
depth_type prev_depth = 0;
|
2007-09-02 11:27:19 +00:00
|
|
|
if (!text_metrics_.isFirstRow(pit_, row_)) {
|
2004-11-24 21:53:46 +00:00
|
|
|
pit_type pit2 = pit_;
|
2003-10-23 08:15:57 +00:00
|
|
|
if (row_.pos() == 0)
|
2003-08-14 12:06:11 +00:00
|
|
|
--pit2;
|
2004-03-25 09:16:36 +00:00
|
|
|
prev_depth = pars_[pit2].getDepth();
|
2003-08-14 12:06:11 +00:00
|
|
|
}
|
2003-06-18 17:43:49 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
depth_type next_depth = 0;
|
2007-09-02 11:27:19 +00:00
|
|
|
if (!text_metrics_.isLastRow(pit_, row_)) {
|
2004-11-24 21:53:46 +00:00
|
|
|
pit_type pit2 = pit_;
|
2004-03-25 09:16:36 +00:00
|
|
|
if (row_.endpos() >= pars_[pit2].size())
|
2003-08-14 12:06:11 +00:00
|
|
|
++pit2;
|
2004-03-25 09:16:36 +00:00
|
|
|
next_depth = pars_[pit2].getDepth();
|
2003-08-14 12:06:11 +00:00
|
|
|
}
|
2003-02-26 17:04:10 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
for (depth_type i = 1; i <= depth; ++i) {
|
2004-08-14 15:55:22 +00:00
|
|
|
int const w = nestMargin() / 5;
|
2004-08-14 21:56:40 +00:00
|
|
|
int x = int(xo_) + w * i;
|
|
|
|
// only consider the changebar space if we're drawing outermost text
|
2009-08-09 15:29:34 +00:00
|
|
|
if (text_.isMainText())
|
2004-08-14 15:55:22 +00:00
|
|
|
x += changebarMargin();
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
int const starty = yo_ - row_.ascent();
|
|
|
|
int const h = row_.height() - 1 - (i - next_depth - 1) * 3;
|
2003-02-26 17:04:10 +00:00
|
|
|
|
2007-10-25 12:41:02 +00:00
|
|
|
pi_.pain.line(x, starty, x, starty + h, Color_depthbar);
|
2003-02-26 17:04:10 +00:00
|
|
|
|
2003-07-28 12:20:42 +00:00
|
|
|
if (i > prev_depth)
|
2007-10-25 12:41:02 +00:00
|
|
|
pi_.pain.fillRectangle(x, starty, w, 2, Color_depthbar);
|
2003-07-28 12:20:42 +00:00
|
|
|
if (i > next_depth)
|
2007-10-25 12:41:02 +00:00
|
|
|
pi_.pain.fillRectangle(x, starty + h, w, 2, Color_depthbar);
|
2003-02-26 17:04:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-12 09:55:38 +00:00
|
|
|
void RowPainter::paintAppendixStart(int y) const
|
2003-03-13 19:55:39 +00:00
|
|
|
{
|
2007-10-29 08:47:19 +00:00
|
|
|
FontInfo pb_font = sane_font;
|
2007-10-25 12:41:02 +00:00
|
|
|
pb_font.setColor(Color_appendix);
|
2003-09-16 09:01:15 +00:00
|
|
|
pb_font.decSize();
|
2003-03-13 19:55:39 +00:00
|
|
|
|
|
|
|
int w = 0;
|
|
|
|
int a = 0;
|
|
|
|
int d = 0;
|
2006-10-17 14:46:45 +00:00
|
|
|
|
|
|
|
docstring const label = _("Appendix");
|
|
|
|
theFontMetrics(pb_font).rectText(label, w, a, d);
|
2003-03-13 19:55:39 +00:00
|
|
|
|
2003-07-28 12:20:42 +00:00
|
|
|
int const text_start = int(xo_ + (width_ - w) / 2);
|
2003-03-13 19:55:39 +00:00
|
|
|
int const text_end = text_start + w;
|
|
|
|
|
2007-10-25 12:41:02 +00:00
|
|
|
pi_.pain.rectText(text_start, y + d, label, pb_font, Color_none, Color_none);
|
2003-03-13 19:55:39 +00:00
|
|
|
|
2007-10-25 12:41:02 +00:00
|
|
|
pi_.pain.line(int(xo_ + 1), y, text_start, y, Color_appendix);
|
|
|
|
pi_.pain.line(text_end, y, int(xo_ + width_ - 2), y, Color_appendix);
|
2003-03-13 19:55:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-29 14:12:11 +00:00
|
|
|
void RowPainter::paintTooLargeMarks(bool const left, bool const right) const
|
2014-07-27 16:55:10 +00:00
|
|
|
{
|
|
|
|
if (left)
|
2015-07-14 15:42:45 +00:00
|
|
|
pi_.pain.line(dotted_line_thickness_, yo_ - row_.ascent(),
|
|
|
|
dotted_line_thickness_, yo_ + row_.descent(),
|
2015-01-11 16:13:36 +00:00
|
|
|
Color_scroll,
|
|
|
|
Painter::line_onoffdash, dotted_line_thickness_);
|
2014-07-27 16:55:10 +00:00
|
|
|
if (right) {
|
2015-07-14 15:42:45 +00:00
|
|
|
int const wwidth = pi_.base.bv->workWidth() - dotted_line_thickness_;
|
2014-07-27 16:55:10 +00:00
|
|
|
pi_.pain.line(wwidth, yo_ - row_.ascent(),
|
2015-01-11 16:13:36 +00:00
|
|
|
wwidth, yo_ + row_.descent(),
|
|
|
|
Color_scroll,
|
|
|
|
Painter::line_onoffdash, dotted_line_thickness_);
|
2014-07-27 16:55:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-29 14:12:11 +00:00
|
|
|
void RowPainter::paintFirst() const
|
2003-02-26 17:04:10 +00:00
|
|
|
{
|
2010-09-06 10:56:27 +00:00
|
|
|
Layout const & layout = par_.layout();
|
2003-02-26 17:04:10 +00:00
|
|
|
|
|
|
|
// start of appendix?
|
2011-10-30 09:16:30 +00:00
|
|
|
if (par_.params().startOfAppendix())
|
2015-10-12 09:55:38 +00:00
|
|
|
paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
|
2003-02-26 17:04:10 +00:00
|
|
|
|
2013-02-09 16:13:01 +00:00
|
|
|
bool const is_first =
|
|
|
|
text_.isFirstInSequence(pit_) || !layout.isParagraphGroup();
|
2007-12-12 19:28:07 +00:00
|
|
|
//lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << endl;
|
2003-02-26 17:04:10 +00:00
|
|
|
|
2013-02-09 16:13:01 +00:00
|
|
|
if (layout.labelIsInline()
|
2015-10-12 09:55:38 +00:00
|
|
|
&& (layout.labeltype != LABEL_STATIC || is_first))
|
2011-10-30 09:16:30 +00:00
|
|
|
paintLabel();
|
2015-10-12 09:55:38 +00:00
|
|
|
else if (is_first && layout.labelIsAbove())
|
2011-10-30 09:16:30 +00:00
|
|
|
paintTopLevelLabel();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-29 14:12:11 +00:00
|
|
|
void RowPainter::paintLabel() const
|
2011-10-30 09:16:30 +00:00
|
|
|
{
|
|
|
|
docstring const str = par_.labelString();
|
|
|
|
if (str.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool const is_rtl = text_.isRTL(par_);
|
|
|
|
Layout const & layout = par_.layout();
|
|
|
|
FontInfo const font = labelFont();
|
|
|
|
FontMetrics const & fm = theFontMetrics(font);
|
|
|
|
double x = x_;
|
|
|
|
|
2015-07-17 22:07:30 +00:00
|
|
|
if (is_rtl)
|
|
|
|
x = width_ - row_.right_margin + fm.width(layout.labelsep);
|
|
|
|
else
|
|
|
|
x = x_ - fm.width(layout.labelsep) - fm.width(str);
|
2013-02-09 16:13:40 +00:00
|
|
|
|
|
|
|
pi_.pain.text(int(x), yo_, str, font);
|
2003-02-26 17:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-29 14:12:11 +00:00
|
|
|
void RowPainter::paintTopLevelLabel() const
|
2011-10-30 09:16:30 +00:00
|
|
|
{
|
|
|
|
BufferParams const & bparams = pi_.base.bv->buffer().params();
|
|
|
|
bool const is_rtl = text_.isRTL(par_);
|
|
|
|
ParagraphParameters const & pparams = par_.params();
|
|
|
|
Layout const & layout = par_.layout();
|
|
|
|
FontInfo const font = labelFont();
|
|
|
|
docstring const str = par_.labelString();
|
|
|
|
if (str.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
double spacing_val = 1.0;
|
|
|
|
if (!pparams.spacing().isDefault())
|
|
|
|
spacing_val = pparams.spacing().getValue();
|
|
|
|
else
|
|
|
|
spacing_val = bparams.spacing().getValue();
|
|
|
|
|
|
|
|
FontMetrics const & fm = theFontMetrics(font);
|
|
|
|
|
|
|
|
int const labeladdon = int(fm.maxHeight()
|
|
|
|
* layout.spacing.getValue() * spacing_val);
|
|
|
|
|
|
|
|
int maxdesc =
|
|
|
|
int(fm.maxDescent() * layout.spacing.getValue() * spacing_val
|
|
|
|
+ (layout.labelbottomsep * defaultRowHeight()));
|
|
|
|
|
|
|
|
double x = x_;
|
2013-02-09 16:13:01 +00:00
|
|
|
if (layout.labeltype == LABEL_CENTERED) {
|
2015-07-17 22:07:30 +00:00
|
|
|
x = row_.left_margin + (width_ - row_.left_margin - row_.right_margin) / 2;
|
2011-10-30 09:16:30 +00:00
|
|
|
x -= fm.width(str) / 2;
|
|
|
|
} else if (is_rtl) {
|
2015-07-17 22:07:30 +00:00
|
|
|
x = width_ - row_.right_margin - fm.width(str);
|
2011-10-30 09:16:30 +00:00
|
|
|
}
|
|
|
|
pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font);
|
|
|
|
}
|
|
|
|
|
2012-10-27 13:45:27 +00:00
|
|
|
|
2009-08-09 18:35:39 +00:00
|
|
|
/** Check if the current paragraph is the last paragraph in a
|
|
|
|
proof environment */
|
|
|
|
static int getEndLabel(pit_type p, Text const & text)
|
|
|
|
{
|
|
|
|
ParagraphList const & pars = text.paragraphs();
|
|
|
|
pit_type pit = p;
|
|
|
|
depth_type par_depth = pars[p].getDepth();
|
|
|
|
while (pit != pit_type(pars.size())) {
|
|
|
|
Layout const & layout = pars[pit].layout();
|
|
|
|
int const endlabeltype = layout.endlabeltype;
|
|
|
|
|
|
|
|
if (endlabeltype != END_LABEL_NO_LABEL) {
|
|
|
|
if (p + 1 == pit_type(pars.size()))
|
|
|
|
return endlabeltype;
|
|
|
|
|
|
|
|
depth_type const next_depth =
|
|
|
|
pars[p + 1].getDepth();
|
|
|
|
if (par_depth > next_depth ||
|
|
|
|
(par_depth == next_depth && layout != pars[p + 1].layout()))
|
|
|
|
return endlabeltype;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (par_depth == 0)
|
|
|
|
break;
|
|
|
|
pit = text.outerHook(pit);
|
|
|
|
if (pit != pit_type(pars.size()))
|
|
|
|
par_depth = pars[pit].getDepth();
|
|
|
|
}
|
|
|
|
return END_LABEL_NO_LABEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-26 17:04:10 +00:00
|
|
|
void RowPainter::paintLast()
|
|
|
|
{
|
2009-08-09 15:29:34 +00:00
|
|
|
bool const is_rtl = text_.isRTL(par_);
|
2009-08-09 18:35:39 +00:00
|
|
|
int const endlabel = getEndLabel(pit_, text_);
|
2003-02-26 17:04:10 +00:00
|
|
|
|
2006-11-23 18:59:05 +00:00
|
|
|
// paint imaginary end-of-paragraph character
|
|
|
|
|
2008-09-22 15:30:26 +00:00
|
|
|
Change const & change = par_.lookupChange(par_.size());
|
|
|
|
if (change.changed()) {
|
2008-09-22 15:41:05 +00:00
|
|
|
FontMetrics const & fm =
|
2008-09-22 15:30:26 +00:00
|
|
|
theFontMetrics(pi_.base.bv->buffer().params().getFont());
|
2006-11-23 18:59:05 +00:00
|
|
|
int const length = fm.maxAscent() / 2;
|
2009-02-09 20:47:32 +00:00
|
|
|
Color col = change.color();
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2007-08-30 13:53:02 +00:00
|
|
|
pi_.pain.line(int(x_) + 1, yo_ + 2, int(x_) + 1, yo_ + 2 - length, col,
|
2010-09-05 14:56:07 +00:00
|
|
|
Painter::line_solid, 3);
|
2008-09-22 15:41:05 +00:00
|
|
|
|
2008-09-22 15:30:26 +00:00
|
|
|
if (change.deleted()) {
|
2008-09-22 15:41:05 +00:00
|
|
|
pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 1 + length,
|
2010-09-05 14:56:07 +00:00
|
|
|
yo_ + 2, col, Painter::line_solid, 3);
|
2008-09-22 15:30:26 +00:00
|
|
|
} else {
|
2008-09-22 15:41:05 +00:00
|
|
|
pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 1,
|
2010-09-05 14:56:07 +00:00
|
|
|
yo_ + 2, col, Painter::line_solid, 3);
|
2008-09-22 15:30:26 +00:00
|
|
|
}
|
2006-11-23 18:59:05 +00:00
|
|
|
}
|
|
|
|
|
2003-02-26 17:04:10 +00:00
|
|
|
// draw an endlabel
|
2006-11-23 18:59:05 +00:00
|
|
|
|
2003-02-26 17:04:10 +00:00
|
|
|
switch (endlabel) {
|
|
|
|
case END_LABEL_BOX:
|
2003-10-28 11:18:40 +00:00
|
|
|
case END_LABEL_FILLED_BOX: {
|
2008-02-27 23:03:26 +00:00
|
|
|
FontInfo const font = labelFont();
|
2006-10-11 17:24:46 +00:00
|
|
|
FontMetrics const & fm = theFontMetrics(font);
|
2006-10-07 16:15:06 +00:00
|
|
|
int const size = int(0.75 * fm.maxAscent());
|
2004-11-30 01:59:49 +00:00
|
|
|
int const y = yo_ - size;
|
2008-01-29 07:31:24 +00:00
|
|
|
int const max_row_width = width_ - size - Inset::TEXT_TO_INSET_OFFSET;
|
|
|
|
int x = is_rtl ? nestMargin() + changebarMargin()
|
2015-07-17 22:07:30 +00:00
|
|
|
: max_row_width - row_.right_margin;
|
2003-02-26 17:04:10 +00:00
|
|
|
|
2008-01-29 07:31:24 +00:00
|
|
|
// If needed, move the box a bit to avoid overlapping with text.
|
|
|
|
int const rem = max_row_width - row_.width();
|
2008-01-28 21:22:29 +00:00
|
|
|
if (rem <= 0)
|
2008-01-29 07:31:24 +00:00
|
|
|
x += is_rtl ? rem : - rem;
|
2003-02-26 17:04:10 +00:00
|
|
|
|
2003-07-28 12:20:42 +00:00
|
|
|
if (endlabel == END_LABEL_BOX)
|
2007-10-25 12:41:02 +00:00
|
|
|
pi_.pain.rectangle(x, y, size, size, Color_eolmarker);
|
2003-07-28 12:20:42 +00:00
|
|
|
else
|
2007-10-25 12:41:02 +00:00
|
|
|
pi_.pain.fillRectangle(x, y, size, size, Color_eolmarker);
|
2003-02-26 17:04:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-10-28 11:18:40 +00:00
|
|
|
|
|
|
|
case END_LABEL_STATIC: {
|
2008-02-27 23:03:26 +00:00
|
|
|
FontInfo const font = labelFont();
|
2006-10-11 17:24:46 +00:00
|
|
|
FontMetrics const & fm = theFontMetrics(font);
|
2008-03-06 21:31:27 +00:00
|
|
|
docstring const & str = par_.layout().endlabelstring();
|
2009-08-22 17:51:41 +00:00
|
|
|
double const x = is_rtl ? x_ - fm.width(str) : x_;
|
2007-08-30 13:53:02 +00:00
|
|
|
pi_.pain.text(int(x), yo_, str, font);
|
2003-02-26 17:04:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-10-28 11:18:40 +00:00
|
|
|
|
2003-02-26 17:04:10 +00:00
|
|
|
case END_LABEL_NO_LABEL:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-30 13:19:24 +00:00
|
|
|
void RowPainter::paintOnlyInsets()
|
|
|
|
{
|
2015-07-18 18:37:53 +00:00
|
|
|
Row::const_iterator cit = row_.begin();
|
|
|
|
Row::const_iterator const & end = row_.end();
|
|
|
|
for ( ; cit != end ; ++cit) {
|
|
|
|
Row::Element const & e = *cit;
|
|
|
|
if (e.type == Row::INSET) {
|
|
|
|
// If outer row has changed, nested insets are repainted completely.
|
|
|
|
pi_.base.bv->coordCache().insets().add(e.inset, int(x_), yo_);
|
|
|
|
bool const nested_inset =
|
|
|
|
(e.inset->asInsetMath() && !e.inset->asInsetMath()->asMacroTemplate())
|
|
|
|
|| e.inset->asInsetText() || e.inset->asInsetTabular();
|
|
|
|
if (!nested_inset) {
|
|
|
|
x_ += e.full_width();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
paintInset(e.inset, e.font, e.change, e.pos);
|
|
|
|
} else
|
|
|
|
x_ += e.full_width();
|
2007-08-30 13:19:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-18 18:37:53 +00:00
|
|
|
|
2003-03-22 17:26:03 +00:00
|
|
|
void RowPainter::paintText()
|
2015-07-16 21:18:55 +00:00
|
|
|
{
|
|
|
|
Row::const_iterator cit = row_.begin();
|
|
|
|
Row::const_iterator const & end = row_.end();
|
|
|
|
for ( ; cit != end ; ++cit) {
|
|
|
|
double const orig_x = x_;
|
|
|
|
Row::Element const & e = *cit;
|
|
|
|
int foreign_descent = 0;
|
|
|
|
|
|
|
|
switch (e.type) {
|
|
|
|
case Row::STRING:
|
|
|
|
case Row::VIRTUAL:
|
2015-07-18 23:22:10 +00:00
|
|
|
paintStringAndSel(e);
|
2015-07-16 21:18:55 +00:00
|
|
|
|
2015-08-26 11:54:35 +00:00
|
|
|
// Paint the spelling marks if enabled.
|
|
|
|
if (lyxrc.spellcheck_continuously && pi_.do_spellcheck)
|
2015-07-18 23:22:10 +00:00
|
|
|
paintMisspelledMark(orig_x, e);
|
2015-07-16 21:18:55 +00:00
|
|
|
break;
|
|
|
|
case Row::INSET: {
|
|
|
|
// If outer row has changed, nested insets are repaint completely.
|
|
|
|
pi_.base.bv->coordCache().insets().add(e.inset, int(x_), yo_);
|
2015-07-16 21:34:33 +00:00
|
|
|
paintInset(e.inset, e.font, e.change, e.pos);
|
2015-07-16 21:18:55 +00:00
|
|
|
foreign_descent = e.dim.descent();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Row::SPACE:
|
2015-07-21 07:51:06 +00:00
|
|
|
pi_.pain.textDecoration(e.font.fontInfo(), int(x_), yo_, int(e.full_width()));
|
|
|
|
x_ += e.full_width();
|
2015-07-16 21:18:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The line that indicates word in a different language
|
|
|
|
paintForeignMark(orig_x, e.font.language(), foreign_descent);
|
|
|
|
|
|
|
|
// change tracking (not for insets that track their own changes)
|
|
|
|
if (e.type != Row::INSET || ! e.inset->canTrackChanges())
|
|
|
|
paintChange(orig_x, e.font, e.change);
|
|
|
|
}
|
2003-02-26 17:04:10 +00:00
|
|
|
}
|
|
|
|
|
2008-02-22 14:05:27 +00:00
|
|
|
|
2015-06-29 14:12:11 +00:00
|
|
|
void RowPainter::paintSelection() const
|
2010-11-25 13:16:30 +00:00
|
|
|
{
|
|
|
|
if (!row_.selection())
|
|
|
|
return;
|
|
|
|
Cursor const & curs = pi_.base.bv->cursor();
|
|
|
|
DocIterator beg = curs.selectionBegin();
|
|
|
|
beg.pit() = pit_;
|
|
|
|
beg.pos() = row_.sel_beg;
|
|
|
|
|
|
|
|
DocIterator end = curs.selectionEnd();
|
|
|
|
end.pit() = pit_;
|
|
|
|
end.pos() = row_.sel_end;
|
|
|
|
|
|
|
|
bool const begin_boundary = beg.pos() >= row_.endpos();
|
|
|
|
bool const end_boundary = row_.sel_end == row_.endpos();
|
|
|
|
|
|
|
|
DocIterator cur = beg;
|
|
|
|
cur.boundary(begin_boundary);
|
|
|
|
int x1 = text_metrics_.cursorX(beg.top(), begin_boundary);
|
|
|
|
int x2 = text_metrics_.cursorX(end.top(), end_boundary);
|
|
|
|
int const y1 = yo_ - row_.ascent();
|
|
|
|
int const y2 = y1 + row_.height();
|
|
|
|
|
|
|
|
int const rm = text_.isMainText() ? pi_.base.bv->rightMargin() : 0;
|
|
|
|
int const lm = text_.isMainText() ? pi_.base.bv->leftMargin() : 0;
|
|
|
|
|
|
|
|
// draw the margins
|
|
|
|
if (row_.begin_margin_sel) {
|
|
|
|
if (text_.isRTL(beg.paragraph())) {
|
2010-12-03 15:40:23 +00:00
|
|
|
pi_.pain.fillRectangle(int(xo_ + x1), y1,
|
|
|
|
text_metrics_.width() - rm - x1, y2 - y1, Color_selection);
|
2010-11-25 13:16:30 +00:00
|
|
|
} else {
|
2010-12-03 15:40:23 +00:00
|
|
|
pi_.pain.fillRectangle(int(xo_ + lm), y1, x1 - lm, y2 - y1,
|
2010-11-25 13:16:30 +00:00
|
|
|
Color_selection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (row_.end_margin_sel) {
|
|
|
|
if (text_.isRTL(beg.paragraph())) {
|
2010-12-03 15:40:23 +00:00
|
|
|
pi_.pain.fillRectangle(int(xo_ + lm), y1, x2 - lm, y2 - y1,
|
2010-11-25 13:16:30 +00:00
|
|
|
Color_selection);
|
|
|
|
} else {
|
2010-12-03 15:40:23 +00:00
|
|
|
pi_.pain.fillRectangle(int(xo_ + x2), y1, text_metrics_.width() - rm - x2,
|
|
|
|
y2 - y1, Color_selection);
|
2010-11-25 13:16:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we are on a boundary from the beginning, it's probably
|
|
|
|
// a RTL boundary and we jump to the other side directly as this
|
|
|
|
// segement is 0-size and confuses the logic below
|
|
|
|
if (cur.boundary())
|
|
|
|
cur.boundary(false);
|
|
|
|
|
|
|
|
// go through row and draw from RTL boundary to RTL boundary
|
|
|
|
while (cur < end) {
|
|
|
|
bool draw_now = false;
|
|
|
|
|
|
|
|
// simplified cursorForward code below which does not
|
|
|
|
// descend into insets and which does not go into the
|
|
|
|
// next line. Compare the logic with the original cursorForward
|
|
|
|
|
|
|
|
// if left of boundary -> just jump to right side, but
|
|
|
|
// for RTL boundaries don't, because: abc|DDEEFFghi -> abcDDEEF|Fghi
|
|
|
|
if (cur.boundary()) {
|
|
|
|
cur.boundary(false);
|
|
|
|
} else if (text_metrics_.isRTLBoundary(cur.pit(), cur.pos() + 1)) {
|
|
|
|
// in front of RTL boundary -> Stay on this side of the boundary
|
|
|
|
// because: ab|cDDEEFFghi -> abc|DDEEFFghi
|
|
|
|
++cur.pos();
|
|
|
|
cur.boundary(true);
|
|
|
|
draw_now = true;
|
|
|
|
} else {
|
|
|
|
// move right
|
|
|
|
++cur.pos();
|
|
|
|
|
|
|
|
// line end?
|
|
|
|
if (cur.pos() == row_.endpos())
|
|
|
|
cur.boundary(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x1 == -1) {
|
|
|
|
// the previous segment was just drawn, now the next starts
|
|
|
|
x1 = text_metrics_.cursorX(cur.top(), cur.boundary());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(cur < end) || draw_now) {
|
|
|
|
x2 = text_metrics_.cursorX(cur.top(), cur.boundary());
|
2010-12-03 15:40:23 +00:00
|
|
|
pi_.pain.fillRectangle(int(xo_ + min(x1, x2)), y1, abs(x2 - x1),
|
|
|
|
y2 - y1, Color_selection);
|
2010-11-25 13:16:30 +00:00
|
|
|
|
|
|
|
// reset x1, so it is set again next round (which will be on the
|
|
|
|
// right side of a boundary or at the selection end)
|
|
|
|
x1 = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|