xo_(x), yo_(y), width_(text_metrics_.width())
{
RowMetrics m = text_metrics_.computeRowMetrics(pit_, row_);
- bidi_.computeTables(par_, *bv_.buffer(), row_);
+ bidi_.computeTables(par_, bv_.buffer(), row_);
x_ = m.x + xo_;
//lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
Font const RowPainter::getLabelFont() const
{
- return text_.getLabelFont(*bv_.buffer(), par_);
+ return text_.getLabelFont(bv_.buffer(), par_);
}
int RowPainter::leftMargin() const
{
- return text_.leftMargin(*bv_.buffer(), max_width_, pit_, row_.pos());
+ return text_.leftMargin(bv_.buffer(), max_width_, pit_, row_.pos());
}
// FIXME: We should always use font, see documentation of
// noFontChange() in Inset.h.
pi.base.font = inset->noFontChange() ?
- bv_.buffer()->params().getFont() :
+ bv_.buffer().params().getFont() :
font;
pi.ltr_pos = (bidi_.level(pos) % 2 == 0);
pi.erased_ = erased_ || par_.isDeleted(pos);
c = par_.getChar(i);
if (!Encodings::isComposeChar_hebrew(c)) {
if (isPrintableNonspace(c)) {
- int const width2 = text_.singleWidth(par_, i, c,
- text_.getFont(*bv_.buffer(), par_, i));
+ int const width2 = pm_.singleWidth(i,
+ text_.getFont(bv_.buffer(), par_, i));
dx = (c == 0x05e8 || // resh
c == 0x05d3) // dalet
? width2 - width
c = par_.getChar(i);
if (!Encodings::isComposeChar_arabic(c)) {
if (isPrintableNonspace(c)) {
- int const width2 = text_.singleWidth(par_, i, c,
- text_.getFont(*bv_.buffer(), par_, i));
+ int const width2 = pm_.singleWidth(i,
+ text_.getFont(bv_.buffer(), par_, i));
dx = (width2 - width) / 2;
}
break;
return;
if (font.language() == latex_language)
return;
- if (font.language() == bv_.buffer()->params().language)
+ if (font.language() == bv_.buffer().params().language)
return;
int const y = yo_ + 1 + desc;
void RowPainter::paintFromPos(pos_type & vpos)
{
pos_type const pos = bidi_.vis2log(vpos);
- Font orig_font = text_.getFont(*bv_.buffer(), par_, pos);
+ Font orig_font = text_.getFont(bv_.buffer(), par_, pos);
double const orig_x = x_;
// special case languages
std::string const & lang = orig_font.language()->lang();
bool const hebrew = lang == "hebrew";
- bool const arabic = lang == "arabic" || lang == "farsi";
+ bool const arabic = lang == "arabic_arabtex" || lang == "arabic_arabi" ||
+ lang == "farsi";
// draw as many chars as we can
if ((!hebrew && !arabic)
void RowPainter::paintAppendix()
{
- if (!par_.params().appendix())
+ // only draw the appendix frame once (for the main text)
+ if (!par_.params().appendix() || !text_.isMainText(bv_.buffer()))
return;
int y = yo_ - row_.ascent();
int const w = nestMargin() / 5;
int x = int(xo_) + w * i;
// only consider the changebar space if we're drawing outermost text
- if (text_.isMainText(*bv_.buffer()))
+ if (text_.isMainText(bv_.buffer()))
x += changebarMargin();
int const starty = yo_ - row_.ascent();
if (parparams.startOfAppendix())
y_top += paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
- Buffer const & buffer = *bv_.buffer();
+ Buffer const & buffer = bv_.buffer();
Layout_ptr const & layout = par_.layout();
pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
} else {
- // FIXME UNICODE
- docstring lab = from_utf8(layout->labelsep);
if (is_rtl) {
x = width_ - leftMargin()
- + fm.width(lab);
+ + fm.width(layout->labelsep);
} else {
- x = x_ - fm.width(lab)
+ x = x_ - fm.width(layout->labelsep)
- fm.width(str);
}
void RowPainter::paintLast()
{
- bool const is_rtl = text_.isRTL(*bv_.buffer(), par_);
+ bool const is_rtl = text_.isRTL(bv_.buffer(), par_);
int const endlabel = getEndLabel(pit_, text_.paragraphs());
// paint imaginary end-of-paragraph character
if (par_.isInserted(par_.size()) || par_.isDeleted(par_.size())) {
- FontMetrics const & fm = theFontMetrics(bv_.buffer()->params().getFont());
+ FontMetrics const & fm = theFontMetrics(bv_.buffer().params().getFont());
int const length = fm.maxAscent() / 2;
Color::color col = par_.isInserted(par_.size()) ? Color::addedtext : Color::deletedtext;
void RowPainter::paintText()
{
pos_type const end = row_.endpos();
+ // Spaces at logical line breaks in bidi text must be skipped during
+ // painting. However, they may appear visually in the middle
+ // of a row; they must be skipped, wherever they are...
+ // * logically "abc_[HEBREW_\nHEBREW]"
+ // * visually "abc_[_WERBEH\nWERBEH]"
+ pos_type skipped_sep_vpos = -1;
pos_type body_pos = par_.beginOfBody();
if (body_pos > 0 &&
(body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
// Use font span to speed things up, see below
FontSpan font_span;
Font font;
- Buffer const & buffer = *bv_.buffer();
+ Buffer const & buffer = bv_.buffer();
+ // If the last logical character is a separator, don't paint it, unless
+ // it's in the last row of a paragraph; see skipped_sep_vpos declaration
+ if (end > 0 && end < par_.size() && par_.isSeparator(end - 1))
+ skipped_sep_vpos = bidi_.log2vis(end - 1);
+
for (pos_type vpos = row_.pos(); vpos < end; ) {
if (x_ > bv_.workWidth())
break;
+ // Skip the separator at the logical end of the row
+ if (vpos == skipped_sep_vpos) {
+ ++vpos;
+ continue;
+ }
+
pos_type const pos = bidi_.vis2log(vpos);
if (pos >= par_.size()) {
font = text_.getFont(buffer, par_, vpos);
}
- const int width_pos =
- text_.singleWidth(par_, pos, par_.getChar(pos), font);
+ const int width_pos = pm_.singleWidth(pos, font);
if (x_ + width_pos < 0) {
x_ += width_pos;
if (running_strikeout && (highly_editable_inset || !is_struckout)) {
// Calculate 1/3 height of the buffer's default font
FontMetrics const & fm
- = theFontMetrics(bv_.buffer()->params().getFont());
+ = theFontMetrics(bv_.buffer().params().getFont());
int const middle = yo_ - fm.maxAscent() / 3;
pain_.line(last_strikeout_x, middle, int(x_), middle,
Color::deletedtext, Painter::line_solid, Painter::line_thin);
}
if (body_pos > 0 && pos == body_pos - 1) {
- // FIXME UNICODE
int const lwidth = theFontMetrics(getLabelFont())
- .width(from_utf8(layout->labelsep));
+ .width(layout->labelsep);
x_ += label_hfill_ + lwidth - width_pos;
}
x_ += 2;
++vpos;
} else if (par_.isSeparator(pos)) {
- Font orig_font = text_.getFont(*bv_.buffer(), par_, pos);
+ Font orig_font = text_.getFont(bv_.buffer(), par_, pos);
double const orig_x = x_;
x_ += width_pos;
if (pos >= body_pos)
if (running_strikeout) {
// calculate 1/3 height of the buffer's default font
FontMetrics const & fm
- = theFontMetrics(bv_.buffer()->params().getFont());
+ = theFontMetrics(bv_.buffer().params().getFont());
int const middle = yo_ - fm.maxAscent() / 3;
pain_.line(last_strikeout_x, middle, int(x_), middle,
Color::deletedtext, Painter::line_solid, Painter::line_thin);
{
// check whether the current inset is nested in a non-wide inset
Cursor & cur = pi.base.bv->cursor();
- for (int i = cur.depth() - 1; --i >= 0; ) {
+ Inset const * cur_in = &cur.inset();
+ // check all higher nested insets
+ for (size_type i = 1; i < cur.depth(); ++i) {
Inset * const in = &cur[i].inset();
- if (in) {
+ if (in == cur_in)
+ // we reached the level of the current inset, so stop
+ return false;
+ else if (in) {
+ if (in->hasFixedWidth())
+ return true;
InsetText * t =
const_cast<InsetText *>(in->asTextInset());
- if (t)
- return !t->wide();
+ if (t && !t->wide())
+ // OK, we are in a non-wide() inset
+ return true;
}
}
return false;
// Clear background of this row
// (if paragraph background was not cleared)
if (!repaintAll &&
- (!(in_inset_alone_on_row && leftEdgeFixed)
+ (!(in_inset_alone_on_row && leftEdgeFixed && !inNarrowIns)
|| row_has_changed)) {
pi.pain.fillRectangle(x, y - rit->ascent(),
rp.maxWidth(), rit->height(),
// Instrumentation for testing row cache (see also
// 12 lines lower):
if (lyxerr.debugging(Debug::PAINTING)) {
- if (text.isMainText(*pi.base.bv->buffer()))
+ if (text.isMainText(pi.base.bv->buffer()))
LYXERR(Debug::PAINTING) << "#";
else
LYXERR(Debug::PAINTING) << "[" <<
void paintText(BufferView & bv,
Painter & pain)
{
- BOOST_ASSERT(bv.buffer());
- Buffer const & buffer = *bv.buffer();
+ Buffer const & buffer = bv.buffer();
Text & text = buffer.text();
bool const select = bv.cursor().selection();
ViewMetricsInfo const & vi = bv.viewMetricsInfo();