mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
add and LyXText::undoSpan to compute the influence of a layout change.
Fix Bug 578. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8331 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fcd7023559
commit
80296aac50
@ -1,3 +1,8 @@
|
|||||||
|
2004-01-08 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
|
* text2.C (undoSpan): add and use
|
||||||
|
* text.C (breakParagraph): use undoSpan (fix bug 578)
|
||||||
|
* lyxtext.h: adjust
|
||||||
|
|
||||||
2004-01-08 Angus Leeming <leeming@lyx.org>
|
2004-01-08 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
@ -441,6 +441,10 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// return past-the-last paragraph influenced by a layout
|
||||||
|
/// change on pit
|
||||||
|
ParagraphList::iterator undoSpan(ParagraphList::iterator pit);
|
||||||
|
|
||||||
/// rebreaks the given par
|
/// rebreaks the given par
|
||||||
void redoParagraphInternal(ParagraphList::iterator pit);
|
void redoParagraphInternal(ParagraphList::iterator pit);
|
||||||
/// used in setlayout
|
/// used in setlayout
|
||||||
|
21
src/text.C
21
src/text.C
@ -596,9 +596,10 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
|
|||||||
// are taken from the layoutfont. Nicer on the screen :)
|
// are taken from the layoutfont. Nicer on the screen :)
|
||||||
LyXLayout_ptr const & layout = pit->layout();
|
LyXLayout_ptr const & layout = pit->layout();
|
||||||
|
|
||||||
// as max get the first character of this row then it can increase but not
|
// as max get the first character of this row then it can
|
||||||
// decrease the height. Just some point to start with so we don't have to
|
// increase but not decrease the height. Just some point to
|
||||||
// do the assignment below too often.
|
// start with so we don't have to do the assignment below too
|
||||||
|
// often.
|
||||||
LyXFont font = getFont(pit, row.pos());
|
LyXFont font = getFont(pit, row.pos());
|
||||||
LyXFont::FONT_SIZE const tmpsize = font.size();
|
LyXFont::FONT_SIZE const tmpsize = font.size();
|
||||||
font = getLayoutFont(pit);
|
font = getLayoutFont(pit);
|
||||||
@ -760,16 +761,16 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
|||||||
bv()->buffer()->params().getLyXTextClass();
|
bv()->buffer()->params().getLyXTextClass();
|
||||||
LyXLayout_ptr const & layout = cpit->layout();
|
LyXLayout_ptr const & layout = cpit->layout();
|
||||||
|
|
||||||
// this is only allowed, if the current paragraph is not empty or caption
|
// this is only allowed, if the current paragraph is not empty
|
||||||
// and if it has not the keepempty flag active
|
// or caption and if it has not the keepempty flag active
|
||||||
if (cpit->empty() && !cpit->allowEmpty()
|
if (cpit->empty() && !cpit->allowEmpty()
|
||||||
&& layout->labeltype != LABEL_SENSITIVE)
|
&& layout->labeltype != LABEL_SENSITIVE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
recUndo(cursor.par());
|
// a layout change may affect also the following paragraph
|
||||||
|
recUndo(cursor.par(), parOffset(undoSpan(cpit)) - 1);
|
||||||
|
|
||||||
// Always break behind a space
|
// Always break behind a space
|
||||||
//
|
|
||||||
// It is better to erase the space (Dekel)
|
// It is better to erase the space (Dekel)
|
||||||
if (cursor.pos() < cpit->size() && cpit->isLineSeparator(cursor.pos()))
|
if (cursor.pos() < cpit->size() && cpit->isLineSeparator(cursor.pos()))
|
||||||
cpit->erase(cursor.pos());
|
cpit->erase(cursor.pos());
|
||||||
@ -1289,8 +1290,9 @@ void LyXText::backspace()
|
|||||||
pos_type lastpos = pit->size();
|
pos_type lastpos = pit->size();
|
||||||
|
|
||||||
if (cursor.pos() == 0) {
|
if (cursor.pos() == 0) {
|
||||||
// The cursor is at the beginning of a paragraph,
|
// The cursor is at the beginning of a paragraph, so
|
||||||
// so the the backspace will collapse two paragraphs into one.
|
// the the backspace will collapse two paragraphs into
|
||||||
|
// one.
|
||||||
|
|
||||||
// but it's not allowed unless it's new
|
// but it's not allowed unless it's new
|
||||||
if (pit->isChangeEdited(0, pit->size()))
|
if (pit->isChangeEdited(0, pit->size()))
|
||||||
@ -1299,7 +1301,6 @@ void LyXText::backspace()
|
|||||||
// we may paste some paragraphs
|
// we may paste some paragraphs
|
||||||
|
|
||||||
// is it an empty paragraph?
|
// is it an empty paragraph?
|
||||||
|
|
||||||
if (lastpos == 0 || (lastpos == 1 && pit->isSeparator(0))) {
|
if (lastpos == 0 || (lastpos == 1 && pit->isSeparator(0))) {
|
||||||
// This is an empty paragraph and we delete it just
|
// This is an empty paragraph and we delete it just
|
||||||
// by moving the cursor one step
|
// by moving the cursor one step
|
||||||
|
53
src/text2.C
53
src/text2.C
@ -268,19 +268,33 @@ void LyXText::makeFontEntriesLayoutSpecific(BufferParams const & params,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// return past-the-last paragraph influenced by a layout change on pit
|
||||||
|
ParagraphList::iterator
|
||||||
|
LyXText::undoSpan(ParagraphList::iterator pit)
|
||||||
|
{
|
||||||
|
ParagraphList::iterator end = paragraphs().end();
|
||||||
|
ParagraphList::iterator nextpit = boost::next(pit);
|
||||||
|
if (nextpit == end)
|
||||||
|
return nextpit;
|
||||||
|
//because of parindents
|
||||||
|
if (!pit->getDepth())
|
||||||
|
return boost::next(nextpit);
|
||||||
|
//because of depth constrains
|
||||||
|
for (; nextpit != end; ++pit, ++nextpit) {
|
||||||
|
if (!pit->getDepth())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return nextpit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ParagraphList::iterator
|
ParagraphList::iterator
|
||||||
LyXText::setLayout(ParagraphList::iterator start,
|
LyXText::setLayout(ParagraphList::iterator start,
|
||||||
ParagraphList::iterator end,
|
ParagraphList::iterator end,
|
||||||
string const & layout)
|
string const & layout)
|
||||||
{
|
{
|
||||||
ParagraphList::iterator undopit = end;
|
BOOST_ASSERT(start != end);
|
||||||
ParagraphList::iterator pars_end = paragraphs().end();
|
ParagraphList::iterator undopit = undoSpan(boost::prior(end));
|
||||||
|
|
||||||
while (undopit != pars_end && undopit->getDepth())
|
|
||||||
++undopit;
|
|
||||||
//because of parindets etc
|
|
||||||
if (undopit != pars_end)
|
|
||||||
++undopit;
|
|
||||||
recUndo(parOffset(start), parOffset(undopit) - 1);
|
recUndo(parOffset(start), parOffset(undopit) - 1);
|
||||||
|
|
||||||
BufferParams const & bufparams = bv()->buffer()->params();
|
BufferParams const & bufparams = bv()->buffer()->params();
|
||||||
@ -582,16 +596,8 @@ void LyXText::setParagraph(Spacing const & spacing, LyXAlignment align,
|
|||||||
string const & labelwidthstring, bool noindent)
|
string const & labelwidthstring, bool noindent)
|
||||||
{
|
{
|
||||||
// make sure that the depth behind the selection are restored, too
|
// make sure that the depth behind the selection are restored, too
|
||||||
ParagraphList::iterator endpit = boost::next(getPar(selEnd()));
|
ParagraphList::iterator undopit = undoSpan(getPar(selEnd()));
|
||||||
ParagraphList::iterator pars_end = paragraphs().end();
|
recUndo(selStart().par(), parOffset(undopit) - 1);
|
||||||
|
|
||||||
while (endpit != pars_end && endpit->getDepth())
|
|
||||||
++endpit;
|
|
||||||
// because of parindents etc.
|
|
||||||
if (endpit != pars_end)
|
|
||||||
++endpit;
|
|
||||||
|
|
||||||
recUndo(selStart().par(), parOffset(endpit) - 1);
|
|
||||||
|
|
||||||
ParagraphList::reverse_iterator pit(getPar(selEnd().par()));
|
ParagraphList::reverse_iterator pit(getPar(selEnd().par()));
|
||||||
ParagraphList::reverse_iterator beg(getPar(selStart().par()));
|
ParagraphList::reverse_iterator beg(getPar(selStart().par()));
|
||||||
@ -615,7 +621,7 @@ void LyXText::setParagraph(Spacing const & spacing, LyXAlignment align,
|
|||||||
params.noindent(noindent);
|
params.noindent(noindent);
|
||||||
}
|
}
|
||||||
|
|
||||||
redoParagraphs(getPar(selStart()), endpit);
|
redoParagraphs(getPar(selStart()), undopit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -952,14 +958,7 @@ void LyXText::cutSelection(bool doclear, bool realcut)
|
|||||||
// make sure that the depth behind the selection are restored, too
|
// make sure that the depth behind the selection are restored, too
|
||||||
ParagraphList::iterator begpit = getPar(selStart().par());
|
ParagraphList::iterator begpit = getPar(selStart().par());
|
||||||
ParagraphList::iterator endpit = getPar(selEnd().par());
|
ParagraphList::iterator endpit = getPar(selEnd().par());
|
||||||
ParagraphList::iterator undopit = boost::next(endpit);
|
ParagraphList::iterator undopit = undoSpan(endpit);
|
||||||
ParagraphList::iterator pars_end = paragraphs().end();
|
|
||||||
|
|
||||||
while (undopit != pars_end && undopit->getDepth())
|
|
||||||
++undopit;
|
|
||||||
//because of parindents etc.
|
|
||||||
if (undopit != pars_end)
|
|
||||||
++undopit;
|
|
||||||
recUndo(selStart().par(), parOffset(undopit) - 1);
|
recUndo(selStart().par(), parOffset(undopit) - 1);
|
||||||
|
|
||||||
int endpos = selEnd().pos();
|
int endpos = selEnd().pos();
|
||||||
|
Loading…
Reference in New Issue
Block a user