mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-15 22:20:44 +01:00
SynEdit: clean up, RightEdge to TLazSynTextArea
git-svn-id: trunk@34669 -
This commit is contained in:
parent
83ccf70cb2
commit
1c7bbcfc56
@ -38,6 +38,7 @@ type
|
||||
FExtraLineSpacing: integer;
|
||||
FVisibleSpecialChars: TSynVisibleSpecialChars;
|
||||
FRightEdgeColumn: integer;
|
||||
FRightEdgeVisible: boolean;
|
||||
|
||||
FTopLine: TLinePos;
|
||||
FLeftChar: Integer;
|
||||
@ -65,23 +66,25 @@ type
|
||||
procedure FontChanged; // must be called by owner of shared tetdrawer
|
||||
procedure Paint(ACanvas: TCanvas; AClip: TRect);
|
||||
|
||||
// Settings controlled by SynEdit
|
||||
procedure SetBounds(ATop, ALeft, ABottom, ARight: Integer);
|
||||
property Padding[Side: TLazSynBorderSide]: integer read GetPadding write SetPadding;
|
||||
property ForegroundColor: TColor read FForegroundColor write FForegroundColor;
|
||||
property BackgroundColor: TColor read FBackgroundColor write FBackgroundColor;
|
||||
property RightEdgeColor: TColor read FRightEdgeColor write FRightEdgeColor;
|
||||
property Padding[Side: TLazSynBorderSide]: integer read GetPadding write SetPadding;
|
||||
property ExtraCharSpacing: integer read FExtraCharSpacing write SetExtraCharSpacing;
|
||||
property ExtraLineSpacing: integer read FExtraLineSpacing write SetExtraLineSpacing;
|
||||
property VisibleSpecialChars: TSynVisibleSpecialChars read FVisibleSpecialChars write FVisibleSpecialChars;
|
||||
property RightEdgeColumn: integer read FRightEdgeColumn write FRightEdgeColumn; // -1 = hide
|
||||
property RightEdgeColumn: integer read FRightEdgeColumn write FRightEdgeColumn;
|
||||
property RightEdgeVisible: boolean read FRightEdgeVisible write FRightEdgeVisible;
|
||||
property RightEdgeColor: TColor read FRightEdgeColor write FRightEdgeColor;
|
||||
|
||||
property TopLine: TLinePos read FTopLine write SetTopLine; // TopView
|
||||
property LeftChar: Integer read FLeftChar write SetLeftChar;
|
||||
|
||||
property TheLinesView: TSynEditStrings read FTheLinesView write FTheLinesView;
|
||||
property DisplayView: TLazSynDisplayView read FDisplayView write FDisplayView;
|
||||
property Highlighter: TSynCustomHighlighter read FHighlighter write FHighlighter;
|
||||
property MarkupManager : TSynEditMarkupManager read FMarkupManager write FMarkupManager;
|
||||
property TheLinesView: TSynEditStrings read FTheLinesView write FTheLinesView;
|
||||
property DisplayView: TLazSynDisplayView read FDisplayView write FDisplayView;
|
||||
property Highlighter: TSynCustomHighlighter read FHighlighter write FHighlighter;
|
||||
property MarkupManager: TSynEditMarkupManager read FMarkupManager write FMarkupManager;
|
||||
public
|
||||
property Left: Integer read FBounds.Left;
|
||||
property Top: Integer read FBounds.Top;
|
||||
@ -207,6 +210,9 @@ begin
|
||||
FPadding[i] := 0;
|
||||
FTopLine := 1;
|
||||
FLeftChar := 1;
|
||||
FRightEdgeColumn := 80;
|
||||
FRightEdgeVisible := True;
|
||||
FRightEdgeColor := clSilver;
|
||||
FontChanged;
|
||||
end;
|
||||
|
||||
@ -493,7 +499,7 @@ var
|
||||
// Draw the right edge under the text if necessary
|
||||
nX := ScreenColumnToXValue(FirstPhysical); // == rcToken.Left
|
||||
if ForceEto then fTextDrawer.ForceNextTokenWithEto;
|
||||
if bDoRightEdge and (RightEdgeColumn >= 0)
|
||||
if bDoRightEdge
|
||||
and (nRightEdge<rcToken.Right) and (nRightEdge>=rcToken.Left)
|
||||
then begin
|
||||
// draw background (use rcToken, so we do not delete the divider-draw-line)
|
||||
@ -626,7 +632,7 @@ var
|
||||
until nX1 >= rcLine.Right;
|
||||
|
||||
// Draw the right edge if necessary.
|
||||
if bDoRightEdge and (RightEdgeColumn >= 0)
|
||||
if bDoRightEdge
|
||||
and (nRightEdge >= eolx) then begin // xx rc Token
|
||||
LCLIntf.MoveToEx(dc, nRightEdge, rcLine.Top, nil);
|
||||
LCLIntf.LineTo(dc, nRightEdge, rcLine.Bottom + 1);
|
||||
@ -963,7 +969,7 @@ begin
|
||||
// If the right edge is visible and in the invalid area, prepare to paint it.
|
||||
// Do this first to realize the pen when getting the dc variable.
|
||||
bDoRightEdge := FALSE;
|
||||
if (RightEdgeColumn > 0) then begin // column value
|
||||
if FRightEdgeVisible then begin // column value
|
||||
nRightEdge := FTextBounds.Left + (RightEdgeColumn - LeftChar + 1) * CharWidth; // pixel value
|
||||
if (nRightEdge >= AClip.Left) and (nRightEdge <= AClip.Right) then
|
||||
bDoRightEdge := TRUE;
|
||||
@ -1019,7 +1025,7 @@ begin
|
||||
AClip.Left := DrawLeft;
|
||||
|
||||
// Draw the right edge if necessary.
|
||||
if bDoRightEdge and (RightEdgeColumn >= 0) then begin
|
||||
if bDoRightEdge then begin
|
||||
LCLIntf.MoveToEx(dc, nRightEdge, AClip.Top, nil);
|
||||
LCLIntf.LineTo(dc, nRightEdge, AClip.Bottom + 1);
|
||||
end;
|
||||
|
||||
@ -445,8 +445,6 @@ type
|
||||
FInvalidateRect: TRect;
|
||||
FIsInDecPaintLock: Boolean;
|
||||
fReadOnly: Boolean;
|
||||
fRightEdge: Integer;
|
||||
fRightEdgeColor: TColor;
|
||||
FScrollBars: TScrollStyle;
|
||||
FOldTopView: Integer;
|
||||
FLastTextChangeStamp: Int64;
|
||||
@ -521,6 +519,8 @@ type
|
||||
function GetMouseTextActions: TSynEditMouseActions;
|
||||
function GetPaintLockOwner: TSynEditBase;
|
||||
function GetPlugin(Index: Integer): TSynEditPlugin;
|
||||
function GetRightEdge: Integer;
|
||||
function GetRightEdgeColor: TColor;
|
||||
function GetTextBetweenPoints(aStartPoint, aEndPoint: TPoint): String;
|
||||
function GetTopLine: Integer;
|
||||
procedure SetBlockTabIndent(AValue: integer);
|
||||
@ -1033,9 +1033,8 @@ type
|
||||
default SYNEDIT_DEFAULT_SHARE_OPTIONS; experimental;
|
||||
property VisibleSpecialChars: TSynVisibleSpecialChars read FVisibleSpecialChars write SetVisibleSpecialChars;
|
||||
property ReadOnly: Boolean read GetReadOnly write SetReadOnly default FALSE;
|
||||
property RightEdge: Integer read fRightEdge write SetRightEdge default 80;
|
||||
property RightEdgeColor: TColor
|
||||
read fRightEdgeColor write SetRightEdgeColor default clSilver;
|
||||
property RightEdge: Integer read GetRightEdge write SetRightEdge default 80;
|
||||
property RightEdgeColor: TColor read GetRightEdgeColor write SetRightEdgeColor default clSilver;
|
||||
property ScrollBars: TScrollStyle
|
||||
read FScrollBars write SetScrollBars default ssBoth;
|
||||
property BracketHighlightStyle: TSynEditBracketHighlightStyle
|
||||
@ -1604,6 +1603,16 @@ begin
|
||||
Result := TSynEditPlugin(fPlugins[Index]);
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.GetRightEdge: Integer;
|
||||
begin
|
||||
Result := FTextArea.RightEdgeColumn;
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.GetRightEdgeColor: TColor;
|
||||
begin
|
||||
Result := FTextArea.RightEdgeColor;
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.GetTextBetweenPoints(aStartPoint, aEndPoint: TPoint): String;
|
||||
begin
|
||||
FInternalBlockSelection.SelectionMode := smNormal;
|
||||
@ -1844,8 +1853,7 @@ begin
|
||||
FPaintLineColor2 := TSynSelectedColor.Create;
|
||||
fBookMarkOpt := TSynBookMarkOpt.Create(Self);
|
||||
fBookMarkOpt.OnChange := {$IFDEF FPC}@{$ENDIF}BookMarkOptionsChanged;
|
||||
// fRightEdge has to be set before FontChanged is called for the first time
|
||||
fRightEdge := 80;
|
||||
|
||||
FLeftGutter := CreateGutter(self, gsLeft, FTextDrawer);
|
||||
FLeftGutter.OnChange := {$IFDEF FPC}@{$ENDIF}GutterChanged;
|
||||
FLeftGutter.OnResize := {$IFDEF FPC}@{$ENDIF}GutterResized;
|
||||
@ -1894,9 +1902,7 @@ begin
|
||||
fBlockIndent := 2;
|
||||
|
||||
FTextArea := TLazSynTextArea.Create(FTextDrawer);
|
||||
if eoHideRightMargin in SYNEDIT_DEFAULT_OPTIONS // follow default
|
||||
then FTextArea.RightEdgeColumn := -1
|
||||
else FTextArea.RightEdgeColumn := fRightEdge;
|
||||
FTextArea.RightEdgeVisible := not(eoHideRightMargin in SYNEDIT_DEFAULT_OPTIONS);
|
||||
FTextArea.ExtraCharSpacing := 0;
|
||||
FTextArea.ExtraLineSpacing := 0;
|
||||
FTextArea.MarkupManager := fMarkupManager;
|
||||
@ -1930,7 +1936,6 @@ begin
|
||||
FMouseActionSearchHandlerList := TSynEditMouseActionSearchList.Create;
|
||||
FMouseActionExecHandlerList := TSynEditMouseActionExecList.Create;
|
||||
|
||||
fRightEdgeColor := clSilver;
|
||||
{$IFDEF SYN_MBCSSUPPORT}
|
||||
fImeCount := 0;
|
||||
fMBCSStepAside := False;
|
||||
@ -3358,7 +3363,6 @@ begin
|
||||
// Then paint the text area if it was (partly) invalidated.
|
||||
FTextArea.ForegroundColor := Font.Color;
|
||||
FTextArea.BackgroundColor := Color;
|
||||
FTextArea.RightEdgeColor := RightEdgeColor;
|
||||
FTextArea.Paint(Canvas, rcClip);
|
||||
// right gutter
|
||||
if FRightGutter.Visible and (rcClip.Right > ClientWidth - FRightGutter.Width - ScrollBarWidth) then begin
|
||||
@ -5327,12 +5331,10 @@ end;
|
||||
|
||||
procedure TCustomSynEdit.SetRightEdge(Value: Integer);
|
||||
begin
|
||||
if fRightEdge <> Value then begin
|
||||
fRightEdge := Value;
|
||||
if eoHideRightMargin in Options
|
||||
then FTextArea.RightEdgeColumn := -1
|
||||
else FTextArea.RightEdgeColumn := Value;
|
||||
Invalidate;
|
||||
if FTextArea.RightEdgeColumn <> Value then begin
|
||||
FTextArea.RightEdgeColumn := Value;
|
||||
if FTextArea.RightEdgeVisible then
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -5341,10 +5343,10 @@ var
|
||||
nX: integer;
|
||||
rcInval: TRect;
|
||||
begin
|
||||
if fRightEdgeColor <> Value then begin
|
||||
fRightEdgeColor := Value;
|
||||
if RightEdgeColor <> Value then begin
|
||||
FTextArea.RightEdgeColor := Value;
|
||||
if HandleAllocated then begin
|
||||
nX := FTextArea.ScreenColumnToXValue(fRightEdge + 1);
|
||||
nX := FTextArea.ScreenColumnToXValue(FTextArea.RightEdgeColumn + 1);
|
||||
rcInval := Rect(nX - 1, 0, nX + 1, ClientHeight-ScrollBarWidth);
|
||||
{$IFDEF VerboseSynEditInvalidate}
|
||||
DebugLn(['TCustomSynEdit.SetRightEdgeColor ',dbgs(rcInval)]);
|
||||
@ -6892,11 +6894,8 @@ begin
|
||||
end;
|
||||
fMarkupSpecialChar.Enabled := (eoShowSpecialChars in fOptions);
|
||||
|
||||
if (eoHideRightMargin in ChangedOptions) then begin
|
||||
if eoHideRightMargin in FOptions
|
||||
then FTextArea.RightEdgeColumn := -1
|
||||
else FTextArea.RightEdgeColumn := fRightEdge;
|
||||
end;
|
||||
if (eoHideRightMargin in ChangedOptions) then
|
||||
FTextArea.RightEdgeVisible := not(eoHideRightMargin in FOptions);
|
||||
|
||||
(* Deal with deprecated Mouse values
|
||||
Those are all controlled by mouse-actions.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user