"Main body" is now just "body"

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6397 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-03-09 12:37:22 +00:00
parent 8c2af0660c
commit 27deed6ea3
7 changed files with 99 additions and 91 deletions

View File

@ -1,3 +1,13 @@
2003-03-08 John Levon <levon@movementarian.org>
* lyxrow.C:
* paragraph.C:
* paragraph.h:
* rowpainter.C:
* text.C:
* text2.C: Remove the "main" bit from the "main body"
notion.
2003-03-08 John Levon <levon@movementarian.org> 2003-03-08 John Levon <levon@movementarian.org>
* text.C (leftMargin): The left margin of an empty * text.C (leftMargin): The left margin of an empty

View File

@ -189,7 +189,7 @@ pos_type Row::lastPrintablePos() const
int Row::numberOfSeparators() const int Row::numberOfSeparators() const
{ {
pos_type const last = lastPrintablePos(); pos_type const last = lastPrintablePos();
pos_type p = max(pos(), par()->beginningOfMainBody()); pos_type p = max(pos(), par()->beginningOfBody());
int n = 0; int n = 0;
for (; p <= last; ++p) { for (; p <= last; ++p) {
@ -213,7 +213,7 @@ int Row::numberOfHfills() const
} }
} }
first = max(first, par()->beginningOfMainBody()); first = max(first, par()->beginningOfBody());
int n = 0; int n = 0;
@ -237,7 +237,7 @@ int Row::numberOfLabelHfills() const
++first; ++first;
} }
last = min(last, par()->beginningOfMainBody()); last = min(last, par()->beginningOfBody());
int n = 0; int n = 0;
// last, because the end is ignored! // last, because the end is ignored!
@ -273,7 +273,7 @@ bool Row::hfillExpansion(pos_type pos) const
// in some labels it does not count // in some labels it does not count
if (par()->layout()->margintype != MARGIN_MANUAL if (par()->layout()->margintype != MARGIN_MANUAL
&& pos < par()->beginningOfMainBody()) && pos < par()->beginningOfBody())
return false; return false;
// if there is anything between the first char of the row and // if there is anything between the first char of the row and

View File

@ -505,10 +505,10 @@ LyXFont const Paragraph::getFont(BufferParams const & bparams,
LyXLayout_ptr const & lout = layout(); LyXLayout_ptr const & lout = layout();
pos_type const main_body = beginningOfMainBody(); pos_type const body_pos = beginningOfBody();
LyXFont layoutfont; LyXFont layoutfont;
if (pos < main_body) if (pos < body_pos)
layoutfont = lout->labelfont; layoutfont = lout->labelfont;
else else
layoutfont = lout->font; layoutfont = lout->font;
@ -841,14 +841,7 @@ void Paragraph::applyLayout(LyXLayout_ptr const & new_layout)
} }
// if the layout of a paragraph contains a manual label, the beginning of the int Paragraph::beginningOfBody() const
// main body is the beginning of the second word. This is what the par-
// function returns. If the layout does not contain a label, the main
// body always starts with position 0. This differentiation is necessary,
// because there cannot be a newline or a blank <= the beginning of the
// main body in TeX.
int Paragraph::beginningOfMainBody() const
{ {
if (layout()->labeltype != LABEL_MANUAL) if (layout()->labeltype != LABEL_MANUAL)
return 0; return 0;
@ -1099,19 +1092,19 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
LyXFont basefont; LyXFont basefont;
// Maybe we have to create a optional argument. // Maybe we have to create a optional argument.
pos_type main_body; pos_type body_pos;
// FIXME: can we actually skip this check and just call // FIXME: can we actually skip this check and just call
// beginningOfMainBody() ?? // beginningOfBody() ??
if (style->labeltype != LABEL_MANUAL) { if (style->labeltype != LABEL_MANUAL) {
main_body = 0; body_pos = 0;
} else { } else {
main_body = beginningOfMainBody(); body_pos = beginningOfBody();
} }
unsigned int column = 0; unsigned int column = 0;
if (main_body > 0) { if (body_pos > 0) {
os << '['; os << '[';
++column; ++column;
basefont = getLabelFont(bparams); basefont = getLabelFont(bparams);
@ -1144,8 +1137,8 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
for (pos_type i = 0; i < size(); ++i) { for (pos_type i = 0; i < size(); ++i) {
++column; ++column;
// First char in paragraph or after label? // First char in paragraph or after label?
if (i == main_body) { if (i == body_pos) {
if (main_body > 0) { if (body_pos > 0) {
if (open_font) { if (open_font) {
column += running_font.latexWriteEndChanges(os, basefont, basefont); column += running_font.latexWriteEndChanges(os, basefont, basefont);
open_font = false; open_font = false;
@ -1190,7 +1183,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
{ {
column += running_font.latexWriteEndChanges(os, column += running_font.latexWriteEndChanges(os,
basefont, basefont,
(i == main_body-1) ? basefont : font); (i == body_pos-1) ? basefont : font);
running_font = basefont; running_font = basefont;
open_font = false; open_font = false;
} }
@ -1198,7 +1191,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
// Blanks are printed before start of fontswitch // Blanks are printed before start of fontswitch
if (c == ' ') { if (c == ' ') {
// Do not print the separation of the optional argument // Do not print the separation of the optional argument
if (i != main_body - 1) { if (i != body_pos - 1) {
pimpl_->simpleTeXBlanks(os, texrow, i, pimpl_->simpleTeXBlanks(os, texrow, i,
column, font, *style); column, font, *style);
} }
@ -1207,7 +1200,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
// Do we need to change font? // Do we need to change font?
if ((font != running_font || if ((font != running_font ||
font.language() != running_font.language()) && font.language() != running_font.language()) &&
i != main_body - 1) i != body_pos - 1)
{ {
column += font.latexWriteStartChanges(os, basefont, column += font.latexWriteStartChanges(os, basefont,
last_font); last_font);
@ -1280,7 +1273,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
} }
// Needed if there is an optional argument but no contents. // Needed if there is an optional argument but no contents.
if (main_body > 0 && main_body == size()) { if (body_pos > 0 && body_pos == size()) {
os << "]~"; os << "]~";
return_value = false; return_value = false;
} }

View File

@ -203,8 +203,13 @@ public:
Paragraph * outerHook(); Paragraph * outerHook();
/// ///
Paragraph const * outerHook() const; Paragraph const * outerHook() const;
///
int beginningOfMainBody() const; /// Paragraphs can contain "manual labels", for example, Description environment.
/// The text for this user-editable label is stored in the paragraph alongside
/// the text of the rest of the paragraph (the body). This function returns
/// the starting position of the body of the text in the paragraph.
int beginningOfBody() const;
/// ///
string const & getLabelstring() const; string const & getLabelstring() const;

View File

@ -470,26 +470,26 @@ void RowPainter::paintSelection()
if ((startrow != row && !is_rtl) || (endrow != row && is_rtl)) if ((startrow != row && !is_rtl) || (endrow != row && is_rtl))
pain_.fillRectangle(xo_, yo_, int(x_), row_.height(), LColor::selection); pain_.fillRectangle(xo_, yo_, int(x_), row_.height(), LColor::selection);
pos_type const main_body = par_.beginningOfMainBody(); pos_type const body_pos = par_.beginningOfBody();
pos_type const last = row_.lastPrintablePos(); pos_type const last = row_.lastPrintablePos();
float tmpx = x_; float tmpx = x_;
for (pos_type vpos = row_.pos(); vpos <= last; ++vpos) { for (pos_type vpos = row_.pos(); vpos <= last; ++vpos) {
pos_type pos = text_.vis2log(vpos); pos_type pos = text_.vis2log(vpos);
float const old_tmpx = tmpx; float const old_tmpx = tmpx;
if (main_body > 0 && pos == main_body - 1) { if (body_pos > 0 && pos == body_pos - 1) {
LyXLayout_ptr const & layout = par_.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 (par_.isLineSeparator(main_body - 1)) if (par_.isLineSeparator(body_pos - 1))
tmpx -= singleWidth(main_body - 1); tmpx -= singleWidth(body_pos - 1);
} }
if (row_.hfillExpansion(pos)) { if (row_.hfillExpansion(pos)) {
tmpx += singleWidth(pos); tmpx += singleWidth(pos);
if (pos >= main_body) if (pos >= body_pos)
tmpx += hfill_; tmpx += hfill_;
else else
tmpx += label_hfill_; tmpx += label_hfill_;
@ -497,7 +497,7 @@ void RowPainter::paintSelection()
else if (par_.isSeparator(pos)) { else if (par_.isSeparator(pos)) {
tmpx += singleWidth(pos); tmpx += singleWidth(pos);
if (pos >= main_body) if (pos >= body_pos)
tmpx += separator_; tmpx += separator_;
} else { } else {
tmpx += singleWidth(pos); tmpx += singleWidth(pos);
@ -930,11 +930,11 @@ void RowPainter::paintLast()
bool RowPainter::paintText() bool RowPainter::paintText()
{ {
pos_type const last = row_.lastPrintablePos(); pos_type const last = row_.lastPrintablePos();
pos_type main_body = par_.beginningOfMainBody(); pos_type body_pos = par_.beginningOfBody();
if (main_body > 0 && if (body_pos > 0 &&
(main_body - 1 > last || (body_pos - 1 > last ||
!par_.isLineSeparator(main_body - 1))) { !par_.isLineSeparator(body_pos - 1))) {
main_body = 0; body_pos = 0;
} }
LyXLayout_ptr const & layout = par_.layout(); LyXLayout_ptr const & layout = par_.layout();
@ -975,12 +975,12 @@ bool RowPainter::paintText()
running_strikeout = false; running_strikeout = false;
} }
if (main_body > 0 && pos == main_body - 1) { if (body_pos > 0 && pos == body_pos - 1) {
int const lwidth = font_metrics::width(layout->labelsep, int const lwidth = font_metrics::width(layout->labelsep,
getLabelFont()); getLabelFont());
x_ += label_hfill_ + lwidth x_ += label_hfill_ + lwidth
- singleWidth(main_body - 1); - singleWidth(body_pos - 1);
} }
if (par_.isHfill(pos)) { if (par_.isHfill(pos)) {
@ -995,7 +995,7 @@ bool RowPainter::paintText()
if (row_.hfillExpansion(pos)) { if (row_.hfillExpansion(pos)) {
int const y2 = (y0 + y1) / 2; int const y2 = (y0 + y1) / 2;
if (pos >= main_body) { if (pos >= body_pos) {
pain_.line(int(x_), y2, pain_.line(int(x_), y2,
int(x_ + hfill_), y2, int(x_ + hfill_), y2,
LColor::added_space, LColor::added_space,
@ -1016,7 +1016,7 @@ bool RowPainter::paintText()
++vpos; ++vpos;
} else if (par_.isSeparator(pos)) { } else if (par_.isSeparator(pos)) {
x_ += singleWidth(pos); x_ += singleWidth(pos);
if (pos >= main_body) if (pos >= body_pos)
x_ += separator_; x_ += separator_;
++vpos; ++vpos;
} else { } else {

View File

@ -298,7 +298,7 @@ void LyXText::computeBidiTables(Buffer const * buf, Row * row) const
int level = 0; int level = 0;
bool rtl = false; bool rtl = false;
bool rtl0 = false; bool rtl0 = false;
pos_type const main_body = row->par()->beginningOfMainBody(); pos_type const body_pos = row->par()->beginningOfBody();
for (pos_type lpos = bidi_start; lpos <= bidi_end; ++lpos) { for (pos_type lpos = bidi_start; lpos <= bidi_end; ++lpos) {
bool is_space = row->par()->isLineSeparator(lpos); bool is_space = row->par()->isLineSeparator(lpos);
@ -321,8 +321,8 @@ void LyXText::computeBidiTables(Buffer const * buf, Row * row) const
bool new_rtl0 = font.isRightToLeft(); bool new_rtl0 = font.isRightToLeft();
int new_level; int new_level;
if (lpos == main_body - 1 if (lpos == body_pos - 1
&& row->pos() < main_body - 1 && row->pos() < body_pos - 1
&& is_space) { && is_space) {
new_level = (rtl_par) ? 1 : 0; new_level = (rtl_par) ? 1 : 0;
new_rtl = new_rtl0 = rtl_par; new_rtl = new_rtl0 = rtl_par;
@ -498,7 +498,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
case MARGIN_MANUAL: case MARGIN_MANUAL:
x += font_metrics::signedWidth(layout->labelindent, labelfont); x += font_metrics::signedWidth(layout->labelindent, labelfont);
// The width of an empty par, even with manual label, should be 0 // The width of an empty par, even with manual label, should be 0
if (!row->par()->empty() && row->pos() >= row->par()->beginningOfMainBody()) { if (!row->par()->empty() && row->pos() >= row->par()->beginningOfBody()) {
if (!row->par()->getLabelWidthString().empty()) { if (!row->par()->getLabelWidthString().empty()) {
x += font_metrics::width(row->par()->getLabelWidthString(), x += font_metrics::width(row->par()->getLabelWidthString(),
labelfont); labelfont);
@ -512,7 +512,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
break; break;
case MARGIN_FIRST_DYNAMIC: case MARGIN_FIRST_DYNAMIC:
if (layout->labeltype == LABEL_MANUAL) { if (layout->labeltype == LABEL_MANUAL) {
if (row->pos() >= row->par()->beginningOfMainBody()) { if (row->pos() >= row->par()->beginningOfBody()) {
x += font_metrics::signedWidth(layout->leftmargin, x += font_metrics::signedWidth(layout->leftmargin,
labelfont); labelfont);
} else { } else {
@ -668,7 +668,7 @@ int LyXText::labelEnd(BufferView & bview, Row const & row) const
if (row.par()->layout()->margintype == MARGIN_MANUAL) { if (row.par()->layout()->margintype == MARGIN_MANUAL) {
Row tmprow = row; Row tmprow = row;
tmprow.pos(row.par()->size()); tmprow.pos(row.par()->size());
// just the beginning of the main body // return the beginning of the body
return leftMargin(&bview, &tmprow); return leftMargin(&bview, &tmprow);
} }
@ -694,7 +694,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
pos_type last_separator = -1; pos_type last_separator = -1;
width -= rightMargin(*bview->buffer(), *row); width -= rightMargin(*bview->buffer(), *row);
pos_type const main_body = par->beginningOfMainBody(); pos_type const body_pos = par->beginningOfBody();
LyXLayout_ptr const & layout = par->layout(); LyXLayout_ptr const & layout = par->layout();
pos_type i = pos; pos_type i = pos;
@ -734,7 +734,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
if (in->display() && if (in->display() &&
(layout->isCommand() || (layout->isCommand() ||
(layout->labeltype == LABEL_MANUAL (layout->labeltype == LABEL_MANUAL
&& i < par->beginningOfMainBody()))) && i < par->beginningOfBody())))
{ {
// display istn't allowd // display istn't allowd
in->display(false); in->display(false);
@ -770,7 +770,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
x += singleWidth(bview, par, i, c); x += singleWidth(bview, par, i, c);
} }
++i; ++i;
if (i == main_body) { if (i == body_pos) {
x += font_metrics::width(layout->labelsep, x += font_metrics::width(layout->labelsep,
getLabelFont(bview->buffer(), par)); getLabelFont(bview->buffer(), par));
if (par->isLineSeparator(i - 1)) if (par->isLineSeparator(i - 1))
@ -796,8 +796,8 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
} }
// manual labels cannot be broken in LaTeX, do not care // manual labels cannot be broken in LaTeX, do not care
if (main_body && last_separator < main_body) if (body_pos && last_separator < body_pos)
last_separator = main_body - 1; last_separator = body_pos - 1;
return last_separator; return last_separator;
} }
@ -825,11 +825,11 @@ int LyXText::fill(BufferView & bview, Row & row, int paper_width) const
Paragraph * par = row.par(); Paragraph * par = row.par();
LyXLayout_ptr const & layout = par->layout(); LyXLayout_ptr const & layout = par->layout();
pos_type const main_body = par->beginningOfMainBody(); pos_type const body_pos = par->beginningOfBody();
pos_type i = row.pos(); pos_type i = row.pos();
while (i <= last) { while (i <= last) {
if (main_body > 0 && i == main_body) { if (body_pos > 0 && i == body_pos) {
w += font_metrics::width(layout->labelsep, getLabelFont(bview.buffer(), par)); w += font_metrics::width(layout->labelsep, getLabelFont(bview.buffer(), par));
if (par->isLineSeparator(i - 1)) if (par->isLineSeparator(i - 1))
w -= singleWidth(&bview, par, i - 1); w -= singleWidth(&bview, par, i - 1);
@ -840,7 +840,7 @@ int LyXText::fill(BufferView & bview, Row & row, int paper_width) const
w += singleWidth(&bview, par, i); w += singleWidth(&bview, par, i);
++i; ++i;
} }
if (main_body > 0 && main_body > last) { if (body_pos > 0 && body_pos > last) {
w += font_metrics::width(layout->labelsep, getLabelFont(bview.buffer(), par)); w += font_metrics::width(layout->labelsep, getLabelFont(bview.buffer(), par));
if (last >= 0 && par->isLineSeparator(last)) if (last >= 0 && par->isLineSeparator(last))
w -= singleWidth(&bview, par, last); w -= singleWidth(&bview, par, last);
@ -857,7 +857,7 @@ int LyXText::fill(BufferView & bview, Row & row, int paper_width) 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(BufferView & bview, Row const & row) const int LyXText::labelFill(BufferView & bview, Row const & row) const
{ {
pos_type last = row.par()->beginningOfMainBody(); pos_type last = row.par()->beginningOfBody();
lyx::Assert(last > 0); lyx::Assert(last > 0);
@ -1572,7 +1572,7 @@ void LyXText::insertChar(BufferView * bview, char c)
return; return;
} }
} else if (IsNewlineChar(c)) { } else if (IsNewlineChar(c)) {
if (cursor.pos() <= cursor.par()->beginningOfMainBody()) { if (cursor.pos() <= cursor.par()->beginningOfBody()) {
charInserted(); charInserted();
return; return;
} }
@ -1775,11 +1775,11 @@ void LyXText::prepareToPrint(BufferView * bview,
nlh = row->numberOfLabelHfills(); nlh = row->numberOfLabelHfills();
// 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 "main 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 (row->par()->size()) if (!row->par()->empty())
++nlh; ++nlh;
if (nlh && !row->par()->getLabelWidthString().empty()) { if (nlh && !row->par()->getLabelWidthString().empty()) {
@ -1849,15 +1849,15 @@ void LyXText::prepareToPrint(BufferView * bview,
computeBidiTables(bview->buffer(), row); computeBidiTables(bview->buffer(), row);
if (is_rtl) { if (is_rtl) {
pos_type main_body = row->par()->beginningOfMainBody(); pos_type body_pos = row->par()->beginningOfBody();
pos_type last = row->lastPos(); pos_type last = row->lastPos();
if (main_body > 0 && if (body_pos > 0 &&
(main_body - 1 > last || (body_pos - 1 > last ||
!row->par()->isLineSeparator(main_body - 1))) { !row->par()->isLineSeparator(body_pos - 1))) {
x += font_metrics::width(layout->labelsep, x += font_metrics::width(layout->labelsep,
getLabelFont(bview->buffer(), row->par())); getLabelFont(bview->buffer(), row->par()));
if (main_body - 1 <= last) if (body_pos - 1 <= last)
x += fill_label_hfill; x += fill_label_hfill;
} }
} }
@ -2586,7 +2586,7 @@ void LyXText::backspace(BufferView * bview)
// delete newlines at the beginning of paragraphs // delete newlines at the beginning of paragraphs
while (!cursor.par()->empty() && while (!cursor.par()->empty() &&
cursor.par()->isNewline(cursor.pos()) && cursor.par()->isNewline(cursor.pos()) &&
cursor.pos() == cursor.par()->beginningOfMainBody()) { cursor.pos() == cursor.par()->beginningOfBody()) {
cursor.par()->erase(cursor.pos()); cursor.par()->erase(cursor.pos());
// refresh the positions // refresh the positions
tmprow = row; tmprow = row;
@ -2734,13 +2734,13 @@ LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
bool left_side = false; bool left_side = false;
pos_type main_body = row->par()->beginningOfMainBody(); pos_type body_pos = row->par()->beginningOfBody();
float last_tmpx = tmpx; float last_tmpx = tmpx;
if (main_body > 0 && if (body_pos > 0 &&
(main_body - 1 > last || (body_pos - 1 > last ||
!row->par()->isLineSeparator(main_body - 1))) !row->par()->isLineSeparator(body_pos - 1)))
main_body = 0; body_pos = 0;
// check for empty row // check for empty row
if (!row->par()->size()) { if (!row->par()->size()) {
@ -2751,23 +2751,23 @@ LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
while (vc <= last && tmpx <= x) { while (vc <= last && tmpx <= x) {
c = vis2log(vc); c = vis2log(vc);
last_tmpx = tmpx; last_tmpx = tmpx;
if (main_body > 0 && c == main_body-1) { if (body_pos > 0 && c == body_pos-1) {
tmpx += fill_label_hfill + tmpx += fill_label_hfill +
font_metrics::width(layout->labelsep, font_metrics::width(layout->labelsep,
getLabelFont(bview->buffer(), row->par())); getLabelFont(bview->buffer(), row->par()));
if (row->par()->isLineSeparator(main_body - 1)) if (row->par()->isLineSeparator(body_pos - 1))
tmpx -= singleWidth(bview, row->par(), main_body-1); tmpx -= singleWidth(bview, row->par(), body_pos-1);
} }
if (row->hfillExpansion(c)) { if (row->hfillExpansion(c)) {
tmpx += singleWidth(bview, row->par(), c); tmpx += singleWidth(bview, row->par(), c);
if (c >= main_body) if (c >= body_pos)
tmpx += fill_hfill; tmpx += fill_hfill;
else else
tmpx += fill_label_hfill; tmpx += fill_label_hfill;
} else if (row->par()->isSeparator(c)) { } else if (row->par()->isSeparator(c)) {
tmpx += singleWidth(bview, row->par(), c); tmpx += singleWidth(bview, row->par(), c);
if (c >= main_body) if (c >= body_pos)
tmpx+= fill_separator; tmpx+= fill_separator;
} else { } else {
tmpx += singleWidth(bview, row->par(), c); tmpx += singleWidth(bview, row->par(), c);

View File

@ -158,7 +158,7 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
// We specialize the 95% common case: // We specialize the 95% common case:
if (!par->getDepth()) { if (!par->getDepth()) {
if (layout->labeltype == LABEL_MANUAL if (layout->labeltype == LABEL_MANUAL
&& pos < par->beginningOfMainBody()) { && pos < par->beginningOfBody()) {
// 1% goes here // 1% goes here
LyXFont f = par->getFontSettings(buf->params, pos); LyXFont f = par->getFontSettings(buf->params, pos);
if (par->inInset()) if (par->inInset())
@ -176,7 +176,7 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
LyXFont layoutfont; LyXFont layoutfont;
if (pos < par->beginningOfMainBody()) { if (pos < par->beginningOfBody()) {
// 1% goes here // 1% goes here
layoutfont = layout->labelfont; layoutfont = layout->labelfont;
} else { } else {
@ -251,7 +251,7 @@ void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
// Get concrete layout font to reduce against // Get concrete layout font to reduce against
LyXFont layoutfont; LyXFont layoutfont;
if (pos < par->beginningOfMainBody()) if (pos < par->beginningOfBody())
layoutfont = layout->labelfont; layoutfont = layout->labelfont;
else else
layoutfont = layout->font; layoutfont = layout->font;
@ -425,7 +425,7 @@ void LyXText::makeFontEntriesLayoutSpecific(Buffer const & buf,
LyXFont layoutfont; LyXFont layoutfont;
for (pos_type pos = 0; pos < par.size(); ++pos) { for (pos_type pos = 0; pos < par.size(); ++pos) {
if (pos < par.beginningOfMainBody()) if (pos < par.beginningOfBody())
layoutfont = layout->labelfont; layoutfont = layout->labelfont;
else else
layoutfont = layout->font; layoutfont = layout->font;
@ -641,7 +641,7 @@ void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall)
if (!selection.set()) { if (!selection.set()) {
// Determine basis font // Determine basis font
LyXFont layoutfont; LyXFont layoutfont;
if (cursor.pos() < cursor.par()->beginningOfMainBody()) { if (cursor.pos() < cursor.par()->beginningOfBody()) {
layoutfont = getLabelFont(bview->buffer(), layoutfont = getLabelFont(bview->buffer(),
cursor.par()); cursor.par());
} else { } else {
@ -1836,33 +1836,33 @@ float LyXText::getCursorX(BufferView * bview, Row * row,
cursor_vpos = (bidi_level(pos) % 2 == 0) cursor_vpos = (bidi_level(pos) % 2 == 0)
? log2vis(pos) : log2vis(pos) + 1; ? log2vis(pos) : log2vis(pos) + 1;
pos_type main_body = row->par()->beginningOfMainBody(); pos_type body_pos = row->par()->beginningOfBody();
if ((main_body > 0) && if ((body_pos > 0) &&
((main_body-1 > last) || ((body_pos-1 > last) ||
!row->par()->isLineSeparator(main_body-1))) !row->par()->isLineSeparator(body_pos-1)))
main_body = 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 = vis2log(vpos); pos_type pos = vis2log(vpos);
if (main_body > 0 && pos == main_body - 1) { if (body_pos > 0 && pos == body_pos - 1) {
x += fill_label_hfill + x += fill_label_hfill +
font_metrics::width( font_metrics::width(
row->par()->layout()->labelsep, row->par()->layout()->labelsep,
getLabelFont(bview->buffer(), getLabelFont(bview->buffer(),
row->par())); row->par()));
if (row->par()->isLineSeparator(main_body - 1)) if (row->par()->isLineSeparator(body_pos - 1))
x -= singleWidth(bview, x -= singleWidth(bview,
row->par(), main_body - 1); row->par(), body_pos - 1);
} }
if (row->hfillExpansion(pos)) { if (row->hfillExpansion(pos)) {
x += singleWidth(bview, row->par(), pos); x += singleWidth(bview, row->par(), pos);
if (pos >= main_body) if (pos >= body_pos)
x += fill_hfill; x += fill_hfill;
else else
x += fill_label_hfill; x += fill_label_hfill;
} else if (row->par()->isSeparator(pos)) { } else if (row->par()->isSeparator(pos)) {
x += singleWidth(bview, row->par(), pos); x += singleWidth(bview, row->par(), pos);
if (pos >= main_body) if (pos >= body_pos)
x += fill_separator; x += fill_separator;
} else } else
x += singleWidth(bview, row->par(), pos); x += singleWidth(bview, row->par(), pos);