mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
bnext-2.diff + some more boost::next stuff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7188 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9740810c16
commit
e20c467a98
@ -1,5 +1,19 @@
|
||||
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.
|
||||
|
||||
|
@ -1,3 +1,17 @@
|
||||
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
|
||||
|
@ -519,8 +519,7 @@ string const InsetERT::get_new_label() const
|
||||
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()) {
|
||||
|
@ -453,8 +453,7 @@ void InsetText::update(BufferView * bv, bool reinit)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!autoBreakRows &&
|
||||
boost::next(paragraphs.begin()) != paragraphs.end())
|
||||
if (!autoBreakRows && paragraphs.size() > 1)
|
||||
collapseParagraphs(bv);
|
||||
|
||||
if (the_locking_inset) {
|
||||
@ -516,14 +515,8 @@ void InsetText::setUpdateStatus(BufferView * bv, int what) const
|
||||
|
||||
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) {
|
||||
@ -591,10 +584,11 @@ void InsetText::insetUnlock(BufferView * bv)
|
||||
} 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;
|
||||
@ -625,8 +619,7 @@ void InsetText::lockInset(BufferView * bv)
|
||||
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));
|
||||
@ -729,11 +722,12 @@ bool InsetText::unlockInsetInInset(BufferView * bv, UpdatableInset * inset,
|
||||
|
||||
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);
|
||||
@ -1010,8 +1004,8 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
// 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));
|
||||
@ -1045,7 +1039,8 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
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)
|
||||
@ -1425,7 +1420,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
/// 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);
|
||||
@ -1830,28 +1825,38 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
|
||||
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
|
||||
@ -2171,8 +2176,8 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
|
||||
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);
|
||||
@ -2180,6 +2185,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
|
||||
restoreLyXTextState(t);
|
||||
return;
|
||||
}
|
||||
|
||||
// one endless line, resize normally not necessary
|
||||
if (!force && getMaxWidth(bv, this) < 0)
|
||||
return;
|
||||
@ -2188,6 +2194,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
|
||||
if (it == cache.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
lyx::Assert(it->second.text.get());
|
||||
|
||||
LyXText * t = it->second.text.get();
|
||||
@ -2199,6 +2206,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
|
||||
|
||||
t->init(bv, true);
|
||||
restoreLyXTextState(t);
|
||||
|
||||
if (the_locking_inset) {
|
||||
inset_x = cix(bv) - top_x + drawTextXOffset;
|
||||
inset_y = ciy(bv) + drawTextYOffset;
|
||||
@ -2551,26 +2559,31 @@ void InsetText::collapseParagraphs(BufferView * bv)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
@ -452,8 +452,10 @@ void RowPainter::paintDepthBar()
|
||||
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_;
|
||||
|
27
src/text.C
27
src/text.C
@ -1731,9 +1731,10 @@ void LyXText::insertChar(char c)
|
||||
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();
|
||||
|
||||
@ -1757,13 +1758,18 @@ void LyXText::insertChar(char c)
|
||||
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;
|
||||
@ -1775,9 +1781,12 @@ void LyXText::insertChar(char c)
|
||||
!= 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 {
|
||||
|
51
src/text2.C
51
src/text2.C
@ -1243,14 +1243,16 @@ void LyXText::updateCounters()
|
||||
// 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)
|
||||
@ -1458,7 +1460,9 @@ void LyXText::replaceSelectionWithString(string const & str)
|
||||
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;
|
||||
}
|
||||
@ -1498,7 +1502,9 @@ void LyXText::insertStringAsParagraphs(string const & str)
|
||||
{
|
||||
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
|
||||
@ -1920,9 +1926,12 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
|
||||
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)
|
||||
@ -1977,10 +1986,12 @@ namespace {
|
||||
* 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())
|
||||
@ -1989,9 +2000,11 @@ namespace {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -2011,11 +2024,13 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y)
|
||||
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());
|
||||
@ -2121,10 +2136,13 @@ void LyXText::cursorUpParagraph()
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2276,8 +2294,9 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
||||
* 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);
|
||||
|
@ -343,10 +343,11 @@ void LyXText::cursorNext()
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user