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