mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 05:29:51 +02:00
SynEdit, Clean-up/Refactor Markup; Also fixes bug #12854 (bracket highlight during replace)
git-svn-id: trunk@18029 -
This commit is contained in:
parent
d11cfa1187
commit
01b2500565
@ -1605,15 +1605,7 @@ begin
|
||||
if sfScrollbarChanged in fStateFlags then
|
||||
UpdateScrollbars;
|
||||
if sfCaretChanged in fStateFlags then
|
||||
UpdateCaret
|
||||
else
|
||||
if not(sfPainting in fStateFlags) then
|
||||
begin
|
||||
if Assigned(fMarkupBracket) then
|
||||
fMarkupBracket.InvalidateBracketHighlight;
|
||||
if Assigned(fMarkupSpecialLine) then
|
||||
fMarkupSpecialLine.InvalidateLineHighlight;
|
||||
end;
|
||||
UpdateCaret;
|
||||
if fStatusChanges <> [] then
|
||||
DoOnStatusChange(fStatusChanges);
|
||||
end;
|
||||
@ -2010,7 +2002,6 @@ begin
|
||||
if sfPainting in fStateFlags then exit;
|
||||
if Visible and HandleAllocated then
|
||||
if (FirstLine = -1) and (LastLine = -1) then begin
|
||||
fMarkupHighAll.InvalidateScreenLines(0, LinesInWindow+1);
|
||||
rcInval := ClientRect;
|
||||
rcInval.Left := fGutterWidth;
|
||||
if sfLinesChanging in fStateFlags then
|
||||
@ -2033,7 +2024,6 @@ begin
|
||||
{ any line visible? }
|
||||
if (l >= f) then begin
|
||||
If LastLine < 0 then LastLine := ScreenRowToRow(LinesInWindow + 1);
|
||||
fMarkupHighAll.InvalidateLines(FirstLine, LastLine);
|
||||
rcInval := Rect(fGutterWidth, fTextHeight * f,
|
||||
ClientWidth-ScrollBarWidth, fTextHeight * l);
|
||||
if sfLinesChanging in fStateFlags then
|
||||
@ -3954,9 +3944,6 @@ procedure TCustomSynEdit.Invalidate;
|
||||
begin
|
||||
//DebugLn('TCustomSynEdit.Invalidate A');
|
||||
//RaiseGDBException('');
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
fMarkupHighAll.InvalidateScreenLines(0, LinesInWindow+1);
|
||||
{$ENDIF}
|
||||
inherited Invalidate;
|
||||
end;
|
||||
|
||||
@ -4168,6 +4155,7 @@ begin
|
||||
end;
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
fCaret.LineCharPos:= Value;
|
||||
fMarkupManager.Caret := Value;
|
||||
{$ENDIF}
|
||||
EnsureCursorPosVisible;
|
||||
Include(fStateFlags, sfCaretChanged);
|
||||
@ -4502,10 +4490,6 @@ begin
|
||||
{$ENDIF}
|
||||
then begin
|
||||
Include(fStateFlags, sfCaretChanged);
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
if assigned(fMarkupBracket) then fMarkupBracket.InvalidateBracketHighlight;
|
||||
if assigned(fMarkupSpecialLine) then fMarkupSpecialLine.InvalidateLineHighlight;
|
||||
{$ENDIF}
|
||||
end else begin
|
||||
Exclude(fStateFlags, sfCaretChanged);
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
@ -4527,10 +4511,6 @@ begin
|
||||
HideCaret;
|
||||
SetCaretPosEx(Handle ,CX + FCaretOffset.X, CY + FCaretOffset.Y);
|
||||
end;
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
if assigned(fMarkupBracket) then fMarkupBracket.InvalidateBracketHighlight;
|
||||
if assigned(fMarkupSpecialLine) then fMarkupSpecialLine.InvalidateLineHighlight;
|
||||
{$ENDIF}
|
||||
{$IFDEF SYN_MBCSSUPPORT}
|
||||
if HandleAllocated then begin
|
||||
cf.dwStyle := CFS_POINT;
|
||||
@ -4877,6 +4857,7 @@ begin
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
if not assigned(fHighlighter) or (Index > Lines.Count - 1) then begin
|
||||
fTextView.FixFoldingAtTextIndex(Index);
|
||||
fMarkupManager.TextChangedScreen(Max(RowToScreenRow(Index+1), 0), LinesInWindow+1);
|
||||
Topline := TopLine;
|
||||
exit;
|
||||
end;
|
||||
@ -4890,6 +4871,7 @@ begin
|
||||
{$ENDIF}
|
||||
if Index >= Lines.Count - 1 then begin
|
||||
fTextView.FixFoldingAtTextIndex(Index);
|
||||
fMarkupManager.TextChangedScreen(Max(RowToScreenRow(Index+1), 0), LinesInWindow+1);
|
||||
Topline := TopLine;
|
||||
Exit;
|
||||
end;
|
||||
@ -4935,6 +4917,8 @@ begin
|
||||
if (Result>Index+1) and (Result<=Lines.Count) then
|
||||
SetCodeFoldAttributes;
|
||||
fTextView.FixFoldingAtTextIndex(FixFStart, Result);
|
||||
fMarkupManager.TextChangedScreen(Max(RowToScreenRow(FixFStart+1), 0),
|
||||
Min(RowToScreenRow(Result), LinesInWindow+1));
|
||||
Topline := TopLine;
|
||||
if FixFStart < index then Invalidate;
|
||||
{$ENDIF}
|
||||
@ -9269,9 +9253,6 @@ begin
|
||||
TopLine + LinesInWindow{$ENDIF})
|
||||
and (Line <= Lines.Count) and HandleAllocated
|
||||
then begin
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
fMarkupHighAll.InvalidateLines(Line, Line);
|
||||
{$ENDIF}
|
||||
// we invalidate gutter and text area of this line
|
||||
rcInval := Rect(0, fTextHeight * RowToScreenRow(Line)
|
||||
, ClientWidth{$IFDEF SYN_LAZARUS}-ScrollBarWidth{$ENDIF}, 0);
|
||||
@ -9482,8 +9463,8 @@ var
|
||||
|
||||
procedure DoFindMatchingQuote;
|
||||
var
|
||||
Test, BracketInc, BracketDec: char;
|
||||
NumBrackets, Len: integer;
|
||||
Test: char;
|
||||
Len: integer;
|
||||
begin
|
||||
StartPt:=Point(PosX,PosY);
|
||||
GetHighlighterAttriAtRowColEx(StartPt, s1, BracketKind, TmpStart, TmpAttr);
|
||||
|
@ -64,6 +64,7 @@ type
|
||||
procedure DoCaretChanged(OldCaret : TPoint); virtual;
|
||||
procedure DoTopLineChanged(OldTopLine : Integer); virtual;
|
||||
procedure DoLinesInWindoChanged(OldLinesInWindow : Integer); virtual;
|
||||
procedure DoTextChanged(StartLine, EndLine : Integer); virtual;
|
||||
procedure DoMarkupChanged(AMarkup: TSynSelectedColor); virtual;
|
||||
|
||||
procedure InvalidateSynLines(FirstLine, LastLine: integer); // Call Synedt to invalidate lines
|
||||
@ -82,6 +83,9 @@ type
|
||||
Function GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; virtual; abstract;
|
||||
Function GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; virtual; abstract;
|
||||
|
||||
// Notifications about Changes to the text
|
||||
Procedure TextChanged(aFirstCodeLine, aLastCodeLine: Integer); virtual;
|
||||
|
||||
property MarkupInfo : TSynSelectedColor read fMarkupInfo;
|
||||
property FGColor : TColor read GetFGColor;
|
||||
property BGColor : TColor read GetBGColor;
|
||||
@ -117,6 +121,10 @@ type
|
||||
Procedure EndMarkup; override;
|
||||
Function GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; override;
|
||||
Function GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; override;
|
||||
|
||||
// Notifications about Changes to the text
|
||||
Procedure TextChangedScreen(aFirstCodeLine, aLastCodeLine: Integer);
|
||||
Procedure TextChanged(aFirstCodeLine, aLastCodeLine: Integer); override;
|
||||
end;
|
||||
|
||||
|
||||
@ -229,6 +237,10 @@ procedure TSynEditMarkup.DoLinesInWindoChanged(OldLinesInWindow : Integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkup.DoTextChanged(StartLine, EndLine: Integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkup.DoMarkupChanged(AMarkup : TSynSelectedColor);
|
||||
begin
|
||||
end;
|
||||
@ -281,6 +293,11 @@ procedure TSynEditMarkup.EndMarkup;
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkup.TextChanged(aFirstCodeLine, aLastCodeLine: Integer);
|
||||
begin
|
||||
DoTextChanged(aFirstCodeLine, aLastCodeLine);
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkup.PrepareMarkupForRow(aRow : Integer);
|
||||
begin
|
||||
end;
|
||||
@ -371,6 +388,19 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupManager.TextChangedScreen(aFirstCodeLine, aLastCodeLine: Integer);
|
||||
begin
|
||||
TextChanged(ScreenRowToRow(aFirstCodeLine), ScreenRowToRow(aLastCodeLine));
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupManager.TextChanged(aFirstCodeLine, aLastCodeLine: Integer);
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
for i := 0 to fMarkUpList.Count-1 do
|
||||
TSynEditMarkup(fMarkUpList[i]).TextChanged(aFirstCodeLine, aLastCodeLine);
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupManager.SetInvalidateLinesMethod(const AValue : TInvalidateLines);
|
||||
var
|
||||
i : integer;
|
||||
|
@ -46,6 +46,11 @@ type
|
||||
protected
|
||||
procedure FindMatchingBracketPair(PhysCaret: TPoint;
|
||||
var StartBracket, EndBracket: TPoint);
|
||||
procedure DoCaretChanged(OldCaret : TPoint); override;
|
||||
procedure DoTopLineChanged(OldTopLine : Integer); override;
|
||||
procedure DoLinesInWindoChanged(OldLinesInWindow : Integer); override;
|
||||
procedure DoTextChanged(StartLine, EndLine : Integer); override;
|
||||
procedure DoMarkupChanged(AMarkup: TSynSelectedColor); override;
|
||||
public
|
||||
constructor Create(ASynEdit: TCustomControl);
|
||||
|
||||
@ -129,6 +134,31 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupBracket.DoCaretChanged(OldCaret: TPoint);
|
||||
begin
|
||||
InvalidateBracketHighlight;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupBracket.DoTopLineChanged(OldTopLine: Integer);
|
||||
begin
|
||||
InvalidateBracketHighlight;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupBracket.DoLinesInWindoChanged(OldLinesInWindow: Integer);
|
||||
begin
|
||||
InvalidateBracketHighlight;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupBracket.DoTextChanged(StartLine, EndLine: Integer);
|
||||
begin
|
||||
InvalidateBracketHighlight;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupBracket.DoMarkupChanged(AMarkup: TSynSelectedColor);
|
||||
begin
|
||||
InvalidateBracketHighlight;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupBracket.InvalidateBracketHighlight;
|
||||
var
|
||||
NewPos, NewAntiPos, SwapPos : TPoint;
|
||||
|
@ -109,6 +109,7 @@ type
|
||||
procedure DoTopLineChanged(OldTopLine : Integer); override;
|
||||
procedure DoLinesInWindoChanged(OldLinesInWindow : Integer); override;
|
||||
procedure DoMarkupChanged(AMarkup: TSynSelectedColor); override;
|
||||
procedure DoTextChanged(StartLine, EndLine: Integer); override;
|
||||
public
|
||||
constructor Create(ASynEdit : TCustomControl);
|
||||
destructor Destroy; override;
|
||||
@ -116,8 +117,6 @@ type
|
||||
Function GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; override;
|
||||
Function GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; override;
|
||||
|
||||
Procedure InvalidateScreenLines(aFirstCodeLine, aLastCodeLine: Integer);
|
||||
Procedure InvalidateLines(aFirstCodeLine, aLastCodeLine: Integer);
|
||||
Procedure Invalidate;
|
||||
Procedure SendLineInvalidation;
|
||||
|
||||
@ -380,12 +379,7 @@ begin
|
||||
SendLineInvalidation;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupHighlightAll.InvalidateScreenLines(aFirstCodeLine, aLastCodeLine : Integer);
|
||||
begin
|
||||
InvalidateLines(ScreenRowToRow(aFirstCodeLine), ScreenRowToRow(aLastCodeLine));
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupHighlightAll.InvalidateLines(aFirstCodeLine, aLastCodeLine : Integer);
|
||||
procedure TSynEditMarkupHighlightAll.DoTextChanged(StartLine, EndLine: Integer);
|
||||
var
|
||||
Pos: Integer;
|
||||
begin
|
||||
@ -396,18 +390,18 @@ begin
|
||||
// Invalidate neighbouring lines, which have an overlapping match
|
||||
Pos := 0;
|
||||
while (Pos < fMatches.Count)
|
||||
and (fMatches.EndPoint[Pos].y < aFirstCodeLine )
|
||||
and (fMatches.EndPoint[Pos].y < StartLine)
|
||||
do inc(Pos);
|
||||
// curent Match ends in aFirstCodeLine or later
|
||||
if fMatches.StartPoint[Pos].y < aFirstCodeLine
|
||||
then InvalidateSynLines(fMatches.StartPoint[Pos].y, aFirstCodeLine - 1);
|
||||
if fMatches.StartPoint[Pos].y < StartLine
|
||||
then InvalidateSynLines(fMatches.StartPoint[Pos].y, StartLine - 1);
|
||||
|
||||
while (Pos < fMatches.Count)
|
||||
and (fMatches.EndPoint[Pos].y = aLastCodeLine )
|
||||
and (fMatches.EndPoint[Pos].y = EndLine )
|
||||
do inc(Pos);
|
||||
// curent Match ends after aLastCodeLine
|
||||
if fMatches.StartPoint[Pos].y <= aLastCodeLine
|
||||
then InvalidateSynLines(aLastCodeLine + 1, fMatches.EndPoint[Pos].y);
|
||||
if fMatches.StartPoint[Pos].y <= EndLine
|
||||
then InvalidateSynLines(EndLine + 1, fMatches.EndPoint[Pos].y);
|
||||
|
||||
fInvalidating := False;
|
||||
fHasInvalidLines := true;
|
||||
|
@ -47,6 +47,11 @@ type
|
||||
protected
|
||||
procedure DoMarkupLineHighlightInfoChange(Sender: TObject);
|
||||
function HasLineHighlight: Boolean;
|
||||
procedure DoCaretChanged(OldCaret : TPoint); override;
|
||||
procedure DoTopLineChanged(OldTopLine : Integer); override;
|
||||
procedure DoLinesInWindoChanged(OldLinesInWindow : Integer); override;
|
||||
procedure DoTextChanged(StartLine, EndLine : Integer); override;
|
||||
procedure DoMarkupChanged(AMarkup: TSynSelectedColor); override;
|
||||
public
|
||||
constructor Create(ASynEdit: TCustomControl);
|
||||
destructor Destroy; override;
|
||||
@ -87,6 +92,31 @@ begin
|
||||
(FMarkupLineHighlightInfo.Foreground <> clNone);
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupSpecialLine.DoCaretChanged(OldCaret: TPoint);
|
||||
begin
|
||||
InvalidateLineHighlight;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupSpecialLine.DoTopLineChanged(OldTopLine: Integer);
|
||||
begin
|
||||
InvalidateLineHighlight;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupSpecialLine.DoLinesInWindoChanged(OldLinesInWindow: Integer);
|
||||
begin
|
||||
InvalidateLineHighlight;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupSpecialLine.DoTextChanged(StartLine, EndLine: Integer);
|
||||
begin
|
||||
InvalidateLineHighlight;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupSpecialLine.DoMarkupChanged(AMarkup: TSynSelectedColor);
|
||||
begin
|
||||
InvalidateLineHighlight;
|
||||
end;
|
||||
|
||||
constructor TSynEditMarkupSpecialLine.Create(ASynEdit: TCustomControl);
|
||||
begin
|
||||
inherited Create(ASynEdit);
|
||||
|
Loading…
Reference in New Issue
Block a user