IDE, SynEdit: Add options for the editor gutter layout. Issue #40170

This commit is contained in:
Martin 2024-03-09 17:42:13 +01:00
parent 69a432d864
commit b1847337ca
9 changed files with 693 additions and 163 deletions

View File

@ -453,7 +453,7 @@ type
private
FOwner: TSynObjectList;
function GetIndex: Integer;
procedure SetIndex(const AValue: Integer);
procedure SetIndex(AValue: Integer);
protected
function Compare(Other: TSynObjectListItem): Integer; virtual;
function GetDisplayName: String; virtual;
@ -1898,8 +1898,10 @@ begin
//
end;
procedure TSynObjectListItem.SetIndex(const AValue: Integer);
procedure TSynObjectListItem.SetIndex(AValue: Integer);
begin
if AValue < 0 then AValue := 0;
if AValue >= Owner.Count then AValue := Owner.Count - 1;
Owner.Move(GetIndex, AValue);
end;

View File

@ -443,11 +443,11 @@ begin
Canvas.FillRect(AClip);
if FLineOnRight then begin
AClip.Right := Min(AClip.Right, Left + Width - FLineOffset);
AClip.Left := Max(AClip.Left, Left + Width - FLineOffset - FLineWidth);
AClip.Right := Min(AClip.Right, Left + LeftOffset + Width - FLineOffset);
AClip.Left := Max(AClip.Left, Left + LeftOffset + Width - FLineOffset - FLineWidth);
end else begin
AClip.Left := Max(AClip.Left, Left + FLineOffset);
AClip.Right := Min(AClip.Right, Left + FLineOffset + FLineWidth);
AClip.Left := Max(AClip.Left, Left + LeftOffset + FLineOffset);
AClip.Right := Min(AClip.Right, Left + LeftOffset + FLineOffset + FLineWidth);
end;
if AClip.Right > AClip.Left then begin
Canvas.Brush.Color := MarkupInfo.Foreground;

View File

@ -1405,7 +1405,7 @@ var
begin
inherited DoResize(Sender);
if (not SynEdit.HandleAllocated) or (not Self.Visible) then exit;
FWinControl.BoundsRect := Bounds(Left,Top,Width,Height);
FWinControl.BoundsRect := Bounds(Left+LeftOffset,Top,Width,Height);
{$IFDEF DARWIN}
FLineMarks.PixelHeight := Height;

View File

@ -16,6 +16,7 @@ type
TSynGutterMarks = class(TSynGutterPartBase)
private
FColumnCount: Integer;
FWantedColumns: integer;
FColumnWidth: Integer;
FDebugMarksImageIndex: Integer;
FInternalImage: TSynInternalImage;
@ -32,14 +33,15 @@ type
var aFirstCustomColumnIdx: integer): Boolean;
Procedure PaintLine(aScreenLine: Integer; Canvas : TCanvas; AClip : TRect); virtual;
property ColumnWidth: Integer read FColumnWidth; // initialized in Paint
property ColumnCount: Integer read FColumnCount;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Paint(Canvas: TCanvas; AClip: TRect; FirstLine, LastLine: integer); override;
procedure SetWidthForColumns(AValue: Integer);
property DebugMarksImageIndex: Integer read FDebugMarksImageIndex write FDebugMarksImageIndex;
property ColumnWidth: Integer read FColumnWidth; // initialized in Paint
property ColumnCount: Integer read FColumnCount;
end;
implementation
@ -62,7 +64,13 @@ end;
function TSynGutterMarks.PreferedWidth: Integer;
begin
Result := 22 + FBookMarkOpt.LeftMargin
Result := 22 + FBookMarkOpt.LeftMargin;
if FWantedColumns > 0 then begin
if assigned(FBookMarkOpt) and assigned(FBookMarkOpt.BookmarkImages) then begin
FColumnWidth := GetImgListRes(FriendEdit.Canvas, FBookMarkOpt.BookmarkImages).Width;
Result := FWantedColumns*FColumnWidth;
end;
end;
end;
function TSynGutterMarks.LeftMarginAtCurrentPPI: Integer;
@ -245,5 +253,16 @@ begin
end;
end;
procedure TSynGutterMarks.SetWidthForColumns(AValue: Integer);
begin
if FWantedColumns = AValue then
exit;
FWantedColumns := AValue;
if not AutoSize then
AutoSize := True
else
DoAutoSize;
end;
end.

View File

@ -63,7 +63,7 @@ uses
SynHighlighterIni, SynHighlighterPo, SynHighlighterPike, SynPluginMultiCaret,
SynEditMarkupFoldColoring, SynEditMarkup, SynGutterLineOverview,
SynBeautifierPascal, SynEditTextDynTabExpander, SynEditTextTabExpander,
SynTextMateSyn, SynEditStrConst, SynHighlighterPosition,
SynTextMateSyn, SynEditStrConst, SynHighlighterPosition, SynGutterMarks,
// codetools
LinkScanner, CodeToolManager,
// BuildIntf
@ -1467,6 +1467,48 @@ type
TEditorOptsScrollPastEolMode = (optScrollFixed, optScrollPage, optScrollNone);
{ TEditorSynGutterOptions }
TEditorSynGutterOptions = class(TPersistent)
private
FDefaults: TEditorSynGutterOptions;
FGClass: TSynGutterPartBaseClass;
FIndex: integer;
FOffsetLeft: integer;
FOffsetRight: integer;
FVisible: boolean;
FWidth: integer;
protected
constructor DoCreate(AIdx: Integer; AGClass: TSynGutterPartBaseClass);
public
constructor Create(AIdx: Integer; AGClass: TSynGutterPartBaseClass);
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure ApplyTo(AGutterPart: TSynGutterPartBase);
procedure ApplyIndexTo(AGutterPart: TSynGutterPartBase);
property Defaults: TEditorSynGutterOptions read FDefaults;
property GClass: TSynGutterPartBaseClass read FGClass;
published
property Visible: boolean read FVisible write FVisible;
property Index: integer read FIndex write FIndex;
property Width: integer read FWidth write FWidth;
property OffsetLeft: integer read FOffsetLeft write FOffsetLeft;
property OffsetRight: integer read FOffsetRight write FOffsetRight;
end;
{ TEditorSynGutterOptionsList }
TEditorSynGutterOptionsList = class(specialize TFPGObjectList<TEditorSynGutterOptions>)
private
function GetByClass(AIndex: TSynGutterPartBaseClass): TEditorSynGutterOptions;
public
procedure Assign(Source: TEditorSynGutterOptionsList);
procedure AssignItems(Source: TEditorSynGutterOptionsList);
procedure Sort;
property ByClass[AIndex: TSynGutterPartBaseClass]: TEditorSynGutterOptions read GetByClass;
end;
{ TEditorOptionsBase }
TEditorOptionsBase = class(TIDEEditorOptions)
@ -1485,7 +1527,14 @@ type
fMultiLineTab: Boolean;
fTabPosition: TTabPosition;
// Display options
fShowOverviewGutter: boolean;
FGutterPartMarks: TEditorSynGutterOptions;
FGutterPartChange: TEditorSynGutterOptions;
FGutterPartFold: TEditorSynGutterOptions;
FGutterPartLine: TEditorSynGutterOptions;
FGutterPartOver: TEditorSynGutterOptions;
FGutterPartSep: TEditorSynGutterOptions;
FGutterPartList: TEditorSynGutterOptionsList;
FGutterRightPartList: TEditorSynGutterOptionsList;
fTopInfoView: boolean;
// Code tools options
fDbgHintAutoTypeCastClass: Boolean;
@ -1540,6 +1589,16 @@ type
public
constructor Create;
destructor Destroy; override;
// Display
property GutterPartMarks: TEditorSynGutterOptions read FGutterPartMarks;
property GutterPartLine: TEditorSynGutterOptions read FGutterPartLine;
property GutterPartChange: TEditorSynGutterOptions read FGutterPartChange;
property GutterPartSep: TEditorSynGutterOptions read FGutterPartSep;
property GutterPartFold: TEditorSynGutterOptions read FGutterPartFold;
property GutterPartOver: TEditorSynGutterOptions read FGutterPartOver;
property GutterPartList: TEditorSynGutterOptionsList read FGutterPartList;
property GutterRightPartList: TEditorSynGutterOptionsList read FGutterRightPartList;
published { use RTTIConf}
// general options
property MultiLineTab: Boolean read fMultiLineTab write fMultiLineTab default False;
@ -1559,8 +1618,7 @@ type
property ExportHtmlWithBackground: Boolean
read fExportHtmlWithBackground write fExportHtmlWithBackground default False;
// Display
property ShowOverviewGutter: boolean
read fShowOverviewGutter write fShowOverviewGutter default True;
property TopInfoView: boolean read fTopInfoView write fTopInfoView default True;
// Code Folding
property ReverseFoldPopUpOrder: Boolean
@ -1677,10 +1735,8 @@ type
// Display options
fVisibleRightMargin: Boolean;
fVisibleGutter: Boolean;
fShowLineNumbers: Boolean;
fShowOnlyLineNumbersMultiplesOf: integer;
fGutterWidth: Integer;
fGutterSeparatorIndex: Integer;
fRightMargin: Integer;
fEditorFont: String;
fEditorFontSize: Integer;
@ -1801,13 +1857,9 @@ type
property VisibleRightMargin: Boolean
read fVisibleRightMargin write fVisibleRightMargin default True;
property VisibleGutter: Boolean read fVisibleGutter write fVisibleGutter default True;
property ShowLineNumbers: Boolean read fShowLineNumbers
write fShowLineNumbers default False;
property ShowOnlyLineNumbersMultiplesOf: integer read fShowOnlyLineNumbersMultiplesOf
write fShowOnlyLineNumbersMultiplesOf;
property GutterWidth: Integer read fGutterWidth write fGutterWidth default 30;
property GutterSeparatorIndex: Integer read FGutterSeparatorIndex
write FGutterSeparatorIndex default 3;
property RightMargin: Integer read fRightMargin write fRightMargin default 80;
property EditorFont: String read fEditorFont write fEditorFont;
property EditorFontSize: Integer read fEditorFontSize write fEditorFontSize;
@ -2156,6 +2208,144 @@ begin
Result := FList.Count;
end;
{ TEditorSynGutterOptions }
constructor TEditorSynGutterOptions.DoCreate(AIdx: Integer;
AGClass: TSynGutterPartBaseClass);
begin
inherited Create;
FGClass := AGClass;
FIndex := AIdx;
FVisible := True;
if FGClass = TSynGutterMarks then begin
FWidth := 2;
end
else
if FGClass = TSynGutterLineNumber then begin
FWidth := 2;
end;
end;
constructor TEditorSynGutterOptions.Create(AIdx: Integer;
AGClass: TSynGutterPartBaseClass);
begin
DoCreate(AIdx, AGClass);
FDefaults := TEditorSynGutterOptions.DoCreate(AIdx, AGClass);
end;
destructor TEditorSynGutterOptions.Destroy;
begin
FreeAndNil(FDefaults);
inherited Destroy;
end;
procedure TEditorSynGutterOptions.Assign(Source: TPersistent);
begin
if Source is TEditorSynGutterOptions then begin
FGClass := TEditorSynGutterOptions(Source).FGClass;
FIndex := TEditorSynGutterOptions(Source).FIndex;
FOffsetLeft := TEditorSynGutterOptions(Source).FOffsetLeft;
FOffsetRight := TEditorSynGutterOptions(Source).FOffsetRight;
FVisible := TEditorSynGutterOptions(Source).FVisible;
FWidth := TEditorSynGutterOptions(Source).FWidth;
end;
end;
procedure TEditorSynGutterOptions.ApplyTo(AGutterPart: TSynGutterPartBase);
begin
if AGutterPart = nil then exit;
if FGClass = TSynGutterMarks then begin
TSynGutterMarks(AGutterPart).SetWidthForColumns(FWidth);
end
else
if FGClass = TSynGutterLineNumber then begin
AGutterPart.AutoSize := True;
TSynGutterLineNumber(AGutterPart).DigitCount := FWidth;
end
else
if FGClass = TSynGutterSeparator then begin
AGutterPart.AutoSize := FWidth = 0;
if FWidth = 0 then begin
TSynGutterSeparator(AGutterPart).Width := 2;
TSynGutterSeparator(AGutterPart).LineWidth := 1;
end
else begin
TSynGutterSeparator(AGutterPart).Width := FWidth;
TSynGutterSeparator(AGutterPart).LineWidth := FWidth;
end;
end
else
begin
AGutterPart.AutoSize := FWidth = 0;
AGutterPart.Width := FWidth;
end;
AGutterPart.Visible := FVisible;
AGutterPart.LeftOffset := FOffsetLeft;
AGutterPart.RightOffset := FOffsetRight;
end;
procedure TEditorSynGutterOptions.ApplyIndexTo(AGutterPart: TSynGutterPartBase);
begin
if AGutterPart <> nil then
AGutterPart.Index := Index;
end;
{ TEditorSynGutterOptionsList }
function SynGutterOptListSortCompare(const Item1, Item2: TEditorSynGutterOptions): Integer;
begin
Result := Item1.Index - Item2.Index;
end;
function TEditorSynGutterOptionsList.GetByClass(AIndex: TSynGutterPartBaseClass
): TEditorSynGutterOptions;
var
i: Integer;
begin
for i := 0 to Count - 1 do
if Items[i].GClass = AIndex then
exit(Items[i]);
end;
procedure TEditorSynGutterOptionsList.Assign(Source: TEditorSynGutterOptionsList);
var
i: Integer;
n: TEditorSynGutterOptions;
begin
Clear;
for i := 0 to Source.Count - 1 do begin
n := TEditorSynGutterOptions.Create(Source[i].Index, Source[i].GClass);
n.Assign(Source[i]);
Add(n);
end;
end;
procedure TEditorSynGutterOptionsList.AssignItems(Source: TEditorSynGutterOptionsList);
var
i: Integer;
itm, dest: TEditorSynGutterOptions;
begin
for i := 0 to Source.Count - 1 do begin
itm := Source.Items[i];
dest := ByClass[itm.GClass];
if dest <> nil then
dest.Assign(itm);
end;
Sort;
end;
procedure TEditorSynGutterOptionsList.Sort;
var
i: Integer;
begin
inherited Sort(@SynGutterOptListSortCompare);
// fix gaps
for i := 0 to Count - 1 do
Items[i].Index := i;
end;
{ TEditorUserDefinedWords }
procedure TEditorUserDefinedWords.SetName(AValue: String);
@ -5127,10 +5317,29 @@ begin
inherited Create;
FScrollOnEditLeftOptions := TSynScrollOnEditLeftOptions.Create;
FScrollOnEditRightOptions := TSynScrollOnEditRightOptions.Create;
FGutterPartMarks := TEditorSynGutterOptions.Create(0, TSynGutterMarks);
FGutterPartLine := TEditorSynGutterOptions.Create(1, TSynGutterLineNumber);
FGutterPartChange:= TEditorSynGutterOptions.Create(2, TSynGutterChanges);
FGutterPartSep := TEditorSynGutterOptions.Create(3, TSynGutterSeparator);
FGutterPartFold := TEditorSynGutterOptions.Create(4, TSynGutterCodeFolding);
FGutterPartOver := TEditorSynGutterOptions.Create(0, TSynGutterLineOverview);
FGutterPartList := TEditorSynGutterOptionsList.Create(True);
FGutterRightPartList := TEditorSynGutterOptionsList.Create(True);
FGutterPartList.Add(FGutterPartMarks);
FGutterPartList.Add(FGutterPartLine);
FGutterPartList.Add(FGutterPartChange);
FGutterPartList.Add(FGutterPartSep);
FGutterPartList.Add(FGutterPartFold);
FGutterRightPartList.Add(FGutterPartOver);
end;
destructor TEditorOptionsBase.Destroy;
begin
FreeAndNil(FGutterPartList);
FreeAndNil(FGutterRightPartList);
FreeAndNil(FScrollOnEditLeftOptions);
FreeAndNil(FScrollOnEditRightOptions);
inherited Destroy;
@ -5147,7 +5356,6 @@ begin
fMultiCaretDeleteSkipLineBreak := False;
fExportHtmlWithBackground := False;
// Display options
fShowOverviewGutter := True;
fTopInfoView := True;
// hints
fDbgHintAutoTypeCastClass := True;
@ -5307,7 +5515,6 @@ begin
fElasticTabsMinWidth := 1;
fBracketHighlightStyle := sbhsBoth;
// Display options
fGutterSeparatorIndex := 3;
fEditorFont := SynDefaultFontName;
fEditorFontSize := SynDefaultFontSize;
fDisableAntialiasing := DefaultEditorDisableAntiAliasing;
@ -5353,6 +5560,8 @@ var
SynEditOpt2: TSynEditorOption2;
FileVersion: LongInt;
DefOpts: TSynEditorOptions;
OldGutterSeparatorIndex: Int64;
OldShowLineNumbers: Boolean;
begin
try
FileVersion:=XMLConfig.GetValue('EditorOptions/Version', EditorOptsFormatVersion);
@ -5438,25 +5647,53 @@ begin
TSynEditBracketHighlightStyle(XMLConfig.GetValue('EditorOptions/General/Editor/BracketHighlightStyle', 2));
// Display options
XMLConfig.ReadObject('EditorOptions/GutterParts/Marks/', FGutterPartMarks, FGutterPartMarks.Defaults);
XMLConfig.ReadObject('EditorOptions/GutterParts/Line/', FGutterPartLine, FGutterPartLine.Defaults);
XMLConfig.ReadObject('EditorOptions/GutterParts/Change/', FGutterPartChange, FGutterPartChange.Defaults);
XMLConfig.ReadObject('EditorOptions/GutterParts/Sep/', FGutterPartSep, FGutterPartSep.Defaults);
XMLConfig.ReadObject('EditorOptions/GutterParts/Fold/', FGutterPartFold, FGutterPartFold.Defaults);
XMLConfig.ReadObject('EditorOptions/GutterParts/Over/', FGutterPartOver, FGutterPartOver.Defaults);
FGutterPartList.Sort;
FGutterRightPartList.Sort;
fVisibleRightMargin :=
XMLConfig.GetValue('EditorOptions/Display/VisibleRightMargin', True);
fVisibleGutter :=
XMLConfig.GetValue('EditorOptions/Display/VisibleGutter', True);
if FileVersion<4 then begin
fShowLineNumbers :=
OldShowLineNumbers :=
XMLConfig.GetValue('EditorOptions/Display/ShowLineNumbers', False);
if OldShowLineNumbers then
FGutterPartLine.Visible := True;
fShowOnlyLineNumbersMultiplesOf :=
XMLConfig.GetValue('EditorOptions/Display/ShowOnlyLineNumbersMultiplesOf', 1);
end else begin
fShowLineNumbers :=
OldShowLineNumbers :=
XMLConfig.GetValue('EditorOptions/Display/ShowLineNumbers', True);
if not OldShowLineNumbers then
FGutterPartLine.Visible := False;
fShowOnlyLineNumbersMultiplesOf :=
XMLConfig.GetValue('EditorOptions/Display/ShowOnlyLineNumbersMultiplesOf', 5);
end;
OldGutterSeparatorIndex :=
XMLConfig.GetValue('EditorOptions/Display/GutterSeparatorIndex', 3);
if OldGutterSeparatorIndex = -1 then
FGutterPartSep.Visible := False
else
if OldGutterSeparatorIndex <> 3 then begin
for i := OldGutterSeparatorIndex+1 to FGutterPartList.Count - 1 do
FGutterPartList[i].Index := FGutterPartList[i].Index + 1;
FGutterPartSep.Index := OldGutterSeparatorIndex;
FGutterPartList.Sort;
end;
if not XMLConfig.GetValue('EditorOptions/Misc/ShowOverviewGutter', True) then
FGutterPartOver.Visible := False;
fGutterWidth :=
XMLConfig.GetValue('EditorOptions/Display/GutterWidth', 30);
FGutterSeparatorIndex :=
XMLConfig.GetValue('EditorOptions/Display/GutterSeparatorIndex', 3);
fRightMargin :=
XMLConfig.GetValue('EditorOptions/Display/RightMargin', 80);
fEditorFont :=
@ -5583,6 +5820,13 @@ begin
XMLConfig.WriteObject('EditorOptions/Misc/', Self, FDefaultValues);
XMLConfig.WriteObject('EditorOptions/GutterParts/Marks/', FGutterPartMarks, FGutterPartMarks.Defaults);
XMLConfig.WriteObject('EditorOptions/GutterParts/Line/', FGutterPartLine, FGutterPartLine.Defaults);
XMLConfig.WriteObject('EditorOptions/GutterParts/Change/', FGutterPartChange, FGutterPartChange.Defaults);
XMLConfig.WriteObject('EditorOptions/GutterParts/Sep/', FGutterPartSep, FGutterPartSep.Defaults);
XMLConfig.WriteObject('EditorOptions/GutterParts/Fold/', FGutterPartFold, FGutterPartFold.Defaults);
XMLConfig.WriteObject('EditorOptions/GutterParts/Over/', FGutterPartOver, FGutterPartOver.Defaults);
// general options
for SynEditOpt := Low(TSynEditorOption) to High(TSynEditorOption) do
begin
@ -5659,14 +5903,13 @@ begin
, fVisibleRightMargin, True);
XMLConfig.SetDeleteValue('EditorOptions/Display/VisibleGutter',
fVisibleGutter, True);
XMLConfig.SetDeleteValue('EditorOptions/Display/ShowLineNumbers',
fShowLineNumbers, True);
XMLConfig.DeleteValue('EditorOptions/Display/ShowLineNumbers');
XMLConfig.SetDeleteValue('EditorOptions/Display/ShowOnlyLineNumbersMultiplesOf',
fShowOnlyLineNumbersMultiplesOf, 5);
XMLConfig.SetDeleteValue('EditorOptions/Display/GutterWidth',
fGutterWidth, 30);
XMLConfig.SetDeleteValue('EditorOptions/Display/GutterSeparatorIndex',
fGutterSeparatorIndex, 3);
XMLConfig.DeleteValue('EditorOptions/Display/GutterSeparatorIndex');
XMLConfig.DeleteValue('EditorOptions/Misc/ShowOverviewGutter');
XMLConfig.SetDeleteValue('EditorOptions/Display/RightMargin',
fRightMargin, 80);
XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFont',
@ -6447,10 +6690,8 @@ begin
// Display options
ASynEdit.Gutter.Visible := fVisibleGutter;
ASynEdit.Gutter.AutoSize := true;
ASynEdit.Gutter.LineNumberPart.Visible := fShowLineNumbers;
ASynEdit.Gutter.LineNumberPart(0).ShowOnlyLineNumbersMultiplesOf :=
fShowOnlyLineNumbersMultiplesOf;
ASynEdit.RightGutter.Visible := ShowOverviewGutter;
if ASynEdit is TIDESynEditor then
TIDESynEditor(ASynEdit).ShowTopInfo := TopInfoView;
@ -6460,9 +6701,6 @@ begin
ASynEdit.Gutter.CodeFoldPart.ReversePopMenuOrder := ReverseFoldPopUpOrder;
ASynEdit.Gutter.Width := fGutterWidth;
ASynEdit.Gutter.SeparatorPart.Visible := FGutterSeparatorIndex <> -1;
if FGutterSeparatorIndex <> -1 then
ASynEdit.Gutter.SeparatorPart(0).Index := FGutterSeparatorIndex;
ASynEdit.RightEdge := fRightMargin;
if fVisibleRightMargin then
@ -6515,16 +6753,30 @@ begin
if ASynEdit.Gutter.ChangesPart<> nil then
ASynEdit.Gutter.ChangesPart.MouseActions.Assign(FUserMouseSettings.GutterActionsChanges);
if (ASynEdit.Gutter.SeparatorPart <> nil) and (GutterSeparatorIndex = 2) and ShowLineNumbers then
if (ASynEdit.Gutter.SeparatorPart <> nil) and
(abs(FGutterPartSep.Index - FGutterPartLine.Index) = 1) and
FGutterPartLine.Visible
then
ASynEdit.Gutter.SeparatorPart.MouseActions.Assign(FUserMouseSettings.GutterActionsLines)
else
if (ASynEdit.Gutter.SeparatorPart <> nil) and (GutterSeparatorIndex >= 2) then
if (ASynEdit.Gutter.SeparatorPart <> nil) and (abs(FGutterPartSep.Index - FGutterPartChange.Index) = 1) then
ASynEdit.Gutter.SeparatorPart.MouseActions.Assign(FUserMouseSettings.GutterActionsChanges);
if ASynEdit.RightGutter.LineOverviewPart <> nil then begin
ASynEdit.RightGutter.LineOverviewPart.MouseActions.Assign(FUserMouseSettings.GutterActionsOverView);
ASynEdit.RightGutter.LineOverviewPart.MouseActionsForMarks.Assign(FUserMouseSettings.GutterActionsOverViewMarks);
end;
GutterPartList.Sort;
for i := 0 to GutterPartList.Count - 1 do begin
GutterPartList[i].ApplyTo(ASynEdit.Gutter.Parts.ByClass[GutterPartList[i].GClass, 0]);
GutterPartList[i].ApplyIndexTo(ASynEdit.Gutter.Parts.ByClass[GutterPartList[i].GClass, 0]);
end;
GutterRightPartList.Sort;
for i := 0 to GutterRightPartList.Count - 1 do begin
GutterRightPartList[i].ApplyTo(ASynEdit.RightGutter.Parts.ByClass[GutterRightPartList[i].GClass, 0]);
GutterRightPartList[i].ApplyIndexTo(ASynEdit.RightGutter.Parts.ByClass[GutterRightPartList[i].GClass, 0]);
end;
ASynEdit.ScrollOnEditLeftOptions.Assign(ScrollOnEditLeftOptions);
ASynEdit.ScrollOnEditRightOptions.Assign(ScrollOnEditRightOptions);
finally

View File

@ -7,18 +7,18 @@ object EditorDisplayOptionsFrame: TEditorDisplayOptionsFrame
ClientWidth = 588
TabOrder = 0
Visible = False
DesignLeft = 176
DesignTop = 232
DesignLeft = 424
DesignTop = 163
object MarginAndGutterGroupBox: TGroupBox
AnchorSideRight.Side = asrBottom
Left = 0
Height = 151
Height = 249
Top = 0
Width = 588
Align = alTop
AutoSize = True
Caption = 'MarginAndGutterGroupBox'
ClientHeight = 131
ClientHeight = 229
ClientWidth = 584
TabOrder = 0
object RightMarginLabel: TLabel
@ -26,7 +26,7 @@ object EditorDisplayOptionsFrame: TEditorDisplayOptionsFrame
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = RightMarginComboBox
AnchorSideTop.Side = asrCenter
Left = 311
Left = 341
Height = 15
Top = 10
Width = 94
@ -38,33 +38,21 @@ object EditorDisplayOptionsFrame: TEditorDisplayOptionsFrame
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ShowOnlyLineNumbersMultiplesOfSpinEdit
AnchorSideTop.Side = asrCenter
Left = 295
Left = 325
Height = 15
Top = 68
Top = 182
Width = 121
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'Every n-th line number'
end
object GutterSeparatorIndexLabel: TLabel
AnchorSideLeft.Control = GutterSeparatorIndexSpinBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GutterSeparatorIndexSpinBox
AnchorSideTop.Side = asrCenter
Left = 297
Height = 15
Top = 39
Width = 140
BorderSpacing.Left = 6
Caption = 'GutterSeparatorIndexLabel'
end
object RightMarginColorLink: TLabel
AnchorSideLeft.Control = RightMarginLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = RightMarginLabel
AnchorSideTop.Side = asrCenter
Cursor = crHandPoint
Left = 411
Left = 441
Height = 15
Top = 10
Width = 117
@ -82,48 +70,34 @@ object EditorDisplayOptionsFrame: TEditorDisplayOptionsFrame
Left = 6
Height = 19
Top = 6
Width = 173
Width = 171
BorderSpacing.Around = 6
Caption = 'VisibleRightMarginCheckBox'
OnChange = GeneralCheckBoxOnChange
TabOrder = 0
OnChange = GeneralCheckBoxOnChange
end
object VisibleGutterCheckBox: TCheckBox
AnchorSideLeft.Control = MarginAndGutterGroupBox
AnchorSideTop.Control = VisibleRightMarginCheckBox
AnchorSideTop.Side = asrBottom
AnchorSideTop.Control = chkTopInfoView
Left = 6
Height = 19
Top = 31
Width = 140
BorderSpacing.Around = 6
Width = 138
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'VisibleGutterCheckBox'
OnChange = GeneralCheckBoxOnChange
TabOrder = 1
end
object ShowLineNumbersCheckBox: TCheckBox
AnchorSideLeft.Control = MarginAndGutterGroupBox
AnchorSideTop.Control = VisibleGutterCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 56
Width = 173
BorderSpacing.Around = 6
Caption = 'ShowLineNumbersCheckBox'
OnChange = GeneralCheckBoxOnChange
OnClick = ShowLineNumbersCheckBoxClick
TabOrder = 2
end
object RightMarginComboBox: TComboBox
AnchorSideLeft.Control = VisibleRightMarginCheckBox
AnchorSideLeft.Control = btnGutterUp
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = MarginAndGutterGroupBox
Left = 235
Left = 265
Height = 23
Top = 6
Width = 70
BorderSpacing.Left = 50
BorderSpacing.Left = 30
BorderSpacing.Around = 6
ItemHeight = 15
Items.Strings = (
@ -131,70 +105,184 @@ object EditorDisplayOptionsFrame: TEditorDisplayOptionsFrame
'78'
'76'
)
TabOrder = 2
OnChange = ComboboxOnChange
OnExit = ComboboxOnExit
OnKeyDown = ComboBoxOnKeyDown
TabOrder = 3
end
object ShowOnlyLineNumbersMultiplesOfSpinEdit: TSpinEdit
AnchorSideLeft.Control = GutterSeparatorIndexSpinBox
AnchorSideTop.Control = GutterSeparatorIndexSpinBox
AnchorSideLeft.Control = RightMarginComboBox
AnchorSideTop.Control = spinGutterPartLeftOffs
AnchorSideTop.Side = asrBottom
Left = 235
Left = 265
Height = 23
Top = 64
Top = 178
Width = 54
BorderSpacing.Top = 6
MaxValue = 65536
MinValue = 1
OnChange = GeneralCheckBoxOnChange
TabOrder = 4
TabOrder = 3
Value = 1
end
object GutterSeparatorIndexSpinBox: TSpinEdit
AnchorSideLeft.Control = RightMarginComboBox
AnchorSideTop.Control = RightMarginComboBox
AnchorSideTop.Side = asrBottom
Left = 235
Height = 23
Top = 35
Width = 56
MaxValue = 4
MinValue = -1
OnChange = GeneralCheckBoxOnChange
TabOrder = 5
end
object chkShowOverview: TCheckBox
AnchorSideLeft.Control = MarginAndGutterGroupBox
AnchorSideTop.Control = ShowLineNumbersCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 81
Width = 117
BorderSpacing.Around = 6
Caption = 'chkShowOverview'
OnChange = GeneralCheckBoxOnChange
TabOrder = 6
end
object chkTopInfoView: TCheckBox
AnchorSideLeft.Control = MarginAndGutterGroupBox
AnchorSideTop.Control = chkShowOverview
AnchorSideLeft.Control = RightMarginComboBox
AnchorSideTop.Control = VisibleRightMarginCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Left = 271
Height = 19
Top = 106
Width = 105
Top = 31
Width = 103
BorderSpacing.Around = 6
Caption = 'chkTopInfoView'
TabOrder = 4
end
object lbGutterParts: TListBox
AnchorSideLeft.Control = MarginAndGutterGroupBox
AnchorSideTop.Control = rgGutterSite
AnchorSideTop.Side = asrBottom
Left = 6
Height = 128
Top = 95
Width = 194
BorderSpacing.Around = 6
ItemHeight = 0
TabOrder = 5
OnClick = lbGutterPartsClick
end
object btnGutterUp: TSpeedButton
AnchorSideLeft.Control = lbGutterParts
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = lbGutterParts
Left = 206
Height = 22
Top = 101
Width = 23
BorderSpacing.Around = 6
OnClick = btnGutterUpClick
end
object btnGutterDown: TSpeedButton
AnchorSideLeft.Control = lbGutterParts
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = btnGutterUp
AnchorSideTop.Side = asrBottom
Left = 206
Height = 22
Top = 129
Width = 23
BorderSpacing.Around = 6
OnClick = btnGutterDownClick
end
object GutterPartVisible: TCheckBox
AnchorSideLeft.Control = RightMarginComboBox
AnchorSideTop.Control = lbGutterParts
Left = 265
Height = 19
Top = 95
Width = 106
Caption = 'GutterPartVisible'
TabOrder = 6
OnChange = spinGutterPartWidthChange
end
object lblGutterPartMargin: TLabel
AnchorSideLeft.Control = GutterPartVisible
AnchorSideTop.Control = spinGutterPartLeftOffs
AnchorSideTop.Side = asrCenter
Left = 265
Height = 15
Top = 153
Width = 105
Caption = 'lblGutterPartMargin'
end
object spinGutterPartLeftOffs: TSpinEdit
AnchorSideLeft.Control = lblGutterPartMargin
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = spinGutterPartWidth
AnchorSideTop.Side = asrBottom
Left = 376
Height = 23
Top = 149
Width = 50
BorderSpacing.Around = 6
MaxValue = 10
TabOrder = 8
OnChange = spinGutterPartWidthChange
end
object spinGutterPartRightOffs: TSpinEdit
AnchorSideLeft.Control = spinGutterPartLeftOffs
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = spinGutterPartLeftOffs
Left = 432
Height = 23
Top = 149
Width = 50
BorderSpacing.Left = 6
MaxValue = 25
TabOrder = 10
OnChange = spinGutterPartWidthChange
end
object spinGutterPartWidth: TSpinEdit
AnchorSideLeft.Control = spinGutterPartLeftOffs
AnchorSideTop.Control = GutterPartVisible
AnchorSideTop.Side = asrBottom
Left = 376
Height = 23
Top = 120
Width = 50
BorderSpacing.Top = 6
BorderSpacing.Bottom = 6
MaxValue = 99
TabOrder = 7
OnChange = spinGutterPartWidthChange
end
object lblGutterPartWidth: TLabel
AnchorSideLeft.Control = GutterPartVisible
AnchorSideTop.Control = spinGutterPartWidth
AnchorSideTop.Side = asrCenter
Left = 265
Height = 15
Top = 124
Width = 99
Caption = 'lblGutterPartWidth'
end
object rgGutterSite: TRadioGroup
AnchorSideLeft.Control = MarginAndGutterGroupBox
AnchorSideTop.Control = VisibleGutterCheckBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = MarginAndGutterGroupBox
AnchorSideRight.Side = asrBottom
Left = 6
Height = 39
Top = 50
Width = 106
AutoFill = True
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Right = 6
ChildSizing.LeftRightSpacing = 6
ChildSizing.HorizontalSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 19
ClientWidth = 102
Columns = 2
Items.Strings = (
'Left'
'Right'
)
TabOrder = 9
OnClick = rgGutterSiteClick
end
end
object EditorFontGroupBox: TGroupBox
AnchorSideRight.Side = asrBottom
Left = 0
Height = 113
Top = 157
Top = 255
Width = 588
Align = alTop
AutoSize = True
@ -251,9 +339,9 @@ object EditorDisplayOptionsFrame: TEditorDisplayOptionsFrame
BorderSpacing.Left = 6
BorderSpacing.Top = 6
ItemHeight = 15
OnEditingDone = EditorFontComboBoxEditingDone
TabOrder = 0
Text = 'EditorFontComboBox'
OnEditingDone = EditorFontComboBoxEditingDone
end
object EditorFontButton: TButton
AnchorSideTop.Control = EditorFontComboBox
@ -268,8 +356,8 @@ object EditorDisplayOptionsFrame: TEditorDisplayOptionsFrame
Anchors = [akTop, akRight, akBottom]
BorderSpacing.Right = 6
Caption = '...'
OnClick = EditorFontButtonClick
TabOrder = 1
OnClick = EditorFontButtonClick
end
object EditorFontSizeSpinEdit: TSpinEdit
AnchorSideLeft.Control = EditorFontGroupBox
@ -281,8 +369,8 @@ object EditorDisplayOptionsFrame: TEditorDisplayOptionsFrame
Width = 50
BorderSpacing.Around = 6
MinValue = -100
OnChange = EditorFontSizeSpinEditChange
TabOrder = 2
OnChange = EditorFontSizeSpinEditChange
end
object ExtraLineSpacingComboBox: TComboBox
AnchorSideLeft.Control = EditorFontSizeLabel
@ -301,10 +389,10 @@ object EditorDisplayOptionsFrame: TEditorDisplayOptionsFrame
'1'
'2'
)
TabOrder = 4
OnChange = ComboboxOnChange
OnExit = ComboboxOnExit
OnKeyDown = ComboBoxOnKeyDown
TabOrder = 4
end
object ExtraCharSpacingComboBox: TComboBox
AnchorSideLeft.Control = ExtraLineSpacingComboBox
@ -321,10 +409,10 @@ object EditorDisplayOptionsFrame: TEditorDisplayOptionsFrame
'1'
'2'
)
TabOrder = 3
OnChange = ComboboxOnChange
OnExit = ComboboxOnExit
OnKeyDown = ComboBoxOnKeyDown
TabOrder = 3
end
object DisableAntialiasingCheckBox: TCheckBox
AnchorSideLeft.Control = EditorFontGroupBox
@ -333,19 +421,19 @@ object EditorDisplayOptionsFrame: TEditorDisplayOptionsFrame
Left = 6
Height = 19
Top = 64
Width = 173
Width = 171
BorderSpacing.Around = 6
Caption = 'DisableAntialiasingCheckBox'
OnChange = GeneralCheckBoxOnChange
TabOrder = 5
OnChange = GeneralCheckBoxOnChange
end
end
inline DisplayPreview: TSynEdit
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 179
Top = 276
Height = 81
Top = 374
Width = 588
Align = alClient
BorderSpacing.Top = 6

View File

@ -27,11 +27,13 @@ interface
uses
Classes, SysUtils,
// LCL
Graphics, Dialogs, StdCtrls, Spin, LCLType, Controls,
Graphics, Dialogs, StdCtrls, Spin, LCLType, Controls, Buttons, ExtCtrls,
// SynEdit
SynEdit, SynEditMouseCmds, SynGutterLineNumber, SynGutterLineOverview, SynGutter, SynEditTypes,
SynEdit, SynEditMouseCmds, SynGutterLineNumber, SynGutterLineOverview,
SynGutter, SynEditTypes, SynGutterBase, SynGutterMarks, SynGutterChanges,
SynGutterCodeFolding,
// IdeIntf
IDEOptionsIntf, IDEOptEditorIntf, IDEUtils,
IDEOptionsIntf, IDEOptEditorIntf, IDEUtils, IDEImagesIntf,
// IDE
EditorOptions, LazarusIDEStrConsts, editor_general_options, editor_color_options,
SourceSynEditor, SourceMarks;
@ -40,8 +42,8 @@ type
{ TEditorDisplayOptionsFrame }
TEditorDisplayOptionsFrame = class(TAbstractIDEOptionsEditor)
GutterPartVisible: TCheckBox;
chkTopInfoView: TCheckBox;
chkShowOverview: TCheckBox;
DisableAntialiasingCheckBox: TCheckBox;
DisplayPreview: TSynEdit;
EditorFontButton: TButton;
@ -53,17 +55,25 @@ type
ExtraCharSpacingLabel: TLabel;
ExtraLineSpacingComboBox: TComboBox;
ExtraLineSpacingLabel: TLabel;
GutterSeparatorIndexLabel: TLabel;
lblGutterPartWidth: TLabel;
lblGutterPartMargin: TLabel;
lbGutterParts: TListBox;
MarginAndGutterGroupBox: TGroupBox;
rgGutterSite: TRadioGroup;
RightMarginColorLink: TLabel;
RightMarginComboBox: TComboBox;
RightMarginLabel: TLabel;
ShowLineNumbersCheckBox: TCheckBox;
ShowOnlyLineNumbersMultiplesOfLabel: TLabel;
ShowOnlyLineNumbersMultiplesOfSpinEdit: TSpinEdit;
GutterSeparatorIndexSpinBox: TSpinEdit;
btnGutterUp: TSpeedButton;
btnGutterDown: TSpeedButton;
spinGutterPartWidth: TSpinEdit;
spinGutterPartLeftOffs: TSpinEdit;
spinGutterPartRightOffs: TSpinEdit;
VisibleGutterCheckBox: TCheckBox;
VisibleRightMarginCheckBox: TCheckBox;
procedure btnGutterDownClick(Sender: TObject);
procedure btnGutterUpClick(Sender: TObject);
procedure EditorFontButtonClick(Sender: TObject);
procedure EditorFontComboBoxEditingDone(Sender: TObject);
procedure EditorFontSizeSpinEditChange(Sender: TObject);
@ -72,13 +82,20 @@ type
Shift: TShiftState);
procedure ComboboxOnChange(Sender: TObject);
procedure GeneralCheckBoxOnChange(Sender: TObject);
procedure lbGutterPartsClick(Sender: TObject);
procedure rgGutterSiteClick(Sender: TObject);
procedure FillGutterPartList;
procedure RightMarginColorLinkClick(Sender: TObject);
procedure RightMarginColorLinkMouseEnter(Sender: TObject);
procedure RightMarginColorLinkMouseLeave(Sender: TObject);
procedure ShowLineNumbersCheckBoxClick(Sender: TObject);
procedure spinGutterPartWidthChange(Sender: TObject);
private
FDialog: TAbstractOptionsEditorDialog;
FUpdatingFontSizeRange: Boolean;
FCurrentGutterPart: TEditorSynGutterOptions;
FCurGutterPartList: TEditorSynGutterOptionsList;
FCurGutterRightPartList: TEditorSynGutterOptionsList;
FGutterParsUpdating: Boolean;
function FontSizeNegativeToPositive(NegativeSize: Integer): Integer;
function GeneralPage: TEditorGeneralOptionsFrame; inline;
procedure SetEditorFontSizeSpinEditValue(FontSize: Integer);
@ -87,11 +104,16 @@ type
function DoSynEditMouse(var {%H-}AnInfo: TSynEditMouseActionInfo;
{%H-}HandleActionProc: TSynEditMouseActionHandler): Boolean;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure UpdatePreviews;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
property CurGutterPartList: TEditorSynGutterOptionsList read FCurGutterPartList;
property CurGutterRightPartList: TEditorSynGutterOptionsList read FCurGutterRightPartList;
end;
implementation
@ -131,6 +153,38 @@ begin
Result := true;
end;
constructor TEditorDisplayOptionsFrame.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FCurGutterPartList := TEditorSynGutterOptionsList.Create(True);
FCurGutterRightPartList := TEditorSynGutterOptionsList.Create(True);
end;
destructor TEditorDisplayOptionsFrame.Destroy;
begin
inherited Destroy;
FCurGutterPartList.Free;
FCurGutterRightPartList.Free;
end;
procedure TEditorDisplayOptionsFrame.UpdatePreviews;
var
i, j: Integer;
begin
with GeneralPage do
for i := Low(PreviewEdits) to High(PreviewEdits) do
if PreviewEdits[i] <> nil then begin
for j := 0 to FCurGutterPartList.Count - 1 do begin
FCurGutterPartList[j].ApplyTo(PreviewEdits[i].Gutter.Parts.ByClass[FCurGutterPartList[j].GClass, 0]);
FCurGutterPartList[j].ApplyIndexTo(PreviewEdits[i].Gutter.Parts.ByClass[FCurGutterPartList[j].GClass, 0]);
end;
for j := 0 to FCurGutterRightPartList.Count - 1 do begin
FCurGutterRightPartList[j].ApplyTo(PreviewEdits[i].RightGutter.Parts.ByClass[FCurGutterRightPartList[j].GClass, 0]);
FCurGutterRightPartList[j].ApplyIndexTo(PreviewEdits[i].RightGutter.Parts.ByClass[FCurGutterRightPartList[j].GClass, 0]);
end;
end;
end;
procedure TEditorDisplayOptionsFrame.EditorFontButtonClick(Sender: TObject);
var
FontDialog: TFontDialog;
@ -262,7 +316,6 @@ procedure TEditorDisplayOptionsFrame.GeneralCheckBoxOnChange(Sender: TObject);
var
a: integer;
AGeneralPage: TEditorGeneralOptionsFrame;
Separator: TSynGutterSeparator;
begin
AGeneralPage := GeneralPage;
@ -274,20 +327,10 @@ begin
if PreviewEdits[a] <> nil then
begin
PreviewEdits[a].Gutter.Visible := VisibleGutterCheckBox.Checked;
PreviewEdits[a].RightGutter.Visible := chkShowOverview.Checked;
PreviewEdits[a].Gutter.LineNumberPart.Visible
:= ShowLineNumbersCheckBox.Checked;
if Assigned(PreviewEdits[a].Gutter.Parts.ByClass[TSynGutterLineNumber, 0]) then
TSynGutterLineNumber(PreviewEdits[a].Gutter.Parts.ByClass[TSynGutterLineNumber, 0])
.ShowOnlyLineNumbersMultiplesOf := ShowOnlyLineNumbersMultiplesOfSpinEdit.Value;
Separator := TSynGutterSeparator(PreviewEdits[a].Gutter.Parts.ByClass[TSynGutterSeparator, 0]);
if Assigned(Separator) then
begin
Separator.Visible := GutterSeparatorIndexSpinBox.Value <> -1;
if Separator.Visible then
Separator.Index := GutterSeparatorIndexSpinBox.Value;
end;
PreviewEdits[a].RightEdge := StrToIntDef(RightMarginComboBox.Text, 80);
if VisibleRightMarginCheckBox.Checked then
PreviewEdits[a].Options := PreviewEdits[a].Options - [eoHideRightMargin]
@ -300,6 +343,107 @@ begin
end;
end;
procedure TEditorDisplayOptionsFrame.lbGutterPartsClick(Sender: TObject);
begin
FCurrentGutterPart := nil;
if lbGutterParts.ItemIndex >= 0 then
FCurrentGutterPart := TEditorSynGutterOptions(lbGutterParts.Items.Objects[lbGutterParts.ItemIndex]);
FGutterParsUpdating := True;
GutterPartVisible.Checked := FCurrentGutterPart.Visible;
spinGutterPartWidth.Value := FCurrentGutterPart.Width;
spinGutterPartLeftOffs.Value := FCurrentGutterPart.OffsetLeft;
spinGutterPartRightOffs.Value := FCurrentGutterPart.OffsetRight;
FGutterParsUpdating := False;
btnGutterUp.Enabled := lbGutterParts.ItemIndex > 0;
btnGutterDown.Enabled := lbGutterParts.ItemIndex < lbGutterParts.Count - 1;
ShowOnlyLineNumbersMultiplesOfSpinEdit.Enabled := (FCurrentGutterPart <> nil) and
(FCurrentGutterPart.GClass = TSynGutterLineNumber);
ShowOnlyLineNumbersMultiplesOfLabel.Enabled := ShowOnlyLineNumbersMultiplesOfSpinEdit.Enabled;
end;
procedure TEditorDisplayOptionsFrame.btnGutterUpClick(Sender: TObject);
var
l: TEditorSynGutterOptionsList;
i, i2: Integer;
begin
if rgGutterSite.Buttons[0].Checked
then l := FCurGutterPartList
else l := FCurGutterRightPartList;
i := lbGutterParts.ItemIndex;
if (i < 1) or (i >= l.Count) then
exit;
i2 := l[i-1].Index;
l[i-1].Index := l[i].Index;
l[i].Index := i2;
l.Sort;
FillGutterPartList;
lbGutterParts.ItemIndex := i - 1;
lbGutterPartsClick(nil);
UpdatePreviews;
end;
procedure TEditorDisplayOptionsFrame.btnGutterDownClick(Sender: TObject);
var
l: TEditorSynGutterOptionsList;
i, i2: Integer;
begin
if rgGutterSite.Buttons[0].Checked
then l := FCurGutterPartList
else l := FCurGutterRightPartList;
i := lbGutterParts.ItemIndex;
if (i < 0) or (i >= l.Count-1) then
exit;
i2 := l[i+1].Index;
l[i+1].Index := l[i].Index;
l[i].Index := i2;
l.Sort;
FillGutterPartList;
lbGutterParts.ItemIndex := i + 1;
lbGutterPartsClick(nil);
UpdatePreviews;
end;
procedure TEditorDisplayOptionsFrame.rgGutterSiteClick(Sender: TObject);
begin
FillGutterPartList;
lbGutterParts.ItemIndex := 0;
lbGutterPartsClick(nil);
end;
procedure TEditorDisplayOptionsFrame.FillGutterPartList;
function GPartName(aGClass: TSynGutterPartBaseClass): string;
begin
Result := '?';
if aGClass = TSynGutterMarks then Result := optDispGutterMarks;
if aGClass = TSynGutterLineNumber then Result := dlgAddHiAttrLineNumber;
if aGClass = TSynGutterChanges then Result := optDispGutterChanges;
if aGClass = TSynGutterSeparator then Result := optDispGutterSeparator;
if aGClass = TSynGutterCodeFolding then Result := optDispGutterFolding;
if aGClass = TSynGutterLineOverview then Result := dlgMouseOptNodeGutterLineOverview;
end;
var
l: TEditorSynGutterOptionsList;
i: Integer;
begin
if rgGutterSite.Buttons[0].Checked
then l := FCurGutterPartList
else l := FCurGutterRightPartList;
lbGutterParts.Clear;
for i := 0 to l.Count - 1 do begin
lbGutterParts.AddItem(GPartName(l[i].GClass), l[i]);
end;
end;
procedure TEditorDisplayOptionsFrame.RightMarginColorLinkClick(Sender: TObject);
var
col: TEditorColorOptionsFrame;
@ -322,10 +466,16 @@ begin
(Sender as TLabel).Font.Color := clBlue;
end;
procedure TEditorDisplayOptionsFrame.ShowLineNumbersCheckBoxClick(Sender: TObject);
procedure TEditorDisplayOptionsFrame.spinGutterPartWidthChange(Sender: TObject);
begin
ShowOnlyLineNumbersMultiplesOfSpinEdit.Enabled := ShowLineNumbersCheckBox.Checked;
ShowOnlyLineNumbersMultiplesOfLabel.Enabled := ShowLineNumbersCheckBox.Checked;
if FGutterParsUpdating then
exit;
FCurrentGutterPart.Visible := GutterPartVisible.Checked;
FCurrentGutterPart.Width := spinGutterPartWidth.Value;
FCurrentGutterPart.OffsetLeft := spinGutterPartLeftOffs.Value;
FCurrentGutterPart.OffsetRight := spinGutterPartRightOffs.Value;
UpdatePreviews;
end;
function TEditorDisplayOptionsFrame.GeneralPage: TEditorGeneralOptionsFrame; inline;
@ -363,9 +513,7 @@ begin
MarginAndGutterGroupBox.Caption := dlgMarginGutter;
VisibleRightMarginCheckBox.Caption := dlgVisibleRightMargin;
VisibleGutterCheckBox.Caption := dlgVisibleGutter;
ShowLineNumbersCheckBox.Caption := dlgShowLineNumbers;
ShowOnlyLineNumbersMultiplesOfLabel.Caption := lisEveryNThLineNumber;
GutterSeparatorIndexLabel.Caption := dlgGutterSeparatorIndex;
RightMarginLabel.Caption := dlgRightMargin;
EditorFontGroupBox.Caption := dlgDefaultEditorFont;
EditorFontSizeLabel.Caption := dlgEditorFontSize;
@ -373,9 +521,19 @@ begin
ExtraLineSpacingLabel.Caption := dlgExtraLineSpacing;
DisableAntialiasingCheckBox.Caption := dlgDisableAntialiasing;
RightMarginColorLink.Caption := dlgColorLink;
chkShowOverview.Caption := lisShowOverviewGutter;
chkTopInfoView.Caption := lisTopInfoView;
btnGutterUp.Images := IDEImages.Images_16;
btnGutterDown.Images := IDEImages.Images_16;
btnGutterUp.ImageIndex := IDEImages.LoadImage('arrow_up', 16);
btnGutterDown.ImageIndex := IDEImages.LoadImage('arrow_down', 16);
rgGutterSite.Items[0] := lisLeftGutter;
rgGutterSite.Items[1] := lisRightGutter;
GutterPartVisible.Caption := lisGutterPartVisible;
lblGutterPartWidth.Caption := lisGutterPartWidth;
lblGutterPartMargin.Caption := lisGutterPartMargin;
with GeneralPage do
AddPreviewEdit(DisplayPreview);
@ -408,10 +566,8 @@ begin
// init the spin-edit first, since it does not trigger on change,
// but is copied when checkboxes are initialized
ShowOnlyLineNumbersMultiplesOfSpinEdit.Value := ShowOnlyLineNumbersMultiplesOf;
GutterSeparatorIndexSpinBox.Value := GutterSeparatorIndex;
VisibleRightMarginCheckBox.Checked := VisibleRightMargin;
VisibleGutterCheckBox.Checked := VisibleGutter;
ShowLineNumbersCheckBox.Checked := ShowLineNumbers;
VisibleRightMarginCheckBox.Checked := VisibleRightMargin;
SetComboBoxText(RightMarginComboBox, IntToStr(RightMargin),cstCaseInsensitive);
SetComboBoxText(EditorFontComboBox, EditorFont,cstCaseInsensitive);
@ -419,12 +575,17 @@ begin
SetComboBoxText(ExtraCharSpacingComboBox, IntToStr(ExtraCharSpacing),cstCaseInsensitive);
SetComboBoxText(ExtraLineSpacingComboBox, IntToStr(ExtraLineSpacing),cstCaseInsensitive);
DisableAntialiasingCheckBox.Checked := DisableAntialiasing;
chkShowOverview.Checked := ShowOverviewGutter;
chkTopInfoView.Checked := TopInfoView;
FCurGutterPartList.Assign(GutterPartList);
FCurGutterRightPartList.Assign(GutterRightPartList);
FCurGutterPartList.Sort;
GutterRightPartList.Sort;
end;
ShowOnlyLineNumbersMultiplesOfLabel.Enabled := ShowLineNumbersCheckBox.Checked;
ShowOnlyLineNumbersMultiplesOfSpinEdit.Enabled := ShowLineNumbersCheckBox.Checked;
rgGutterSite.Buttons[0].Checked := True;
FillGutterPartList;
lbGutterParts.ItemIndex := 0;
lbGutterPartsClick(nil);
end;
procedure TEditorDisplayOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
@ -433,9 +594,7 @@ begin
begin
VisibleRightMargin := VisibleRightMarginCheckBox.Checked;
VisibleGutter := VisibleGutterCheckBox.Checked;
ShowLineNumbers := ShowLineNumbersCheckBox.Checked;
ShowOnlyLineNumbersMultiplesOf := ShowOnlyLineNumbersMultiplesOfSpinEdit.Value;
GutterSeparatorIndex := GutterSeparatorIndexSpinBox.Value;
VisibleRightMargin := VisibleRightMarginCheckBox.Checked;
RightMargin := StrToIntDef(RightMarginComboBox.Text, 80);
EditorFont := EditorFontComboBox.Text;
@ -443,8 +602,9 @@ begin
ExtraCharSpacing := StrToIntDef(ExtraCharSpacingComboBox.Text, ExtraCharSpacing);
ExtraLineSpacing := StrToIntDef(ExtraLineSpacingComboBox.Text, ExtraLineSpacing);
DisableAntialiasing := DisableAntialiasingCheckBox.Checked;
ShowOverviewGutter := chkShowOverview.Checked;
TopInfoView := chkTopInfoView.Checked;
GutterPartList.AssignItems(FCurGutterPartList);
GutterRightPartList.AssignItems(FCurGutterRightPartList);
end;
end;

View File

@ -5468,9 +5468,14 @@ resourcestring
+'not be deleted because it is not owned by %s.';
lisFilter3 = 'Filter: %s';
lisFileExtensionOfPrograms = 'File extension of programs';
lisEveryNThLineNumber = 'Every n-th line number';
lisEveryNThLineNumber = 'Show every n-th line number';
lisShowOverviewGutter = 'Show overview gutter';
lisTopInfoView = 'Show Class/Procedure hint';
lisLeftGutter = 'Left Gutter';
lisRightGutter = 'Right Gutter';
lisGutterPartVisible = 'Visible';
lisGutterPartWidth = 'Width';
lisGutterPartMargin = 'Margin';
lisLink = 'Link:';
lisShort = 'Short:';
lisInsertUrlTag = 'Insert url tag';
@ -6441,6 +6446,10 @@ resourcestring
+'You may want to rebuild the IDE with the packages installed. After the '
+'rebuild, the debugger backend can be changed in the menu: Tools -> '
+'Options.';
optDispGutterMarks = 'Marks';
optDispGutterChanges = 'Changes';
optDispGutterSeparator = 'Separator';
optDispGutterFolding = 'Folding';
implementation

View File

@ -11983,12 +11983,12 @@ begin
ActEdit:=ActiveEditor;
if ActEdit = nil then exit;
MenuItem.Checked := not EditorOpts.ShowLineNumbers;
MenuItem.Checked := not EditorOpts.GutterPartLine.Visible;
ShowLineNumbers:=MenuItem.Checked;
for i:=0 to SourceEditorCount-1 do
SourceEditors[i].EditorComponent.Gutter.LineNumberPart.Visible := ShowLineNumbers;
EditorOpts.ShowLineNumbers := ShowLineNumbers;
EditorOpts.GutterPartLine.Visible := ShowLineNumbers;
EditorOpts.Save;
end;