From 6569cfc81e77bf00c3fb02d3438c0ed325b8f767 Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Wed, 30 May 2007 19:38:22 +0000 Subject: [PATCH] * avoid redraw if possible (OK by Abdel and Dov) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18580 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Cursor.cpp | 13 ++++++------- src/Cursor.h | 11 ++++++++--- src/Text3.cpp | 18 ++++++++---------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/Cursor.cpp b/src/Cursor.cpp index b3bdadeb6c..d34f348d73 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -1168,7 +1168,7 @@ bool Cursor::upDownInMath(bool up) } -bool Cursor::upDownInText(bool up) +bool Cursor::upDownInText(bool up, bool & updateNeeded) { BOOST_ASSERT(text()); @@ -1248,12 +1248,11 @@ bool Cursor::upDownInText(bool up) Cursor dummy = *this; if (dummy == old) ++dummy.pos(); - - bool const changed = bv().checkDepm(dummy, old); - - // Make sure that cur gets back whatever happened to dummy(Lgb) - if (changed) + if (bv().checkDepm(dummy, old)) { + updateNeeded = true; + // Make sure that cur gets back whatever happened to dummy(Lgb) operator=(dummy); + } } else { // if there is a selection, we stay out of any inset, and just jump to the right position: Cursor old = *this; @@ -1274,7 +1273,7 @@ bool Cursor::upDownInText(bool up) } } - bv().checkDepm(*this, old); + updateNeeded |= bv().checkDepm(*this, old); } updateTextTargetOffset(); diff --git a/src/Cursor.h b/src/Cursor.h index c33478d523..998b667679 100644 --- a/src/Cursor.h +++ b/src/Cursor.h @@ -256,12 +256,17 @@ public: /// return false for empty math insets bool backspace(); /// move the cursor up by sending an internal LFUN_UP + /// return true if fullscreen update is needed bool up(); - /// move the cursor up by sending an internal LFUN_DOWN + /// move the cursor up by sending an internal LFUN_DOWN, + /// return true if fullscreen update is needed bool down(); - /// move up/down in a text inset, called for LFUN_UP/DOWN - bool upDownInText(bool up); + /// move up/down in a text inset, called for LFUN_UP/DOWN, + /// return true if successful, updateNeeded set to true if fullscreen + /// update is needed, otherwise it's not touched + bool upDownInText(bool up, bool & updateNeeded); /// move up/down in math or any non text inset, call for LFUN_UP/DOWN + /// return true if successful bool upDownInMath(bool up); /// void plainErase(); diff --git a/src/Text3.cpp b/src/Text3.cpp index 968b893a01..396202436d 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -467,30 +467,28 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) break; case LFUN_UP: - case LFUN_UP_SELECT: + case LFUN_UP_SELECT: { //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl; needsUpdate |= cur.selHandle(cmd.action == LFUN_UP_SELECT); - needsUpdate |= cur.upDownInText(true); - - if (!needsUpdate && oldTopSlice == cur.top() - && cur.boundary() == oldBoundary) + bool const successful = cur.upDownInText(true, needsUpdate); + if (!successful) cur.undispatched(); if (cur.selection()) saveSelection(cur); break; + } case LFUN_DOWN: - case LFUN_DOWN_SELECT: + case LFUN_DOWN_SELECT: { //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl; needsUpdate |= cur.selHandle(cmd.action == LFUN_DOWN_SELECT); - needsUpdate |= cur.upDownInText(false); - - if (!needsUpdate && oldTopSlice == cur.top() && - cur.boundary() == oldBoundary) + bool const successful = cur.upDownInText(false, needsUpdate); + if (!successful) cur.undispatched(); if (cur.selection()) saveSelection(cur); break; + } case LFUN_PARAGRAPH_UP: case LFUN_PARAGRAPH_UP_SELECT: -- 2.39.5