Skip to content

Commit

Permalink
Make folding optional internally. Not yet disabled anywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnlaan committed Jun 16, 2024
1 parent e11f027 commit c0ec9d7
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions Projects/Src/CompScintEdit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,28 @@ interface

TCompScintEdit = class(TScintEdit)
private
FFolding: Boolean;
FTheme: TTheme;
FOpeningFile: Boolean;
FUsed: Boolean; { The IDE only shows 1 memo at a time so can't use .Visible to check if a memo is used }
FIndicatorCount: array[TCompScintIndicatorNumber] of Integer;
FIndicatorHash: array[TCompScintIndicatorNumber] of String;
procedure SetFolding(const Value: Boolean);
protected
procedure CreateWnd; override;
public
constructor Create(AOwner: TComponent); override;
property Theme: TTheme read FTheme write FTheme;
property OpeningFile: Boolean read FOpeningFile write FOpeningFile;
property Used: Boolean read FUsed write FUsed;
procedure UpdateIndicators(const Ranges: TScintRangeList;
const IndicatorNumber: TCompScintIndicatorNumber);
procedure UpdateMarginsAndSquigglyWidths(const IconMarkersWidth,
BaseChangeHistoryWidth, FolderMarkersWidth, LeftBlankMarginWidth,
BaseChangeHistoryWidth, BaseFolderMarkersWidth, LeftBlankMarginWidth,
RightBlankMarginWidth, SquigglyWidth: Integer);
procedure UpdateThemeColorsAndStyleAttributes;
published
property Folding: Boolean read FFolding write SetFolding default True;
end;

TCompScintFileEdit = class(TCompScintEdit)
Expand Down Expand Up @@ -136,6 +141,12 @@ implementation

{ TCompScintEdit }

constructor TCompScintEdit.Create(AOwner: TComponent);
begin
inherited;
FFolding := True;
end;

procedure TCompScintEdit.CreateWnd;
const
SC_MARK_BACKFORE = 3030; { new marker type added in Inno Setup's Scintilla build }
Expand Down Expand Up @@ -207,19 +218,19 @@ procedure TCompScintEdit.CreateWnd;
Call(SCI_SETMARGINCURSORN, 1, SC_CURSORARROW);

{ Set up the gutter column with change history. Note: width of the column is
set up for us by TScintEdit.UpdateChangeHistoryWidth. Also see
set up by UpdateMarginsAndSquigglyWidths. Also see
https://scintilla.org/ChangeHistory.html }
Call(SCI_SETMARGINTYPEN, 2, SC_MARGIN_SYMBOL);
Call(SCI_SETMARGINMASKN, 2, not (SC_MASK_FOLDERS or mmIconsMask));
Call(SCI_SETMARGINCURSORN, 2, SC_CURSORARROW);

{ Set up the gutter column with folding markers. Note: width of the column is
set up by UpdateMarginsAndSquigglyWidths. }
Call(SCI_SETMARGINTYPEN, 3, SC_MARGIN_SYMBOL);
Call(SCI_SETMARGINMASKN, 3, LPARAM(SC_MASK_FOLDERS));
Call(SCI_SETMARGINCURSORN, 3, SC_CURSORARROW);
Call(SCI_SETMARGINWIDTHN, 3, 16);
Call(SCI_SETMARGINSENSITIVEN, 3, 1);
Call(SCI_SETAUTOMATICFOLD, SC_AUTOMATICFOLD_SHOW or SC_AUTOMATICFOLD_CLICK or SC_AUTOMATICFOLD_CHANGE, 0);

Call(SCI_MARKERDEFINE, SC_MARKNUM_FOLDEROPEN, SC_MARK_ARROWDOWN);
Call(SCI_MARKERDEFINE, SC_MARKNUM_FOLDER, SC_MARK_ARROW);
Call(SCI_MARKERDEFINE, SC_MARKNUM_FOLDERSUB, SC_MARK_EMPTY);
Expand All @@ -228,6 +239,7 @@ procedure TCompScintEdit.CreateWnd;
Call(SCI_MARKERDEFINE, SC_MARKNUM_FOLDEROPENMID, SC_MARK_EMPTY);
Call(SCI_MARKERDEFINE, SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_EMPTY);

{ Set up the line markers }
Call(SCI_MARKERDEFINE, mmLineError, SC_MARK_BACKFORE);
Call(SCI_MARKERSETFORE, mmLineError, clWhite);
Call(SCI_MARKERSETBACK, mmLineError, clMaroon);
Expand All @@ -239,6 +251,17 @@ procedure TCompScintEdit.CreateWnd;
Call(SCI_MARKERSETBACK, mmLineStep, clBlue); { May be overwritten by UpdateThemeColorsAndStyleAttributes }
end;

procedure TCompScintEdit.SetFolding(const Value: Boolean);
begin
if FFolding <> Value then begin
FFolding := Value;
{ If FFolding is True then caller must set the margin width using
UpdateMarginsAndSquigglyWidths else we set it to 0 now }
if not FFolding then
Call(SCI_SETMARGINWIDTHN, 3, 0);
end;
end;

procedure TCompScintEdit.UpdateIndicators(const Ranges: TScintRangeList;
const IndicatorNumber: TCompScintIndicatorNumber);

Expand Down Expand Up @@ -280,7 +303,7 @@ procedure TCompScintEdit.UpdateIndicators(const Ranges: TScintRangeList;
end;

procedure TCompScintEdit.UpdateMarginsAndSquigglyWidths(const IconMarkersWidth,
BaseChangeHistoryWidth, FolderMarkersWidth, LeftBlankMarginWidth,
BaseChangeHistoryWidth, BaseFolderMarkersWidth, LeftBlankMarginWidth,
RightBlankMarginWidth, SquigglyWidth: Integer);
begin
Call(SCI_SETMARGINWIDTHN, 1, IconMarkersWidth);
Expand All @@ -292,6 +315,11 @@ procedure TCompScintEdit.UpdateMarginsAndSquigglyWidths(const IconMarkersWidth,
ChangeHistoryWidth := 0; { Current this is just the preprocessor output memo }
Call(SCI_SETMARGINWIDTHN, 2, ChangeHistoryWidth);

var FolderMarkersWidth: Integer;
if FFolding then
FolderMarkersWidth := BaseFolderMarkersWidth
else
FolderMarkersWidth := 0;
Call(SCI_SETMARGINWIDTHN, 3, FolderMarkersWidth);

{ Note: the first parameter is unused so the value '0' doesn't mean anything below }
Expand Down

0 comments on commit c0ec9d7

Please sign in to comment.