From 2f8967b43b1b76239673e57aff8f3486f42bd31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Vigna?= Date: Sun, 17 Jul 2005 16:12:48 +0000 Subject: [PATCH] bug 575: allow merging of paragraphs by Delete/Backspace with the same Layout git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10294 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 +++++ src/text.C | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 32ccda9556..c364b1591a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2005-07-17 Juergen Vigna + + * text.C (Delete, backspace): fixed so that paragraph with the + same layout can be merged by Delete/Backspace. + 2005-07-17 Michael Schmitt * text.C (readParToken): fix spelling. diff --git a/src/text.C b/src/text.C index b047b618e0..63b5d4a91d 100644 --- a/src/text.C +++ b/src/text.C @@ -1549,12 +1549,22 @@ void LyXText::changeCase(LCursor & cur, LyXText::TextCase action) void LyXText::Delete(LCursor & cur) { BOOST_ASSERT(this == cur.text()); + if (cur.pos() != cur.lastpos()) { recordUndo(cur, Undo::DELETE, cur.pit()); setCursorIntern(cur, cur.pit(), cur.pos() + 1, false, cur.boundary()); backspace(cur); + } else if (cur.pit() != cur.lastpit()) { + LCursor scur = cur; + + setCursorIntern(cur, cur.pit()+1, 0, false, false); + if (pars_[cur.pit()].layout() == pars_[scur.pit()].layout()) { + recordUndo(scur, Undo::DELETE, scur.pit()); + backspace(cur); + } else { + setCursorIntern(scur, scur.pit(), scur.pos(), false, scur.boundary()); + } } - // should we do anything in an else branch? } @@ -1617,6 +1627,7 @@ void LyXText::backspace(LCursor & cur) // layout. I think it is a real bug of all other // word processors to allow it. It confuses the user. // Correction: Pasting is always allowed with standard-layout + // Correction (Jug 20050717): Remove check about alignment! Buffer & buf = cur.buffer(); BufferParams const & bufparams = buf.params(); LyXTextClass const & tclass = bufparams.getLyXTextClass(); @@ -1624,8 +1635,8 @@ void LyXText::backspace(LCursor & cur) if (cpit != tmppit && (pars_[cpit].layout() == pars_[tmppit].layout() - || pars_[tmppit].layout() == tclass.defaultLayout()) - && pars_[cpit].getAlign() == pars_[tmppit].getAlign()) { + || pars_[tmppit].layout() == tclass.defaultLayout())) + { mergeParagraph(bufparams, pars_, cpit); if (cur.pos() != 0 && pars_[cpit].isSeparator(cur.pos() - 1))