mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-09 10:47:57 +00:00
small stuff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7436 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7fa3f39b0d
commit
6e844a0aed
@ -16,9 +16,7 @@ using std::min;
|
||||
bool isParEnd(LyXText const & lt, RowList::iterator rit)
|
||||
{
|
||||
RowList::iterator next_row = boost::next(rit);
|
||||
|
||||
return next_row == lt.rows().end() ||
|
||||
next_row->par() != rit->par();
|
||||
return next_row == lt.rows().end() || next_row->par() != rit->par();
|
||||
}
|
||||
|
||||
|
||||
@ -27,11 +25,10 @@ pos_type lastPos(LyXText const & lt, RowList::iterator rit)
|
||||
if (rit->par()->empty())
|
||||
return 0;
|
||||
|
||||
if (isParEnd(lt, rit)) {
|
||||
if (isParEnd(lt, rit))
|
||||
return rit->par()->size() - 1;
|
||||
} else {
|
||||
|
||||
return boost::next(rit)->pos() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -75,15 +72,11 @@ int numberOfSeparators(LyXText const & lt, RowList::iterator rit)
|
||||
{
|
||||
pos_type const last = lastPrintablePos(lt, rit);
|
||||
ParagraphList::iterator pit = rit->par();
|
||||
|
||||
int n = 0;
|
||||
|
||||
pos_type p = max(rit->pos(), pit->beginningOfBody());
|
||||
for (; p < last; ++p) {
|
||||
if (pit->isSeparator(p)) {
|
||||
for ( ; p < last; ++p)
|
||||
if (pit->isSeparator(p))
|
||||
++n;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -98,10 +91,9 @@ int numberOfHfills(LyXText const & lt, RowList::iterator rit)
|
||||
|
||||
// hfill *DO* count at the beginning of paragraphs!
|
||||
if (first) {
|
||||
while (first < last && pit->isHfill(first)) {
|
||||
while (first < last && pit->isHfill(first))
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
first = max(first, pit->beginningOfBody());
|
||||
|
||||
@ -151,15 +143,9 @@ bool hfillExpansion(LyXText const & lt, RowList::iterator rit, pos_type pos)
|
||||
|
||||
// at the end of a row it does not count
|
||||
// unless another hfill exists on the line
|
||||
if (pos >= lastPos(lt, rit)) {
|
||||
pos_type i = rit->pos();
|
||||
while (i < pos && !pit->isHfill(i)) {
|
||||
++i;
|
||||
}
|
||||
if (i == pos) {
|
||||
if (pos >= lastPos(lt, rit))
|
||||
for (pos_type i = rit->pos(); i < pos && !pit->isHfill(i); ++i)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// at the beginning of a row it does not count, if it is not
|
||||
// the first row of a paragaph
|
||||
|
63
src/text.C
63
src/text.C
@ -154,7 +154,7 @@ int LyXText::workWidth(InsetOld const * inset) const
|
||||
ownerParagraphs().end(),
|
||||
*inset->parOwner());
|
||||
if (par == ownerParagraphs().end()) {
|
||||
lyxerr[Debug::GUI] << "LyXText::workWidth: unexpected\n";
|
||||
lyxerr << "LyXText::workWidth: unexpected\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -167,13 +167,10 @@ int LyXText::workWidth(InsetOld const * inset) const
|
||||
// Optimization here: in most cases, the real row is
|
||||
// not needed, but only the par/pos values. So we just
|
||||
// construct a dummy row for leftMargin. (JMarc)
|
||||
Row dummyrow;
|
||||
dummyrow.par(par);
|
||||
dummyrow.pos(pos);
|
||||
return workWidth() - leftMargin(dummyrow);
|
||||
} else {
|
||||
int dummy_y;
|
||||
RowList::iterator row = getRow(par, pos, dummy_y);
|
||||
return workWidth() - leftMargin(Row(par, pos));
|
||||
}
|
||||
|
||||
RowList::iterator row = getRow(par, pos);
|
||||
RowList::iterator frow = row;
|
||||
RowList::iterator beg = rowlist_.begin();
|
||||
|
||||
@ -184,15 +181,11 @@ int LyXText::workWidth(InsetOld const * inset) const
|
||||
|
||||
unsigned int maxw = 0;
|
||||
while (!isParEnd(*this, frow)) {
|
||||
if ((frow != row) && (maxw < frow->width()))
|
||||
if (frow != row && maxw < frow->width())
|
||||
maxw = frow->width();
|
||||
++frow;
|
||||
}
|
||||
if (maxw)
|
||||
return maxw;
|
||||
|
||||
}
|
||||
return workWidth();
|
||||
return maxw ? maxw : workWidth();
|
||||
}
|
||||
|
||||
|
||||
@ -738,14 +731,12 @@ int LyXText::rightMargin(Buffer const & buf, Row const & row) const
|
||||
LyXTextClass const & tclass = buf.params.getLyXTextClass();
|
||||
LyXLayout_ptr const & layout = row.par()->layout();
|
||||
|
||||
int x = PAPER_MARGIN
|
||||
return PAPER_MARGIN
|
||||
+ font_metrics::signedWidth(tclass.rightmargin(),
|
||||
tclass.defaultfont());
|
||||
|
||||
x += font_metrics::signedWidth(layout->rightmargin,
|
||||
+ font_metrics::signedWidth(layout->rightmargin,
|
||||
tclass.defaultfont())
|
||||
* 4 / (row.par()->getDepth() + 4);
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@ -1075,16 +1066,12 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
Assert(rit != rows().end());
|
||||
|
||||
// get the maximum ascent and the maximum descent
|
||||
float layoutasc = 0;
|
||||
float layoutdesc = 0;
|
||||
float tmptop = 0;
|
||||
double layoutasc = 0;
|
||||
double layoutdesc = 0;
|
||||
double tmptop = 0;
|
||||
|
||||
// ok, let us initialize the maxasc and maxdesc value.
|
||||
// This depends in LaTeX of the font of the last character
|
||||
// in the paragraph. The hack below is necessary because
|
||||
// of the possibility of open footnotes
|
||||
|
||||
// Correction: only the fontsize count. The other properties
|
||||
// Only the fontsize count. The other properties
|
||||
// are taken from the layoutfont. Nicer on the screen :)
|
||||
ParagraphList::iterator pit = rit->par();
|
||||
|
||||
@ -1101,20 +1088,17 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
|
||||
LyXFont labelfont = getLabelFont(pit);
|
||||
|
||||
float spacing_val = 1.0;
|
||||
if (!pit->params().spacing().isDefault()) {
|
||||
double spacing_val = 1.0;
|
||||
if (!pit->params().spacing().isDefault())
|
||||
spacing_val = pit->params().spacing().getValue();
|
||||
} else {
|
||||
else
|
||||
spacing_val = bv()->buffer()->params.spacing.getValue();
|
||||
}
|
||||
//lyxerr << "spacing_val = " << spacing_val << endl;
|
||||
|
||||
int maxasc = int(font_metrics::maxAscent(font) *
|
||||
layout->spacing.getValue() *
|
||||
spacing_val);
|
||||
layout->spacing.getValue() * spacing_val);
|
||||
int maxdesc = int(font_metrics::maxDescent(font) *
|
||||
layout->spacing.getValue() *
|
||||
spacing_val);
|
||||
layout->spacing.getValue() * spacing_val);
|
||||
|
||||
pos_type const pos_end = lastPos(*this, rit);
|
||||
int labeladdon = 0;
|
||||
@ -1130,7 +1114,8 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
|
||||
// Check if any insets are larger
|
||||
for (pos_type pos = rit->pos(); pos <= pos_end; ++pos) {
|
||||
// Manual inlined optimised version of common case of "maxwidth += singleWidth(pit, pos);"
|
||||
// Manual inlined optimised version of common case of
|
||||
// "maxwidth += singleWidth(pit, pos);"
|
||||
char const c = par.getChar(pos);
|
||||
|
||||
if (IsPrintable(c)) {
|
||||
@ -1391,9 +1376,9 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
|
||||
double x = 0;
|
||||
if (layout->margintype != MARGIN_RIGHT_ADDRESS_BOX) {
|
||||
double dummy;
|
||||
// this IS needed
|
||||
rit->width(maxwidth);
|
||||
double dummy;
|
||||
prepareToPrint(rit, x, dummy, dummy, dummy, false);
|
||||
}
|
||||
rit->width(int(maxwidth + x));
|
||||
@ -1401,11 +1386,10 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
width = max(0, workWidth());
|
||||
RowList::iterator it = rows().begin();
|
||||
RowList::iterator end = rows().end();
|
||||
for (; it != end; ++it) {
|
||||
for (; it != end; ++it)
|
||||
if (it->width() > width)
|
||||
width = it->width();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2642,8 +2626,7 @@ void LyXText::backspace()
|
||||
|
||||
if (isBoundary(bv()->buffer(), *cursor.par(), cursor.pos())
|
||||
!= cursor.boundary())
|
||||
setCursor(cursor.par(), cursor.pos(), false,
|
||||
!cursor.boundary());
|
||||
setCursor(cursor.par(), cursor.pos(), false, !cursor.boundary());
|
||||
|
||||
lastpos = cursor.par()->size();
|
||||
if (cursor.pos() == lastpos)
|
||||
|
Loading…
Reference in New Issue
Block a user