mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
change a few par_type args in LyXText::* to Paragrpah & to speed things
up git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8940 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0fe5cc3913
commit
93430a89da
@ -1,3 +1,11 @@
|
|||||||
|
2004-08-14 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
* text.C:
|
||||||
|
* text2.C:
|
||||||
|
* rowpainter.C:
|
||||||
|
* lyxtext.h (several functions): use a Paragraph & argument
|
||||||
|
instead of par_type
|
||||||
|
|
||||||
2004-08-15 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
2004-08-15 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||||
|
|
||||||
* metricsinfo.h: add a new field ltr_pos to PainterInfo
|
* metricsinfo.h: add a new field ltr_pos to PainterInfo
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
FontIterator::FontIterator(LyXText const & text, lyx::par_type pit,
|
FontIterator::FontIterator(LyXText const & text, lyx::par_type pit,
|
||||||
lyx::pos_type pos)
|
lyx::pos_type pos)
|
||||||
: text_(text), pit_(pit), pos_(pos),
|
: text_(text), pit_(pit), pos_(pos),
|
||||||
font_(text.getFont(pit, pos)),
|
font_(text.getFont(text.getPar(pit), pos)),
|
||||||
endspan_(text.getPar(pit).getEndPosOfFontSpan(pos)),
|
endspan_(text.getPar(pit).getEndPosOfFontSpan(pos)),
|
||||||
bodypos_(text.getPar(pit).beginOfBody())
|
bodypos_(text.getPar(pit).beginOfBody())
|
||||||
{}
|
{}
|
||||||
@ -43,7 +43,7 @@ FontIterator & FontIterator::operator++()
|
|||||||
{
|
{
|
||||||
++pos_;
|
++pos_;
|
||||||
if (pos_ > endspan_ || pos_ == bodypos_) {
|
if (pos_ > endspan_ || pos_ == bodypos_) {
|
||||||
font_ = text_.getFont(pit_, pos_);
|
font_ = text_.getFont(text_.getPar(pit_), pos_);
|
||||||
endspan_ = text_.getPar(pit_).getEndPosOfFontSpan(pos_);
|
endspan_ = text_.getPar(pit_).getEndPosOfFontSpan(pos_);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -1693,7 +1693,8 @@ bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf,
|
|||||||
// we can only set this if we are not too far right
|
// we can only set this if we are not too far right
|
||||||
if (cols < columns) {
|
if (cols < columns) {
|
||||||
InsetText & inset = loctab->getCellInset(cell);
|
InsetText & inset = loctab->getCellInset(cell);
|
||||||
LyXFont const font = inset.text_.getFont(0, 0);
|
Paragraph & par = inset.text_.getPar(0);
|
||||||
|
LyXFont const font = inset.text_.getFont(par, 0);
|
||||||
inset.setText(buf.substr(op, p - op), font);
|
inset.setText(buf.substr(op, p - op), font);
|
||||||
++cols;
|
++cols;
|
||||||
++cell;
|
++cell;
|
||||||
@ -1703,7 +1704,8 @@ bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf,
|
|||||||
// we can only set this if we are not too far right
|
// we can only set this if we are not too far right
|
||||||
if (cols < columns) {
|
if (cols < columns) {
|
||||||
InsetText & inset = tabular.getCellInset(cell);
|
InsetText & inset = tabular.getCellInset(cell);
|
||||||
LyXFont const font = inset.text_.getFont(0, 0);
|
Paragraph & par = inset.text_.getPar(0);
|
||||||
|
LyXFont const font = inset.text_.getFont(par, 0);
|
||||||
inset.setText(buf.substr(op, p - op), font);
|
inset.setText(buf.substr(op, p - op), font);
|
||||||
}
|
}
|
||||||
cols = ocol;
|
cols = ocol;
|
||||||
@ -1718,7 +1720,8 @@ bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf,
|
|||||||
// check for the last cell if there is no trailing '\n'
|
// check for the last cell if there is no trailing '\n'
|
||||||
if (cell < cells && op < len) {
|
if (cell < cells && op < len) {
|
||||||
InsetText & inset = loctab->getCellInset(cell);
|
InsetText & inset = loctab->getCellInset(cell);
|
||||||
LyXFont const font = inset.text_.getFont(0, 0);
|
Paragraph & par = inset.text_.getPar(0);
|
||||||
|
LyXFont const font = inset.text_.getFont(par, 0);
|
||||||
inset.setText(buf.substr(op, len - op), font);
|
inset.setText(buf.substr(op, len - op), font);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -59,11 +59,11 @@ public:
|
|||||||
/// update y coordinate cache of all paragraphs
|
/// update y coordinate cache of all paragraphs
|
||||||
void updateParPositions();
|
void updateParPositions();
|
||||||
///
|
///
|
||||||
LyXFont getFont(par_type pit, pos_type pos) const;
|
LyXFont getFont(Paragraph const & par, pos_type pos) const;
|
||||||
///
|
///
|
||||||
LyXFont getLayoutFont(par_type pit) const;
|
LyXFont getLayoutFont(par_type pit) const;
|
||||||
///
|
///
|
||||||
LyXFont getLabelFont(par_type pit) const;
|
LyXFont getLabelFont(Paragraph const & par) const;
|
||||||
///
|
///
|
||||||
void setCharFont(par_type pit, pos_type pos, LyXFont const & font);
|
void setCharFont(par_type pit, pos_type pos, LyXFont const & font);
|
||||||
///
|
///
|
||||||
@ -271,9 +271,9 @@ public:
|
|||||||
InsetBase * checkInsetHit(int x, int y) const;
|
InsetBase * checkInsetHit(int x, int y) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
int singleWidth(par_type pit, pos_type pos) const;
|
int singleWidth(Paragraph const & par, pos_type pos) const;
|
||||||
///
|
///
|
||||||
int singleWidth(par_type pit,
|
int singleWidth(Paragraph const & par,
|
||||||
pos_type pos, char c, LyXFont const & Font) const;
|
pos_type pos, char c, LyXFont const & Font) const;
|
||||||
|
|
||||||
/// return the color of the canvas
|
/// return the color of the canvas
|
||||||
@ -399,7 +399,7 @@ private:
|
|||||||
/// sets row.width to the minimum space a row needs on the screen in pixel
|
/// sets row.width to the minimum space a row needs on the screen in pixel
|
||||||
void setRowWidth(par_type pit, Row & row) const;
|
void setRowWidth(par_type pit, Row & row) const;
|
||||||
/// the minimum space a manual label needs on the screen in pixels
|
/// the minimum space a manual label needs on the screen in pixels
|
||||||
int labelFill(par_type pit, Row const & row) const;
|
int labelFill(Paragraph const & par, Row const & row) const;
|
||||||
/// FIXME
|
/// FIXME
|
||||||
int labelEnd(par_type pit) const;
|
int labelEnd(par_type pit) const;
|
||||||
|
|
||||||
|
117
src/rowpainter.C
117
src/rowpainter.C
@ -104,7 +104,8 @@ private:
|
|||||||
Row & row_;
|
Row & row_;
|
||||||
|
|
||||||
/// Row's paragraph
|
/// Row's paragraph
|
||||||
mutable par_type pit_;
|
par_type const pit_;
|
||||||
|
Paragraph const & par_;
|
||||||
|
|
||||||
// Looks ugly - is
|
// Looks ugly - is
|
||||||
double xo_;
|
double xo_;
|
||||||
@ -120,12 +121,12 @@ private:
|
|||||||
RowPainter::RowPainter(BufferView const & bv, Painter & pain,
|
RowPainter::RowPainter(BufferView const & bv, Painter & pain,
|
||||||
LyXText const & text, par_type pit, RowList::iterator rit, int y)
|
LyXText const & text, par_type pit, RowList::iterator rit, int y)
|
||||||
: bv_(bv), pain_(pain), text_(text), pars_(text.paragraphs()),
|
: bv_(bv), pain_(pain), text_(text), pars_(text.paragraphs()),
|
||||||
rit_(rit), row_(*rit), pit_(pit),
|
rit_(rit), row_(*rit), pit_(pit), par_(text.paragraphs()[pit]),
|
||||||
xo_(text_.xo_), yo_(y), width_(text_.width())
|
xo_(text_.xo_), yo_(y), width_(text_.width())
|
||||||
{
|
{
|
||||||
//lyxerr << "RowPainter: x: " << x_ << " xo: " << xo << " yo: " << yo
|
//lyxerr << "RowPainter: x: " << x_ << " xo: " << xo << " yo: " << yo
|
||||||
// << " pit->y: " << pit_->y
|
// << " pit->y: " << pit_->y
|
||||||
// << " row: " << (pars_[pit_].size() ? pars_[pit_].getChar(row_.pos()) : 'X') << endl;
|
// << " row: " << (par_.size() ? par_.getChar(row_.pos()) : 'X') << endl;
|
||||||
|
|
||||||
RowMetrics m = text_.computeRowMetrics(pit, row_);
|
RowMetrics m = text_.computeRowMetrics(pit, row_);
|
||||||
x_ = m.x + xo_;
|
x_ = m.x + xo_;
|
||||||
@ -154,7 +155,7 @@ RowPainter::RowPainter(BufferView const & bv, Painter & pain,
|
|||||||
if (row_.pos() == 0)
|
if (row_.pos() == 0)
|
||||||
paintFirst();
|
paintFirst();
|
||||||
|
|
||||||
if (row_.endpos() >= pars_[pit_].size())
|
if (row_.endpos() >= par_.size())
|
||||||
paintLast();
|
paintLast();
|
||||||
|
|
||||||
// paint text
|
// paint text
|
||||||
@ -165,26 +166,26 @@ RowPainter::RowPainter(BufferView const & bv, Painter & pain,
|
|||||||
/// "temporary"
|
/// "temporary"
|
||||||
LyXFont const RowPainter::getFont(pos_type pos) const
|
LyXFont const RowPainter::getFont(pos_type pos) const
|
||||||
{
|
{
|
||||||
return text_.getFont(pit_, pos);
|
return text_.getFont(par_, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int RowPainter::singleWidth(lyx::pos_type pos) const
|
int RowPainter::singleWidth(lyx::pos_type pos) const
|
||||||
{
|
{
|
||||||
return text_.singleWidth(pit_, pos);
|
return text_.singleWidth(par_, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int RowPainter::singleWidth(lyx::pos_type pos, char c) const
|
int RowPainter::singleWidth(lyx::pos_type pos, char c) const
|
||||||
{
|
{
|
||||||
LyXFont const & font = text_.getFont(pit_, pos);
|
LyXFont const & font = text_.getFont(par_, pos);
|
||||||
return text_.singleWidth(pit_, pos, c, font);
|
return text_.singleWidth(par_, pos, c, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXFont const RowPainter::getLabelFont() const
|
LyXFont const RowPainter::getLabelFont() const
|
||||||
{
|
{
|
||||||
return text_.getLabelFont(pit_);
|
return text_.getLabelFont(par_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -196,7 +197,7 @@ int RowPainter::leftMargin() const
|
|||||||
|
|
||||||
void RowPainter::paintInset(pos_type const pos)
|
void RowPainter::paintInset(pos_type const pos)
|
||||||
{
|
{
|
||||||
InsetBase const * inset = pars_[pit_].getInset(pos);
|
InsetBase const * inset = par_.getInset(pos);
|
||||||
BOOST_ASSERT(inset);
|
BOOST_ASSERT(inset);
|
||||||
PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
|
PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
|
||||||
pi.base.font = getFont(pos);
|
pi.base.font = getFont(pos);
|
||||||
@ -215,7 +216,7 @@ void RowPainter::paintHebrewComposeChar(pos_type & vpos)
|
|||||||
string str;
|
string str;
|
||||||
|
|
||||||
// first char
|
// first char
|
||||||
char c = pars_[pit_].getChar(pos);
|
char c = par_.getChar(pos);
|
||||||
str += c;
|
str += c;
|
||||||
++vpos;
|
++vpos;
|
||||||
|
|
||||||
@ -224,7 +225,7 @@ void RowPainter::paintHebrewComposeChar(pos_type & vpos)
|
|||||||
int dx = 0;
|
int dx = 0;
|
||||||
|
|
||||||
for (pos_type i = pos - 1; i >= 0; --i) {
|
for (pos_type i = pos - 1; i >= 0; --i) {
|
||||||
c = pars_[pit_].getChar(i);
|
c = par_.getChar(i);
|
||||||
if (!Encodings::IsComposeChar_hebrew(c)) {
|
if (!Encodings::IsComposeChar_hebrew(c)) {
|
||||||
if (IsPrintableNonspace(c)) {
|
if (IsPrintableNonspace(c)) {
|
||||||
int const width2 = singleWidth(i, c);
|
int const width2 = singleWidth(i, c);
|
||||||
@ -248,8 +249,8 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos)
|
|||||||
string str;
|
string str;
|
||||||
|
|
||||||
// first char
|
// first char
|
||||||
char c = pars_[pit_].getChar(pos);
|
char c = par_.getChar(pos);
|
||||||
c = pars_[pit_].transformChar(c, pos);
|
c = par_.transformChar(c, pos);
|
||||||
str += c;
|
str += c;
|
||||||
++vpos;
|
++vpos;
|
||||||
|
|
||||||
@ -258,7 +259,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos)
|
|||||||
int dx = 0;
|
int dx = 0;
|
||||||
|
|
||||||
for (pos_type i = pos - 1; i >= 0; --i) {
|
for (pos_type i = pos - 1; i >= 0; --i) {
|
||||||
c = pars_[pit_].getChar(i);
|
c = par_.getChar(i);
|
||||||
if (!Encodings::IsComposeChar_arabic(c)) {
|
if (!Encodings::IsComposeChar_arabic(c)) {
|
||||||
if (IsPrintableNonspace(c)) {
|
if (IsPrintableNonspace(c)) {
|
||||||
int const width2 = singleWidth(i, c);
|
int const width2 = singleWidth(i, c);
|
||||||
@ -280,26 +281,26 @@ void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
|
|||||||
|
|
||||||
// first character
|
// first character
|
||||||
string str;
|
string str;
|
||||||
str += pars_[pit_].getChar(pos);
|
str += par_.getChar(pos);
|
||||||
if (arabic) {
|
if (arabic) {
|
||||||
unsigned char c = str[0];
|
unsigned char c = str[0];
|
||||||
str[0] = pars_[pit_].transformChar(c, pos);
|
str[0] = par_.transformChar(c, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool prev_struckout = isDeletedText(pars_[pit_], pos);
|
bool prev_struckout = isDeletedText(par_, pos);
|
||||||
bool prev_newtext = isInsertedText(pars_[pit_], pos);
|
bool prev_newtext = isInsertedText(par_, pos);
|
||||||
|
|
||||||
// collect as much similar chars as we can
|
// collect as much similar chars as we can
|
||||||
for (++vpos; vpos < end && (pos = text_.bidi.vis2log(vpos)) >= 0; ++vpos) {
|
for (++vpos; vpos < end && (pos = text_.bidi.vis2log(vpos)) >= 0; ++vpos) {
|
||||||
char c = pars_[pit_].getChar(pos);
|
char c = par_.getChar(pos);
|
||||||
|
|
||||||
if (!IsPrintableNonspace(c))
|
if (!IsPrintableNonspace(c))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (prev_struckout != isDeletedText(pars_[pit_], pos))
|
if (prev_struckout != isDeletedText(par_, pos))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (prev_newtext != isInsertedText(pars_[pit_], pos))
|
if (prev_newtext != isInsertedText(par_, pos))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (arabic && Encodings::IsComposeChar_arabic(c))
|
if (arabic && Encodings::IsComposeChar_arabic(c))
|
||||||
@ -312,7 +313,7 @@ void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (arabic)
|
if (arabic)
|
||||||
c = pars_[pit_].transformChar(c, pos);
|
c = par_.transformChar(c, pos);
|
||||||
|
|
||||||
str += c;
|
str += c;
|
||||||
}
|
}
|
||||||
@ -352,7 +353,7 @@ void RowPainter::paintFromPos(pos_type & vpos)
|
|||||||
|
|
||||||
double const orig_x = x_;
|
double const orig_x = x_;
|
||||||
|
|
||||||
char const c = pars_[pit_].getChar(pos);
|
char const c = par_.getChar(pos);
|
||||||
|
|
||||||
if (c == Paragraph::META_INSET) {
|
if (c == Paragraph::META_INSET) {
|
||||||
paintInset(pos);
|
paintInset(pos);
|
||||||
@ -396,7 +397,7 @@ void RowPainter::paintBackground()
|
|||||||
|
|
||||||
void RowPainter::paintSelection()
|
void RowPainter::paintSelection()
|
||||||
{
|
{
|
||||||
bool const is_rtl = text_.isRTL(pars_[pit_]);
|
bool const is_rtl = text_.isRTL(par_);
|
||||||
|
|
||||||
// the current selection
|
// the current selection
|
||||||
LCursor const & cur = bv_.cursor();
|
LCursor const & cur = bv_.cursor();
|
||||||
@ -408,7 +409,7 @@ void RowPainter::paintSelection()
|
|||||||
RowList::iterator endrow = pars_[endpit].getRow(cur.selEnd().pos());
|
RowList::iterator endrow = pars_[endpit].getRow(cur.selEnd().pos());
|
||||||
int const h = row_.height();
|
int const h = row_.height();
|
||||||
|
|
||||||
int const row_y = text_.yo_ + pars_[pit_].y + row_.y_offset();
|
int const row_y = text_.yo_ + par_.y + row_.y_offset();
|
||||||
|
|
||||||
bool const sel_starts_here = startpit == pit_ && startrow == rit_;
|
bool const sel_starts_here = startpit == pit_ && startrow == rit_;
|
||||||
bool const sel_ends_here = endpit == pit_ && endrow == rit_;
|
bool const sel_ends_here = endpit == pit_ && endrow == rit_;
|
||||||
@ -442,7 +443,7 @@ void RowPainter::paintSelection()
|
|||||||
pain_.fillRectangle(int(xo_), yo_,
|
pain_.fillRectangle(int(xo_), yo_,
|
||||||
int(x_), h, LColor::selection);
|
int(x_), h, LColor::selection);
|
||||||
|
|
||||||
pos_type const body_pos = pars_[pit_].beginOfBody();
|
pos_type const body_pos = par_.beginOfBody();
|
||||||
pos_type const end = row_.endpos();
|
pos_type const end = row_.endpos();
|
||||||
double tmpx = x_;
|
double tmpx = x_;
|
||||||
|
|
||||||
@ -450,24 +451,24 @@ void RowPainter::paintSelection()
|
|||||||
pos_type pos = text_.bidi.vis2log(vpos);
|
pos_type pos = text_.bidi.vis2log(vpos);
|
||||||
double const old_tmpx = tmpx;
|
double const old_tmpx = tmpx;
|
||||||
if (body_pos > 0 && pos == body_pos - 1) {
|
if (body_pos > 0 && pos == body_pos - 1) {
|
||||||
LyXLayout_ptr const & layout = pars_[pit_].layout();
|
LyXLayout_ptr const & layout = par_.layout();
|
||||||
LyXFont const lfont = getLabelFont();
|
LyXFont const lfont = getLabelFont();
|
||||||
|
|
||||||
tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
|
tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
|
||||||
|
|
||||||
if (pars_[pit_].isLineSeparator(body_pos - 1))
|
if (par_.isLineSeparator(body_pos - 1))
|
||||||
tmpx -= singleWidth(body_pos - 1);
|
tmpx -= singleWidth(body_pos - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpx += singleWidth(pos);
|
tmpx += singleWidth(pos);
|
||||||
|
|
||||||
if (hfillExpansion(pars_[pit_], row_, pos)) {
|
if (hfillExpansion(par_, row_, pos)) {
|
||||||
if (pos >= body_pos)
|
if (pos >= body_pos)
|
||||||
tmpx += hfill_;
|
tmpx += hfill_;
|
||||||
else
|
else
|
||||||
tmpx += label_hfill_;
|
tmpx += label_hfill_;
|
||||||
} else {
|
} else {
|
||||||
if (pars_[pit_].isSeparator(pos) && pos >= body_pos)
|
if (par_.isSeparator(pos) && pos >= body_pos)
|
||||||
tmpx += separator_;
|
tmpx += separator_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,7 +495,7 @@ void RowPainter::paintChangeBar()
|
|||||||
pos_type const start = row_.pos();
|
pos_type const start = row_.pos();
|
||||||
pos_type const end = row_.endpos();
|
pos_type const end = row_.endpos();
|
||||||
|
|
||||||
if (start == end || !pars_[pit_].isChanged(start, end - 1))
|
if (start == end || !par_.isChanged(start, end - 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int const height = text_.isLastRow(pit_, row_)
|
int const height = text_.isLastRow(pit_, row_)
|
||||||
@ -507,12 +508,12 @@ void RowPainter::paintChangeBar()
|
|||||||
|
|
||||||
void RowPainter::paintAppendix()
|
void RowPainter::paintAppendix()
|
||||||
{
|
{
|
||||||
if (!pars_[pit_].params().appendix())
|
if (!par_.params().appendix())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int y = yo_;
|
int y = yo_;
|
||||||
|
|
||||||
if (pars_[pit_].params().startOfAppendix())
|
if (par_.params().startOfAppendix())
|
||||||
y += 2 * defaultRowHeight();
|
y += 2 * defaultRowHeight();
|
||||||
|
|
||||||
pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
|
pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
|
||||||
@ -522,7 +523,7 @@ void RowPainter::paintAppendix()
|
|||||||
|
|
||||||
void RowPainter::paintDepthBar()
|
void RowPainter::paintDepthBar()
|
||||||
{
|
{
|
||||||
Paragraph::depth_type const depth = pars_[pit_].getDepth();
|
Paragraph::depth_type const depth = par_.getDepth();
|
||||||
|
|
||||||
if (depth <= 0)
|
if (depth <= 0)
|
||||||
return;
|
return;
|
||||||
@ -588,7 +589,7 @@ int RowPainter::paintAppendixStart(int y)
|
|||||||
|
|
||||||
void RowPainter::paintFirst()
|
void RowPainter::paintFirst()
|
||||||
{
|
{
|
||||||
ParagraphParameters const & parparams = pars_[pit_].params();
|
ParagraphParameters const & parparams = par_.params();
|
||||||
|
|
||||||
int y_top = 0;
|
int y_top = 0;
|
||||||
|
|
||||||
@ -598,12 +599,12 @@ void RowPainter::paintFirst()
|
|||||||
|
|
||||||
Buffer const & buffer = *bv_.buffer();
|
Buffer const & buffer = *bv_.buffer();
|
||||||
|
|
||||||
LyXLayout_ptr const & layout = pars_[pit_].layout();
|
LyXLayout_ptr const & layout = par_.layout();
|
||||||
|
|
||||||
if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
|
if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
|
||||||
if (pit_ != 0) {
|
if (pit_ != 0) {
|
||||||
if (layout->latextype == LATEX_PARAGRAPH
|
if (layout->latextype == LATEX_PARAGRAPH
|
||||||
&& !pars_[pit_].getDepth()) {
|
&& !par_.getDepth()) {
|
||||||
y_top += buffer.params().getDefSkip().inPixels(bv_);
|
y_top += buffer.params().getDefSkip().inPixels(bv_);
|
||||||
} else {
|
} else {
|
||||||
LyXLayout_ptr const & playout = pars_[pit_ - 1].layout();
|
LyXLayout_ptr const & playout = pars_[pit_ - 1].layout();
|
||||||
@ -616,9 +617,9 @@ void RowPainter::paintFirst()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool const is_rtl = text_.isRTL(pars_[pit_]);
|
bool const is_rtl = text_.isRTL(par_);
|
||||||
bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
|
bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
|
||||||
//lyxerr << "paintFirst: " << pars_[pit_].id() << " is_seq: " << is_seq << std::endl;
|
//lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << std::endl;
|
||||||
|
|
||||||
// should we print a label?
|
// should we print a label?
|
||||||
if (layout->labeltype >= LABEL_STATIC
|
if (layout->labeltype >= LABEL_STATIC
|
||||||
@ -627,9 +628,9 @@ void RowPainter::paintFirst()
|
|||||||
|| is_seq)) {
|
|| is_seq)) {
|
||||||
|
|
||||||
LyXFont font = getLabelFont();
|
LyXFont font = getLabelFont();
|
||||||
if (!pars_[pit_].getLabelstring().empty()) {
|
if (!par_.getLabelstring().empty()) {
|
||||||
double x = x_;
|
double x = x_;
|
||||||
string const str = pars_[pit_].getLabelstring();
|
string const str = par_.getLabelstring();
|
||||||
|
|
||||||
// this is special code for the chapter layout. This is
|
// this is special code for the chapter layout. This is
|
||||||
// printed in an extra row and has a pagebreak at
|
// printed in an extra row and has a pagebreak at
|
||||||
@ -677,8 +678,8 @@ void RowPainter::paintFirst()
|
|||||||
layout->labeltype == LABEL_BIBLIO ||
|
layout->labeltype == LABEL_BIBLIO ||
|
||||||
layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
|
layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
|
||||||
LyXFont font = getLabelFont();
|
LyXFont font = getLabelFont();
|
||||||
if (!pars_[pit_].getLabelstring().empty()) {
|
if (!par_.getLabelstring().empty()) {
|
||||||
string const str = pars_[pit_].getLabelstring();
|
string const str = par_.getLabelstring();
|
||||||
float spacing_val = 1.0;
|
float spacing_val = 1.0;
|
||||||
if (!parparams.spacing().isDefault()) {
|
if (!parparams.spacing().isDefault()) {
|
||||||
spacing_val = parparams.spacing().getValue();
|
spacing_val = parparams.spacing().getValue();
|
||||||
@ -693,7 +694,7 @@ void RowPainter::paintFirst()
|
|||||||
double x = x_;
|
double x = x_;
|
||||||
if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
|
if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
|
||||||
x = ((is_rtl ? leftMargin() : x_)
|
x = ((is_rtl ? leftMargin() : x_)
|
||||||
+ width_ - text_.rightMargin(pars_[pit_])) / 2;
|
+ width_ - text_.rightMargin(par_)) / 2;
|
||||||
x -= font_metrics::width(str, font) / 2;
|
x -= font_metrics::width(str, font) / 2;
|
||||||
} else if (is_rtl) {
|
} else if (is_rtl) {
|
||||||
x = width_ - leftMargin() -
|
x = width_ - leftMargin() -
|
||||||
@ -709,7 +710,7 @@ void RowPainter::paintFirst()
|
|||||||
|
|
||||||
void RowPainter::paintLast()
|
void RowPainter::paintLast()
|
||||||
{
|
{
|
||||||
bool const is_rtl = text_.isRTL(pars_[pit_]);
|
bool const is_rtl = text_.isRTL(par_);
|
||||||
int const endlabel = getEndLabel(pit_, text_.paragraphs());
|
int const endlabel = getEndLabel(pit_, text_.paragraphs());
|
||||||
|
|
||||||
// draw an endlabel
|
// draw an endlabel
|
||||||
@ -733,10 +734,10 @@ void RowPainter::paintLast()
|
|||||||
|
|
||||||
case END_LABEL_STATIC: {
|
case END_LABEL_STATIC: {
|
||||||
LyXFont font = getLabelFont();
|
LyXFont font = getLabelFont();
|
||||||
string const & str = pars_[pit_].layout()->endlabelstring();
|
string const & str = par_.layout()->endlabelstring();
|
||||||
double const x = is_rtl ?
|
double const x = is_rtl ?
|
||||||
x_ - font_metrics::width(str, font)
|
x_ - font_metrics::width(str, font)
|
||||||
: - text_.rightMargin(pars_[pit_]) - row_.width();
|
: - text_.rightMargin(par_) - row_.width();
|
||||||
pain_.text(int(x), yo_ + row_.baseline(), str, font);
|
pain_.text(int(x), yo_ + row_.baseline(), str, font);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -750,13 +751,13 @@ void RowPainter::paintLast()
|
|||||||
void RowPainter::paintText()
|
void RowPainter::paintText()
|
||||||
{
|
{
|
||||||
pos_type const end = row_.endpos();
|
pos_type const end = row_.endpos();
|
||||||
pos_type body_pos = pars_[pit_].beginOfBody();
|
pos_type body_pos = par_.beginOfBody();
|
||||||
if (body_pos > 0 &&
|
if (body_pos > 0 &&
|
||||||
(body_pos > end || !pars_[pit_].isLineSeparator(body_pos - 1))) {
|
(body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
|
||||||
body_pos = 0;
|
body_pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LyXLayout_ptr const & layout = pars_[pit_].layout();
|
LyXLayout_ptr const & layout = par_.layout();
|
||||||
|
|
||||||
bool running_strikeout = false;
|
bool running_strikeout = false;
|
||||||
bool is_struckout = false;
|
bool is_struckout = false;
|
||||||
@ -768,7 +769,7 @@ void RowPainter::paintText()
|
|||||||
|
|
||||||
pos_type pos = text_.bidi.vis2log(vpos);
|
pos_type pos = text_.bidi.vis2log(vpos);
|
||||||
|
|
||||||
if (pos >= pars_[pit_].size()) {
|
if (pos >= par_.size()) {
|
||||||
++vpos;
|
++vpos;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -779,15 +780,15 @@ void RowPainter::paintText()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
is_struckout = isDeletedText(pars_[pit_], pos);
|
is_struckout = isDeletedText(par_, pos);
|
||||||
|
|
||||||
if (is_struckout && !running_strikeout) {
|
if (is_struckout && !running_strikeout) {
|
||||||
running_strikeout = true;
|
running_strikeout = true;
|
||||||
last_strikeout_x = int(x_);
|
last_strikeout_x = int(x_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool const highly_editable_inset = pars_[pit_].isInset(pos)
|
bool const highly_editable_inset = par_.isInset(pos)
|
||||||
&& isHighlyEditableInset(pars_[pit_].getInset(pos));
|
&& isHighlyEditableInset(par_.getInset(pos));
|
||||||
|
|
||||||
// if we reach the end of a struck out range, paint it
|
// if we reach the end of a struck out range, paint it
|
||||||
// we also don't paint across things like tables
|
// we also don't paint across things like tables
|
||||||
@ -805,7 +806,7 @@ void RowPainter::paintText()
|
|||||||
x_ += label_hfill_ + lwidth - singleWidth(body_pos - 1);
|
x_ += label_hfill_ + lwidth - singleWidth(body_pos - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pars_[pit_].isHfill(pos)) {
|
if (par_.isHfill(pos)) {
|
||||||
x_ += 1;
|
x_ += 1;
|
||||||
|
|
||||||
int const y0 = yo_ + row_.baseline();
|
int const y0 = yo_ + row_.baseline();
|
||||||
@ -813,7 +814,7 @@ void RowPainter::paintText()
|
|||||||
|
|
||||||
pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
|
pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
|
||||||
|
|
||||||
if (hfillExpansion(pars_[pit_], row_, pos)) {
|
if (hfillExpansion(par_, row_, pos)) {
|
||||||
int const y2 = (y0 + y1) / 2;
|
int const y2 = (y0 + y1) / 2;
|
||||||
|
|
||||||
if (pos >= body_pos) {
|
if (pos >= body_pos) {
|
||||||
@ -831,7 +832,7 @@ void RowPainter::paintText()
|
|||||||
}
|
}
|
||||||
x_ += 2;
|
x_ += 2;
|
||||||
++vpos;
|
++vpos;
|
||||||
} else if (pars_[pit_].isSeparator(pos)) {
|
} else if (par_.isSeparator(pos)) {
|
||||||
x_ += singleWidth(pos);
|
x_ += singleWidth(pos);
|
||||||
if (pos >= body_pos)
|
if (pos >= body_pos)
|
||||||
x_ += separator_;
|
x_ += separator_;
|
||||||
|
205
src/text.C
205
src/text.C
@ -439,17 +439,15 @@ int LyXText::height() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int LyXText::singleWidth(par_type par, pos_type pos) const
|
int LyXText::singleWidth(Paragraph const & par, pos_type pos) const
|
||||||
{
|
{
|
||||||
char const c = pars_[par].getChar(pos);
|
return singleWidth(par, pos, par.getChar(pos), getFont(par, pos));
|
||||||
return singleWidth(par, pos, c, getFont(par, pos));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int LyXText::singleWidth(par_type const pit,
|
int LyXText::singleWidth(Paragraph const & par,
|
||||||
pos_type pos, char c, LyXFont const & font) const
|
pos_type pos, char c, LyXFont const & font) const
|
||||||
{
|
{
|
||||||
Paragraph const & par = pars_[pit];
|
|
||||||
if (pos >= par.size()) {
|
if (pos >= par.size()) {
|
||||||
lyxerr << "in singleWidth(), pos: " << pos << endl;
|
lyxerr << "in singleWidth(), pos: " << pos << endl;
|
||||||
BOOST_ASSERT(false);
|
BOOST_ASSERT(false);
|
||||||
@ -520,7 +518,7 @@ int LyXText::leftMargin(par_type const pit, pos_type const pos) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LyXFont const labelfont = getLabelFont(pit);
|
LyXFont const labelfont = getLabelFont(par);
|
||||||
switch (layout->margintype) {
|
switch (layout->margintype) {
|
||||||
case MARGIN_DYNAMIC:
|
case MARGIN_DYNAMIC:
|
||||||
if (!layout->leftmargin.empty())
|
if (!layout->leftmargin.empty())
|
||||||
@ -730,13 +728,13 @@ void LyXText::rowBreakPoint(par_type const pit, Row & row) const
|
|||||||
char const c = par.getChar(i);
|
char const c = par.getChar(i);
|
||||||
|
|
||||||
{
|
{
|
||||||
int thiswidth = singleWidth(pit, i, c, *fi);
|
int thiswidth = singleWidth(par, i, c, *fi);
|
||||||
|
|
||||||
// add the auto-hfill from label end to the body
|
// add the auto-hfill from label end to the body
|
||||||
if (body_pos && i == body_pos) {
|
if (body_pos && i == body_pos) {
|
||||||
int add = font_metrics::width(layout->labelsep, getLabelFont(pit));
|
int add = font_metrics::width(layout->labelsep, getLabelFont(par));
|
||||||
if (pars_[pit].isLineSeparator(i - 1))
|
if (par.isLineSeparator(i - 1))
|
||||||
add -= singleWidth(pit, i - 1);
|
add -= singleWidth(par, i - 1);
|
||||||
|
|
||||||
add = std::max(add, labelEnd(pit) - x);
|
add = std::max(add, labelEnd(pit) - x);
|
||||||
thiswidth += add;
|
thiswidth += add;
|
||||||
@ -818,20 +816,20 @@ void LyXText::setRowWidth(par_type const pit, Row & row) const
|
|||||||
FontIterator fi = FontIterator(*this, pit, i);
|
FontIterator fi = FontIterator(*this, pit, i);
|
||||||
for ( ; i < end; ++i, ++fi) {
|
for ( ; i < end; ++i, ++fi) {
|
||||||
if (body_pos > 0 && i == body_pos) {
|
if (body_pos > 0 && i == body_pos) {
|
||||||
w += font_metrics::width(labelsep, getLabelFont(pit));
|
w += font_metrics::width(labelsep, getLabelFont(par));
|
||||||
if (par.isLineSeparator(i - 1))
|
if (par.isLineSeparator(i - 1))
|
||||||
w -= singleWidth(pit, i - 1);
|
w -= singleWidth(par, i - 1);
|
||||||
w = max(w, labelEnd(pit));
|
w = max(w, labelEnd(pit));
|
||||||
}
|
}
|
||||||
char const c = par.getChar(i);
|
char const c = par.getChar(i);
|
||||||
w += singleWidth(pit, i, c, *fi);
|
w += singleWidth(par, i, c, *fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body_pos > 0 && body_pos >= end) {
|
if (body_pos > 0 && body_pos >= end) {
|
||||||
w += font_metrics::width(labelsep, getLabelFont(pit));
|
w += font_metrics::width(labelsep, getLabelFont(par));
|
||||||
if (end > 0 && par.isLineSeparator(end - 1))
|
if (end > 0 && par.isLineSeparator(end - 1))
|
||||||
w -= singleWidth(pit, end - 1);
|
w -= singleWidth(par, end - 1);
|
||||||
w = max(w, labelEnd(pit));
|
w = max(w, labelEnd(pit));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -840,9 +838,9 @@ void LyXText::setRowWidth(par_type const pit, Row & row) const
|
|||||||
|
|
||||||
|
|
||||||
// returns the minimum space a manual label needs on the screen in pixel
|
// returns the minimum space a manual label needs on the screen in pixel
|
||||||
int LyXText::labelFill(par_type pit, Row const & row) const
|
int LyXText::labelFill(Paragraph const & par, Row const & row) const
|
||||||
{
|
{
|
||||||
pos_type last = pars_[pit].beginOfBody();
|
pos_type last = par.beginOfBody();
|
||||||
|
|
||||||
BOOST_ASSERT(last > 0);
|
BOOST_ASSERT(last > 0);
|
||||||
|
|
||||||
@ -850,18 +848,18 @@ int LyXText::labelFill(par_type pit, Row const & row) const
|
|||||||
--last;
|
--last;
|
||||||
|
|
||||||
// a separator at this end does not count
|
// a separator at this end does not count
|
||||||
if (pars_[pit].isLineSeparator(last))
|
if (par.isLineSeparator(last))
|
||||||
--last;
|
--last;
|
||||||
|
|
||||||
int w = 0;
|
int w = 0;
|
||||||
for (pos_type i = row.pos(); i <= last; ++i)
|
for (pos_type i = row.pos(); i <= last; ++i)
|
||||||
w += singleWidth(pit, i);
|
w += singleWidth(par, i);
|
||||||
|
|
||||||
string const & label = pars_[pit].params().labelWidthString();
|
string const & label = par.params().labelWidthString();
|
||||||
if (label.empty())
|
if (label.empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return max(0, font_metrics::width(label, getLabelFont(pit)) - w);
|
return max(0, font_metrics::width(label, getLabelFont(par)) - w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -871,8 +869,9 @@ LColor_color LyXText::backgroundColor() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::setHeightOfRow(par_type pit, Row & row)
|
void LyXText::setHeightOfRow(par_type const pit, Row & row)
|
||||||
{
|
{
|
||||||
|
Paragraph const & par = pars_[pit];
|
||||||
// get the maximum ascent and the maximum descent
|
// get the maximum ascent and the maximum descent
|
||||||
double layoutasc = 0;
|
double layoutasc = 0;
|
||||||
double layoutdesc = 0;
|
double layoutdesc = 0;
|
||||||
@ -881,30 +880,29 @@ void LyXText::setHeightOfRow(par_type pit, Row & row)
|
|||||||
// ok, let us initialize the maxasc and maxdesc value.
|
// ok, let us initialize the maxasc and maxdesc value.
|
||||||
// Only the fontsize count. The other properties
|
// Only the fontsize count. The other properties
|
||||||
// are taken from the layoutfont. Nicer on the screen :)
|
// are taken from the layoutfont. Nicer on the screen :)
|
||||||
LyXLayout_ptr const & layout = pars_[pit].layout();
|
LyXLayout_ptr const & layout = par.layout();
|
||||||
|
|
||||||
// as max get the first character of this row then it can
|
// as max get the first character of this row then it can
|
||||||
// increase but not decrease the height. Just some point to
|
// increase but not decrease the height. Just some point to
|
||||||
// start with so we don't have to do the assignment below too
|
// start with so we don't have to do the assignment below too
|
||||||
// often.
|
// often.
|
||||||
LyXFont font = getFont(pit, row.pos());
|
LyXFont font = getFont(par, row.pos());
|
||||||
LyXFont::FONT_SIZE const tmpsize = font.size();
|
LyXFont::FONT_SIZE const tmpsize = font.size();
|
||||||
font = getLayoutFont(pit);
|
font = getLayoutFont(pit);
|
||||||
LyXFont::FONT_SIZE const size = font.size();
|
LyXFont::FONT_SIZE const size = font.size();
|
||||||
font.setSize(tmpsize);
|
font.setSize(tmpsize);
|
||||||
|
|
||||||
LyXFont labelfont = getLabelFont(pit);
|
LyXFont labelfont = getLabelFont(par);
|
||||||
|
|
||||||
// these are minimum values
|
// these are minimum values
|
||||||
double const spacing_val =
|
double const spacing_val = layout->spacing.getValue() * spacing(par);
|
||||||
layout->spacing.getValue() * spacing(pars_[pit]);
|
|
||||||
//lyxerr << "spacing_val = " << spacing_val << endl;
|
//lyxerr << "spacing_val = " << spacing_val << endl;
|
||||||
int maxasc = int(font_metrics::maxAscent(font) * spacing_val);
|
int maxasc = int(font_metrics::maxAscent(font) * spacing_val);
|
||||||
int maxdesc = int(font_metrics::maxDescent(font) * spacing_val);
|
int maxdesc = int(font_metrics::maxDescent(font) * spacing_val);
|
||||||
|
|
||||||
// insets may be taller
|
// insets may be taller
|
||||||
InsetList::const_iterator ii = pars_[pit].insetlist.begin();
|
InsetList::const_iterator ii = par.insetlist.begin();
|
||||||
InsetList::const_iterator iend = pars_[pit].insetlist.end();
|
InsetList::const_iterator iend = par.insetlist.end();
|
||||||
for ( ; ii != iend; ++ii) {
|
for ( ; ii != iend; ++ii) {
|
||||||
if (ii->pos >= row.pos() && ii->pos < row.endpos()) {
|
if (ii->pos >= row.pos() && ii->pos < row.endpos()) {
|
||||||
maxasc = max(maxasc, ii->inset->ascent());
|
maxasc = max(maxasc, ii->inset->ascent());
|
||||||
@ -919,7 +917,7 @@ void LyXText::setHeightOfRow(par_type pit, Row & row)
|
|||||||
pos_type const pos_end = row.endpos();
|
pos_type const pos_end = row.endpos();
|
||||||
|
|
||||||
LyXFont::FONT_SIZE maxsize =
|
LyXFont::FONT_SIZE maxsize =
|
||||||
pars_[pit].highestFontInRange(row.pos(), pos_end, size);
|
par.highestFontInRange(row.pos(), pos_end, size);
|
||||||
if (maxsize > font.size()) {
|
if (maxsize > font.size()) {
|
||||||
font.setSize(maxsize);
|
font.setSize(maxsize);
|
||||||
maxasc = max(maxasc, font_metrics::maxAscent(font));
|
maxasc = max(maxasc, font_metrics::maxAscent(font));
|
||||||
@ -939,7 +937,7 @@ void LyXText::setHeightOfRow(par_type pit, Row & row)
|
|||||||
if (bv()->buffer()->params().paragraph_separation
|
if (bv()->buffer()->params().paragraph_separation
|
||||||
== BufferParams::PARSEP_SKIP
|
== BufferParams::PARSEP_SKIP
|
||||||
&& pit != 0
|
&& pit != 0
|
||||||
&& ((layout->isParagraph() && pars_[pit].getDepth() == 0)
|
&& ((layout->isParagraph() && par.getDepth() == 0)
|
||||||
|| (pars_[pit - 1].layout()->isParagraph()
|
|| (pars_[pit - 1].layout()->isParagraph()
|
||||||
&& pars_[pit - 1].getDepth() == 0)))
|
&& pars_[pit - 1].getDepth() == 0)))
|
||||||
{
|
{
|
||||||
@ -954,7 +952,7 @@ void LyXText::setHeightOfRow(par_type pit, Row & row)
|
|||||||
if (layout->counter == "chapter" && bufparams.secnumdepth >= 0) {
|
if (layout->counter == "chapter" && bufparams.secnumdepth >= 0) {
|
||||||
labeladdon = int(font_metrics::maxHeight(labelfont)
|
labeladdon = int(font_metrics::maxHeight(labelfont)
|
||||||
* layout->spacing.getValue()
|
* layout->spacing.getValue()
|
||||||
* spacing(pars_[pit]));
|
* spacing(par));
|
||||||
}
|
}
|
||||||
|
|
||||||
// special code for the top label
|
// special code for the top label
|
||||||
@ -962,12 +960,12 @@ void LyXText::setHeightOfRow(par_type pit, Row & row)
|
|||||||
|| layout->labeltype == LABEL_BIBLIO
|
|| layout->labeltype == LABEL_BIBLIO
|
||||||
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
|
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
|
||||||
&& isFirstInSequence(pit, paragraphs())
|
&& isFirstInSequence(pit, paragraphs())
|
||||||
&& !pars_[pit].getLabelstring().empty())
|
&& !par.getLabelstring().empty())
|
||||||
{
|
{
|
||||||
labeladdon = int(
|
labeladdon = int(
|
||||||
font_metrics::maxHeight(labelfont)
|
font_metrics::maxHeight(labelfont)
|
||||||
* layout->spacing.getValue()
|
* layout->spacing.getValue()
|
||||||
* spacing(pars_[pit])
|
* spacing(par)
|
||||||
+ (layout->topsep + layout->labelbottomsep) * dh);
|
+ (layout->topsep + layout->labelbottomsep) * dh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -975,11 +973,11 @@ void LyXText::setHeightOfRow(par_type pit, Row & row)
|
|||||||
// a section, or between the items of a itemize or enumerate
|
// a section, or between the items of a itemize or enumerate
|
||||||
// environment.
|
// environment.
|
||||||
|
|
||||||
par_type prev = depthHook(pit, pars_, pars_[pit].getDepth());
|
par_type prev = depthHook(pit, pars_, par.getDepth());
|
||||||
if (prev != pit
|
if (prev != pit
|
||||||
&& pars_[prev].layout() == layout
|
&& pars_[prev].layout() == layout
|
||||||
&& pars_[prev].getDepth() == pars_[pit].getDepth()
|
&& pars_[prev].getDepth() == par.getDepth()
|
||||||
&& pars_[prev].getLabelWidthString() == pars_[pit].getLabelWidthString())
|
&& pars_[prev].getLabelWidthString() == par.getLabelWidthString())
|
||||||
{
|
{
|
||||||
layoutasc = layout->itemsep * dh;
|
layoutasc = layout->itemsep * dh;
|
||||||
} else if (pit != 0 || row.pos() != 0) {
|
} else if (pit != 0 || row.pos() != 0) {
|
||||||
@ -999,7 +997,7 @@ void LyXText::setHeightOfRow(par_type pit, Row & row)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// is it a bottom line?
|
// is it a bottom line?
|
||||||
if (row.endpos() >= pars_[pit].size()) {
|
if (row.endpos() >= par.size()) {
|
||||||
// add the layout spaces, for example before and after
|
// add the layout spaces, for example before and after
|
||||||
// a section, or between the items of a itemize or enumerate
|
// a section, or between the items of a itemize or enumerate
|
||||||
// environment
|
// environment
|
||||||
@ -1036,6 +1034,10 @@ void LyXText::setHeightOfRow(par_type pit, Row & row)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void LyXText::breakParagraph(LCursor & cur, char keep_layout)
|
void LyXText::breakParagraph(LCursor & cur, char keep_layout)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(this == cur.text());
|
BOOST_ASSERT(this == cur.text());
|
||||||
@ -1083,7 +1085,7 @@ void LyXText::breakParagraph(LCursor & cur, char keep_layout)
|
|||||||
|
|
||||||
// well this is the caption hack since one caption is really enough
|
// well this is the caption hack since one caption is really enough
|
||||||
if (layout->labeltype == LABEL_SENSITIVE) {
|
if (layout->labeltype == LABEL_SENSITIVE) {
|
||||||
if (!cur.pos())
|
if (cur.pos() == 0)
|
||||||
// set to standard-layout
|
// set to standard-layout
|
||||||
pars_[cpit].applyLayout(tclass.defaultLayout());
|
pars_[cpit].applyLayout(tclass.defaultLayout());
|
||||||
else
|
else
|
||||||
@ -1138,7 +1140,7 @@ void LyXText::insertChar(LCursor & cur, char c)
|
|||||||
|
|
||||||
Paragraph & par = cur.paragraph();
|
Paragraph & par = cur.paragraph();
|
||||||
// try to remove this
|
// try to remove this
|
||||||
par_type pit = cur.par();
|
par_type const pit = cur.par();
|
||||||
|
|
||||||
bool const freeSpacing = par.layout()->free_spacing ||
|
bool const freeSpacing = par.layout()->free_spacing ||
|
||||||
par.isFreeSpacing();
|
par.isFreeSpacing();
|
||||||
@ -1153,8 +1155,8 @@ void LyXText::insertChar(LCursor & cur, char c)
|
|||||||
!(contains(number_seperators, c) &&
|
!(contains(number_seperators, c) &&
|
||||||
cur.pos() != 0 &&
|
cur.pos() != 0 &&
|
||||||
cur.pos() != cur.lastpos() &&
|
cur.pos() != cur.lastpos() &&
|
||||||
getFont(pit, cur.pos()).number() == LyXFont::ON &&
|
getFont(par, cur.pos()).number() == LyXFont::ON &&
|
||||||
getFont(pit, cur.pos() - 1).number() == LyXFont::ON)
|
getFont(par, cur.pos() - 1).number() == LyXFont::ON)
|
||||||
)
|
)
|
||||||
number(cur); // Set current_font.number to OFF
|
number(cur); // Set current_font.number to OFF
|
||||||
} else if (IsDigit(c) &&
|
} else if (IsDigit(c) &&
|
||||||
@ -1171,7 +1173,7 @@ void LyXText::insertChar(LCursor & cur, char c)
|
|||||||
setCharFont(pit, cur.pos() - 1, current_font);
|
setCharFont(pit, cur.pos() - 1, current_font);
|
||||||
} else if (contains(number_seperators, c)
|
} else if (contains(number_seperators, c)
|
||||||
&& cur.pos() >= 2
|
&& cur.pos() >= 2
|
||||||
&& getFont(pit, cur.pos() - 2).number() == LyXFont::ON) {
|
&& getFont(par, cur.pos() - 2).number() == LyXFont::ON) {
|
||||||
setCharFont(pit, cur.pos() - 1, current_font);
|
setCharFont(pit, cur.pos() - 1, current_font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1243,40 +1245,41 @@ void LyXText::charInserted()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RowMetrics LyXText::computeRowMetrics(par_type pit, Row const & row) const
|
RowMetrics LyXText::computeRowMetrics(par_type const pit, Row const & row) const
|
||||||
{
|
{
|
||||||
RowMetrics result;
|
RowMetrics result;
|
||||||
|
Paragraph const & par = pars_[pit];
|
||||||
|
|
||||||
double w = width_ - row.width();
|
double w = width_ - row.width();
|
||||||
|
|
||||||
bool const is_rtl = isRTL(pars_[pit]);
|
bool const is_rtl = isRTL(par);
|
||||||
if (is_rtl)
|
if (is_rtl)
|
||||||
result.x = rightMargin(pars_[pit]);
|
result.x = rightMargin(par);
|
||||||
else
|
else
|
||||||
result.x = leftMargin(pit, row.pos());
|
result.x = leftMargin(pit, row.pos());
|
||||||
|
|
||||||
// is there a manual margin with a manual label
|
// is there a manual margin with a manual label
|
||||||
LyXLayout_ptr const & layout = pars_[pit].layout();
|
LyXLayout_ptr const & layout = par.layout();
|
||||||
|
|
||||||
if (layout->margintype == MARGIN_MANUAL
|
if (layout->margintype == MARGIN_MANUAL
|
||||||
&& layout->labeltype == LABEL_MANUAL) {
|
&& layout->labeltype == LABEL_MANUAL) {
|
||||||
/// We might have real hfills in the label part
|
/// We might have real hfills in the label part
|
||||||
int nlh = numberOfLabelHfills(pars_[pit], row);
|
int nlh = numberOfLabelHfills(par, row);
|
||||||
|
|
||||||
// A manual label par (e.g. List) has an auto-hfill
|
// A manual label par (e.g. List) has an auto-hfill
|
||||||
// between the label text and the body of the
|
// between the label text and the body of the
|
||||||
// paragraph too.
|
// paragraph too.
|
||||||
// But we don't want to do this auto hfill if the par
|
// But we don't want to do this auto hfill if the par
|
||||||
// is empty.
|
// is empty.
|
||||||
if (!pars_[pit].empty())
|
if (!par.empty())
|
||||||
++nlh;
|
++nlh;
|
||||||
|
|
||||||
if (nlh && !pars_[pit].getLabelWidthString().empty())
|
if (nlh && !par.getLabelWidthString().empty())
|
||||||
result.label_hfill = labelFill(pit, row) / double(nlh);
|
result.label_hfill = labelFill(par, row) / double(nlh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// are there any hfills in the row?
|
// are there any hfills in the row?
|
||||||
int const nh = numberOfHfills(pars_[pit], row);
|
int const nh = numberOfHfills(par, row);
|
||||||
|
|
||||||
if (nh) {
|
if (nh) {
|
||||||
if (w > 0)
|
if (w > 0)
|
||||||
@ -1288,28 +1291,28 @@ RowMetrics LyXText::computeRowMetrics(par_type pit, Row const & row) const
|
|||||||
// is it block, flushleft or flushright?
|
// is it block, flushleft or flushright?
|
||||||
// set x how you need it
|
// set x how you need it
|
||||||
int align;
|
int align;
|
||||||
if (pars_[pit].params().align() == LYX_ALIGN_LAYOUT)
|
if (par.params().align() == LYX_ALIGN_LAYOUT)
|
||||||
align = layout->align;
|
align = layout->align;
|
||||||
else
|
else
|
||||||
align = pars_[pit].params().align();
|
align = par.params().align();
|
||||||
|
|
||||||
// Display-style insets should always be on a centred row
|
// Display-style insets should always be on a centred row
|
||||||
// The test on pars_[pit].size() is to catch zero-size pars, which
|
// The test on par.size() is to catch zero-size pars, which
|
||||||
// would trigger the assert in Paragraph::getInset().
|
// would trigger the assert in Paragraph::getInset().
|
||||||
//inset = pars_[pit].size() ? pars_[pit].getInset(row.pos()) : 0;
|
//inset = par.size() ? par.getInset(row.pos()) : 0;
|
||||||
if (!pars_[pit].empty()
|
if (!par.empty()
|
||||||
&& pars_[pit].isInset(row.pos())
|
&& par.isInset(row.pos())
|
||||||
&& pars_[pit].getInset(row.pos())->display())
|
&& par.getInset(row.pos())->display())
|
||||||
{
|
{
|
||||||
align = LYX_ALIGN_CENTER;
|
align = LYX_ALIGN_CENTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (align) {
|
switch (align) {
|
||||||
case LYX_ALIGN_BLOCK: {
|
case LYX_ALIGN_BLOCK: {
|
||||||
int const ns = numberOfSeparators(pars_[pit], row);
|
int const ns = numberOfSeparators(par, row);
|
||||||
bool disp_inset = false;
|
bool disp_inset = false;
|
||||||
if (row.endpos() < pars_[pit].size()) {
|
if (row.endpos() < par.size()) {
|
||||||
InsetBase const * in = pars_[pit].getInset(row.endpos());
|
InsetBase const * in = par.getInset(row.endpos());
|
||||||
if (in)
|
if (in)
|
||||||
disp_inset = in->display();
|
disp_inset = in->display();
|
||||||
}
|
}
|
||||||
@ -1317,8 +1320,8 @@ RowMetrics LyXText::computeRowMetrics(par_type pit, Row const & row) const
|
|||||||
// par, does not end in newline, and is not row above a
|
// par, does not end in newline, and is not row above a
|
||||||
// display inset... then stretch it
|
// display inset... then stretch it
|
||||||
if (ns
|
if (ns
|
||||||
&& row.endpos() < pars_[pit].size()
|
&& row.endpos() < par.size()
|
||||||
&& !pars_[pit].isNewline(row.endpos() - 1)
|
&& !par.isNewline(row.endpos() - 1)
|
||||||
&& !disp_inset
|
&& !disp_inset
|
||||||
) {
|
) {
|
||||||
result.separator = w / ns;
|
result.separator = w / ns;
|
||||||
@ -1336,15 +1339,15 @@ RowMetrics LyXText::computeRowMetrics(par_type pit, Row const & row) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bidi.computeTables(pars_[pit], *bv()->buffer(), row);
|
bidi.computeTables(par, *bv()->buffer(), row);
|
||||||
if (is_rtl) {
|
if (is_rtl) {
|
||||||
pos_type body_pos = pars_[pit].beginOfBody();
|
pos_type body_pos = par.beginOfBody();
|
||||||
pos_type end = row.endpos();
|
pos_type end = row.endpos();
|
||||||
|
|
||||||
if (body_pos > 0
|
if (body_pos > 0
|
||||||
&& (body_pos > end || !pars_[pit].isLineSeparator(body_pos - 1)))
|
&& (body_pos > end || !par.isLineSeparator(body_pos - 1)))
|
||||||
{
|
{
|
||||||
result.x += font_metrics::width(layout->labelsep, getLabelFont(pit));
|
result.x += font_metrics::width(layout->labelsep, getLabelFont(par));
|
||||||
if (body_pos <= end)
|
if (body_pos <= end)
|
||||||
result.x += result.label_hfill;
|
result.x += result.label_hfill;
|
||||||
}
|
}
|
||||||
@ -1687,43 +1690,44 @@ Row const & LyXText::firstRow() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::redoParagraphInternal(par_type pit)
|
void LyXText::redoParagraphInternal(par_type const pit)
|
||||||
{
|
{
|
||||||
// remove rows of paragraph, keep track of height changes
|
// remove rows of paragraph, keep track of height changes
|
||||||
height_ -= pars_[pit].height;
|
Paragraph & par = pars_[pit];
|
||||||
|
height_ -= par.height;
|
||||||
|
|
||||||
// clear old data
|
// clear old data
|
||||||
pars_[pit].rows.clear();
|
par.rows.clear();
|
||||||
pars_[pit].height = 0;
|
par.height = 0;
|
||||||
pars_[pit].width = 0;
|
par.width = 0;
|
||||||
|
|
||||||
// redo insets
|
// redo insets
|
||||||
InsetList::iterator ii = pars_[pit].insetlist.begin();
|
InsetList::iterator ii = par.insetlist.begin();
|
||||||
InsetList::iterator iend = pars_[pit].insetlist.end();
|
InsetList::iterator iend = par.insetlist.end();
|
||||||
for (; ii != iend; ++ii) {
|
for (; ii != iend; ++ii) {
|
||||||
Dimension dim;
|
Dimension dim;
|
||||||
int const w = maxwidth_ - leftMargin(pit) - rightMargin(pars_[pit]);
|
int const w = maxwidth_ - leftMargin(pit) - rightMargin(par);
|
||||||
MetricsInfo mi(bv(), getFont(pit, ii->pos), w);
|
MetricsInfo mi(bv(), getFont(par, ii->pos), w);
|
||||||
ii->inset->metrics(mi, dim);
|
ii->inset->metrics(mi, dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rebreak the paragraph
|
// rebreak the paragraph
|
||||||
pars_[pit].setBeginOfBody();
|
par.setBeginOfBody();
|
||||||
pos_type z = 0;
|
pos_type z = 0;
|
||||||
do {
|
do {
|
||||||
Row row(z);
|
Row row(z);
|
||||||
rowBreakPoint(pit, row);
|
rowBreakPoint(pit, row);
|
||||||
setRowWidth(pit, row);
|
setRowWidth(pit, row);
|
||||||
setHeightOfRow(pit, row);
|
setHeightOfRow(pit, row);
|
||||||
row.y_offset(pars_[pit].height);
|
row.y_offset(par.height);
|
||||||
pars_[pit].rows.push_back(row);
|
par.rows.push_back(row);
|
||||||
pars_[pit].width = std::max(pars_[pit].width, row.width());
|
par.width = std::max(par.width, row.width());
|
||||||
pars_[pit].height += row.height();
|
par.height += row.height();
|
||||||
z = row.endpos();
|
z = row.endpos();
|
||||||
} while (z < pars_[pit].size());
|
} while (z < par.size());
|
||||||
|
|
||||||
height_ += pars_[pit].height;
|
height_ += par.height;
|
||||||
//lyxerr << "redoParagraph: " << pars_[pit].rows.size() << " rows\n";
|
//lyxerr << "redoParagraph: " << par.rows.size() << " rows\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1919,11 +1923,12 @@ int LyXText::descent() const
|
|||||||
|
|
||||||
int LyXText::cursorX(CursorSlice const & cur) const
|
int LyXText::cursorX(CursorSlice const & cur) const
|
||||||
{
|
{
|
||||||
par_type pit = cur.par();
|
par_type const pit = cur.par();
|
||||||
if (pars_[pit].rows.empty())
|
Paragraph const & par = pars_[pit];
|
||||||
|
if (par.rows.empty())
|
||||||
return xo_;
|
return xo_;
|
||||||
|
|
||||||
Row const & row = *pars_[pit].getRow(cur.pos());
|
Row const & row = *par.getRow(cur.pos());
|
||||||
|
|
||||||
pos_type pos = cur.pos();
|
pos_type pos = cur.pos();
|
||||||
pos_type cursor_vpos = 0;
|
pos_type cursor_vpos = 0;
|
||||||
@ -1937,7 +1942,7 @@ int LyXText::cursorX(CursorSlice const & cur) const
|
|||||||
if (end <= row_pos)
|
if (end <= row_pos)
|
||||||
cursor_vpos = row_pos;
|
cursor_vpos = row_pos;
|
||||||
else if (pos >= end)
|
else if (pos >= end)
|
||||||
cursor_vpos = isRTL(pars_[pit]) ? row_pos : end;
|
cursor_vpos = isRTL(par) ? row_pos : end;
|
||||||
else if (pos > row_pos && pos >= end)
|
else if (pos > row_pos && pos >= end)
|
||||||
// Place cursor after char at (logical) position pos - 1
|
// Place cursor after char at (logical) position pos - 1
|
||||||
cursor_vpos = (bidi.level(pos - 1) % 2 == 0)
|
cursor_vpos = (bidi.level(pos - 1) % 2 == 0)
|
||||||
@ -1947,33 +1952,33 @@ int LyXText::cursorX(CursorSlice const & cur) const
|
|||||||
cursor_vpos = (bidi.level(pos) % 2 == 0)
|
cursor_vpos = (bidi.level(pos) % 2 == 0)
|
||||||
? bidi.log2vis(pos) : bidi.log2vis(pos) + 1;
|
? bidi.log2vis(pos) : bidi.log2vis(pos) + 1;
|
||||||
|
|
||||||
pos_type body_pos = pars_[pit].beginOfBody();
|
pos_type body_pos = par.beginOfBody();
|
||||||
if (body_pos > 0 &&
|
if (body_pos > 0 &&
|
||||||
(body_pos > end || !pars_[pit].isLineSeparator(body_pos - 1)))
|
(body_pos > end || !par.isLineSeparator(body_pos - 1)))
|
||||||
body_pos = 0;
|
body_pos = 0;
|
||||||
|
|
||||||
for (pos_type vpos = row_pos; vpos < cursor_vpos; ++vpos) {
|
for (pos_type vpos = row_pos; vpos < cursor_vpos; ++vpos) {
|
||||||
pos_type pos = bidi.vis2log(vpos);
|
pos_type pos = bidi.vis2log(vpos);
|
||||||
if (body_pos > 0 && pos == body_pos - 1) {
|
if (body_pos > 0 && pos == body_pos - 1) {
|
||||||
x += m.label_hfill
|
x += m.label_hfill
|
||||||
+ font_metrics::width(pars_[pit].layout()->labelsep,
|
+ font_metrics::width(par.layout()->labelsep,
|
||||||
getLabelFont(pit));
|
getLabelFont(par));
|
||||||
if (pars_[pit].isLineSeparator(body_pos - 1))
|
if (par.isLineSeparator(body_pos - 1))
|
||||||
x -= singleWidth(pit, body_pos - 1);
|
x -= singleWidth(par, body_pos - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hfillExpansion(pars_[pit], row, pos)) {
|
if (hfillExpansion(par, row, pos)) {
|
||||||
x += singleWidth(pit, pos);
|
x += singleWidth(par, pos);
|
||||||
if (pos >= body_pos)
|
if (pos >= body_pos)
|
||||||
x += m.hfill;
|
x += m.hfill;
|
||||||
else
|
else
|
||||||
x += m.label_hfill;
|
x += m.label_hfill;
|
||||||
} else if (pars_[pit].isSeparator(pos)) {
|
} else if (par.isSeparator(pos)) {
|
||||||
x += singleWidth(pit, pos);
|
x += singleWidth(par, pos);
|
||||||
if (pos >= body_pos)
|
if (pos >= body_pos)
|
||||||
x += m.separator;
|
x += m.separator;
|
||||||
} else
|
} else
|
||||||
x += singleWidth(pit, pos);
|
x += singleWidth(par, pos);
|
||||||
}
|
}
|
||||||
return xo_ + int(x);
|
return xo_ + int(x);
|
||||||
}
|
}
|
||||||
|
81
src/text2.C
81
src/text2.C
@ -90,7 +90,7 @@ void LyXText::init(BufferView * bv)
|
|||||||
for (par_type pit = 0; pit != end; ++pit)
|
for (par_type pit = 0; pit != end; ++pit)
|
||||||
pars_[pit].rows.clear();
|
pars_[pit].rows.clear();
|
||||||
|
|
||||||
current_font = getFont(0, 0);
|
current_font = getFont(pars_[0], 0);
|
||||||
redoParagraphs(0, end);
|
redoParagraphs(0, end);
|
||||||
updateCounters();
|
updateCounters();
|
||||||
}
|
}
|
||||||
@ -149,11 +149,10 @@ InsetBase * LyXText::checkInsetHit(int x, int y) const
|
|||||||
// The difference is that this one is used for displaying, and thus we
|
// The difference is that this one is used for displaying, and thus we
|
||||||
// are allowed to make cosmetic improvements. For instance make footnotes
|
// are allowed to make cosmetic improvements. For instance make footnotes
|
||||||
// smaller. (Asger)
|
// smaller. (Asger)
|
||||||
LyXFont LyXText::getFont(par_type const pit, pos_type const pos) const
|
LyXFont LyXText::getFont(Paragraph const & par, pos_type const pos) const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(pos >= 0);
|
BOOST_ASSERT(pos >= 0);
|
||||||
|
|
||||||
Paragraph const & par = pars_[pit];
|
|
||||||
LyXLayout_ptr const & layout = par.layout();
|
LyXLayout_ptr const & layout = par.layout();
|
||||||
#ifdef WITH_WARNINGS
|
#ifdef WITH_WARNINGS
|
||||||
#warning broken?
|
#warning broken?
|
||||||
@ -186,7 +185,6 @@ LyXFont LyXText::getFont(par_type const pit, pos_type const pos) const
|
|||||||
font.realize(font_);
|
font.realize(font_);
|
||||||
|
|
||||||
// Realize with the fonts of lesser depth.
|
// Realize with the fonts of lesser depth.
|
||||||
//font.realize(outerFont(pit, paragraphs()));
|
|
||||||
font.realize(defaultfont_);
|
font.realize(defaultfont_);
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
@ -209,16 +207,15 @@ LyXFont LyXText::getLayoutFont(par_type const pit) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXFont LyXText::getLabelFont(par_type pit) const
|
LyXFont LyXText::getLabelFont(Paragraph const & par) const
|
||||||
{
|
{
|
||||||
LyXLayout_ptr const & layout = pars_[pit].layout();
|
LyXLayout_ptr const & layout = par.layout();
|
||||||
|
|
||||||
if (!pars_[pit].getDepth())
|
if (!par.getDepth())
|
||||||
return layout->reslabelfont;
|
return layout->reslabelfont;
|
||||||
|
|
||||||
LyXFont font = layout->labelfont;
|
LyXFont font = layout->labelfont;
|
||||||
// Realize with the fonts of lesser depth.
|
// Realize with the fonts of lesser depth.
|
||||||
font.realize(outerFont(pit, paragraphs()));
|
|
||||||
font.realize(defaultfont_);
|
font.realize(defaultfont_);
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
@ -436,7 +433,7 @@ void LyXText::setFont(LCursor & cur, LyXFont const & font, bool toggleall)
|
|||||||
LyXFont layoutfont;
|
LyXFont layoutfont;
|
||||||
par_type pit = cur.par();
|
par_type pit = cur.par();
|
||||||
if (cur.pos() < pars_[pit].beginOfBody())
|
if (cur.pos() < pars_[pit].beginOfBody())
|
||||||
layoutfont = getLabelFont(pit);
|
layoutfont = getLabelFont(pars_[pit]);
|
||||||
else
|
else
|
||||||
layoutfont = getLayoutFont(pit);
|
layoutfont = getLayoutFont(pit);
|
||||||
|
|
||||||
@ -460,21 +457,18 @@ void LyXText::setFont(LCursor & cur, LyXFont const & font, bool toggleall)
|
|||||||
par_type const beg = cur.selBegin().par();
|
par_type const beg = cur.selBegin().par();
|
||||||
par_type const end = cur.selEnd().par();
|
par_type const end = cur.selEnd().par();
|
||||||
|
|
||||||
DocIterator pos = cur.selectionBegin();
|
DocIterator dit = cur.selectionBegin();
|
||||||
DocIterator posend = cur.selectionEnd();
|
DocIterator ditend = cur.selectionEnd();
|
||||||
|
|
||||||
lyxerr[Debug::DEBUG] << "pos: " << pos << " posend: " << posend
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
BufferParams const & params = cur.buffer().params();
|
BufferParams const & params = cur.buffer().params();
|
||||||
|
|
||||||
// Don't use forwardChar here as posend might have
|
// Don't use forwardChar here as ditend might have
|
||||||
// pos() == lastpos() and forwardChar would miss it.
|
// pos() == lastpos() and forwardChar would miss it.
|
||||||
for (; pos != posend; pos.forwardPos()) {
|
for (; dit != ditend; dit.forwardPos()) {
|
||||||
if (pos.pos() != pos.lastpos()) {
|
if (dit.pos() != dit.lastpos()) {
|
||||||
LyXFont f = getFont(pos.par(), pos.pos());
|
LyXFont f = getFont(dit.paragraph(), dit.pos());
|
||||||
f.update(font, params.language, toggleall);
|
f.update(font, params.language, toggleall);
|
||||||
setCharFont(pos.par(), pos.pos(), f);
|
setCharFont(dit.par(), dit.pos(), f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1028,7 +1022,7 @@ void LyXText::setCurrentFont(LCursor & cur)
|
|||||||
{
|
{
|
||||||
BOOST_ASSERT(this == cur.text());
|
BOOST_ASSERT(this == cur.text());
|
||||||
pos_type pos = cur.pos();
|
pos_type pos = cur.pos();
|
||||||
par_type pit = cur.par();
|
Paragraph & par = cur.paragraph();
|
||||||
|
|
||||||
if (cur.boundary() && pos > 0)
|
if (cur.boundary() && pos > 0)
|
||||||
--pos;
|
--pos;
|
||||||
@ -1037,7 +1031,7 @@ void LyXText::setCurrentFont(LCursor & cur)
|
|||||||
if (pos == cur.lastpos())
|
if (pos == cur.lastpos())
|
||||||
--pos;
|
--pos;
|
||||||
else // potentional bug... BUG (Lgb)
|
else // potentional bug... BUG (Lgb)
|
||||||
if (pars_[pit].isSeparator(pos)) {
|
if (par.isSeparator(pos)) {
|
||||||
if (pos > cur.textRow().pos() &&
|
if (pos > cur.textRow().pos() &&
|
||||||
bidi.level(pos) % 2 ==
|
bidi.level(pos) % 2 ==
|
||||||
bidi.level(pos - 1) % 2)
|
bidi.level(pos - 1) % 2)
|
||||||
@ -1048,13 +1042,13 @@ void LyXText::setCurrentFont(LCursor & cur)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BufferParams const & bufparams = cur.buffer().params();
|
BufferParams const & bufparams = cur.buffer().params();
|
||||||
current_font = pars_[pit].getFontSettings(bufparams, pos);
|
current_font = par.getFontSettings(bufparams, pos);
|
||||||
real_current_font = getFont(pit, pos);
|
real_current_font = getFont(par, pos);
|
||||||
|
|
||||||
if (cur.pos() == cur.lastpos()
|
if (cur.pos() == cur.lastpos()
|
||||||
&& bidi.isBoundary(cur.buffer(), pars_[pit], cur.pos())
|
&& bidi.isBoundary(cur.buffer(), par, cur.pos())
|
||||||
&& !cur.boundary()) {
|
&& !cur.boundary()) {
|
||||||
Language const * lang = pars_[pit].getParLanguage(bufparams);
|
Language const * lang = par.getParLanguage(bufparams);
|
||||||
current_font.setLanguage(lang);
|
current_font.setLanguage(lang);
|
||||||
current_font.setNumber(LyXFont::OFF);
|
current_font.setNumber(LyXFont::OFF);
|
||||||
real_current_font.setLanguage(lang);
|
real_current_font.setLanguage(lang);
|
||||||
@ -1066,26 +1060,27 @@ void LyXText::setCurrentFont(LCursor & cur)
|
|||||||
// x is an absolute screen coord
|
// x is an absolute screen coord
|
||||||
// returns the column near the specified x-coordinate of the row
|
// returns the column near the specified x-coordinate of the row
|
||||||
// x is set to the real beginning of this column
|
// x is set to the real beginning of this column
|
||||||
pos_type LyXText::getColumnNearX(par_type pit,
|
pos_type LyXText::getColumnNearX(par_type const pit,
|
||||||
Row const & row, int & x, bool & boundary) const
|
Row const & row, int & x, bool & boundary) const
|
||||||
{
|
{
|
||||||
x -= xo_;
|
x -= xo_;
|
||||||
RowMetrics const r = computeRowMetrics(pit, row);
|
RowMetrics const r = computeRowMetrics(pit, row);
|
||||||
|
Paragraph const & par = pars_[pit];
|
||||||
|
|
||||||
pos_type vc = row.pos();
|
pos_type vc = row.pos();
|
||||||
pos_type end = row.endpos();
|
pos_type end = row.endpos();
|
||||||
pos_type c = 0;
|
pos_type c = 0;
|
||||||
LyXLayout_ptr const & layout = pars_[pit].layout();
|
LyXLayout_ptr const & layout = par.layout();
|
||||||
|
|
||||||
bool left_side = false;
|
bool left_side = false;
|
||||||
|
|
||||||
pos_type body_pos = pars_[pit].beginOfBody();
|
pos_type body_pos = par.beginOfBody();
|
||||||
|
|
||||||
double tmpx = r.x;
|
double tmpx = r.x;
|
||||||
double last_tmpx = tmpx;
|
double last_tmpx = tmpx;
|
||||||
|
|
||||||
if (body_pos > 0 &&
|
if (body_pos > 0 &&
|
||||||
(body_pos > end || !pars_[pit].isLineSeparator(body_pos - 1)))
|
(body_pos > end || !par.isLineSeparator(body_pos - 1)))
|
||||||
body_pos = 0;
|
body_pos = 0;
|
||||||
|
|
||||||
// check for empty row
|
// check for empty row
|
||||||
@ -1099,23 +1094,23 @@ pos_type LyXText::getColumnNearX(par_type pit,
|
|||||||
last_tmpx = tmpx;
|
last_tmpx = tmpx;
|
||||||
if (body_pos > 0 && c == body_pos - 1) {
|
if (body_pos > 0 && c == body_pos - 1) {
|
||||||
tmpx += r.label_hfill +
|
tmpx += r.label_hfill +
|
||||||
font_metrics::width(layout->labelsep, getLabelFont(pit));
|
font_metrics::width(layout->labelsep, getLabelFont(par));
|
||||||
if (pars_[pit].isLineSeparator(body_pos - 1))
|
if (par.isLineSeparator(body_pos - 1))
|
||||||
tmpx -= singleWidth(pit, body_pos - 1);
|
tmpx -= singleWidth(par, body_pos - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hfillExpansion(pars_[pit], row, c)) {
|
if (hfillExpansion(par, row, c)) {
|
||||||
tmpx += singleWidth(pit, c);
|
tmpx += singleWidth(par, c);
|
||||||
if (c >= body_pos)
|
if (c >= body_pos)
|
||||||
tmpx += r.hfill;
|
tmpx += r.hfill;
|
||||||
else
|
else
|
||||||
tmpx += r.label_hfill;
|
tmpx += r.label_hfill;
|
||||||
} else if (pars_[pit].isSeparator(c)) {
|
} else if (par.isSeparator(c)) {
|
||||||
tmpx += singleWidth(pit, c);
|
tmpx += singleWidth(par, c);
|
||||||
if (c >= body_pos)
|
if (c >= body_pos)
|
||||||
tmpx += r.separator;
|
tmpx += r.separator;
|
||||||
} else {
|
} else {
|
||||||
tmpx += singleWidth(pit, c);
|
tmpx += singleWidth(par, c);
|
||||||
}
|
}
|
||||||
++vc;
|
++vc;
|
||||||
}
|
}
|
||||||
@ -1130,11 +1125,11 @@ pos_type LyXText::getColumnNearX(par_type pit,
|
|||||||
boundary = false;
|
boundary = false;
|
||||||
// This (rtl_support test) is not needed, but gives
|
// This (rtl_support test) is not needed, but gives
|
||||||
// some speedup if rtl_support == false
|
// some speedup if rtl_support == false
|
||||||
bool const lastrow = lyxrc.rtl_support && row.endpos() == pars_[pit].size();
|
bool const lastrow = lyxrc.rtl_support && row.endpos() == par.size();
|
||||||
|
|
||||||
// If lastrow is false, we don't need to compute
|
// If lastrow is false, we don't need to compute
|
||||||
// the value of rtl.
|
// the value of rtl.
|
||||||
bool const rtl = lastrow ? isRTL(pars_[pit]) : false;
|
bool const rtl = lastrow ? isRTL(par) : false;
|
||||||
if (lastrow &&
|
if (lastrow &&
|
||||||
((rtl && left_side && vc == row.pos() && x < tmpx - 5) ||
|
((rtl && left_side && vc == row.pos() && x < tmpx - 5) ||
|
||||||
(!rtl && !left_side && vc == end && x > tmpx + 5)))
|
(!rtl && !left_side && vc == end && x > tmpx + 5)))
|
||||||
@ -1148,15 +1143,15 @@ pos_type LyXText::getColumnNearX(par_type pit,
|
|||||||
bool const rtl = (bidi.level(c) % 2 == 1);
|
bool const rtl = (bidi.level(c) % 2 == 1);
|
||||||
if (left_side == rtl) {
|
if (left_side == rtl) {
|
||||||
++c;
|
++c;
|
||||||
boundary = bidi.isBoundary(*bv()->buffer(), pars_[pit], c);
|
boundary = bidi.isBoundary(*bv()->buffer(), par, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row.pos() < end && c >= end && pars_[pit].isNewline(end - 1)) {
|
if (row.pos() < end && c >= end && par.isNewline(end - 1)) {
|
||||||
if (bidi.level(end -1) % 2 == 0)
|
if (bidi.level(end -1) % 2 == 0)
|
||||||
tmpx -= singleWidth(pit, end - 1);
|
tmpx -= singleWidth(par, end - 1);
|
||||||
else
|
else
|
||||||
tmpx += singleWidth(pit, end - 1);
|
tmpx += singleWidth(par, end - 1);
|
||||||
c = end - 1;
|
c = end - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user