On Tue, 2006-01-03 at 21:40 +0100, Michael Gerz wrote:
> Martin Vermeer wrote:
> 
> >Yes, it works... apparently because !vi.singlerow implies select, in a
> >way that I haven't been able to figure out. So you don't actually save
> >anything.
> >
> >Still might be wise to delete select from the two places where it occurs
> >together with || vi.singlerow.
> >  
> >
> Could you please remove the conditions? I don't feel authorized to do so 
> by myself... :-)

Instead, consider the attached patch. What it achieves is making all
inside-paragraph selecting operations, whether by keyboard or by mouse,
of single-paragraph type. This _should_ produce a speed-up as long as
the selection remains within a paragraph.

I tried to test that there are no "turds" or other side effects, and it
seems to be OK. Please test some more if you can.

I think this is clean enough for 1.4.0, or else 1.4.1. Depends a bit on
how much of a useful speed-up it produces.

- Martin

BTW I find the attached second patch, for RowPainter profiling, useful.
As we have been talking so much about "real" profiling, this is like a
lightweight proto-profiler. Would this be welcome in CVS?

- M

Index: BufferView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v
retrieving revision 1.189
diff -u -p -r1.189 BufferView.h
--- BufferView.h	1 Dec 2005 10:28:47 -0000	1.189
+++ BufferView.h	4 Jan 2006 09:09:24 -0000
@@ -40,7 +40,8 @@ namespace Update {
 	enum flags {
 		FitCursor = 1,
 		Force = 2,
-		SinglePar = 4
+		SinglePar = 4,
+		MultiParSel = 8
 	};
 
 inline flags operator|(flags const f, flags const g)
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.600
diff -u -p -r1.600 BufferView_pimpl.C
--- BufferView_pimpl.C	29 Nov 2005 15:08:32 -0000	1.600
+++ BufferView_pimpl.C	4 Jan 2006 09:09:25 -0000
@@ -36,6 +36,7 @@
 #include "intl.h"
 #include "insetiterator.h"
 #include "LaTeXFeatures.h"
+#include "LyXAction.h"
 #include "lyx_cb.h" // added for Dispatch functions
 #include "lyx_main.h"
 #include "lyxfind.h"
@@ -658,6 +659,17 @@ bool BufferView::Pimpl::fitCursor()
 }
 
 
+bool BufferView::Pimpl::multiParSel()
+{
+	if (!cursor_.selection())
+		return false;
+	bool ret = multiparsel_cache_;
+	multiparsel_cache_ = cursor_.selBegin().pit() != cursor_.selEnd().pit();
+	// Either this, or previous selection spans paragraphs
+	return ret || multiparsel_cache_;
+}
+
+
 void BufferView::Pimpl::update(Update::flags flags)
 {
 	lyxerr[Debug::DEBUG]
@@ -682,12 +694,16 @@ void BufferView::Pimpl::update(Update::f
 
 		// First drawing step
 		ViewMetricsInfo vi = metrics(flags & Update::SinglePar);
-		bool forceupdate(flags & Update::Force);
+		bool forceupdate(flags & (Update::Force | Update::SinglePar));
 
 		if ((flags & Update::FitCursor) && fitCursor()) {
 			forceupdate = true;
 			vi = metrics();
 		}
+		if ((flags & Update::MultiParSel) && multiParSel()) {
+			forceupdate = true;
+			vi = metrics();
+		}
 		if (forceupdate) {
 			// Second drawing step
 			screen().redraw(*bv_, vi);
@@ -989,7 +1005,7 @@ bool BufferView::Pimpl::workAreaDispatch
 		if (cur.result().update())
 			update(Update::FitCursor | Update::Force);
 		else
-			update();
+			update(Update::FitCursor | Update::MultiParSel);
 	}
 
 	// See workAreaKeyPress
Index: BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.129
diff -u -p -r1.129 BufferView_pimpl.h
--- BufferView_pimpl.h	7 Nov 2005 15:06:42 -0000	1.129
+++ BufferView_pimpl.h	4 Jan 2006 09:09:25 -0000
@@ -59,6 +59,8 @@ public:
 	void resizeCurrentBuffer();
 	//
 	bool fitCursor();
+	//
+	bool multiParSel();
 	///
 	void update(Update::flags flags = Update::Force);
 	///
@@ -183,6 +185,7 @@ private:
 	///
 	LCursor cursor_;
 	///
+	bool multiparsel_cache_;
 	///
 	lyx::pit_type anchor_ref_;
 	///
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.323
diff -u -p -r1.323 text3.C
--- text3.C	31 Dec 2005 11:40:32 -0000	1.323
+++ text3.C	4 Jan 2006 09:09:26 -0000
@@ -1531,10 +1531,14 @@ void LyXText::dispatch(LCursor & cur, Fu
 
 	if (singleParUpdate)
 		// Inserting characters does not change par height
-	   	if (cur.bottom().paragraph().dim().height() 
+		if (cur.bottom().paragraph().dim().height() 
 		    == olddim.height()) {
 			// if so, update _only_ this paragraph
-			cur.bv().update(Update::SinglePar | Update::Force);
+			cur.bv().update(Update::SinglePar |
+					Update::FitCursor |
+					Update::MultiParSel);
+			cur.noUpdate();
+			return;
 		} else
 			needsUpdate = true;
 	if (!needsUpdate
Index: LyXAction.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v
retrieving revision 1.210
diff -u -p -r1.210 LyXAction.C
--- LyXAction.C	25 Oct 2005 15:07:22 -0000	1.210
+++ LyXAction.C	4 Jan 2006 09:09:27 -0000
@@ -97,7 +97,7 @@ void LyXAction::init()
 		{ LFUN_UNDERBAR, "accent-underbar", Noop },
 		{ LFUN_UNDERDOT, "accent-underdot", Noop },
 		{ LFUN_APPENDIX, "appendix", Noop },
-		{ LFUN_LEFTSEL, "backward-select", ReadOnly },
+		{ LFUN_LEFTSEL, "backward-select", ReadOnly | SingleParUpdate },
 		{ LFUN_BOOKMARK_GOTO, "bookmark-goto", ReadOnly },
 		{ LFUN_BOOKMARK_SAVE, "bookmark-save", ReadOnly },
 		{ LFUN_BREAKLINE, "break-line", Noop },
@@ -143,8 +143,8 @@ void LyXAction::init()
 		{ LFUN_DEPTH_MIN, "depth-decrement", Noop },
 		{ LFUN_DEPTH_PLUS, "depth-increment", Noop },
 		{ LFUN_LDOTS, "dots-insert", Noop },
-		{ LFUN_DOWN, "down", ReadOnly | NoUpdate},
-		{ LFUN_DOWNSEL, "down-select", ReadOnly },
+		{ LFUN_DOWN, "down", ReadOnly | NoUpdate },
+		{ LFUN_DOWNSEL, "down-select", ReadOnly | SingleParUpdate },
 		{ LFUN_DROP_LAYOUTS_CHOICE, "drop-layouts-choice", ReadOnly },
 		{ LFUN_END_OF_SENTENCE, "end-of-sentence-period-insert", Noop },
 		{ LFUN_ENVIRONMENT_INSERT, "environment-insert", Noop },
@@ -173,7 +173,7 @@ void LyXAction::init()
 		{ LFUN_FONT_STATE, "font-state", ReadOnly },
 		{ LFUN_UNDERLINE, "font-underline", Noop },
 		{ LFUN_INSET_FOOTNOTE, "footnote-insert", Noop },
-		{ LFUN_RIGHTSEL, "forward-select", ReadOnly },
+		{ LFUN_RIGHTSEL, "forward-select", ReadOnly | SingleParUpdate },
 		{ LFUN_HFILL, "hfill-insert", Noop },
 		{ LFUN_HELP_OPEN, "help-open", NoBuffer | Argument},
 		{ LFUN_HTMLURL, "html-insert", Noop },
@@ -198,10 +198,10 @@ void LyXAction::init()
 		{ LFUN_LAYOUT_PARAGRAPH, "layout-paragraph", ReadOnly },
 		{ LFUN_LAYOUT_TABULAR, "layout-tabular", Noop },
 		{ LFUN_HOME, "line-begin", ReadOnly | NoUpdate},
-		{ LFUN_HOMESEL, "line-begin-select", ReadOnly },
+		{ LFUN_HOMESEL, "line-begin-select", ReadOnly | SingleParUpdate },
 		{ LFUN_DELETE_LINE_FORWARD, "line-delete-forward", Noop },
 		{ LFUN_END, "line-end", ReadOnly | NoUpdate},
-		{ LFUN_ENDSEL, "line-end-select", ReadOnly },
+		{ LFUN_ENDSEL, "line-end-select", ReadOnly | SingleParUpdate },
 #if 0
 		{ LFUN_INSET_LIST, "list-insert", Noop },
 #endif
@@ -283,7 +283,7 @@ void LyXAction::init()
 		{ LFUN_TOGGLECURSORFOLLOW, "toggle-cursor-follows-scrollbar", ReadOnly },
 		{ LFUN_UNDO, "undo", Noop },
 		{ LFUN_UP, "up", ReadOnly | NoUpdate},
-		{ LFUN_UPSEL, "up-select", ReadOnly },
+		{ LFUN_UPSEL, "up-select", ReadOnly | SingleParUpdate },
 		{ LFUN_URL, "url-insert", Noop },
 		{ LFUN_VC_CHECKIN, "vc-check-in", ReadOnly },
 		{ LFUN_VC_CHECKOUT, "vc-check-out", ReadOnly },
@@ -291,14 +291,14 @@ void LyXAction::init()
 		{ LFUN_VC_REVERT, "vc-revert", ReadOnly },
 		{ LFUN_VC_UNDO, "vc-undo-last", ReadOnly },
 		{ LFUN_WORDLEFT, "word-backward", ReadOnly | NoUpdate},
-		{ LFUN_WORDLEFTSEL, "word-backward-select", ReadOnly },
+		{ LFUN_WORDLEFTSEL, "word-backward-select", ReadOnly | SingleParUpdate },
 		{ LFUN_CAPITALIZE_WORD, "word-capitalize", Noop },
 		{ LFUN_DELETE_WORD_BACKWARD, "word-delete-backward", Noop },
 		{ LFUN_DELETE_WORD_FORWARD, "word-delete-forward", Noop },
 		{ LFUN_WORDFINDBACKWARD, "word-find-backward", ReadOnly },
 		{ LFUN_WORDFINDFORWARD, "word-find-forward", ReadOnly },
 		{ LFUN_WORDRIGHT, "word-forward", ReadOnly | NoUpdate},
-		{ LFUN_WORDRIGHTSEL, "word-forward-select", ReadOnly },
+		{ LFUN_WORDRIGHTSEL, "word-forward-select", ReadOnly | SingleParUpdate },
 		{ LFUN_LOWCASE_WORD, "word-lowcase", Noop },
 		{ LFUN_WORDSEL, "word-select", ReadOnly },
 		{ LFUN_UPCASE_WORD, "word-upcase", Noop },
@@ -348,7 +348,7 @@ void LyXAction::init()
 		{ LFUN_FINISHED_UP, "", ReadOnly },
 		{ LFUN_FINISHED_DOWN, "", ReadOnly },
 		{ LFUN_MOUSE_PRESS, "", ReadOnly },
-		{ LFUN_MOUSE_MOTION, "", ReadOnly },
+		{ LFUN_MOUSE_MOTION, "", ReadOnly | SingleParUpdate },
 		{ LFUN_MOUSE_RELEASE, "", ReadOnly },
 		{ LFUN_MOUSE_DOUBLE, "", ReadOnly },
 		{ LFUN_MOUSE_TRIPLE, "", ReadOnly },
Index: debug.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/debug.C,v
retrieving revision 1.44
diff -u -p -r1.44 debug.C
--- debug.C	17 Jul 2005 12:39:54 -0000	1.44
+++ debug.C	4 Jan 2006 09:13:49 -0000
@@ -63,6 +63,7 @@ error_item errorTags[] = {
 	{ Debug::GRAPHICS,  "graphics",  N_("Graphics conversion and loading")},
 	{ Debug::CHANGES,   "changes",   N_("Change tracking")},
 	{ Debug::EXTERNAL,  "external",  N_("External template/inset messages")},
+	{ Debug::PAINTING,  "painting",  N_("RowPainter profiling")},
 	{ Debug::DEBUG,     "debug",     N_("Developers' general debug messages")},
 	{ Debug::ANY,       "any",       N_("All debugging messages")}
 };
Index: debug.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/debug.h,v
retrieving revision 1.39
diff -u -p -r1.39 debug.h
--- debug.h	19 Jan 2005 15:03:29 -0000	1.39
+++ debug.h	4 Jan 2006 09:13:49 -0000
@@ -74,6 +74,8 @@ public:
 		///
 		EXTERNAL   = (1 << 23),
 		///
+		PAINTING   = (1 << 24),
+		///
 		DEBUG      = (1 << 31),
 		///
 		ANY = 0xffffffff
Index: rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.162
diff -u -p -r1.162 rowpainter.C
--- rowpainter.C	1 Jan 2006 23:06:23 -0000	1.162
+++ rowpainter.C	4 Jan 2006 09:13:50 -0000
@@ -787,7 +787,10 @@ void paintPar
 			
 			// Instrumentation for testing row cache (see also
 			// 12 lines lower):
-			//lyxerr << "#";
+			if (text.isMainText())
+    				lyxerr[Debug::PAINTING] << "#";
+			else
+    				lyxerr[Debug::PAINTING] << "@";
 			rp.paintAppendix();
 			rp.paintDepthBar();
 			rp.paintChangeBar();
@@ -799,7 +802,7 @@ void paintPar
 		}
 		y += rit->descent();
 	}
-	//lyxerr << "." << endl;
+	lyxerr[Debug::PAINTING] << "." << endl;
 }
 
 } // namespace anon
@@ -813,7 +816,7 @@ void paintText(BufferView const & bv, Vi
 
 	PainterInfo pi(const_cast<BufferView *>(&bv), pain);
 	if (select || !vi.singlepar) {
-		// Clear background (Delegated to rows if no selection)
+		// Clear background (if not delegated to rows)
 		pain.fillRectangle(0, vi.y1, bv.workWidth(), vi.y2 - vi.y1,
 			text->backgroundColor());
 	}

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to