int LyXText::top_y() const
{
- if (isInInset() || anchor_row_ == rowlist_.end() )
+ if (anchor_row_ == rowlist_.end())
return 0;
+
return anchor_row_->y() + anchor_row_offset_;
}
void LyXText::top_y(int newy)
{
- if (rows().empty() || isInInset())
+ if (rows().empty())
+ return;
+
+ if (isInInset()) {
+ anchor_row_ = rows().begin();
+ anchor_row_offset_ = newy;
return;
+ }
+
lyxerr[Debug::GUI] << "setting top y = " << newy << endl;
int y = newy;
}
-int LyXText::workWidth(Inset * inset) const
+int LyXText::workWidth(Inset const * inset) const
{
- Paragraph * par = inset->parOwner();
- lyx::Assert(par);
+ ParagraphList::iterator par = std::find(ownerParagraphs().begin(),
+ ownerParagraphs().end(),
+ *inset->parOwner());
+ //lyx::Assert(par);
pos_type pos = par->getPositionOfInset(inset);
lyx::Assert(pos != -1);
unsigned char const prev_char = pos > 0 ? par.getChar(pos - 1) : ' ';
unsigned char next_char = ' ';
- for (pos_type i = pos + 1; i < par.size(); ++i)
- if (!Encodings::IsComposeChar_arabic(par.getChar(i))) {
- next_char = par.getChar(i);
+ pos_type const par_size = par.size();
+
+ for (pos_type i = pos + 1; i < par_size; ++i) {
+ unsigned char const par_char = par.getChar(i);
+ if (!Encodings::IsComposeChar_arabic(par_char)) {
+ next_char = par_char;
break;
}
+ }
if (Encodings::is_arabic(next_char)) {
if (Encodings::is_arabic(prev_char) &&
return;
}
- Inset * inset = row->par()->inInset();
+ ParagraphList::iterator row_par = row->par();
+
+ Inset * inset = row_par->inInset();
if (inset && inset->owner() &&
inset->owner()->lyxCode() == Inset::ERT_CODE) {
bidi_start = -1;
pos_type stack[2];
bool const rtl_par =
- row->par()->isRightToLeftPar(buf->params);
+ row_par->isRightToLeftPar(buf->params);
int level = 0;
bool rtl = false;
bool rtl0 = false;
- pos_type const body_pos = row->par()->beginningOfBody();
+ pos_type const body_pos = row_par->beginningOfBody();
for (pos_type lpos = bidi_start; lpos <= bidi_end; ++lpos) {
- bool is_space = row->par()->isLineSeparator(lpos);
+ bool is_space = row_par->isLineSeparator(lpos);
pos_type const pos =
(is_space && lpos + 1 <= bidi_end &&
- !row->par()->isLineSeparator(lpos + 1) &&
- !row->par()->isNewline(lpos + 1))
+ !row_par->isLineSeparator(lpos + 1) &&
+ !row_par->isNewline(lpos + 1))
? lpos + 1 : lpos;
- LyXFont font = row->par()->getFontSettings(buf->params, pos);
+ LyXFont font = row_par->getFontSettings(buf->params, pos);
if (pos != lpos && 0 < lpos && rtl0 && font.isRightToLeft() &&
font.number() == LyXFont::ON &&
- row->par()->getFontSettings(buf->params, lpos - 1).number()
+ row_par->getFontSettings(buf->params, lpos - 1).number()
== LyXFont::ON) {
- font = row->par()->getFontSettings(buf->params, lpos);
+ font = row_par->getFontSettings(buf->params, lpos);
is_space = false;
}
if (row.par()->layout() == tclass.defaultLayout()) {
// find the previous same level paragraph
if (row.par() != ownerParagraphs().begin()) {
- Paragraph * newpar = row.par()
- ->depthHook(row.par()->getDepth());
- if (newpar &&
- newpar->layout()->nextnoindent)
+ ParagraphList::iterator newpit =
+ depthHook(row.par(), ownerParagraphs(),
+ row.par()->getDepth());
+ if (newpit == row.par() &&
+ newpit->layout()->nextnoindent)
parindent.erase();
}
}
} else {
// find the next level paragraph
- Paragraph * newpar = row.par()->outerHook();
+ ParagraphList::iterator newpar = outerHook(row.par(),
+ ownerParagraphs());
// make a corresponding row. Needed to call leftMargin()
// check wether it is a sufficent paragraph
- if (newpar && newpar->layout()->isEnvironment()) {
+ if (newpar != ownerParagraphs().end() &&
+ newpar->layout()->isEnvironment()) {
Row dummyrow;
dummyrow.par(newpar);
dummyrow.pos(newpar->size());
x = leftMargin(dummyrow);
}
- if (newpar && row.par()->layout() == tclass.defaultLayout()) {
+ if (newpar != ownerParagraphs().end() &&
+ row.par()->layout() == tclass.defaultLayout()) {
if (newpar->params().noindent())
parindent.erase();
else {
// theorems (JMarc)
|| (layout->labeltype == LABEL_STATIC
&& layout->latextype == LATEX_ENVIRONMENT
- && ! row.par()->isFirstInSequence())) {
+ && !isFirstInSequence(row.par(), ownerParagraphs()))) {
x += font_metrics::signedWidth(layout->leftmargin,
labelfont);
} else if (layout->labeltype != LABEL_TOP_ENVIRONMENT
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
|| (layout->labeltype == LABEL_STATIC
&& layout->latextype == LATEX_ENVIRONMENT
- && ! row.par()->isFirstInSequence()))
+ && !isFirstInSequence(row.par(), ownerParagraphs())))
&& align == LYX_ALIGN_BLOCK
&& !row.par()->params().noindent()
// in tabulars and ert paragraphs are never indented!
};
-pos_type
-LyXText::rowBreakPoint(Row const & row) const
+pos_type LyXText::rowBreakPoint(Row const & row) const
{
ParagraphList::iterator pit = row.par();
// or the end of the par, then choose the possible break
// nearest that.
- int const left = leftMargin(const_cast<Row&>(row));
+ int const left = leftMargin(row);
int x = left;
// pixel width since last breakpoint
// get the pure distance
pos_type const last = lastPrintablePos(*this, row);
+ ParagraphList::iterator pit = row->par();
+ LyXLayout_ptr const & layout = pit->layout();
+
// special handling of the right address boxes
- if (row->par()->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
+ if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
int const tmpfill = row->fill();
row->fill(0); // the minfill in MarginLeft()
w = leftMargin(*row);
} else
w = leftMargin(*row);
- ParagraphList::iterator pit = row->par();
- LyXLayout_ptr const & layout = pit->layout();
-
pos_type const body_pos = pit->beginningOfBody();
pos_type i = row->pos();
// returns the minimum space a manual label needs on the screen in pixel
int LyXText::labelFill(Row const & row) const
{
- pos_type last = row.par()->beginningOfBody();
+ ParagraphList::iterator pit = row.par();
+
+ pos_type last = pit->beginningOfBody();
lyx::Assert(last > 0);
--last;
// a separator at this end does not count
- if (row.par()->isLineSeparator(last))
+ if (pit->isLineSeparator(last))
--last;
int w = 0;
pos_type i = row.pos();
while (i <= last) {
- w += singleWidth(row.par(), i);
+ w += singleWidth(pit, i);
++i;
}
int fill = 0;
- string const & labwidstr = row.par()->params().labelWidthString();
+ string const & labwidstr = pit->params().labelWidthString();
if (!labwidstr.empty()) {
- LyXFont const labfont = getLabelFont(bv()->buffer(), row.par());
+ LyXFont const labfont = getLabelFont(bv()->buffer(), pit);
int const labwidth = font_metrics::width(labwidstr, labfont);
fill = max(labwidth - w, 0);
}
void LyXText::setHeightOfRow(RowList::iterator rit)
{
- // No need to do anything then...
- if (rit == rows().end())
- return;
+ lyx::Assert(rit != rows().end());
// get the maximum ascent and the maximum descent
- int asc = 0;
- int desc = 0;
float layoutasc = 0;
float layoutdesc = 0;
float tmptop = 0;
// Correction: only the fontsize count. The other properties
// are taken from the layoutfont. Nicer on the screen :)
ParagraphList::iterator pit = rit->par();
- ParagraphList::iterator firstpit = pit;
- LyXLayout_ptr const & layout = firstpit->layout();
+ LyXLayout_ptr const & layout = pit->layout();
// as max get the first character of this row then it can increase but not
// decrease the height. Just some point to start with so we don't have to
LyXFont labelfont = getLabelFont(bv()->buffer(), pit);
float spacing_val = 1.0;
- if (!rit->par()->params().spacing().isDefault()) {
- spacing_val = rit->par()->params().spacing().getValue();
+ if (!pit->params().spacing().isDefault()) {
+ spacing_val = pit->params().spacing().getValue();
} else {
spacing_val = bv()->buffer()->params.spacing.getValue();
}
int labeladdon = 0;
int maxwidth = 0;
- if (!rit->par()->empty()) {
+ if (!pit->empty()) {
// Check if any insets are larger
for (pos_type pos = rit->pos(); pos <= pos_end; ++pos) {
- if (rit->par()->isInset(pos)) {
- tmpfont = getFont(bv()->buffer(), rit->par(), pos);
- tmpinset = rit->par()->getInset(pos);
+ if (pit->isInset(pos)) {
+ tmpfont = getFont(bv()->buffer(), pit, pos);
+ tmpinset = pit->getInset(pos);
if (tmpinset) {
#if 1 // this is needed for deep update on initialitation
#warning inset->update FIXME
tmpinset->update(bv());
#endif
- asc = tmpinset->ascent(bv(), tmpfont);
- desc = tmpinset->descent(bv(), tmpfont);
maxwidth += tmpinset->width(bv(), tmpfont);
- maxasc = max(maxasc, asc);
- maxdesc = max(maxdesc, desc);
+ maxasc = max(maxasc,
+ tmpinset->ascent(bv(), tmpfont));
+ maxdesc = max(maxdesc,
+ tmpinset->descent(bv(), tmpfont));
}
} else {
- maxwidth += singleWidth(rit->par(), pos);
+ maxwidth += singleWidth(pit, pos);
}
}
}
// This is not completely correct, but we can live with the small,
// cosmetic error for now.
LyXFont::FONT_SIZE maxsize =
- rit->par()->highestFontInRange(rit->pos(), pos_end, size);
+ pit->highestFontInRange(rit->pos(), pos_end, size);
if (maxsize > font.size()) {
font.setSize(maxsize);
-
- asc = font_metrics::maxAscent(font);
- desc = font_metrics::maxDescent(font);
- if (asc > maxasc)
- maxasc = asc;
- if (desc > maxdesc)
- maxdesc = desc;
+ maxasc = max(maxasc, font_metrics::maxAscent(font));
+ maxdesc = max(maxdesc, font_metrics::maxDescent(font));
}
// This is nicer with box insets:
rit->ascent_of_text(maxasc);
// is it a top line?
- if (!rit->pos() && (rit->par() == firstpit)) {
+ if (!rit->pos()) {
// some parksips VERY EASY IMPLEMENTATION
if (bv()->buffer()->params.paragraph_separation ==
BufferParams::PARSEP_SKIP)
{
if (layout->isParagraph()
- && firstpit->getDepth() == 0
- && firstpit != ownerParagraphs().begin())
+ && pit->getDepth() == 0
+ && pit != ownerParagraphs().begin())
{
maxasc += bv()->buffer()->params.getDefSkip().inPixels(*bv());
- } else if (firstpit != ownerParagraphs().begin() &&
- boost::prior(firstpit)->layout()->isParagraph() &&
- boost::prior(firstpit)->getDepth() == 0)
+ } else if (pit != ownerParagraphs().begin() &&
+ boost::prior(pit)->layout()->isParagraph() &&
+ boost::prior(pit)->getDepth() == 0)
{
// is it right to use defskip here too? (AS)
maxasc += bv()->buffer()->params.getDefSkip().inPixels(*bv());
}
// the top margin
- if (rit->par() == ownerParagraphs().begin() && !isInInset())
+ if (pit == ownerParagraphs().begin() && !isInInset())
maxasc += PAPER_MARGIN;
// add the vertical spaces, that the user added
- maxasc += getLengthMarkerHeight(*bv(), firstpit->params().spaceTop());
+ maxasc += getLengthMarkerHeight(*bv(), pit->params().spaceTop());
// do not forget the DTP-lines!
// there height depends on the font of the nearest character
- if (firstpit->params().lineTop())
+ if (pit->params().lineTop())
maxasc += 2 * font_metrics::ascent('x', getFont(bv()->buffer(),
- firstpit, 0));
+ pit, 0));
// and now the pagebreaks
- if (firstpit->params().pagebreakTop())
+ if (pit->params().pagebreakTop())
maxasc += 3 * defaultRowHeight();
- if (firstpit->params().startOfAppendix())
+ if (pit->params().startOfAppendix())
maxasc += 3 * defaultRowHeight();
// This is special code for the chapter, since the label of this
&& bv()->buffer()->params.secnumdepth >= 0)
{
float spacing_val = 1.0;
- if (!rit->par()->params().spacing().isDefault()) {
- spacing_val = rit->par()->params().spacing().getValue();
+ if (!pit->params().spacing().isDefault()) {
+ spacing_val = pit->params().spacing().getValue();
} else {
spacing_val = bv()->buffer()->params.spacing.getValue();
}
if ((layout->labeltype == LABEL_TOP_ENVIRONMENT
|| layout->labeltype == LABEL_BIBLIO
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
- && rit->par()->isFirstInSequence()
- && !rit->par()->getLabelstring().empty())
+ && isFirstInSequence(pit, ownerParagraphs())
+ && !pit->getLabelstring().empty())
{
float spacing_val = 1.0;
- if (!rit->par()->params().spacing().isDefault()) {
- spacing_val = rit->par()->params().spacing().getValue();
+ if (!pit->params().spacing().isDefault()) {
+ spacing_val = pit->params().spacing().getValue();
} else {
spacing_val = bv()->buffer()->params.spacing.getValue();
}
+ layout->labelbottomsep * defaultRowHeight());
}
- // and now the layout spaces, for example before and after a section,
- // or between the items of a itemize or enumerate environment
-
- if (!firstpit->params().pagebreakTop()) {
- Paragraph * prev = rit->par()->previous();
- if (prev)
- prev = rit->par()->depthHook(rit->par()->getDepth());
- if (prev && prev->layout() == firstpit->layout() &&
- prev->getDepth() == firstpit->getDepth() &&
- prev->getLabelWidthString() == firstpit->getLabelWidthString())
+ // And now the layout spaces, for example before and after
+ // a section, or between the items of a itemize or enumerate
+ // environment.
+
+ if (!pit->params().pagebreakTop()) {
+ ParagraphList::iterator prev =
+ depthHook(pit, ownerParagraphs(),
+ pit->getDepth());
+ if (prev != pit && prev->layout() == layout &&
+ prev->getDepth() == pit->getDepth() &&
+ prev->getLabelWidthString() == pit->getLabelWidthString())
{
layoutasc = (layout->itemsep * defaultRowHeight());
} else if (rit != rows().begin()) {
tmptop = layout->topsep;
- if (boost::prior(rit)->par()->getDepth() >= rit->par()->getDepth())
+ if (boost::prior(pit)->getDepth() >= pit->getDepth())
tmptop -= boost::prior(rit)->par()->layout()->bottomsep;
if (tmptop > 0)
layoutasc = (tmptop * defaultRowHeight());
- } else if (rit->par()->params().lineTop()) {
+ } else if (pit->params().lineTop()) {
tmptop = layout->topsep;
if (tmptop > 0)
layoutasc = (tmptop * defaultRowHeight());
}
- prev = rit->par()->outerHook();
- if (prev) {
+ prev = outerHook(pit, ownerParagraphs());
+ if (prev != ownerParagraphs().end()) {
maxasc += int(prev->layout()->parsep * defaultRowHeight());
- } else {
- if (firstpit != ownerParagraphs().begin() &&
- boost::prior(firstpit)->getDepth() == 0 &&
- boost::prior(firstpit)->layout() !=
- firstpit->layout())
- {
- // avoid parsep
- } else if (firstpit != ownerParagraphs().begin()) {
+ } else if (pit != ownerParagraphs().begin()) {
+ ParagraphList::iterator prior_pit = boost::prior(pit);
+ if (prior_pit->getDepth() != 0 ||
+ prior_pit->layout() == layout) {
maxasc += int(layout->parsep * defaultRowHeight());
}
}
}
// is it a bottom line?
- if (rit->par() == pit
- && (boost::next(rit) == rows().end() ||
- boost::next(rit)->par() != rit->par())) {
+ RowList::iterator next_rit = boost::next(rit);
+ if (next_rit == rows().end() ||
+ next_rit->par() != pit) {
// the bottom margin
- if (boost::next(pit) == ownerParagraphs().end() &&
+ ParagraphList::iterator nextpit = boost::next(pit);
+ if (nextpit == ownerParagraphs().end() &&
!isInInset())
maxdesc += PAPER_MARGIN;
// add the vertical spaces, that the user added
- maxdesc += getLengthMarkerHeight(*bv(), firstpit->params().spaceBottom());
+ maxdesc += getLengthMarkerHeight(*bv(), pit->params().spaceBottom());
// do not forget the DTP-lines!
// there height depends on the font of the nearest character
- if (firstpit->params().lineBottom())
+ if (pit->params().lineBottom())
maxdesc += 2 * font_metrics::ascent('x',
getFont(bv()->buffer(),
pit,
max(pos_type(0), pit->size() - 1)));
// and now the pagebreaks
- if (firstpit->params().pagebreakBottom())
+ if (pit->params().pagebreakBottom())
maxdesc += 3 * defaultRowHeight();
// and now the layout spaces, for example before and after
// a section, or between the items of a itemize or enumerate
// environment
- if (!firstpit->params().pagebreakBottom()
- && rit->par()->next()) {
- ParagraphList::iterator nextpit = boost::next(rit->par());
- ParagraphList::iterator comparepit = rit->par();
+ if (!pit->params().pagebreakBottom()
+ && nextpit != ownerParagraphs().end()) {
+ ParagraphList::iterator comparepit = pit;
float usual = 0;
float unusual = 0;
if (comparepit->getDepth() > nextpit->getDepth()) {
usual = (comparepit->layout()->bottomsep * defaultRowHeight());
- comparepit = comparepit->depthHook(nextpit->getDepth());
+ comparepit = depthHook(comparepit, ownerParagraphs(), nextpit->getDepth());
if (comparepit->layout()!= nextpit->layout()
|| nextpit->getLabelWidthString() !=
comparepit->getLabelWidthString())
}
// incalculate the layout spaces
- maxasc += int(layoutasc * 2 / (2 + firstpit->getDepth()));
- maxdesc += int(layoutdesc * 2 / (2 + firstpit->getDepth()));
+ maxasc += int(layoutasc * 2 / (2 + pit->getDepth()));
+ maxdesc += int(layoutdesc * 2 / (2 + pit->getDepth()));
// calculate the new height of the text
height -= rit->height();
RowList::iterator end = rows().end();
if (z < rit->par()->size()) {
- if (boost::next(rit) == end ||
- (boost::next(rit) != end &&
- boost::next(rit)->par() != rit->par())) {
+ RowList::iterator next_rit = boost::next(rit);
+
+ if (next_rit == end ||
+ (next_rit != end &&
+ next_rit->par() != rit->par())) {
// insert a new row
++z;
Row newrow(rit->par(), z);
- rit = rowlist_.insert(boost::next(rit), newrow);
+ rit = rowlist_.insert(next_rit, newrow);
} else {
++rit;
++z;
RowList::iterator end = rows().end();
if (z < rit->par()->size()) {
- if (boost::next(rit) == end ||
- (boost::next(rit) != end &&
- boost::next(rit)->par() != rit->par())) {
+ RowList::iterator next_rit = boost::next(rit);
+
+ if (next_rit == end ||
+ (next_rit != end &&
+ next_rit->par() != rit->par())) {
// insert a new row
++z;
Row newrow(rit->par(), z);
- rit = rowlist_.insert(boost::next(rit), newrow);
+ rit = rowlist_.insert(next_rit, newrow);
} else {
++rit;
++z;
LyXLayout_ptr const & layout = cursor.par()->layout();
// this is only allowed, if the current paragraph is not empty or caption
- // and if it has not the keepempty flag aktive
- if (cursor.par()->empty()
- && layout->labeltype != LABEL_SENSITIVE
- && !layout->keepempty)
+ // and if it has not the keepempty flag active
+ if (cursor.par()->empty() && !cursor.par()->allowEmpty()
+ && layout->labeltype != LABEL_SENSITIVE)
return;
- setUndo(bv(), Undo::FINISH, &*cursor.par(), &*boost::next(cursor.par()));
+ setUndo(bv(), Undo::FINISH, cursor.par());
// Always break behind a space
//
// breakParagraph call should return a bool if it inserts the
// paragraph before or behind and we should react on that one
// but we can fix this in 1.3.0 (Jug 20020509)
- bool const isempty = (layout->keepempty && cursor.par()->empty());
+ bool const isempty = (cursor.par()->allowEmpty() && cursor.par()->empty());
::breakParagraph(bv()->buffer()->params, paragraphs, cursor.par(), cursor.pos(),
keep_layout);
cursor.par()->applyLayout(tclass.defaultLayout());
else
// set to standard-layout
- cursor.par()->next()->applyLayout(tclass.defaultLayout());
+ boost::next(cursor.par())->applyLayout(tclass.defaultLayout());
}
// if the cursor is at the beginning of a row without prior newline,
// Do not forget the special right address boxes
if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
RowList::iterator r = cursor.row();
- while (r != rows().begin() && boost::prior(r)->par() == r->par()) {
+ RowList::iterator beg = rows().begin();
+
+ while (r != beg && boost::prior(r)->par() == r->par()) {
--r;
y -= r->height();
}
// When ::breakParagraph is called from within an inset we must
// ensure that the correct ParagraphList is used. Today that is not
// the case and the Buffer::paragraphs is used. Not good. (Lgb)
- while (!cursor.par()->next()->empty()
- && cursor.par()->next()->isNewline(0))
- cursor.par()->next()->erase(0);
+ ParagraphList::iterator next_par = boost::next(cursor.par());
+
+ while (!next_par->empty() && next_par->isNewline(0))
+ next_par->erase(0);
- insertParagraph(cursor.par()->next(), boost::next(cursor.row()));
+ insertParagraph(next_par, boost::next(cursor.row()));
updateCounters();
// This check is necessary. Otherwise the new empty paragraph will
// be deleted automatically. And it is more friendly for the user!
if (cursor.pos() || isempty)
- setCursor(boost::next(cursor.par()), 0);
+ setCursor(next_par, 0);
else
setCursor(cursor.par(), 0);
// same Paragraph one to the right and make a rebreak
void LyXText::insertChar(char c)
{
- setUndo(bv(), Undo::INSERT, &*cursor.par(), &*boost::next(cursor.par()));
+ setUndo(bv(), Undo::INSERT, cursor.par());
// When the free-spacing option is set for the current layout,
// disable the double-space checking
cursor.par()->isNewline(cursor.pos() - 2))
) {
setCharFont(bv()->buffer(),
- &*cursor.par(),
+ cursor.par(),
cursor.pos() - 1,
current_font);
} else if (contains(number_seperators, c) &&
// Here case LyXText::InsertInset already insertet the character
cursor.par()->insertChar(cursor.pos(), c);
}
- setCharFont(bv()->buffer(), &*cursor.par(), cursor.pos(), rawtmpfont);
+ setCharFont(bv()->buffer(), cursor.par(), cursor.pos(), rawtmpfont);
if (!jumped_over_space) {
// refresh the positions
false, cursor.boundary());
// cursor MUST be in row now.
- if (boost::next(row) != rows().end() &&
- boost::next(row)->par() == row->par())
- need_break_row = boost::next(row);
+ RowList::iterator next_row = boost::next(row);
+ if (next_row != rows().end() &&
+ next_row->par() == row->par())
+ need_break_row = next_row;
else
need_break_row = rows().end();
if (c == Paragraph::META_INSET || row->fill() < 0) {
postPaint(y);
breakAgainOneRow(row);
+
+ RowList::iterator next_row = boost::next(row);
+
// will the cursor be in another row now?
if (lastPos(*this, row) <= cursor.pos() + 1 &&
- boost::next(row) != rows().end()) {
- if (boost::next(row) != rows().end() &&
- boost::next(row)->par() == row->par())
+ next_row != rows().end()) {
+ if (next_row != rows().end() &&
+ next_row->par() == row->par()) {
// this should always be true
++row;
+ }
+
breakAgainOneRow(row);
}
current_font = rawtmpfont;
!= cursor.boundary())
setCursor(cursor.par(), cursor.pos(), false,
!cursor.boundary());
- if (boost::next(row) != rows().end() &&
- boost::next(row)->par() == row->par())
- need_break_row = boost::next(row);
+
+ next_row = boost::next(row);
+
+ if (next_row != rows().end() &&
+ next_row->par() == row->par())
+ need_break_row = next_row;
else
need_break_row = rows().end();
} else {
void LyXText::charInserted()
{
// Here we could call FinishUndo for every 20 characters inserted.
- // This is from my experience how emacs does it.
+ // This is from my experience how emacs does it. (Lgb)
static unsigned int counter;
if (counter < 20) {
++counter;
float & fill_label_hfill,
bool bidi) const
{
- float nlh;
-
float w = rit->fill();
fill_hfill = 0;
fill_label_hfill = 0;
fill_separator = 0;
fill_label_hfill = 0;
+ ParagraphList::iterator pit = rit->par();
+
bool const is_rtl =
- rit->par()->isRightToLeftPar(bv()->buffer()->params);
+ pit->isRightToLeftPar(bv()->buffer()->params);
if (is_rtl) {
x = (workWidth() > 0)
? rightMargin(*bv()->buffer(), *rit) : 0;
? leftMargin(*rit) : 0;
// is there a manual margin with a manual label
- LyXLayout_ptr const & layout = rit->par()->layout();
+ LyXLayout_ptr const & layout = pit->layout();
if (layout->margintype == MARGIN_MANUAL
&& layout->labeltype == LABEL_MANUAL) {
/// We might have real hfills in the label part
- nlh = numberOfLabelHfills(*this, rit);
+ float nlh = numberOfLabelHfills(*this, rit);
// A manual label par (e.g. List) has an auto-hfill
// between the label text and the body of the
// paragraph too.
// But we don't want to do this auto hfill if the par
// is empty.
- if (!rit->par()->empty())
+ if (!pit->empty())
++nlh;
- if (nlh && !rit->par()->getLabelWidthString().empty()) {
+ if (nlh && !pit->getLabelWidthString().empty()) {
fill_label_hfill = labelFill(*rit) / nlh;
}
}
// is it block, flushleft or flushright?
// set x how you need it
int align;
- if (rit->par()->params().align() == LYX_ALIGN_LAYOUT) {
+ if (pit->params().align() == LYX_ALIGN_LAYOUT) {
align = layout->align;
} else {
- align = rit->par()->params().align();
+ align = pit->params().align();
}
// center displayed insets
Inset * inset = 0;
- if (rit->pos() < rit->par()->size()
- && rit->par()->isInset(rit->pos())
- && (inset = rit->par()->getInset(rit->pos()))
+ if (rit->pos() < pit->size()
+ && pit->isInset(rit->pos())
+ && (inset = pit->getInset(rit->pos()))
&& (inset->display())) // || (inset->scroll() < 0)))
align = (inset->lyxCode() == Inset::MATHMACRO_CODE)
? LYX_ALIGN_BLOCK : LYX_ALIGN_CENTER;
// ERT insets should always be LEFT ALIGNED on screen
- inset = rit->par()->inInset();
+ inset = pit->inInset();
if (inset && inset->owner() &&
inset->owner()->lyxCode() == Inset::ERT_CODE)
{
{
float const ns = numberOfSeparators(*this, rit);
RowList::iterator next_row = boost::next(rit);
+ ParagraphList::iterator next_pit = next_row->par();
if (ns && next_row != rowlist_.end() &&
- next_row->par() == rit->par() &&
- !(next_row->par()->isNewline(next_row->pos() - 1))
- && !(next_row->par()->isInset(next_row->pos()) &&
- next_row->par()->getInset(next_row->pos()) &&
- next_row->par()->getInset(next_row->pos())->display())
+ next_pit == pit &&
+ !(next_pit->isNewline(next_row->pos() - 1))
+ && !(next_pit->isInset(next_row->pos()) &&
+ next_pit->getInset(next_row->pos()) &&
+ next_pit->getInset(next_row->pos())->display())
) {
fill_separator = w / ns;
} else if (is_rtl) {
computeBidiTables(bv()->buffer(), rit);
if (is_rtl) {
- pos_type body_pos = rit->par()->beginningOfBody();
+ pos_type body_pos = pit->beginningOfBody();
pos_type last = lastPos(*this, rit);
if (body_pos > 0 &&
(body_pos - 1 > last ||
- !rit->par()->isLineSeparator(body_pos - 1))) {
+ !pit->isLineSeparator(body_pos - 1))) {
x += font_metrics::width(layout->labelsep,
getLabelFont(bv()->buffer(),
- rit->par()));
+ pit));
if (body_pos - 1 <= last)
x += fill_label_hfill;
}
void LyXText::cursorRightOneWord()
{
// treat floats, HFills and Insets as words
- LyXCursor tmpcursor = cursor;
+ ParagraphList::iterator pit = cursor.par();
+ pos_type pos = cursor.pos();
+
// CHECK See comment on top of text.C
- if (tmpcursor.pos() == tmpcursor.par()->size()
- && tmpcursor.par()->next()) {
- tmpcursor.par(tmpcursor.par()->next());
- tmpcursor.pos(0);
+ if (pos == pit->size()
+ && boost::next(pit) != ownerParagraphs().end()) {
+ ++pit;
+ pos = 0;
} else {
- int steps = 0;
-
// Skip through initial nonword stuff.
- while (tmpcursor.pos() < tmpcursor.par()->size() &&
- ! tmpcursor.par()->isWord(tmpcursor.pos())) {
- // printf("Current pos1 %d", tmpcursor.pos()) ;
- tmpcursor.pos(tmpcursor.pos() + 1);
- ++steps;
+ while (pos < pit->size() && !pit->isWord(pos)) {
+ ++pos;
}
// Advance through word.
- while (tmpcursor.pos() < tmpcursor.par()->size() &&
- tmpcursor.par()->isWord(tmpcursor.pos())) {
- // printf("Current pos2 %d", tmpcursor.pos()) ;
- tmpcursor.pos(tmpcursor.pos() + 1);
- ++steps;
+ while (pos < pit->size() && pit->isWord(pos)) {
+ ++pos;
}
}
- setCursor(tmpcursor.par(), tmpcursor.pos());
+ setCursor(pit, pos);
}
void LyXText::cursorLeftOneWord(LyXCursor & cur)
{
// treat HFills, floats and Insets as words
- cur = cursor;
- while (cur.pos()
- && (cur.par()->isSeparator(cur.pos() - 1)
- || cur.par()->isKomma(cur.pos() - 1)
- || cur.par()->isNewline(cur.pos() - 1))
- && !(cur.par()->isHfill(cur.pos() - 1)
- || cur.par()->isInset(cur.pos() - 1)))
- cur.pos(cur.pos() - 1);
-
- if (cur.pos()
- && (cur.par()->isInset(cur.pos() - 1)
- || cur.par()->isHfill(cur.pos() - 1))) {
- cur.pos(cur.pos() - 1);
- } else if (!cur.pos()) {
- if (cur.par() != ownerParagraphs().begin()) {
- cur.par(boost::prior(cur.par()));
- cur.pos(cur.par()->size());
+
+ ParagraphList::iterator pit = cursor.par();
+ pos_type pos = cursor.pos();
+
+ while (pos &&
+ (pit->isSeparator(pos - 1) ||
+ pit->isKomma(pos - 1) ||
+ pit->isNewline(pos - 1)) &&
+ !(pit->isHfill(pos - 1) ||
+ pit->isInset(pos - 1)))
+ --pos;
+
+ if (pos &&
+ (pit->isInset(pos - 1) ||
+ pit->isHfill(pos - 1))) {
+ --pos;
+ } else if (!pos) {
+ if (pit != ownerParagraphs().begin()) {
+ --pit;
+ pos = pit->size();
}
} else { // Here, cur != 0
- while (cur.pos() > 0 &&
- cur.par()->isWord(cur.pos() - 1))
- cur.pos(cur.pos() - 1);
+ while (pos > 0 &&
+ pit->isWord(pos - 1))
+ --pos;
}
+
+ cur.par(pit);
+ cur.pos(pos);
}
if (!selection.set() && cursor.par()->size())
return;
- bv()->hideCursor();
-
if (selection.start.par() == selection.end.par()) {
LyXCursor & startc = selection.start;
LyXCursor & endc = selection.end;
- setUndo(bv(), Undo::INSERT, &*startc.par(), &*boost::next(startc.par()));
+ setUndo(bv(), Undo::INSERT, startc.par());
startc.par()->acceptChange(startc.pos(), endc.pos());
finishUndo();
clearSelection();
if (!selection.set() && cursor.par()->size())
return;
- bv()->hideCursor();
-
if (selection.start.par() == selection.end.par()) {
LyXCursor & startc = selection.start;
LyXCursor & endc = selection.end;
- setUndo(bv(), Undo::INSERT, &*startc.par(),
- &*boost::next(startc.par()));
+ setUndo(bv(), Undo::INSERT, startc.par());
startc.par()->rejectChange(startc.pos(), endc.pos());
finishUndo();
clearSelection();
- redoParagraphs(startc, startc.par()->next());
+ redoParagraphs(startc, boost::next(startc.par()));
setCursorIntern(startc.par(), 0);
}
#warning handle multi par selection
}
// we have to go on checking so move cursor to the next char
if (cursor.pos() == cursor.par()->size()) {
- if (!cursor.par()->next())
+ if (boost::next(cursor.par()) == ownerParagraphs().end())
return word;
- cursor.par(cursor.par()->next());
+ cursor.par(boost::next(cursor.par()));
cursor.pos(0);
} else
cursor.pos(cursor.pos() + 1);
if (cursor.pos() < cursor.par()->size() &&
cursor.par()->isInset(cursor.pos())) {
// lock the inset!
- cursor.par()->getInset(cursor.pos())->edit(bv());
+ FuncRequest cmd(bv(), LFUN_INSET_EDIT, "left");
+ cursor.par()->getInset(cursor.pos())->localDispatch(cmd);
// now call us again to do the above trick
// but obviously we have to start from down below ;)
return bv()->text->selectNextWordToSpellcheck(value);
lyx::Assert(from <= to);
- setUndo(bv(), Undo::FINISH, &*from.par(), &*boost::next(to.par()));
+ setUndo(bv(), Undo::FINISH, from.par(), to.par());
pos_type pos = from.pos();
ParagraphList::iterator pit = from.par();
}
#warning changes
pit->setChar(pos, c);
- checkParagraph(&*pit, pos);
+ checkParagraph(pit, pos);
++pos;
}
LyXCursor tmpcursor = cursor;
// to make sure undo gets the right cursor position
cursor = old_cursor;
- setUndo(bv(), Undo::DELETE,
- &*cursor.par(), &*boost::next(cursor.par()));
+ setUndo(bv(), Undo::DELETE, cursor.par());
cursor = tmpcursor;
backspace();
}
if (cursor.par() != ownerParagraphs().begin()) {
setUndo(bv(), Undo::DELETE,
- &*boost::prior(cursor.par()),
- &*boost::next(cursor.par()));
+ boost::prior(cursor.par()),
+ cursor.par());
}
ParagraphList::iterator tmppit = cursor.par();
} else {
// this is the code for a normal backspace, not pasting
// any paragraphs
- setUndo(bv(), Undo::DELETE,
- &*cursor.par(), &*boost::next(cursor.par()));
+ setUndo(bv(), Undo::DELETE, cursor.par());
// We used to do cursorLeftIntern() here, but it is
// not a good idea since it triggers the auto-delete
// mechanism. So we do a cursorLeftIntern()-lite,
if (cursor.pos() < lastPos(*this, row) ||
!cursor.par()->isLineSeparator(cursor.pos())) {
row->fill(row->fill() + singleWidth(
- &*cursor.par(),
+ cursor.par(),
cursor.pos()));
}
if (cursor.pos() < cursor.par()->size()
&& !cursor.par()->isSeparator(cursor.pos())) {
cursor.par()->insertChar(cursor.pos(), ' ');
- setCharFont(bv()->buffer(), &*cursor.par(),
+ setCharFont(bv()->buffer(), cursor.par(),
cursor.pos(), current_font);
// refresh the positions
tmprow = row;