From c0533e4dd6decd6049bcd8ef04b66fa6f743bfd0 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Fri, 15 Oct 2010 11:14:54 +0200 Subject: memo CursorLine property improvements and sanity checks * The selection variables were not updated before * Little error checking was done, so you could get index out of bounds errors. --- src/gui/fpg_memo.pas | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/fpg_memo.pas b/src/gui/fpg_memo.pas index 41587135..789da3c3 100644 --- a/src/gui/fpg_memo.pas +++ b/src/gui/fpg_memo.pas @@ -246,13 +246,18 @@ var MaxLine: integer; yp: integer; begin - if (aValue < 0) or (aValue = FCursorLine) then + if (aValue < 0) or (aValue = FCursorLine) or (AValue > FLines.Count-1) then Exit; // wrong value + if aValue < FFirstLine then begin FFirstLine := aValue; // moves the selected line to the top of the displayed rectangle FCursorLine := aValue; FCursorPos := 0; + FSelStartPos := FCursorPos; + FSelStartLine := FCursorLine; + FSelEndLine := -1; + AdjustCursor; RePaint; Exit; end; @@ -272,15 +277,21 @@ begin FFirstLine := aValue; FCursorLine := aValue; FCursorPos := 0; + FSelStartPos := FCursorPos; + FSelStartLine := FCursorLine; + FSelEndLine := -1; + AdjustCursor; RePaint; - Exit; end else begin FCursorLine := aValue; FCursorPos := 0; + FSelStartPos := FCursorPos; + FSelStartLine := FCursorLine; + FSelEndLine := -1; + AdjustCursor; RePaint; - Exit; end; end; -- cgit v1.2.3-70-g09d2