SynEdit: allow caret to end of longest line (instead of MaxLeftChar), if eoScrollPastEOL is set

git-svn-id: trunk@32039 -
This commit is contained in:
martin 2011-08-24 10:10:01 +00:00
parent f22b324a64
commit 3968c44b39
2 changed files with 16 additions and 5 deletions

View File

@ -557,6 +557,7 @@ type
procedure SetExtraCharSpacing(const Value: integer);
procedure SetLastMouseCaret(const AValue: TPoint);
function CurrentMaxLeftChar: Integer;
function CurrentMaxLineLen: Integer;
procedure SetLeftChar(Value: Integer);
procedure SetLineText(Value: string);
procedure SetMaxLeftChar(Value: integer);
@ -1585,10 +1586,10 @@ begin
TSynEditStringList(FLines).AttachSynEdit(Self);
FCaret := TSynEditCaret.Create;
FCaret.MaxLeftChar := @FMaxLeftChar;
FCaret.MaxLeftChar := @CurrentMaxLineLen;
FCaret.AddChangeHandler({$IFDEF FPC}@{$ENDIF}CaretChanged);
FInternalCaret := TSynEditCaret.Create;
FInternalCaret.MaxLeftChar := @FMaxLeftChar;
FInternalCaret.MaxLeftChar := @CurrentMaxLineLen;
// Create the lines/views
FTrimmedLinesView := TSynEditStringTrimmingList.Create(fLines, fCaret);
@ -4271,6 +4272,15 @@ begin
Result := Result - fCharsInWindow + 1 + FScreenCaret.ExtraLineChars;
end;
function TCustomSynEdit.CurrentMaxLineLen: Integer;
begin
if not HandleAllocated then // don't know chars in window yet
exit(MaxInt);
Result := FTheLinesView.LengthOfLongestLine + 1;
if (eoScrollPastEol in Options) and (Result < fMaxLeftChar) then
Result := fMaxLeftChar;
end;
procedure TCustomSynEdit.SetLeftChar(Value: Integer);
begin
Value := Min(Value, CurrentMaxLeftChar);

View File

@ -46,6 +46,7 @@ type
TInvalidateLines = procedure(FirstLine, LastLine: integer) of Object;
TLinesCountChanged = procedure(FirstLine, Count: integer) of Object;
TMaxLeftCharFunc = function: Integer of object;
{ TSynEditPointBase }
@ -180,7 +181,7 @@ type
FOldLinePos: Integer; // 1 based
FOldCharPos: Integer; // 1 based
FAdjustToNextChar: Boolean;
FMaxLeftChar: PInteger;
FMaxLeftChar: TMaxLeftCharFunc;
FChangeOnTouch: Boolean;
FSkipTabs: Boolean;
FTouched: Boolean;
@ -244,7 +245,7 @@ type
property SkipTabs: Boolean read FSkipTabs write SetSkipTabs;
property AllowPastEOL: Boolean read FAllowPastEOL write SetAllowPastEOL;
property KeepCaretX: Boolean read FKeepCaretX write SetKeepCaretX;
property MaxLeftChar: PInteger write FMaxLeftChar;
property MaxLeftChar: TMaxLeftCharFunc write FMaxLeftChar;
end;
TSynCaretType = (ctVerticalLine, ctHorizontalLine, ctHalfBlock, ctBlock);
@ -572,7 +573,7 @@ begin
try
if (fCharPos <> NewCharPos) or (fLinePos <> NewLine) or ForceSet then begin
if FMaxLeftChar <> nil then
nMaxX := FMaxLeftChar^
nMaxX := FMaxLeftChar()
else
nMaxX := MaxInt;
if NewLine > FLines.Count then