}
}
- text_->bidi.computeTables(par, buffer, row);
if (is_rtl) {
pos_type body_pos = par.beginOfBody();
pos_type end = row.endpos();
x -= xo;
RowMetrics const r = computeRowMetrics(pit, row);
Paragraph const & par = text_->getPar(pit);
+ Bidi bidi;
+ bidi.computeTables(par, buffer, row);
pos_type vc = row.pos();
pos_type end = row.endpos();
= theFontMetrics(text_->getLabelFont(buffer, par));
while (vc < end && tmpx <= x) {
- c = text_->bidi.vis2log(vc);
+ c = bidi.vis2log(vc);
last_tmpx = tmpx;
if (body_pos > 0 && c == body_pos - 1) {
// FIXME UNICODE
(!rtl && !left_side && vc == end && x > tmpx + 5)))
c = end;
else if (vc == row.pos()) {
- c = text_->bidi.vis2log(vc);
- if (text_->bidi.level(c) % 2 == 1)
+ c = bidi.vis2log(vc);
+ if (bidi.level(c) % 2 == 1)
++c;
} else {
- c = text_->bidi.vis2log(vc - 1);
- bool const rtl = (text_->bidi.level(c) % 2 == 1);
+ c = bidi.vis2log(vc - 1);
+ bool const rtl = (bidi.level(c) % 2 == 1);
if (left_side == rtl) {
++c;
boundary = text_->isRTLBoundary(buffer, par, c);
// specially, so cursor up/down doesn't get stuck in an air gap -- MV
// Newline inset, air gap below:
if (row.pos() < end && c >= end && par.isNewline(end - 1)) {
- if (text_->bidi.level(end -1) % 2 == 0)
+ if (bidi.level(end -1) % 2 == 0)
tmpx -= text_->singleWidth(buffer, par, end - 1);
else
tmpx += text_->singleWidth(buffer, par, end - 1);
#include "rowpainter.h"
+#include "Bidi.h"
#include "Buffer.h"
#include "CoordCache.h"
#include "Cursor.h"
ParagraphMetrics const & pm_;
int max_width_;
+ /// bidi cache, static to speed up rowpaint and reduce size.
+ /// Only one rowpainter is used at a time anyway
+ static Bidi bidi_;
+
/// is row erased? (change tracking)
bool erased_;
};
+Bidi RowPainter::bidi_;
+
+
RowPainter::RowPainter(PainterInfo & pi,
Text const & text, pit_type pit, Row const & row, int x, int y)
: bv_(*pi.base.bv), pain_(pi.pain), text_(text),
row_(row), pit_(pit), par_(text.paragraphs()[pit]),
pm_(text_metrics_.parMetrics(pit)),
max_width_(bv_.workWidth()),
- erased_(pi.erased_),
+ erased_(pi.erased_),
xo_(x), yo_(y), width_(text_metrics_.width())
{
RowMetrics m = text_metrics_.computeRowMetrics(pit_, row_);
+ bidi_.computeTables(par_, *bv_.buffer(), row_);
x_ = m.x + xo_;
//lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
pi.base.font = inset->noFontChange() ?
bv_.buffer()->params().getFont() :
font;
- pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
+ pi.ltr_pos = (bidi_.level(pos) % 2 == 0);
pi.erased_ = erased_ || par_.isDeleted(pos);
#ifdef DEBUG_METRICS
int const x1 = int(x_);
void RowPainter::paintHebrewComposeChar(pos_type & vpos, Font const & font)
{
- pos_type pos = text_.bidi.vis2log(vpos);
+ pos_type pos = bidi_.vis2log(vpos);
docstring str;
void RowPainter::paintArabicComposeChar(pos_type & vpos, Font const & font)
{
- pos_type pos = text_.bidi.vis2log(vpos);
+ pos_type pos = bidi_.vis2log(vpos);
docstring str;
// first char
bool hebrew, bool arabic)
{
// This method takes up 70% of time when typing
- pos_type pos = text_.bidi.vis2log(vpos);
+ pos_type pos = bidi_.vis2log(vpos);
pos_type const end = row_.endpos();
FontSpan const font_span = par_.fontSpan(pos);
Change::Type const prev_change = par_.lookupChange(pos).type;
// collect as much similar chars as we can
for (++vpos ; vpos < end ; ++vpos) {
- pos = text_.bidi.vis2log(vpos);
+ pos = bidi_.vis2log(vpos);
if (pos < font_span.first || pos > font_span.last)
break;
void RowPainter::paintFromPos(pos_type & vpos)
{
- pos_type const pos = text_.bidi.vis2log(vpos);
+ pos_type const pos = bidi_.vis2log(vpos);
Font orig_font = text_.getFont(*bv_.buffer(), par_, pos);
double const orig_x = x_;
if (x_ > bv_.workWidth())
break;
- pos_type const pos = text_.bidi.vis2log(vpos);
+ pos_type const pos = bidi_.vis2log(vpos);
if (pos >= par_.size()) {
++vpos;