2003-06-18 Lars Gullik Bjønnes <larsbj@gullik.net>
+ * text3.C (cursorNext): add tmp var
+
+ * text2.C (updateCounters): for function calling out of for clause
+ (replaceSelectionWithString): ditto
+ (insertStringAsParagraphs): ditto
+ (getColumnNearX): add tmp var
+ (setCursorFromCoordinates): add tmp var
+ (cursorDownParagraph): add tmp var
+ (deleteEmptyParagraphMechanism): add tmp var
+
+ * text.C (insertChar): add tmp var
+
+ * rowpainter.C (paintDepthBar): add tmp var
+
* CutAndPaste.C (availableSelections): potentially check all
paragraphs in a cut to fill the shown strings.
+2003-06-18 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * insettext.C (update): simplify
+ (updateLocal): remove commented code
+ (insetUnlock): simplify
+ (lockInset): simplify
+ (updateInsetInInset): simplify
+ (localDispatch): simplify
+ (setFont): simplify
+ (resizeLyXText): simplify
+ (collapseParagraphs): simplify
+
+ * insetert.C (get_new_label): simplify
+
2003-06-17 Lars Gullik Bjønnes <larsbj@lyx.org>
* insettext.C (localDispatch): handle arg to LFUN_PASTE, call
la += inset.paragraphs.begin()->getChar(j);
++i;
}
- if (boost::next(inset.paragraphs.begin()) != inset.paragraphs.end() ||
- (i > 0 && j < p_siz)) {
+ if (p_siz > 1 || (i > 0 && j < p_siz)) {
la += "...";
}
if (la.empty()) {
return;
}
- if (!autoBreakRows &&
- boost::next(paragraphs.begin()) != paragraphs.end())
+ if (!autoBreakRows && paragraphs.size() > 1)
collapseParagraphs(bv);
if (the_locking_inset) {
void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty)
{
-#if 0
- if (!autoBreakRows &&
- boost::next(paragraphs.begin()) != paragraphs.end())
- collapseParagraphs(bv);
-#else
if (!autoBreakRows && paragraphs.size() > 1)
collapseParagraphs(bv);
-#endif
bool clear = false;
if (!lt) {
} else
bv->owner()->setLayout(bv->text->cursor.par()->layout()->name());
// hack for deleteEmptyParMech
- if (!paragraphs.begin()->empty()) {
- lt->setCursor(paragraphs.begin(), 0);
- } else if (boost::next(paragraphs.begin()) != paragraphs.end()) {
- lt->setCursor(boost::next(paragraphs.begin()), 0);
+ ParagraphList::iterator first_par = paragraphs.begin();
+ if (!first_par->empty()) {
+ lt->setCursor(first_par, 0);
+ } else if (paragraphs.size() > 1) {
+ lt->setCursor(boost::next(first_par), 0);
}
if (clear)
lt = 0;
finishUndo();
// If the inset is empty set the language of the current font to the
// language to the surronding text (if different).
- if (paragraphs.begin()->empty() &&
- boost::next(paragraphs.begin()) == paragraphs.end() &&
+ if (paragraphs.begin()->empty() && paragraphs.size() == 1 &&
bv->getParentLanguage(this) != lt->current_font.language()) {
LyXFont font(LyXFont::ALL_IGNORE);
font.setLanguage(bv->getParentLanguage(this));
bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
{
- if (!autoBreakRows &&
- boost::next(paragraphs.begin()) != paragraphs.end())
+ if (!autoBreakRows && paragraphs.size() > 1)
collapseParagraphs(bv);
+
if (inset == this)
return true;
+
bool clear = false;
if (!lt) {
lt = getLyXText(bv);
// If the inset is empty set the language of the current font to the
// language to the surronding text (if different).
if (paragraphs.begin()->empty() &&
- boost::next(paragraphs.begin()) == paragraphs.end()&&
- bv->getParentLanguage(this) != lt->current_font.language())
+ paragraphs.size() == 1 &&
+ bv->getParentLanguage(this) != lt->current_font.language())
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setLanguage(bv->getParentLanguage(this));
}
bool was_empty = (paragraphs.begin()->empty() &&
- boost::next(paragraphs.begin()) == paragraphs.end());
+ paragraphs.size() == 1);
+
no_selection = false;
RESULT result = UpdatableInset::localDispatch(cmd);
if (result != UNDISPATCHED)
/// If the action has deleted all text in the inset, we need to change the
// language to the language of the surronding text.
if (!was_empty && paragraphs.begin()->empty() &&
- boost::next(paragraphs.begin()) == paragraphs.end()) {
+ paragraphs.size() == 1) {
LyXFont font(LyXFont::ALL_IGNORE);
font.setLanguage(bv->getParentLanguage(this));
setFont(bv, font, false);
the_locking_inset->setFont(bv, font, toggleall, selectall);
return;
}
- if ((boost::next(paragraphs.begin()) == paragraphs.end() &&
- paragraphs.begin()->empty()) || cpar(bv)->empty()) {
+
+ if ((paragraphs.size() == 1 && paragraphs.begin()->empty())
+ || cpar(bv)->empty()) {
getLyXText(bv)->setFont(font, toggleall);
return;
}
+
bool clear = false;
if (!lt) {
lt = getLyXText(bv);
clear = true;
}
+
if (lt->selection.set()) {
setUndo(bv, Undo::EDIT, lt->cursor.par());
}
+
if (selectall)
selectAll(bv);
+
lt->toggleFree(font, toggleall);
+
if (selectall)
lt->clearSelection();
+
bv->fitCursor();
+
bool flag = (selectall || lt->selection.set());
+
if (clear)
lt = 0;
+
if (flag)
updateLocal(bv, FULL, true);
else
return;
}
do_resize = 0;
- if (boost::next(paragraphs.begin()) == paragraphs.end() &&
- paragraphs.begin()->empty()) { // no data, resize not neccessary!
+ if (paragraphs.size() == 1 && paragraphs.begin()->empty()) {
+ // no data, resize not neccessary!
// we have to do this as a fixed width may have changed!
LyXText * t = getLyXText(bv);
saveLyXTextState(t);
restoreLyXTextState(t);
return;
}
+
// one endless line, resize normally not necessary
if (!force && getMaxWidth(bv, this) < 0)
return;
if (it == cache.end()) {
return;
}
+
lyx::Assert(it->second.text.get());
LyXText * t = it->second.text.get();
t->init(bv, true);
restoreLyXTextState(t);
+
if (the_locking_inset) {
inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
{
LyXText * llt = getLyXText(bv);
- while (boost::next(paragraphs.begin()) != paragraphs.end()) {
- if (!paragraphs.begin()->empty() &&
- !boost::next(paragraphs.begin())->empty() &&
- !paragraphs.begin()->isSeparator(paragraphs.begin()->size() - 1))
- {
- paragraphs.begin()->insertChar(paragraphs.begin()->size(), ' ');
+ while (paragraphs.size() > 1) {
+ ParagraphList::iterator first_par = paragraphs.begin();
+ ParagraphList::iterator next_par = boost::next(first_par);
+ size_t const first_par_size = first_par->size();
+
+ if (!first_par->empty() &&
+ !next_par->empty() &&
+ !first_par->isSeparator(first_par_size - 1)) {
+ first_par->insertChar(first_par_size, ' ');
}
+
if (llt->selection.set()) {
- if (llt->selection.start.par() == boost::next(paragraphs.begin())) {
- llt->selection.start.par(paragraphs.begin());
+ if (llt->selection.start.par() == next_par) {
+ llt->selection.start.par(first_par);
llt->selection.start.pos(
- llt->selection.start.pos() + paragraphs.begin()->size());
+ llt->selection.start.pos() + first_par_size);
}
- if (llt->selection.end.par() == boost::next(paragraphs.begin())) {
- llt->selection.end.par(paragraphs.begin());
+ if (llt->selection.end.par() == next_par) {
+ llt->selection.end.par(first_par);
llt->selection.end.pos(
- llt->selection.end.pos() + paragraphs.begin()->size());
+ llt->selection.end.pos() + first_par_size);
}
}
- mergeParagraph(bv->buffer()->params, paragraphs, paragraphs.begin());
+
+ mergeParagraph(bv->buffer()->params, paragraphs, first_par);
}
reinitLyXText();
}
if (row_ != text_.rows().begin())
prev_depth = boost::prior(row_)->par()->getDepth();
Paragraph::depth_type next_depth = 0;
- if (boost::next(row_) != text_.rows().end())
- next_depth = boost::next(row_)->par()->getDepth();
+
+ RowList::iterator next_row = boost::next(row_);
+ if (next_row != text_.rows().end())
+ next_depth = next_row->par()->getDepth();
for (Paragraph::depth_type i = 1; i <= depth; ++i) {
int x = (PAPER_MARGIN / 5) * i + xo_;
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 {
// CHECK if this is really needed. (Lgb)
bv()->buffer()->params.getLyXTextClass().counters().reset();
- for (; pit != ownerParagraphs().end(); ++pit) {
+ ParagraphList::iterator beg = ownerParagraphs().begin();
+ ParagraphList::iterator end = ownerParagraphs().end();
+ for (; pit != end; ++pit) {
while (rowit->par() != pit)
++rowit;
string const oldLabel = pit->params().labelString();
size_t maxdepth = 0;
- if (pit != ownerParagraphs().begin())
+ if (pit != beg)
maxdepth = boost::prior(pit)->getMaxDepthAfter();
if (pit->params().depth() > maxdepth)
selection.start.pos());
// Insert the new string
- for (string::const_iterator cit = str.begin(); cit != str.end(); ++cit) {
+ string::const_iterator cit = str.begin();
+ string::const_iterator end = str.end();
+ for (; cit != end; ++cit) {
selection.end.par()->insertChar(pos, (*cit), font);
++pos;
}
{
string linestr(str);
bool newline_inserted = false;
- for (string::size_type i = 0; i < linestr.length(); ++i) {
+ string::size_type const siz = linestr.length();
+
+ for (string::size_type i = 0; i < siz; ++i) {
if (linestr[i] == '\n') {
if (newline_inserted) {
// we know that \r will be ignored by
boundary = false;
// This (rtl_support test) is not needed, but gives
// some speedup if rtl_support=false
+ RowList::iterator next_rit = boost::next(rit);
+
bool const lastrow = lyxrc.rtl_support &&
- (boost::next(rit) == rowlist_.end() ||
- boost::next(rit)->par() != rit_par);
+ (next_rit == rowlist_.end() ||
+ next_rit->par() != rit_par);
+
// If lastrow is false, we don't need to compute
// the value of rtl.
bool const rtl = (lastrow)
* and the next row is filled by an inset that spans an entire
* row.
*/
- bool beforeFullRowInset(LyXText & lt, LyXCursor const & cur) {
+ bool beforeFullRowInset(LyXText & lt, LyXCursor const & cur)
+ {
RowList::iterator row = cur.row();
if (boost::next(row) == lt.rows().end())
return false;
+
Row const & next = *boost::next(row);
if (next.pos() != cur.pos() || next.par() != cur.par())
if (cur.pos() == cur.par()->size()
|| !cur.par()->isInset(cur.pos()))
return false;
+
Inset const * inset = cur.par()->getInset(cur.pos());
if (inset->needFullRow() || inset->display())
return true;
+
return false;
}
}
cur.row(row);
if (beforeFullRowInset(*this, cur)) {
- pos_type last = lastPrintablePos(*this, row);
- float x = getCursorX(boost::next(row), cur.pos(), last, bound);
+ pos_type const last = lastPrintablePos(*this, row);
+ RowList::iterator next_row = boost::next(row);
+
+ float x = getCursorX(next_row, cur.pos(), last, bound);
cur.ix(int(x));
- cur.iy(y + row->height() + boost::next(row)->baseline());
- cur.irow(boost::next(row));
+ cur.iy(y + row->height() + next_row->baseline());
+ cur.irow(next_row);
} else {
cur.iy(cur.y());
cur.ix(cur.x());
void LyXText::cursorDownParagraph()
{
- if (boost::next(cursor.par()) != ownerParagraphs().end()) {
- setCursor(boost::next(cursor.par()), 0);
+ ParagraphList::iterator par = cursor.par();
+ ParagraphList::iterator next_par = boost::next(par);
+
+ if (next_par != ownerParagraphs().end()) {
+ setCursor(next_par, 0);
} else {
- setCursor(cursor.par(), cursor.par()->size());
+ setCursor(par, par->size());
}
}
* the parindent that can occur or dissappear.
* The next row can change its height, if
* there is another layout before */
- if (boost::next(prevrow) != rows().end()) {
- breakAgain(boost::next(prevrow));
+ RowList::iterator tmprit = boost::next(prevrow);
+ if (tmprit != rows().end()) {
+ breakAgain(tmprit);
updateCounters();
}
setHeightOfRow(prevrow);
}
}
bv()->screen().draw(bv()->text, bv(), new_y);
- if (boost::next(cursor.row()) != rows().end()) {
+
+ RowList::iterator next_row = boost::next(cursor.row());
+ if (next_row != rows().end()) {
LyXCursor cur;
- setCursor(cur, boost::next(cursor.row())->par(),
- boost::next(cursor.row())->pos(), false);
+ setCursor(cur, next_row->par(), next_row->pos(), false);
if (cur.y() < top_y() + bv()->workHeight()) {
cursorDown(true);
}