IDE: Editor-Options, fixed wrap column

This commit is contained in:
Martin 2025-02-27 17:45:09 +01:00
parent a83574e245
commit 4162ac50d8
5 changed files with 288 additions and 155 deletions

View File

@ -1603,12 +1603,14 @@ type
// Wordwrap
FWordWrapCaretWrapPos: TLazSynEditWrapCaretPos;
FWordWrapEnabled: Boolean;
FWordWrapFixedWidth: boolean;
FWordWrapForceHomeEnd: Boolean;
FWordWrapIndent: Integer;
FWordWrapIndentMax: Integer;
FWordWrapIndentMaxRel: Integer;
FWordWrapIndentMin: Integer;
FWordWrapIndentUseOffset: boolean;
FWordWrapMaxWidth: Integer;
FWordWrapMinWidth: Integer;
fUseTabHistory: Boolean;
@ -1695,6 +1697,8 @@ type
property WordWrapCaretWrapPos: TLazSynEditWrapCaretPos read FWordWrapCaretWrapPos write FWordWrapCaretWrapPos;
property WordWrapForceHomeEnd: Boolean read FWordWrapForceHomeEnd write FWordWrapForceHomeEnd;
property WordWrapMinWidth: Integer read FWordWrapMinWidth write FWordWrapMinWidth default 10;
property WordWrapMaxWidth: Integer read FWordWrapMaxWidth write FWordWrapMaxWidth default 0;
property WordWrapFixedWidth: boolean read FWordWrapFixedWidth write FWordWrapFixedWidth default False;
property WordWrapIndent: Integer read FWordWrapIndent write FWordWrapIndent default 0;
property WordWrapIndentUseOffset: boolean read FWordWrapIndentUseOffset write FWordWrapIndentUseOffset default True;
@ -6847,6 +6851,10 @@ begin
TIDESynEditor(ASynEdit).WordWrapCaretWrapPos := WordWrapCaretWrapPos;
TIDESynEditor(ASynEdit).WordWrapForceHomeEnd := FWordWrapForceHomeEnd;
TIDESynEditor(ASynEdit).WordWrapMinWidth := WordWrapMinWidth;
if WordWrapFixedWidth then
TIDESynEditor(ASynEdit).WordWrapMaxWidth := WordWrapMinWidth
else
TIDESynEditor(ASynEdit).WordWrapMaxWidth := WordWrapMaxWidth;
TIDESynEditor(ASynEdit).WordWrapIndent := WordWrapIndent;
TIDESynEditor(ASynEdit).WordWrapIndentUseOffset := WordWrapIndentUseOffset;
TIDESynEditor(ASynEdit).WordWrapIndentMin := WordWrapIndentMin;

View File

@ -2,11 +2,10 @@ object EditorWordWrapOptionsFrame: TEditorWordWrapOptionsFrame
Left = 0
Height = 380
Top = 0
Width = 428
ChildSizing.Layout = cclLeftToRightThenTopToBottom
Width = 387
ChildSizing.ControlsPerLine = 2
ClientHeight = 380
ClientWidth = 428
ClientWidth = 387
TabOrder = 0
DesignLeft = 599
DesignTop = 61
@ -18,7 +17,7 @@ object EditorWordWrapOptionsFrame: TEditorWordWrapOptionsFrame
Left = 6
Height = 19
Top = 6
Width = 416
Width = 375
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
Caption = 'cbEnableWordWrap'
@ -33,7 +32,7 @@ object EditorWordWrapOptionsFrame: TEditorWordWrapOptionsFrame
Left = 6
Height = 19
Top = 31
Width = 416
Width = 375
Anchors = [akTop, akLeft, akRight]
AutoFill = True
AutoSize = True
@ -58,120 +57,74 @@ object EditorWordWrapOptionsFrame: TEditorWordWrapOptionsFrame
Left = 6
Height = 19
Top = 56
Width = 416
Width = 375
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
Caption = 'cbHomeEndKey'
TabOrder = 4
TabOrder = 2
end
object DividerBevel1: TDividerBevel
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = cbHomeEndKey
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 15
Height = 245
Top = 81
Width = 416
Caption = 'DividerBevel1'
Width = 375
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
Font.Style = [fsBold]
ParentFont = False
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Panel2
AnchorSideBottom.Control = Panel2
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 151
Top = 102
Width = 140
Anchors = [akTop, akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Around = 6
BevelOuter = bvNone
ChildSizing.EnlargeVertical = crsSameSize
ChildSizing.ShrinkVertical = crsSameSize
ChildSizing.HorizontalSpacing = 6
ChildSizing.VerticalSpacing = 4
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 151
ClientWidth = 140
TabOrder = 2
ChildSizing.ControlsPerLine = 2
ClientHeight = 245
ClientWidth = 375
TabOrder = 3
object lblBevelColumn: TLabel
Left = 0
Height = 15
Top = 0
Width = 140
Caption = ' '
end
object lblBevelCol2: TLabel
Left = 146
Height = 15
Top = 0
Width = 60
Caption = ' '
end
object DividerBevelColumn: TDividerBevel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = lblBevelColumn
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 0
Height = 15
Top = 0
Width = 375
Caption = 'DividerBevelColumn'
Anchors = [akTop, akLeft, akRight]
Font.Style = [fsBold]
ParentFont = False
end
object lbMinWordWrapWidth: TLabel
Left = 0
Height = 15
Top = 5
Top = 23
Width = 140
BorderSpacing.CellAlignVertical = ccaCenter
Caption = 'lbMinWordWrapWidth'
end
object lbWordWrapIndent: TLabel
Left = 0
Height = 15
Top = 30
Width = 140
BorderSpacing.CellAlignVertical = ccaCenter
Caption = 'lbWordWrapIndent'
end
object cbIndentIsOffset: TCheckBox
Left = 0
Height = 19
Top = 53
Width = 140
BorderSpacing.CellAlignVertical = ccaCenter
Caption = 'cbIndentIsOffset'
TabOrder = 0
OnChange = cbIndentIsOffsetChange
end
object lbWordWrapIndentMin: TLabel
Left = 0
Height = 15
Top = 81
Width = 140
BorderSpacing.CellAlignVertical = ccaCenter
Caption = 'lbWordWrapIndentMin'
end
object lbWordWrapIndentMax: TLabel
Left = 0
Height = 15
Top = 106
Width = 140
BorderSpacing.CellAlignVertical = ccaCenter
Caption = 'lbWordWrapIndentMax'
end
object lbWordWrapIndentMaxRel: TLabel
Left = 0
Height = 15
Top = 131
Width = 140
BorderSpacing.CellAlignVertical = ccaCenter
Caption = 'lbWordWrapIndentMaxRel'
end
end
object Panel2: TPanel
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = DividerBevel1
AnchorSideTop.Side = asrBottom
Left = 152
Height = 151
Top = 102
Width = 60
AutoSize = True
BorderSpacing.Left = 6
BevelOuter = bvNone
ClientHeight = 151
ClientWidth = 60
TabOrder = 3
object edMinWordWrapWidth: TSpinEdit
AnchorSideTop.Control = Panel2
AnchorSideRight.Side = asrBottom
Left = 0
Left = 146
Height = 23
Top = 3
Top = 19
Width = 60
Alignment = taRightJustify
BorderSpacing.Top = 3
@ -180,16 +133,104 @@ object EditorWordWrapOptionsFrame: TEditorWordWrapOptionsFrame
Constraints.MinWidth = 60
MaxValue = 9999
MinValue = 1
TabOrder = 1
Value = 10
end
object lbMaxWordWrapWidth: TLabel
Left = 0
Height = 15
Top = 50
Width = 140
BorderSpacing.CellAlignVertical = ccaCenter
Caption = 'lbMaxWordWrapWidth'
end
object edMaxWordWrapWidth: TSpinEdit
AnchorSideRight.Side = asrBottom
Left = 146
Height = 23
Top = 46
Width = 60
Alignment = taRightJustify
BorderSpacing.Top = 3
BorderSpacing.Bottom = 3
Constraints.MaxWidth = 60
Constraints.MinWidth = 60
MaxValue = 9999
TabOrder = 0
Value = 10
end
object edWordWrapIndent: TSpinEdit
AnchorSideTop.Control = edMinWordWrapWidth
AnchorSideTop.Side = asrBottom
object lblFixedCol: TLabel
Left = 0
Height = 15
Top = 73
Width = 140
BorderSpacing.Bottom = 8
Caption = ' '
end
object lblFixedCol2: TLabel
AnchorSideBottom.Side = asrBottom
Left = 146
Height = 15
Top = 73
Width = 60
Caption = ' '
end
object cbFixedWidth: TCheckBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = lblFixedCol
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 0
Height = 19
Top = 73
Width = 375
Anchors = [akTop, akLeft, akRight]
Caption = 'cbFixedWidth'
TabOrder = 2
OnChange = cbFixedWidthChange
end
object lblBevelIndent: TLabel
Left = 0
Height = 15
Top = 96
Width = 140
Caption = ' '
end
object lblBevelIndent2: TLabel
Left = 146
Height = 15
Top = 96
Width = 60
Caption = ' '
end
object DividerBevelIndent: TDividerBevel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = lblBevelIndent
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 0
Height = 15
Top = 96
Width = 375
Caption = 'DividerBevelIndent'
Anchors = [akTop, akLeft, akRight]
Font.Style = [fsBold]
ParentFont = False
end
object lbWordWrapIndent: TLabel
Left = 0
Height = 15
Top = 119
Width = 140
BorderSpacing.CellAlignVertical = ccaCenter
Caption = 'lbWordWrapIndent'
end
object edWordWrapIndent: TSpinEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 146
Height = 23
Top = 29
Top = 115
Width = 60
Alignment = taRightJustify
BorderSpacing.Top = 3
@ -198,61 +239,54 @@ object EditorWordWrapOptionsFrame: TEditorWordWrapOptionsFrame
Constraints.MinWidth = 60
MaxValue = 100
MinValue = -100
TabOrder = 1
Value = 10
end
object Label1: TLabel
AnchorSideTop.Control = edWordWrapIndent
AnchorSideTop.Side = asrBottom
Left = 0
Height = 15
Top = 55
Width = 3
BorderSpacing.Top = 3
BorderSpacing.Bottom = 3
Caption = ' '
end
object edWordWrapIndentMin: TSpinEdit
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 0
Height = 23
Top = 73
Width = 60
Alignment = taRightJustify
BorderSpacing.Top = 3
BorderSpacing.Bottom = 3
Constraints.MaxWidth = 60
Constraints.MinWidth = 60
MaxValue = 100
TabOrder = 2
Value = 10
end
object edWordWrapIndentMax: TSpinEdit
AnchorSideTop.Control = edWordWrapIndentMin
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 0
Height = 23
Top = 99
Width = 60
Alignment = taRightJustify
BorderSpacing.Top = 3
BorderSpacing.Bottom = 3
Constraints.MaxWidth = 60
Constraints.MinWidth = 60
MaxValue = 100
TabOrder = 3
Value = 10
end
object edWordWrapIndentMaxRel: TSpinEdit
AnchorSideTop.Control = edWordWrapIndentMax
AnchorSideTop.Side = asrBottom
object lblIndentOffs: TLabel
Left = 0
Height = 15
Top = 142
Width = 140
BorderSpacing.Bottom = 8
Caption = ' '
end
object lblIndentOffs2: TLabel
Left = 146
Height = 15
Top = 142
Width = 60
BorderSpacing.Bottom = 8
Caption = ' '
end
object cbIndentIsOffset: TCheckBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = lblIndentOffs
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 0
Height = 19
Top = 142
Width = 375
Anchors = [akTop, akLeft, akRight]
BorderSpacing.CellAlignVertical = ccaCenter
Caption = 'cbIndentIsOffset'
TabOrder = 4
OnChange = cbIndentIsOffsetChange
end
object lbWordWrapIndentMin: TLabel
Left = 0
Height = 15
Top = 169
Width = 140
BorderSpacing.CellAlignVertical = ccaCenter
Caption = 'lbWordWrapIndentMin'
end
object edWordWrapIndentMin: TSpinEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 146
Height = 23
Top = 125
Top = 165
Width = 60
Alignment = taRightJustify
BorderSpacing.Top = 3
@ -260,7 +294,55 @@ object EditorWordWrapOptionsFrame: TEditorWordWrapOptionsFrame
Constraints.MaxWidth = 60
Constraints.MinWidth = 60
MaxValue = 100
TabOrder = 4
TabOrder = 5
Value = 10
end
object lbWordWrapIndentMax: TLabel
Left = 0
Height = 15
Top = 196
Width = 140
BorderSpacing.CellAlignVertical = ccaCenter
Caption = 'lbWordWrapIndentMax'
end
object edWordWrapIndentMax: TSpinEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 146
Height = 23
Top = 192
Width = 60
Alignment = taRightJustify
BorderSpacing.Top = 3
BorderSpacing.Bottom = 3
Constraints.MaxWidth = 60
Constraints.MinWidth = 60
MaxValue = 100
TabOrder = 6
Value = 10
end
object lbWordWrapIndentMaxRel: TLabel
Left = 0
Height = 15
Top = 223
Width = 140
BorderSpacing.CellAlignVertical = ccaCenter
Caption = 'lbWordWrapIndentMaxRel'
end
object edWordWrapIndentMaxRel: TSpinEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 146
Height = 23
Top = 219
Width = 60
Alignment = taRightJustify
BorderSpacing.Top = 3
BorderSpacing.Bottom = 3
Constraints.MaxWidth = 60
Constraints.MinWidth = 60
MaxValue = 100
TabOrder = 7
Value = 10
end
end

View File

@ -21,21 +21,32 @@ type
cbEnableWordWrap: TCheckBox;
cbIndentIsOffset: TCheckBox;
cbHomeEndKey: TCheckBox;
DividerBevel1: TDividerBevel;
cbFixedWidth: TCheckBox;
DividerBevelIndent: TDividerBevel;
DividerBevelColumn: TDividerBevel;
edMinWordWrapWidth: TSpinEdit;
edMaxWordWrapWidth: TSpinEdit;
edWordWrapIndentMax: TSpinEdit;
edWordWrapIndentMaxRel: TSpinEdit;
edWordWrapIndent: TSpinEdit;
edWordWrapIndentMin: TSpinEdit;
Label1: TLabel;
lblBevelColumn: TLabel;
lblBevelCol2: TLabel;
lblBevelIndent: TLabel;
lblBevelIndent2: TLabel;
lblFixedCol: TLabel;
lblIndentOffs: TLabel;
lblFixedCol2: TLabel;
lblIndentOffs2: TLabel;
lbMinWordWrapWidth: TLabel;
lbMaxWordWrapWidth: TLabel;
lbWordWrapIndentMin: TLabel;
lbWordWrapIndent: TLabel;
lbWordWrapIndentMax: TLabel;
lbWordWrapIndentMaxRel: TLabel;
Panel1: TPanel;
Panel2: TPanel;
rgCaretWrapPos: TRadioGroup;
procedure cbFixedWidthChange(Sender: TObject);
procedure cbIndentIsOffsetChange(Sender: TObject);
private
@ -67,6 +78,15 @@ begin
end;
end;
procedure TEditorWordWrapOptionsFrame.cbFixedWidthChange(Sender: TObject);
begin
edMaxWordWrapWidth.Enabled := not cbFixedWidth.Checked;
case cbFixedWidth.Checked of
True: lbMinWordWrapWidth.Caption := dlgOptWordWrapFixedLineLength;
False: lbMinWordWrapWidth.Caption := dlgOptWordWrapMinimumLineLength;
end;
end;
function TEditorWordWrapOptionsFrame.GetTitle: String;
begin
Result := dlgOptWordWrap;
@ -79,9 +99,12 @@ begin
rgCaretWrapPos.Items.Add(dlgOptWordWrapEndOfLine);
rgCaretWrapPos.Items.Add(dlgOptWordWrapStartOfNextLine);
cbHomeEndKey.Caption := dlgOptWordWrapHomeEndKey;
DividerBevel1.Caption := dlgOptWordWrapSectionIndent;
DividerBevelColumn.Caption := dlgOptWordWrapSectionColumn;
lbMinWordWrapWidth.Caption := dlgOptWordWrapMinimumLineLength;
lbMaxWordWrapWidth.Caption := dlgOptWordWrapMaximumLineLength;
cbFixedWidth.Caption := dlgOptWordWrapCheckFixedLength;
DividerBevelIndent.Caption := dlgOptWordWrapSectionIndent;
lbWordWrapIndent.Caption := dlgOptWordWrapIndent;
cbIndentIsOffset.Caption := dlgOptWordWrapIndentIsOffset;
lbWordWrapIndentMin.Caption := dlgOptWordWrapIndentMin;
@ -96,14 +119,19 @@ begin
wcpEOL: rgCaretWrapPos.ItemIndex := 0;
wcpBOL: rgCaretWrapPos.ItemIndex := 1;
end;
edMinWordWrapWidth.Value := (AOptions as TEditorOptions).WordWrapMinWidth;
cbHomeEndKey.Checked := (AOptions as TEditorOptions).WordWrapForceHomeEnd;
cbFixedWidth.Checked := (AOptions as TEditorOptions).WordWrapFixedWidth;
edMinWordWrapWidth.Value := (AOptions as TEditorOptions).WordWrapMinWidth;
edMaxWordWrapWidth.Value := (AOptions as TEditorOptions).WordWrapMaxWidth;
edWordWrapIndent.Value := (AOptions as TEditorOptions).WordWrapIndent;
cbIndentIsOffset.Checked := (AOptions as TEditorOptions).WordWrapIndentUseOffset;
edWordWrapIndentMin.Value := (AOptions as TEditorOptions).WordWrapIndentMin;
edWordWrapIndentMax.Value := (AOptions as TEditorOptions).WordWrapIndentMax;
edWordWrapIndentMaxRel.Value := (AOptions as TEditorOptions).WordWrapIndentMaxRel;
cbFixedWidthChange(nil);
end;
procedure TEditorWordWrapOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
@ -113,9 +141,12 @@ begin
0: (AOptions as TEditorOptions).WordWrapCaretWrapPos := wcpEOL;
1: (AOptions as TEditorOptions).WordWrapCaretWrapPos := wcpBOL;
end;
(AOptions as TEditorOptions).WordWrapMinWidth := edMinWordWrapWidth.Value;
(AOptions as TEditorOptions).WordWrapForceHomeEnd := cbHomeEndKey.Checked;
(AOptions as TEditorOptions).WordWrapFixedWidth := cbFixedWidth.Checked;
(AOptions as TEditorOptions).WordWrapMinWidth := edMinWordWrapWidth.Value;
(AOptions as TEditorOptions).WordWrapMaxWidth := edMaxWordWrapWidth.Value;
(AOptions as TEditorOptions).WordWrapIndent := edWordWrapIndent.Value;
(AOptions as TEditorOptions).WordWrapIndentUseOffset := cbIndentIsOffset.Checked;
(AOptions as TEditorOptions).WordWrapIndentMin := edWordWrapIndentMin.Value;

View File

@ -1657,8 +1657,12 @@ resourcestring
dlgOptWordWrapEndOfLine = 'end of line';
dlgOptWordWrapStartOfNextLine = 'start of next line';
dlgOptWordWrapHomeEndKey = 'Force default home/end keys to subline start/end';
dlgOptWordWrapSectionIndent = 'Indent settings';
dlgOptWordWrapSectionColumn = 'Wrap column settings';
dlgOptWordWrapCheckFixedLength = 'Wrap at fixed column';
dlgOptWordWrapFixedLineLength = 'Fixed line length';
dlgOptWordWrapMinimumLineLength = 'Minimum line length';
dlgOptWordWrapMaximumLineLength = 'Maximum line length';
dlgOptWordWrapSectionIndent = 'Indent settings';
dlgOptWordWrapIndent = 'Indent width';
dlgOptWordWrapIndentIsOffset = 'Indent relative to text';
dlgOptWordWrapIndentMin = 'Minimum indent width';

View File

@ -306,6 +306,7 @@ type
procedure SetWordWrapIndentMaxRel(AValue: Integer);
procedure SetWordWrapIndentMin(AValue: Integer);
procedure SetWordWrapIndentUseOffset(AValue: boolean);
procedure SetWordWrapMaxWidth(AValue: Integer);
procedure SetWordWrapMinWidth(AValue: Integer);
procedure SrcSynCaretChanged(Sender: TObject);
function GetHighlighter: TSynCustomFoldHighlighter;
@ -357,6 +358,7 @@ type
property WordWrapCaretWrapPos: TLazSynEditWrapCaretPos write SetWordWrapCaretWrapPos;
property WordWrapForceHomeEnd: Boolean write SetWordWrapForceHomeEnd;
property WordWrapMinWidth: Integer write SetWordWrapMinWidth;
property WordWrapMaxWidth: Integer write SetWordWrapMaxWidth;
property WordWrapIndent: Integer write SetWordWrapIndent;
property WordWrapIndentUseOffset: boolean write SetWordWrapIndentUseOffset;
@ -1649,6 +1651,12 @@ begin
FWrapView.WrapIndentIsOffset := AValue;
end;
procedure TIDESynEditor.SetWordWrapMaxWidth(AValue: Integer);
begin
if FWrapView <> nil then
FWrapView.MaxWrapWidth := AValue;
end;
procedure TIDESynEditor.SetWordWrapMinWidth(AValue: Integer);
begin
if FWrapView <> nil then