On Fri, Dec 16, 2005 at 12:41:04PM +0100, Jean-Marc Lasgouttes wrote: > >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes: > > Martin> The really intended patch attached (curse Evo for not > Martin> displaying outgoing attachments!) > > It looks much better. LyXText::backspace could probably be modifed to > return true when an update is needed (or maybe set cur.needsUpdate() > directly, would that work?). > > You can apply it.
The other part of this patch reworked and tested. (Now I had to include Delete :-) More code, but a lot clearer. OK to go in? - Martin
Index: lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.332
diff -u -p -r1.332 lyxtext.h
--- lyxtext.h 6 Dec 2005 14:54:21 -0000 1.332
+++ lyxtext.h 17 Dec 2005 21:21:56 -0000
@@ -221,9 +221,9 @@ public:
///
void cursorBottom(LCursor & cur);
///
- void Delete(LCursor & cur);
+ bool Delete(LCursor & cur);
///
- void backspace(LCursor & cur);
+ bool backspace(LCursor & cur);
///
bool selectWordWhenUnderCursor(LCursor & cur, lyx::word_location);
///
Index: text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.637
diff -u -p -r1.637 text.C
--- text.C 6 Dec 2005 14:54:21 -0000 1.637
+++ text.C 17 Dec 2005 21:21:57 -0000
@@ -1534,31 +1534,34 @@ void LyXText::changeCase(LCursor & cur,
}
-void LyXText::Delete(LCursor & cur)
+bool LyXText::Delete(LCursor & cur)
{
BOOST_ASSERT(this == cur.text());
+ bool needsUpdate(false);
if (cur.pos() != cur.lastpos()) {
recordUndo(cur, Undo::DELETE, cur.pit());
setCursorIntern(cur, cur.pit(), cur.pos() + 1, false,
cur.boundary());
- backspace(cur);
+ needsUpdate = 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);
+ needsUpdate = backspace(cur);
} else {
setCursorIntern(scur, scur.pit(), scur.pos(), false,
scur.boundary());
}
}
+ return needsUpdate;
}
-void LyXText::backspace(LCursor & cur)
+bool LyXText::backspace(LCursor & cur)
{
BOOST_ASSERT(this == cur.text());
+ bool needsUpdate(false);
if (cur.pos() == 0) {
// The cursor is at the beginning of a paragraph, so
// the the backspace will collapse two paragraphs into
@@ -1567,7 +1570,7 @@ void LyXText::backspace(LCursor & cur)
// but it's not allowed unless it's new
Paragraph & par = cur.paragraph();
if (par.isChangeEdited(0, par.size()))
- return;
+ return false;
// we may paste some paragraphs
@@ -1592,7 +1595,7 @@ void LyXText::backspace(LCursor & cur)
}
cursorLeft(cur);
- return;
+ return true;
}
}
@@ -1626,6 +1629,7 @@ void LyXText::backspace(LCursor & cur)
|| pars_[tmppit].layout() == tclass.defaultLayout()))
{
mergeParagraph(bufparams, pars_, cpit);
+ needsUpdate = true;
if (cur.pos() != 0 && pars_[cpit].isSeparator(cur.pos()
- 1))
--cur.pos();
@@ -1651,6 +1655,8 @@ void LyXText::backspace(LCursor & cur)
setCurrentFont(cur);
setCursor(cur, cur.pit(), cur.pos(), false, cur.boundary());
+
+ return needsUpdate;
}
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.321
diff -u -p -r1.321 text3.C
--- text3.C 1 Dec 2005 10:28:49 -0000 1.321
+++ text3.C 17 Dec 2005 21:21:58 -0000
@@ -621,7 +621,7 @@ void LyXText::dispatch(LCursor & cur, Fu
case LFUN_DELETE:
if (!cur.selection()) {
- Delete(cur);
+ needsUpdate = Delete(cur);
cur.resetAnchor();
// It is possible to make it a lot faster still
// just comment out the line below...
@@ -649,7 +649,7 @@ void LyXText::dispatch(LCursor & cur, Fu
case LFUN_BACKSPACE:
if (!cur.selection()) {
if
(bv->owner()->getIntl().getTransManager().backspace()) {
- backspace(cur);
+ needsUpdate = backspace(cur);
cur.resetAnchor();
// It is possible to make it a lot faster still
// just comment out the line below...
pgpgjubm5Hpv4.pgp
Description: PGP signature
