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)
|
bool isParEnd(LyXText const & lt, RowList::iterator rit)
|
||||||
{
|
{
|
||||||
RowList::iterator next_row = boost::next(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())
|
if (rit->par()->empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (isParEnd(lt, rit)) {
|
if (isParEnd(lt, rit))
|
||||||
return rit->par()->size() - 1;
|
return rit->par()->size() - 1;
|
||||||
} else {
|
|
||||||
return boost::next(rit)->pos() - 1;
|
return boost::next(rit)->pos() - 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -73,18 +70,14 @@ pos_type lastPrintablePos(LyXText const & lt, RowList::iterator rit)
|
|||||||
|
|
||||||
int numberOfSeparators(LyXText const & lt, RowList::iterator rit)
|
int numberOfSeparators(LyXText const & lt, RowList::iterator rit)
|
||||||
{
|
{
|
||||||
pos_type const last = lastPrintablePos(lt, rit);
|
pos_type const last = lastPrintablePos(lt, rit);
|
||||||
ParagraphList::iterator pit = rit->par();
|
ParagraphList::iterator pit = rit->par();
|
||||||
|
int n = 0;
|
||||||
int n = 0;
|
pos_type p = max(rit->pos(), pit->beginningOfBody());
|
||||||
|
for ( ; p < last; ++p)
|
||||||
pos_type p = max(rit->pos(), pit->beginningOfBody());
|
if (pit->isSeparator(p))
|
||||||
for (; p < last; ++p) {
|
++n;
|
||||||
if (pit->isSeparator(p)) {
|
return n;
|
||||||
++n;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,9 +91,8 @@ int numberOfHfills(LyXText const & lt, RowList::iterator rit)
|
|||||||
|
|
||||||
// hfill *DO* count at the beginning of paragraphs!
|
// hfill *DO* count at the beginning of paragraphs!
|
||||||
if (first) {
|
if (first) {
|
||||||
while (first < last && pit->isHfill(first)) {
|
while (first < last && pit->isHfill(first))
|
||||||
++first;
|
++first;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
first = max(first, pit->beginningOfBody());
|
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
|
// at the end of a row it does not count
|
||||||
// unless another hfill exists on the line
|
// unless another hfill exists on the line
|
||||||
if (pos >= lastPos(lt, rit)) {
|
if (pos >= lastPos(lt, rit))
|
||||||
pos_type i = rit->pos();
|
for (pos_type i = rit->pos(); i < pos && !pit->isHfill(i); ++i)
|
||||||
while (i < pos && !pit->isHfill(i)) {
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
if (i == pos) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// at the beginning of a row it does not count, if it is not
|
// at the beginning of a row it does not count, if it is not
|
||||||
// the first row of a paragaph
|
// the first row of a paragaph
|
||||||
|
91
src/text.C
91
src/text.C
@ -154,7 +154,7 @@ int LyXText::workWidth(InsetOld const * inset) const
|
|||||||
ownerParagraphs().end(),
|
ownerParagraphs().end(),
|
||||||
*inset->parOwner());
|
*inset->parOwner());
|
||||||
if (par == ownerParagraphs().end()) {
|
if (par == ownerParagraphs().end()) {
|
||||||
lyxerr[Debug::GUI] << "LyXText::workWidth: unexpected\n";
|
lyxerr << "LyXText::workWidth: unexpected\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,32 +167,25 @@ int LyXText::workWidth(InsetOld const * inset) const
|
|||||||
// Optimization here: in most cases, the real row is
|
// Optimization here: in most cases, the real row is
|
||||||
// not needed, but only the par/pos values. So we just
|
// not needed, but only the par/pos values. So we just
|
||||||
// construct a dummy row for leftMargin. (JMarc)
|
// construct a dummy row for leftMargin. (JMarc)
|
||||||
Row dummyrow;
|
return workWidth() - leftMargin(Row(par, pos));
|
||||||
dummyrow.par(par);
|
|
||||||
dummyrow.pos(pos);
|
|
||||||
return workWidth() - leftMargin(dummyrow);
|
|
||||||
} else {
|
|
||||||
int dummy_y;
|
|
||||||
RowList::iterator row = getRow(par, pos, dummy_y);
|
|
||||||
RowList::iterator frow = row;
|
|
||||||
RowList::iterator beg = rowlist_.begin();
|
|
||||||
|
|
||||||
while (frow != beg && frow->par() == boost::prior(frow)->par())
|
|
||||||
--frow;
|
|
||||||
|
|
||||||
// FIXME: I don't understand this code - jbl
|
|
||||||
|
|
||||||
unsigned int maxw = 0;
|
|
||||||
while (!isParEnd(*this, frow)) {
|
|
||||||
if ((frow != row) && (maxw < frow->width()))
|
|
||||||
maxw = frow->width();
|
|
||||||
++frow;
|
|
||||||
}
|
|
||||||
if (maxw)
|
|
||||||
return maxw;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return workWidth();
|
|
||||||
|
RowList::iterator row = getRow(par, pos);
|
||||||
|
RowList::iterator frow = row;
|
||||||
|
RowList::iterator beg = rowlist_.begin();
|
||||||
|
|
||||||
|
while (frow != beg && frow->par() == boost::prior(frow)->par())
|
||||||
|
--frow;
|
||||||
|
|
||||||
|
// FIXME: I don't understand this code - jbl
|
||||||
|
|
||||||
|
unsigned int maxw = 0;
|
||||||
|
while (!isParEnd(*this, frow)) {
|
||||||
|
if (frow != row && maxw < frow->width())
|
||||||
|
maxw = frow->width();
|
||||||
|
++frow;
|
||||||
|
}
|
||||||
|
return maxw ? maxw : workWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -738,14 +731,12 @@ int LyXText::rightMargin(Buffer const & buf, Row const & row) const
|
|||||||
LyXTextClass const & tclass = buf.params.getLyXTextClass();
|
LyXTextClass const & tclass = buf.params.getLyXTextClass();
|
||||||
LyXLayout_ptr const & layout = row.par()->layout();
|
LyXLayout_ptr const & layout = row.par()->layout();
|
||||||
|
|
||||||
int x = PAPER_MARGIN
|
return PAPER_MARGIN
|
||||||
+ font_metrics::signedWidth(tclass.rightmargin(),
|
+ font_metrics::signedWidth(tclass.rightmargin(),
|
||||||
tclass.defaultfont());
|
tclass.defaultfont());
|
||||||
|
+ font_metrics::signedWidth(layout->rightmargin,
|
||||||
x += font_metrics::signedWidth(layout->rightmargin,
|
|
||||||
tclass.defaultfont())
|
tclass.defaultfont())
|
||||||
* 4 / (row.par()->getDepth() + 4);
|
* 4 / (row.par()->getDepth() + 4);
|
||||||
return x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1075,17 +1066,13 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
|||||||
Assert(rit != rows().end());
|
Assert(rit != rows().end());
|
||||||
|
|
||||||
// get the maximum ascent and the maximum descent
|
// get the maximum ascent and the maximum descent
|
||||||
float layoutasc = 0;
|
double layoutasc = 0;
|
||||||
float layoutdesc = 0;
|
double layoutdesc = 0;
|
||||||
float tmptop = 0;
|
double tmptop = 0;
|
||||||
|
|
||||||
// ok, let us initialize the maxasc and maxdesc value.
|
// ok, let us initialize the maxasc and maxdesc value.
|
||||||
// This depends in LaTeX of the font of the last character
|
// Only the fontsize count. The other properties
|
||||||
// in the paragraph. The hack below is necessary because
|
// are taken from the layoutfont. Nicer on the screen :)
|
||||||
// of the possibility of open footnotes
|
|
||||||
|
|
||||||
// Correction: only the fontsize count. The other properties
|
|
||||||
// are taken from the layoutfont. Nicer on the screen :)
|
|
||||||
ParagraphList::iterator pit = rit->par();
|
ParagraphList::iterator pit = rit->par();
|
||||||
|
|
||||||
LyXLayout_ptr const & layout = pit->layout();
|
LyXLayout_ptr const & layout = pit->layout();
|
||||||
@ -1101,20 +1088,17 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
|||||||
|
|
||||||
LyXFont labelfont = getLabelFont(pit);
|
LyXFont labelfont = getLabelFont(pit);
|
||||||
|
|
||||||
float spacing_val = 1.0;
|
double spacing_val = 1.0;
|
||||||
if (!pit->params().spacing().isDefault()) {
|
if (!pit->params().spacing().isDefault())
|
||||||
spacing_val = pit->params().spacing().getValue();
|
spacing_val = pit->params().spacing().getValue();
|
||||||
} else {
|
else
|
||||||
spacing_val = bv()->buffer()->params.spacing.getValue();
|
spacing_val = bv()->buffer()->params.spacing.getValue();
|
||||||
}
|
|
||||||
//lyxerr << "spacing_val = " << spacing_val << endl;
|
//lyxerr << "spacing_val = " << spacing_val << endl;
|
||||||
|
|
||||||
int maxasc = int(font_metrics::maxAscent(font) *
|
int maxasc = int(font_metrics::maxAscent(font) *
|
||||||
layout->spacing.getValue() *
|
layout->spacing.getValue() * spacing_val);
|
||||||
spacing_val);
|
|
||||||
int maxdesc = int(font_metrics::maxDescent(font) *
|
int maxdesc = int(font_metrics::maxDescent(font) *
|
||||||
layout->spacing.getValue() *
|
layout->spacing.getValue() * spacing_val);
|
||||||
spacing_val);
|
|
||||||
|
|
||||||
pos_type const pos_end = lastPos(*this, rit);
|
pos_type const pos_end = lastPos(*this, rit);
|
||||||
int labeladdon = 0;
|
int labeladdon = 0;
|
||||||
@ -1130,7 +1114,8 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
|||||||
|
|
||||||
// Check if any insets are larger
|
// Check if any insets are larger
|
||||||
for (pos_type pos = rit->pos(); pos <= pos_end; ++pos) {
|
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);
|
char const c = par.getChar(pos);
|
||||||
|
|
||||||
if (IsPrintable(c)) {
|
if (IsPrintable(c)) {
|
||||||
@ -1391,9 +1376,9 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
|||||||
|
|
||||||
double x = 0;
|
double x = 0;
|
||||||
if (layout->margintype != MARGIN_RIGHT_ADDRESS_BOX) {
|
if (layout->margintype != MARGIN_RIGHT_ADDRESS_BOX) {
|
||||||
double dummy;
|
|
||||||
// this IS needed
|
// this IS needed
|
||||||
rit->width(maxwidth);
|
rit->width(maxwidth);
|
||||||
|
double dummy;
|
||||||
prepareToPrint(rit, x, dummy, dummy, dummy, false);
|
prepareToPrint(rit, x, dummy, dummy, dummy, false);
|
||||||
}
|
}
|
||||||
rit->width(int(maxwidth + x));
|
rit->width(int(maxwidth + x));
|
||||||
@ -1401,10 +1386,9 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
|||||||
width = max(0, workWidth());
|
width = max(0, workWidth());
|
||||||
RowList::iterator it = rows().begin();
|
RowList::iterator it = rows().begin();
|
||||||
RowList::iterator end = rows().end();
|
RowList::iterator end = rows().end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it)
|
||||||
if (it->width() > width)
|
if (it->width() > width)
|
||||||
width = it->width();
|
width = it->width();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2642,8 +2626,7 @@ void LyXText::backspace()
|
|||||||
|
|
||||||
if (isBoundary(bv()->buffer(), *cursor.par(), cursor.pos())
|
if (isBoundary(bv()->buffer(), *cursor.par(), cursor.pos())
|
||||||
!= cursor.boundary())
|
!= cursor.boundary())
|
||||||
setCursor(cursor.par(), cursor.pos(), false,
|
setCursor(cursor.par(), cursor.pos(), false, !cursor.boundary());
|
||||||
!cursor.boundary());
|
|
||||||
|
|
||||||
lastpos = cursor.par()->size();
|
lastpos = cursor.par()->size();
|
||||||
if (cursor.pos() == lastpos)
|
if (cursor.pos() == lastpos)
|
||||||
|
Loading…
Reference in New Issue
Block a user