On Thu, 2005-09-29 at 14:09 +0200, Jean-Marc Lasgouttes wrote: > >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes: > > Martin> Here's a better one even. Now also delete and backspace are > Martin> treated in the same way as selfinsert. > > A question: could it be possible to change needsUpdate (and thus > cur.result()) to be of type Update::flag and pass all the information > back to LyXFunc::dispatch by this channel only?
I looked at that, and gave up: it requires intrusive changes in cursor and dispatchresult. As to changing needsUpdate, there are lots of methods returning a boolean. They would all have to change. The idea is good though. > I guess what I'd like to know is whether we could avoid most explicit > calls to bv().update() from LyXText::dispatch, and also the special > casing on LFUNs names, since the LFUNs would be able to tell by > themselves what they expect. I did try something along those lines: it requires adding SingleParUpdate to LyXAction. See attached (only the relevant files included). > For example, when a LFUN requires SinglePar, the code would test > whether the metrics have changed to decide what to do. Yes, I see what you want to do... I just don't see how to do so without touching a lot of code. > It is not that I am unhappy with the patch... I propose to leave it at this, and commit it in the current state. Anything else has 'can of worms' written all over it ;-) - Martin
Index: text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.308 diff -u -p -r1.308 text3.C --- text3.C 27 Sep 2005 08:42:28 -0000 1.308 +++ text3.C 29 Sep 2005 16:57:19 -0000 @@ -294,7 +294,15 @@ void LyXText::dispatch(LCursor & cur, Fu CursorSlice oldTopSlice = cur.top(); bool oldBoundary = cur.boundary(); bool sel = cur.selection(); - bool needsUpdate = !lyxaction.funcHasFlag(cmd.action, LyXAction::NoUpdate); + // Signals that, even if needsUpdate == false, an update of the + // cursor paragraph is required + bool singleParUpdate = lyxaction.funcHasFlag(cmd.action, + LyXAction::SingleParUpdate); + // Signals that a full-screen update is required + bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action, + LyXAction::NoUpdate) || singleParUpdate); + // Remember the old paragraph metric + Dimension olddim = cur.paragraph().dim(); switch (cmd.action) { @@ -1125,13 +1133,6 @@ void LyXText::dispatch(LCursor & cur, Fu cur.resetAnchor(); moveCursor(cur, false); - - needsUpdate = redoParagraph(cur.pit()); - if (!needsUpdate) { - // update only this paragraph - cur.bv().update(Update::SinglePar | Update::Force); - } - bv->updateScrollbar(); break; } @@ -1528,6 +1529,14 @@ void LyXText::dispatch(LCursor & cur, Fu break; } + if (singleParUpdate) + // Inserting characters does not change par height + if (cur.paragraph().dim().asc == olddim.asc + && cur.paragraph().dim().des == olddim.des) { + // if so, update _only_ this paragraph + cur.bv().update(Update::SinglePar | Update::Force); + } else + needsUpdate = true; if (!needsUpdate && &oldTopSlice.inset() == &cur.inset() && oldTopSlice.idx() == cur.idx() Index: LyXAction.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v retrieving revision 1.207 diff -u -p -r1.207 LyXAction.C --- LyXAction.C 25 Jun 2005 15:57:15 -0000 1.207 +++ LyXAction.C 29 Sep 2005 16:57:19 -0000 @@ -136,9 +136,9 @@ void LyXAction::init() { LFUN_COPY, "copy", ReadOnly }, { LFUN_CUT, "cut", Noop }, { LFUN_DATE_INSERT, "date-insert", Noop }, - { LFUN_BACKSPACE, "delete-backward", Noop }, + { LFUN_BACKSPACE, "delete-backward", SingleParUpdate }, { LFUN_BACKSPACE_SKIP, "delete-backward-skip", Noop }, - { LFUN_DELETE, "delete-forward", Noop }, + { LFUN_DELETE, "delete-forward", SingleParUpdate }, { LFUN_DELETE_SKIP, "delete-forward-skip", Noop }, { LFUN_DEPTH_MIN, "depth-decrement", Noop }, { LFUN_DEPTH_PLUS, "depth-increment", Noop }, @@ -257,7 +257,7 @@ void LyXAction::init() { LFUN_PRIOR, "screen-up", ReadOnly | NoUpdate}, { LFUN_PRIORSEL, "screen-up-select", ReadOnly }, { LFUN_SCROLL_INSET, "inset-scroll", ReadOnly }, - { LFUN_SELFINSERT, "self-insert", Noop }, + { LFUN_SELFINSERT, "self-insert", SingleParUpdate }, { LFUN_SPACE_INSERT, "space-insert", Noop }, { LFUN_CHARATCURSOR, "server-char-after", ReadOnly }, { LFUN_GETFONT, "server-get-font", ReadOnly }, Index: LyXAction.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.h,v retrieving revision 1.29 diff -u -p -r1.29 LyXAction.h --- LyXAction.h 8 Feb 2005 02:06:34 -0000 1.29 +++ LyXAction.h 29 Sep 2005 16:57:19 -0000 @@ -51,7 +51,8 @@ public: ReadOnly = 1, //< can be used in RO mode (perhaps this should change) NoBuffer = 2, //< Can be used when there is no document open Argument = 4, //< Requires argument - NoUpdate = 8 //< Does not (usually) require update + NoUpdate = 8, //< Does not (usually) require update + SingleParUpdate = 16 //< Usually only requires this par updated }; LyXAction();
signature.asc
Description: This is a digitally signed message part