mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
make redoParagraph more independent of current cursor
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7470 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
aa848b8ccf
commit
5eb1059f50
@ -625,8 +625,7 @@ bool BufferView::ChangeInsets(InsetOld::Code code,
|
||||
// How to set the cursor corretly when it.size()>1 ??
|
||||
if (it.size() == 1) {
|
||||
text->setCursorIntern(it.pit(), 0);
|
||||
text->redoParagraphs(text->cursor,
|
||||
boost::next(text->cursor.par()));
|
||||
text->redoParagraph(text->cursor.par());
|
||||
text->partialRebreak();
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,13 @@
|
||||
|
||||
* buffer.[Ch]: file_format is no longer a buffer data element.
|
||||
|
||||
2003-08-01 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* BufferView.C:
|
||||
* lyxtext.h:
|
||||
* text.C:
|
||||
* text2.C: make redoParagraph more independent of current cursor
|
||||
|
||||
2003-07-30 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* paragraph.[Ch] (copyIntoMinibuffer): removed unused function
|
||||
|
@ -289,8 +289,8 @@ bool InsetCollapsable::hitButton(FuncRequest const & cmd) const
|
||||
|
||||
InsetOld::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd)
|
||||
{
|
||||
lyxerr << "InsetCollapsable::localDispatch: "
|
||||
<< cmd.action << " '" << cmd.argument << "'\n";
|
||||
//lyxerr << "InsetCollapsable::localDispatch: "
|
||||
// << cmd.action << " '" << cmd.argument << "'\n";
|
||||
BufferView * bv = cmd.view();
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_EDIT: {
|
||||
|
@ -131,15 +131,15 @@ public:
|
||||
*/
|
||||
void setFont(LyXFont const &, bool toggleall = false);
|
||||
|
||||
/** deletes and inserts again all paragaphs between the cursor
|
||||
and the specified par. The Cursor is needed to set the refreshing
|
||||
parameters.
|
||||
This function is needed after SetLayout and SetFont etc.
|
||||
*/
|
||||
void redoParagraphs(LyXCursor const & cursor,
|
||||
ParagraphList::iterator endpit);
|
||||
///
|
||||
/// rebreaks all paragaphs between the given pars.
|
||||
void redoParagraphs(ParagraphList::iterator begin,
|
||||
ParagraphList::iterator end);
|
||||
/// rebreaks the given par
|
||||
void redoParagraph(ParagraphList::iterator pit);
|
||||
/// rebreaks the cursor par
|
||||
void redoParagraph();
|
||||
/// returns first row belongin to some par
|
||||
RowList::iterator firstRow(ParagraphList::iterator pit);
|
||||
|
||||
///
|
||||
void toggleFree(LyXFont const &, bool toggleall = false);
|
||||
|
@ -1579,7 +1579,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
||||
void LyXText::redoParagraph()
|
||||
{
|
||||
clearSelection();
|
||||
redoParagraphs(cursor, boost::next(cursor.par()));
|
||||
redoParagraph(cursor.par());
|
||||
setCursorIntern(cursor.par(), cursor.pos());
|
||||
}
|
||||
|
||||
@ -2007,7 +2007,7 @@ void LyXText::acceptChange()
|
||||
startc.par()->acceptChange(startc.pos(), endc.pos());
|
||||
finishUndo();
|
||||
clearSelection();
|
||||
redoParagraphs(startc, boost::next(startc.par()));
|
||||
redoParagraph(startc.par());
|
||||
setCursorIntern(startc.par(), 0);
|
||||
}
|
||||
#warning handle multi par selection
|
||||
@ -2026,7 +2026,7 @@ void LyXText::rejectChange()
|
||||
startc.par()->rejectChange(startc.pos(), endc.pos());
|
||||
finishUndo();
|
||||
clearSelection();
|
||||
redoParagraphs(startc, boost::next(startc.par()));
|
||||
redoParagraph(startc.par());
|
||||
setCursorIntern(startc.par(), 0);
|
||||
}
|
||||
#warning handle multi par selection
|
||||
|
85
src/text2.C
85
src/text2.C
@ -443,7 +443,7 @@ void LyXText::setLayout(string const & layout)
|
||||
|
||||
ParagraphList::iterator endpit = setLayout(cursor, selection.start,
|
||||
selection.end, layout);
|
||||
redoParagraphs(selection.start, endpit);
|
||||
redoParagraphs(selection.start.par(), endpit);
|
||||
|
||||
// we have to reset the selection, because the
|
||||
// geometry could have changed
|
||||
@ -511,15 +511,12 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
|
||||
if (test_only)
|
||||
return changed;
|
||||
|
||||
// Wow, redoParagraphs is stupid.
|
||||
LyXCursor tmpcursor;
|
||||
setCursor(tmpcursor, start, 0);
|
||||
|
||||
redoParagraphs(tmpcursor, pastend);
|
||||
redoParagraphs(start, pastend);
|
||||
|
||||
// We need to actually move the text->cursor. I don't
|
||||
// understand why ...
|
||||
tmpcursor = cursor;
|
||||
LyXCursor tmpcursor = cursor;
|
||||
|
||||
// we have to reset the visual selection because the
|
||||
// geometry could have changed
|
||||
@ -589,7 +586,7 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
|
||||
}
|
||||
unFreezeUndo();
|
||||
|
||||
redoParagraphs(selection.start, boost::next(selection.end.par()));
|
||||
redoParagraph(selection.start.par());
|
||||
|
||||
// we have to reset the selection, because the
|
||||
// geometry could have changed, but we keep
|
||||
@ -621,17 +618,31 @@ void LyXText::redoHeightOfParagraph()
|
||||
}
|
||||
|
||||
|
||||
// deletes and inserts again all paragraphs between the cursor
|
||||
// and the specified par
|
||||
// This function is needed after SetLayout and SetFont etc.
|
||||
void LyXText::redoParagraphs(LyXCursor const & cur,
|
||||
ParagraphList::iterator endpit)
|
||||
RowList::iterator LyXText::firstRow(ParagraphList::iterator pit)
|
||||
{
|
||||
RowList::iterator tmprit = getRow(cur);
|
||||
RowList::iterator rit;
|
||||
for (rit = rows().begin(); rit != rows().end(); ++rit)
|
||||
if (rit->par() == pit)
|
||||
break;
|
||||
return rit;
|
||||
}
|
||||
|
||||
|
||||
// rebreaks all paragraphs between the specified pars
|
||||
// This function is needed after SetLayout and SetFont etc.
|
||||
void LyXText::redoParagraphs(ParagraphList::iterator start,
|
||||
ParagraphList::iterator endpit)
|
||||
{
|
||||
RowList::iterator rit = firstRow(start);
|
||||
|
||||
if (rit == rows().end()) {
|
||||
lyxerr << "LyXText::redoParagraphs: should not happen\n";
|
||||
Assert(0);
|
||||
}
|
||||
|
||||
ParagraphList::iterator first_phys_pit;
|
||||
RowList::iterator prevrit;
|
||||
if (tmprit == rows().begin()) {
|
||||
if (rit == rows().begin()) {
|
||||
// A trick/hack for UNDO.
|
||||
// This is needed because in an UNDO/REDO we could have
|
||||
// changed the ownerParagraph() so the paragraph inside
|
||||
@ -640,30 +651,28 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
|
||||
first_phys_pit = ownerParagraphs().begin();
|
||||
prevrit = rows().end();
|
||||
} else {
|
||||
first_phys_pit = tmprit->par();
|
||||
while (tmprit != rows().begin()
|
||||
&& boost::prior(tmprit)->par() == first_phys_pit)
|
||||
first_phys_pit = rit->par();
|
||||
while (rit != rows().begin()
|
||||
&& boost::prior(rit)->par() == first_phys_pit)
|
||||
{
|
||||
--tmprit;
|
||||
--rit;
|
||||
}
|
||||
prevrit = boost::prior(tmprit);
|
||||
prevrit = boost::prior(rit);
|
||||
}
|
||||
|
||||
// remove it
|
||||
while (tmprit != rows().end() && tmprit->par() != endpit) {
|
||||
RowList::iterator tmprit2 = tmprit++;
|
||||
removeRow(tmprit2);
|
||||
while (rit != rows().end() && rit->par() != endpit) {
|
||||
RowList::iterator rit2 = rit++;
|
||||
removeRow(rit2);
|
||||
}
|
||||
|
||||
// Reinsert the paragraphs.
|
||||
ParagraphList::iterator tmppit = first_phys_pit;
|
||||
|
||||
while (tmppit != ownerParagraphs().end()) {
|
||||
insertParagraph(tmppit, tmprit);
|
||||
while (tmprit != rows().end()
|
||||
&& tmprit->par() == tmppit) {
|
||||
++tmprit;
|
||||
}
|
||||
insertParagraph(tmppit, rit);
|
||||
while (rit != rows().end() && rit->par() == tmppit)
|
||||
++rit;
|
||||
++tmppit;
|
||||
if (tmppit == endpit)
|
||||
break;
|
||||
@ -673,13 +682,19 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
|
||||
else
|
||||
setHeightOfRow(rows().begin());
|
||||
postPaint();
|
||||
if (tmprit != rows().end())
|
||||
setHeightOfRow(tmprit);
|
||||
if (rit != rows().end())
|
||||
setHeightOfRow(rit);
|
||||
|
||||
updateCounters();
|
||||
}
|
||||
|
||||
|
||||
void LyXText::redoParagraph(ParagraphList::iterator pit)
|
||||
{
|
||||
redoParagraphs(pit, boost::next(pit));
|
||||
}
|
||||
|
||||
|
||||
void LyXText::fullRebreak()
|
||||
{
|
||||
init(bv());
|
||||
@ -948,7 +963,7 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
|
||||
}
|
||||
postPaint();
|
||||
|
||||
redoParagraphs(selection.start, endpit);
|
||||
redoParagraphs(selection.start.par(), endpit);
|
||||
|
||||
clearSelection();
|
||||
setCursor(selection.start.par(), selection.start.pos());
|
||||
@ -1279,7 +1294,7 @@ void LyXText::cutSelection(bool doclear, bool realcut)
|
||||
if (doclear)
|
||||
selection.start.par()->stripLeadingSpaces();
|
||||
|
||||
redoParagraphs(selection.start, boost::next(endpit));
|
||||
redoParagraphs(selection.start.par(), boost::next(endpit));
|
||||
#warning FIXME latent bug
|
||||
// endpit will be invalidated on redoParagraphs once ParagraphList
|
||||
// becomes a std::list? There are maybe other places on which this
|
||||
@ -1347,7 +1362,7 @@ void LyXText::pasteSelection(size_t sel_index)
|
||||
bufferErrors(*bv()->buffer(), el);
|
||||
bv()->showErrorList(_("Paste"));
|
||||
|
||||
redoParagraphs(cursor, endpit);
|
||||
redoParagraphs(cursor.par(), endpit);
|
||||
|
||||
setCursor(cursor.par(), cursor.pos());
|
||||
clearSelection();
|
||||
@ -1417,7 +1432,7 @@ void LyXText::insertStringAsLines(string const & str)
|
||||
|
||||
bv()->buffer()->insertStringAsLines(pit, pos, current_font, str);
|
||||
|
||||
redoParagraphs(cursor, endpit);
|
||||
redoParagraphs(cursor.par(), endpit);
|
||||
setCursor(cursor.par(), cursor.pos());
|
||||
selection.cursor = cursor;
|
||||
setCursor(pit, pos);
|
||||
@ -2067,7 +2082,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
||||
&& old_cursor.par()->isLineSeparator(old_cursor.pos())
|
||||
&& old_cursor.par()->isLineSeparator(old_cursor.pos() - 1)) {
|
||||
old_cursor.par()->erase(old_cursor.pos() - 1);
|
||||
redoParagraphs(old_cursor, boost::next(old_cursor.par()));
|
||||
redoParagraph(old_cursor.par());
|
||||
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning This will not work anymore when we have multiple views of the same buffer
|
||||
@ -2185,7 +2200,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
||||
}
|
||||
if (!deleted) {
|
||||
if (old_cursor.par()->stripLeadingSpaces()) {
|
||||
redoParagraphs(old_cursor, boost::next(old_cursor.par()));
|
||||
redoParagraph(old_cursor.par());
|
||||
// correct cursor y
|
||||
setCursorIntern(cursor.par(), cursor.pos());
|
||||
selection.cursor = cursor;
|
||||
|
Loading…
Reference in New Issue
Block a user