|
From: Eden K. <fo...@ap...> - 2001-03-15 05:14:56
|
hello.
there is a bug in TSynEdit when eoKeepCaretX and eoScrollPastEol are
combined. X position isn't updated. here is a bug fix:
(in TCustomSynEdit.ExecuteCommand)
....
ecLineStart, ecSelLineStart:
begin
MoveCaretAndSelection(CaretXY, Point(1, CaretY),
Command = ecSelLineStart);
fLastCaretX := fCaretX; // <- this one
end;
ecLineEnd, ecSelLineEnd:
begin
MoveCaretAndSelection(CaretXY, Point(1 + Length(LineText),
CaretY),
Command = ecSelLineEnd);
fLastCaretX := fCaretX; // <- and this one
end;
please let me know if there are some problems about it.
anyway, i implemented one more caret behaivour, as seen in MS visual studio,
enhanced homekey positioning. if caret is positioned somewhere in the middle
of the line, first press of homekey sets caret position on first nonblank
character. the second one place it in the beginning.
here is some code for it:
---------------------------
TSynEditorOption = (eoAltSetsColumnMode, eoAutoIndent, eoDragDropEditing,
eoDropFiles, eoHalfPageScroll, eoKeepCaretX, eoNoCaret, eoNoSelection,
eoScrollByOneLess, eoScrollPastEof, eoScrollPastEol, eoShowScrollHint,
eoSmartTabs, eoTabsToSpaces, eoTrimTrailingSpaces,
eoEnhanceHomeKey); // <- i added this one
(in TCustomSynEdit.ExecuteCommand)
ecLineStart, ecSelLineStart:
begin
DoHomeKey(Command = ecSelLineStart);
// MoveCaretAndSelection(CaretXY, Point(1, CaretY), <- the old one
// Command = ecSelLineStart); <- the old one
fLastCaretX := fCaretX;
end;
....
procedure TCustomSynEdit.DoHomeKey(Selection:boolean);
var
newX :integer;
first_nonblank :integer;
s :string;
begin
if (eoEnhanceHomeKey in fOptions) then begin
s:=fLines[CaretXY.Y-1];
first_nonblank:=1;
while (first_nonblank<Length(s)) and (s[first_nonblank]=' ') do
inc(first_nonblank);
dec(first_nonblank);
newX:=CaretXY.X-1;
if (newX>first_nonblank) or (newX=0) then
newX:=first_nonblank+1
else
newX:=1;
end else
newX:=1;
MoveCaretAndSelection(CaretXY, Point(newX, CaretY), Selection);
end;
---------------------------
that's all from me for now.
eden
|