IDE, SynEdit: introduce block-indent by tab. issue #0020256

git-svn-id: trunk@33382 -
This commit is contained in:
martin 2011-11-07 02:44:22 +00:00
parent 4600e3eb2f
commit 4ca8f0c158
5 changed files with 242 additions and 135 deletions

View File

@ -351,6 +351,7 @@ type
procedure WMVScroll(var Msg: {$IFDEF SYN_LAZARUS}TLMScroll{$ELSE}TWMScroll{$ENDIF}); message WM_VSCROLL; procedure WMVScroll(var Msg: {$IFDEF SYN_LAZARUS}TLMScroll{$ELSE}TWMScroll{$ENDIF}); message WM_VSCROLL;
private private
FBlockIndent: integer; FBlockIndent: integer;
FBlockTabIndent: integer;
FCaret: TSynEditCaret; FCaret: TSynEditCaret;
FInternalCaret: TSynEditCaret; FInternalCaret: TSynEditCaret;
FScreenCaret: TSynEditScreenCaret; FScreenCaret: TSynEditScreenCaret;
@ -477,6 +478,7 @@ type
function GetPaintLockOwner: TSynEditBase; function GetPaintLockOwner: TSynEditBase;
function GetPlugin(Index: Integer): TSynEditPlugin; function GetPlugin(Index: Integer): TSynEditPlugin;
function GetTextBetweenPoints(aStartPoint, aEndPoint: TPoint): String; function GetTextBetweenPoints(aStartPoint, aEndPoint: TPoint): String;
procedure SetBlockTabIndent(AValue: integer);
procedure SetDefSelectionMode(const AValue: TSynSelectionMode); procedure SetDefSelectionMode(const AValue: TSynSelectionMode);
procedure SetFoldState(const AValue: String); procedure SetFoldState(const AValue: String);
procedure SetMouseActions(const AValue: TSynEditMouseActions); procedure SetMouseActions(const AValue: TSynEditMouseActions);
@ -922,7 +924,8 @@ type
read GetTrimSpaceType write SetTrimSpaceType; read GetTrimSpaceType write SetTrimSpaceType;
property BookMarkOptions: TSynBookMarkOpt property BookMarkOptions: TSynBookMarkOpt
read fBookMarkOpt write fBookMarkOpt; read fBookMarkOpt write fBookMarkOpt;
property BlockIndent: integer read fBlockIndent write SetBlockIndent default 2; property BlockIndent: integer read FBlockIndent write SetBlockIndent default 2;
property BlockTabIndent: integer read FBlockTabIndent write SetBlockTabIndent default 0;
property ExtraCharSpacing: integer property ExtraCharSpacing: integer
read fExtraCharSpacing write SetExtraCharSpacing default 0; read fExtraCharSpacing write SetExtraCharSpacing default 0;
property ExtraLineSpacing: integer property ExtraLineSpacing: integer
@ -1012,6 +1015,7 @@ type
property Align; property Align;
property Beautifier; property Beautifier;
property BlockIndent; property BlockIndent;
property BlockTabIndent;
property BorderSpacing; property BorderSpacing;
{$IFNDEF SYN_LAZARUS} {$IFNDEF SYN_LAZARUS}
property Ctl3D; property Ctl3D;
@ -1193,9 +1197,9 @@ type
TSynEditUndoIndent = class(TSynEditUndoItem) TSynEditUndoIndent = class(TSynEditUndoItem)
public public
FPosY1, FPosY2, FCnt: Integer; FPosY1, FPosY2, FCnt, FTabCnt: Integer;
public public
constructor Create(APosY, EPosY, ACnt: Integer); constructor Create(APosY, EPosY, ACnt, ATabCnt: Integer);
function PerformUndo(Caller: TObject): Boolean; override; function PerformUndo(Caller: TObject): Boolean; override;
end; end;
@ -1292,11 +1296,12 @@ end;
{ TSynEditUndoIndent } { TSynEditUndoIndent }
constructor TSynEditUndoIndent.Create(APosY, EPosY, ACnt: Integer); constructor TSynEditUndoIndent.Create(APosY, EPosY, ACnt, ATabCnt: Integer);
begin begin
FPosY1 := APosY; FPosY1 := APosY;
FPosY2 := EPosY; FPosY2 := EPosY;
FCnt := ACnt; FCnt := ACnt;
FTabCnt := ATabCnt;
end; end;
function TSynEditUndoIndent.PerformUndo(Caller: TObject): Boolean; function TSynEditUndoIndent.PerformUndo(Caller: TObject): Boolean;
@ -1446,6 +1451,12 @@ begin
Result := FInternalBlockSelection.SelText; Result := FInternalBlockSelection.SelText;
end; end;
procedure TCustomSynEdit.SetBlockTabIndent(AValue: integer);
begin
if FBlockTabIndent = AValue then Exit;
FBlockTabIndent := AValue;
end;
procedure TCustomSynEdit.SetDefSelectionMode(const AValue: TSynSelectionMode); procedure TCustomSynEdit.SetDefSelectionMode(const AValue: TSynSelectionMode);
begin begin
FBlockSelection.SelectionMode := AValue; // Includes active FBlockSelection.SelectionMode := AValue; // Includes active
@ -5172,10 +5183,13 @@ begin
SetCaretAndSelection(LogicalToPhysicalPos(Point(1,TSynEditUndoIndent(Item).FPosY1)), SetCaretAndSelection(LogicalToPhysicalPos(Point(1,TSynEditUndoIndent(Item).FPosY1)),
Point(1, TSynEditUndoIndent(Item).FPosY1), Point(2, TSynEditUndoIndent(Item).FPosY2), Point(1, TSynEditUndoIndent(Item).FPosY1), Point(2, TSynEditUndoIndent(Item).FPosY2),
smNormal); smNormal);
x := fBlockIndent; x := FBlockIndent;
fBlockIndent := TSynEditUndoIndent(Item).FCnt; y := FBlockTabIndent;
FBlockIndent := TSynEditUndoIndent(Item).FCnt;
FBlockTabIndent := TSynEditUndoIndent(Item).FTabCnt;
DoBlockIndent; DoBlockIndent;
fBlockIndent := x; FBlockIndent := x;
FBlockTabIndent := y;
end end
else else
if Item.ClassType = TSynEditUndoUnIndent then if Item.ClassType = TSynEditUndoUnIndent then
@ -5263,7 +5277,7 @@ end;
procedure TCustomSynEdit.UndoItem(Item: TSynEditUndoItem); procedure TCustomSynEdit.UndoItem(Item: TSynEditUndoItem);
var var
Line, OldText: PChar; Line, OldText: PChar;
y, Len, Len2: integer; y, Len, Len2, LenT: integer;
function GetLeadWSLen : integer; function GetLeadWSLen : integer;
var var
@ -5283,14 +5297,16 @@ begin
begin begin
// add to redo list // add to redo list
fRedoList.AddChange(TSynEditUndoIndent.Create(TSynEditUndoIndent(Item).FPosY1, fRedoList.AddChange(TSynEditUndoIndent.Create(TSynEditUndoIndent(Item).FPosY1,
TSynEditUndoIndent(Item).FPosY2, TSynEditUndoIndent(Item).FCnt)); TSynEditUndoIndent(Item).FPosY2, TSynEditUndoIndent(Item).FCnt, TSynEditUndoIndent(Item).FTabCnt));
// quick unintend (must all be spaces, as inserted...) // quick unintend (must all be spaces, as inserted...)
fRedoList.Lock; fRedoList.Lock;
Len2 := TSynEditUndoIndent(Item).FCnt; Len2 := TSynEditUndoIndent(Item).FCnt;
LenT := TSynEditUndoIndent(Item).FTabCnt;
for y := TSynEditUndoUnIndent(Item).FPosY1 to TSynEditUndoUnIndent(Item).FPosY2 do begin for y := TSynEditUndoUnIndent(Item).FPosY1 to TSynEditUndoUnIndent(Item).FPosY2 do begin
Line := PChar(FTheLinesView[y - 1]); Line := PChar(FTheLinesView[y - 1]);
Len := GetLeadWSLen; Len := GetLeadWSLen;
FTheLinesView.EditDelete(Len+1-Len2, y, Len2); FTheLinesView.EditDelete(Len+1-Len2, y, Len2);
FTheLinesView.EditDelete(1, y, LenT);
end; end;
fRedoList.Unlock; fRedoList.Unlock;
end end
@ -7824,7 +7840,7 @@ var
BB,BE : TPoint; BB,BE : TPoint;
Line : PChar; Line : PChar;
Len, e, y: integer; Len, e, y: integer;
Spaces: String; Spaces, Tabs: String;
function GetLeadWSLen : integer; function GetLeadWSLen : integer;
var var
@ -7853,7 +7869,8 @@ begin
else e := BE.y; else e := BE.y;
end; end;
Spaces := StringOfChar(#32, fBlockIndent); Spaces := StringOfChar(#32, FBlockIndent);
Tabs := StringOfChar( #9, FBlockTabIndent);
fUndoList.Lock; fUndoList.Lock;
fRedoList.Lock; fRedoList.Lock;
try try
@ -7862,13 +7879,14 @@ begin
Line := PChar(FTheLinesView[y - 1]); Line := PChar(FTheLinesView[y - 1]);
Len := GetLeadWSLen; Len := GetLeadWSLen;
FTheLinesView.EditInsert(Len + 1, y, Spaces); FTheLinesView.EditInsert(Len + 1, y, Spaces);
FTheLinesView.EditInsert(1, y, Tabs);
end; end;
finally finally
fUndoList.Unlock; fUndoList.Unlock;
fRedoList.Unlock; fRedoList.Unlock;
end; end;
fUndoList.AddChange(TSynEditUndoIndent.Create(BB.Y, e, fBlockIndent)); fUndoList.AddChange(TSynEditUndoIndent.Create(BB.Y, e, FBlockIndent, FBlockTabIndent));
finally finally
FTrimmedLinesView.ForceTrim; // Otherwise it may reset the block FTrimmedLinesView.ForceTrim; // Otherwise it may reset the block
FCaret.LineBytePos := FBlockSelection.EndLineBytePos; FCaret.LineBytePos := FBlockSelection.EndLineBytePos;
@ -7885,6 +7903,7 @@ var
FullStrToDelete: PChar; FullStrToDelete: PChar;
Line: PChar; Line: PChar;
Len, LogP1, PhyP1, LogP2, PhyP2, y, StrToDeleteLen, e : integer; Len, LogP1, PhyP1, LogP2, PhyP2, y, StrToDeleteLen, e : integer;
i, i2, j: Integer;
SomethingDeleted : Boolean; SomethingDeleted : Boolean;
HasTab: Boolean; HasTab: Boolean;
@ -7970,6 +7989,25 @@ begin
if LogP1 - LogP2 > 0 then if LogP1 - LogP2 > 0 then
FTheLinesView.EditDelete(LogP2, y, LogP1 - LogP2); FTheLinesView.EditDelete(LogP2, y, LogP1 - LogP2);
SomethingDeleted := SomethingDeleted or (LogP1 - LogP2 > 0); SomethingDeleted := SomethingDeleted or (LogP1 - LogP2 > 0);
// Todo: create FullTabStrToDelete for tabs
fUndoList.Unlock;
fRedoList.Unlock;
Line := PChar(FTheLinesView[y - 1]);
j := 0;
for i := 1 to FBlockTabIndent do begin
i2 := fTabWidth;
while (i2 > 0) and (Line[j] = #32) do begin
dec(i2);
inc(j);
end;
if (i2 > 0) and (Line[j] = #9) then inc(j);
end;
if j > 0 then
FTheLinesView.EditDelete(1, y, j);
fUndoList.Lock;
fRedoList.Lock;
end; end;
fUndoList.Unlock; fUndoList.Unlock;

View File

@ -930,6 +930,7 @@ type
TEditorOptions = class(TAbstractIDEEnvironmentOptions) TEditorOptions = class(TAbstractIDEEnvironmentOptions)
private private
FBlockTabIndent: Integer;
FCompletionLongLineHintInMSec: Integer; FCompletionLongLineHintInMSec: Integer;
FCompletionLongLineHintType: TSynCompletionLongHintType; FCompletionLongLineHintType: TSynCompletionLongHintType;
FPasExtendedKeywordsMode: Boolean; FPasExtendedKeywordsMode: Boolean;
@ -1077,6 +1078,8 @@ type
write FShowGutterHints; write FShowGutterHints;
property BlockIndent: Integer property BlockIndent: Integer
read fBlockIndent write fBlockIndent default 2; read fBlockIndent write fBlockIndent default 2;
property BlockTabIndent: Integer
read FBlockTabIndent write FBlockTabIndent default 0;
property BlockIndentType: TSynBeautifierIndentType property BlockIndentType: TSynBeautifierIndentType
read fBlockIndentType write fBlockIndentType default sbitCopySpaceTab; read fBlockIndentType write fBlockIndentType default sbitCopySpaceTab;
property TrimSpaceType: TSynEditStringTrimmingType property TrimSpaceType: TSynEditStringTrimmingType
@ -3062,6 +3065,7 @@ begin
FCopyWordAtCursorOnCopyNone := True; FCopyWordAtCursorOnCopyNone := True;
FShowGutterHints := True; FShowGutterHints := True;
fBlockIndent := 2; fBlockIndent := 2;
FBlockTabIndent := 0;
fBlockIndentType := sbitSpace; fBlockIndentType := sbitSpace;
FTrimSpaceType := settEditLine; FTrimSpaceType := settEditLine;
fUndoLimit := 32767; fUndoLimit := 32767;
@ -3189,6 +3193,8 @@ begin
'EditorOptions/General/Editor/UseSyntaxHighlight', True); 'EditorOptions/General/Editor/UseSyntaxHighlight', True);
fBlockIndent := fBlockIndent :=
XMLConfig.GetValue('EditorOptions/General/Editor/BlockIndent', 2); XMLConfig.GetValue('EditorOptions/General/Editor/BlockIndent', 2);
FBlockTabIndent :=
XMLConfig.GetValue('EditorOptions/General/Editor/BlockTabIndent', 0);
fBlockIndentType := GetSynBeautifierIndentType fBlockIndentType := GetSynBeautifierIndentType
(XMLConfig.GetValue('EditorOptions/General/Editor/BlockIndentType', (XMLConfig.GetValue('EditorOptions/General/Editor/BlockIndentType',
'SpaceIndent')); 'SpaceIndent'));
@ -3397,6 +3403,8 @@ begin
, fUseSyntaxHighlight, True); , fUseSyntaxHighlight, True);
XMLConfig.SetDeleteValue('EditorOptions/General/Editor/BlockIndent' XMLConfig.SetDeleteValue('EditorOptions/General/Editor/BlockIndent'
, fBlockIndent, 2); , fBlockIndent, 2);
XMLConfig.SetDeleteValue('EditorOptions/General/Editor/BlockTabIndent'
, FBlockTabIndent, 0);
XMLConfig.SetDeleteValue('EditorOptions/General/Editor/BlockIndentType' XMLConfig.SetDeleteValue('EditorOptions/General/Editor/BlockIndentType'
, GetSynBeautifierIndentName(fBlockIndentType), 'SpaceIndent'); , GetSynBeautifierIndentName(fBlockIndentType), 'SpaceIndent');
XMLConfig.SetDeleteValue('EditorOptions/General/Editor/SpaceTrimType' XMLConfig.SetDeleteValue('EditorOptions/General/Editor/SpaceTrimType'
@ -3978,6 +3986,7 @@ begin
ASynEdit.Options := fSynEditOptions; ASynEdit.Options := fSynEditOptions;
ASynEdit.Options2 := fSynEditOptions2; ASynEdit.Options2 := fSynEditOptions2;
ASynEdit.BlockIndent := fBlockIndent; ASynEdit.BlockIndent := fBlockIndent;
ASynEdit.BlockTabIndent := FBlockTabIndent;
(ASynEdit.Beautifier as TSynBeautifier).IndentType := fBlockIndentType; (ASynEdit.Beautifier as TSynBeautifier).IndentType := fBlockIndentType;
ASynEdit.TrimSpaceType := FTrimSpaceType; ASynEdit.TrimSpaceType := FTrimSpaceType;
ASynEdit.TabWidth := fTabWidth; ASynEdit.TabWidth := fTabWidth;

View File

@ -1,9 +1,8 @@
inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
Height = 423 Height = 442
Width = 434 Width = 434
ClientHeight = 423 ClientHeight = 442
ClientWidth = 434 ClientWidth = 434
TabOrder = 0
Visible = False Visible = False
DesignLeft = 295 DesignLeft = 295
DesignTop = 212 DesignTop = 212
@ -13,9 +12,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = BlockIndentComboBox AnchorSideTop.Control = BlockIndentComboBox
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 112 Left = 112
Height = 18 Height = 16
Top = 232 Top = 252
Width = 109 Width = 92
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'BlockIndentLabel' Caption = 'BlockIndentLabel'
ParentColor = False ParentColor = False
@ -26,9 +25,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = TabWidthsComboBox AnchorSideTop.Control = TabWidthsComboBox
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 324 Left = 324
Height = 18 Height = 16
Top = 232 Top = 154
Width = 98 Width = 86
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'TabWidthsLabel' Caption = 'TabWidthsLabel'
ParentColor = False ParentColor = False
@ -39,9 +38,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = UndoLimitComboBox AnchorSideTop.Control = UndoLimitComboBox
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 324 Left = 324
Height = 18 Height = 16
Top = 27 Top = 24
Width = 100 Width = 85
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'UndoLimitLabel' Caption = 'UndoLimitLabel'
ParentColor = False ParentColor = False
@ -51,10 +50,10 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = BlockIndentTypeComboBox AnchorSideTop.Control = BlockIndentTypeComboBox
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 112 Left = 324
Height = 18 Height = 16
Top = 263 Top = 192
Width = 137 Width = 118
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'BlockIndentTypeLabel' Caption = 'BlockIndentTypeLabel'
ParentColor = False ParentColor = False
@ -65,13 +64,14 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = TabWidthsComboBox AnchorSideBottom.Control = TabWidthsComboBox
Left = 6 Left = 6
Height = 27 Height = 23
Top = 228 Top = 249
Width = 100 Width = 100
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 3 BorderSpacing.Top = 3
ItemHeight = 0 ItemHeight = 15
Items.Strings = ( Items.Strings = (
'0'
'1' '1'
'2' '2'
'4' '4'
@ -83,15 +83,17 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
TabOrder = 0 TabOrder = 0
end end
object TabWidthsComboBox: TComboBox[5] object TabWidthsComboBox: TComboBox[5]
AnchorSideLeft.Control = SmartTabsCheckBox AnchorSideLeft.Control = UndoLimitComboBox
AnchorSideTop.Control = BlockIndentComboBox AnchorSideTop.Control = IndentsTabsGroupDivider
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 218 Left = 218
Height = 27 Height = 23
Top = 228 Top = 151
Width = 100 Width = 100
ItemHeight = 0 BorderSpacing.Top = 6
ItemHeight = 15
Items.Strings = ( Items.Strings = (
'1' '1'
'2' '2'
@ -109,11 +111,11 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = UndoGroupDivider AnchorSideTop.Control = UndoGroupDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 218 Left = 218
Height = 27 Height = 23
Top = 23 Top = 21
Width = 100 Width = 100
BorderSpacing.Top = 6 BorderSpacing.Top = 6
ItemHeight = 0 ItemHeight = 15
Items.Strings = ( Items.Strings = (
'32767' '32767'
'4096' '4096'
@ -129,9 +131,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = UndoAfterSaveCheckBox AnchorSideTop.Control = UndoAfterSaveCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 21 Height = 19
Top = 44 Top = 40
Width = 158 Width = 134
BorderSpacing.Left = 6 BorderSpacing.Left = 6
Caption = 'GroupUndoCheckBox' Caption = 'GroupUndoCheckBox'
OnChange = GroupUndoCheckBoxChange OnChange = GroupUndoCheckBoxChange
@ -142,9 +144,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = UndoGroupDivider AnchorSideTop.Control = UndoGroupDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 21 Height = 19
Top = 23 Top = 21
Width = 182 Width = 151
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6 BorderSpacing.Top = 6
Caption = 'UndoAfterSaveCheckBox' Caption = 'UndoAfterSaveCheckBox'
@ -155,9 +157,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = ScrollGroupDivider AnchorSideTop.Control = ScrollGroupDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 21 Height = 19
Top = 94 Top = 86
Width = 191 Width = 161
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6 BorderSpacing.Top = 6
Caption = 'ScrollPastEndFileCheckBox' Caption = 'ScrollPastEndFileCheckBox'
@ -169,9 +171,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = AlwaysVisibleCursorCheckBox AnchorSideTop.Control = AlwaysVisibleCursorCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 21 Height = 19
Top = 379 Top = 356
Width = 197 Width = 165
BorderSpacing.Left = 6 BorderSpacing.Left = 6
Caption = 'ScrollPastEndLineCheckBox' Caption = 'ScrollPastEndLineCheckBox'
OnChange = ScrollPastEndLineCheckBoxChange OnChange = ScrollPastEndLineCheckBoxChange
@ -182,9 +184,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = ScrollGroupDivider AnchorSideTop.Control = ScrollGroupDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 218 Left = 218
Height = 21 Height = 19
Top = 94 Top = 86
Width = 191 Width = 158
BorderSpacing.Top = 6 BorderSpacing.Top = 6
Caption = 'ScrollByOneLessCheckBox' Caption = 'ScrollByOneLessCheckBox'
OnChange = ScrollByOneLessCheckBoxChange OnChange = ScrollByOneLessCheckBoxChange
@ -195,9 +197,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = ScrollPastEndFileCheckBox AnchorSideTop.Control = ScrollPastEndFileCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 21 Height = 19
Top = 115 Top = 105
Width = 176 Width = 149
BorderSpacing.Left = 6 BorderSpacing.Left = 6
Caption = 'HalfPageScrollCheckBox' Caption = 'HalfPageScrollCheckBox'
OnChange = HalfPageScrollCheckBoxChange OnChange = HalfPageScrollCheckBoxChange
@ -205,14 +207,13 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
end end
object AutoIndentCheckBox: TCheckBox[13] object AutoIndentCheckBox: TCheckBox[13]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = IndentsTabsGroupDivider AnchorSideTop.Control = SmartTabsCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 21 Height = 19
Top = 165 Top = 189
Width = 155 Width = 132
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'AutoIndentCheckBox' Caption = 'AutoIndentCheckBox'
OnChange = AutoIndentCheckBoxChange OnChange = AutoIndentCheckBoxChange
TabOrder = 9 TabOrder = 9
@ -222,35 +223,38 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = AutoIndentLink AnchorSideTop.Control = AutoIndentLink
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 21 Height = 19
Top = 204 Top = 227
Width = 187 Width = 160
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 3
Caption = 'TabIndentBlocksCheckBox' Caption = 'TabIndentBlocksCheckBox'
OnChange = TabIndentBlocksCheckBoxChange OnChange = TabIndentBlocksCheckBoxChange
TabOrder = 10 TabOrder = 10
end end
object SmartTabsCheckBox: TCheckBox[15] object SmartTabsCheckBox: TCheckBox[15]
AnchorSideLeft.Control = UndoLimitComboBox AnchorSideLeft.Control = Owner
AnchorSideTop.Control = IndentsTabsGroupDivider AnchorSideTop.Control = TabsToSpacesCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 218 Left = 6
Height = 21 Height = 19
Top = 165 Top = 170
Width = 153 Width = 128
BorderSpacing.Top = 6 BorderSpacing.Left = 6
Caption = 'SmartTabsCheckBox' Caption = 'SmartTabsCheckBox'
OnChange = SmartTabsCheckBoxChange OnChange = SmartTabsCheckBoxChange
TabOrder = 11 TabOrder = 11
end end
object TabsToSpacesCheckBox: TCheckBox[16] object TabsToSpacesCheckBox: TCheckBox[16]
AnchorSideLeft.Control = SmartTabsCheckBox AnchorSideLeft.Control = Owner
AnchorSideTop.Control = SmartTabsCheckBox AnchorSideTop.Control = IndentsTabsGroupDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 218 Left = 6
Height = 21 Height = 19
Top = 186 Top = 151
Width = 173 Width = 147
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'TabsToSpacesCheckBox' Caption = 'TabsToSpacesCheckBox'
OnChange = TabsToSpacesCheckBoxChange OnChange = TabsToSpacesCheckBoxChange
TabOrder = 12 TabOrder = 12
@ -260,9 +264,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = CaretGroupDivider AnchorSideTop.Control = CaretGroupDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 21 Height = 19
Top = 316 Top = 299
Width = 165 Width = 140
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6 BorderSpacing.Top = 6
Caption = 'KeepCursorXCheckBox' Caption = 'KeepCursorXCheckBox'
@ -274,9 +278,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = KeepCursorXCheckBox AnchorSideTop.Control = KeepCursorXCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 21 Height = 19
Top = 337 Top = 318
Width = 191 Width = 158
BorderSpacing.Left = 6 BorderSpacing.Left = 6
Caption = 'PersistentCursorCheckBox' Caption = 'PersistentCursorCheckBox'
OnChange = PersistentCursorCheckBoxChange OnChange = PersistentCursorCheckBoxChange
@ -287,9 +291,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = PersistentCursorCheckBox AnchorSideTop.Control = PersistentCursorCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 21 Height = 19
Top = 358 Top = 337
Width = 211 Width = 178
BorderSpacing.Left = 6 BorderSpacing.Left = 6
Caption = 'AlwaysVisibleCursorCheckBox' Caption = 'AlwaysVisibleCursorCheckBox'
OnChange = AlwaysVisibleCursorCheckBoxChange OnChange = AlwaysVisibleCursorCheckBoxChange
@ -300,9 +304,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = CaretGroupDivider AnchorSideTop.Control = CaretGroupDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 218 Left = 218
Height = 21 Height = 19
Top = 316 Top = 299
Width = 220 Width = 182
BorderSpacing.Top = 6 BorderSpacing.Top = 6
Caption = 'CursorSkipsSelectionCheckBox' Caption = 'CursorSkipsSelectionCheckBox'
OnChange = CursorSkipsSelectionCheckBoxChange OnChange = CursorSkipsSelectionCheckBoxChange
@ -312,9 +316,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideLeft.Control = CursorSkipsSelectionCheckBox AnchorSideLeft.Control = CursorSkipsSelectionCheckBox
AnchorSideTop.Control = AlwaysVisibleCursorCheckBox AnchorSideTop.Control = AlwaysVisibleCursorCheckBox
Left = 218 Left = 218
Height = 21 Height = 19
Top = 358 Top = 337
Width = 281 Width = 236
Caption = 'HomeKeyJumpsToNearestStartCheckBox' Caption = 'HomeKeyJumpsToNearestStartCheckBox'
OnChange = HomeKeyJumpsToNearestStartCheckBoxChange OnChange = HomeKeyJumpsToNearestStartCheckBoxChange
TabOrder = 17 TabOrder = 17
@ -323,25 +327,22 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideLeft.Control = HomeKeyJumpsToNearestStartCheckBox AnchorSideLeft.Control = HomeKeyJumpsToNearestStartCheckBox
AnchorSideTop.Control = ScrollPastEndLineCheckBox AnchorSideTop.Control = ScrollPastEndLineCheckBox
Left = 218 Left = 218
Height = 21 Height = 19
Top = 379 Top = 356
Width = 266 Width = 223
Caption = 'EndKeyJumpsToNearestStartCheckBox' Caption = 'EndKeyJumpsToNearestStartCheckBox'
OnChange = EndKeyJumpsToNearestStartCheckBoxChange OnChange = EndKeyJumpsToNearestStartCheckBoxChange
TabOrder = 18 TabOrder = 18
end end
object BlockIndentTypeComboBox: TComboBox[23] object BlockIndentTypeComboBox: TComboBox[23]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = UndoLimitComboBox
AnchorSideTop.Control = BlockIndentComboBox AnchorSideTop.Control = AutoIndentCheckBox
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = TabWidthsComboBox AnchorSideBottom.Control = TabWidthsComboBox
Left = 6 Left = 218
Height = 29 Height = 23
Top = 258 Top = 189
Width = 100 Width = 100
BorderSpacing.Left = 6 ItemHeight = 15
BorderSpacing.Top = 3
ItemHeight = 0
ItemWidth = 200 ItemWidth = 200
OnChange = ComboboxOnChange OnChange = ComboboxOnChange
OnExit = ComboBoxOnExit OnExit = ComboBoxOnExit
@ -354,9 +355,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = BlockGroupDivider AnchorSideTop.Control = BlockGroupDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 21 Height = 19
Top = 429 Top = 402
Width = 183 Width = 152
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6 BorderSpacing.Top = 6
Caption = 'PersistentBlockCheckBox' Caption = 'PersistentBlockCheckBox'
@ -368,9 +369,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = BlockGroupDivider AnchorSideTop.Control = BlockGroupDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 218 Left = 218
Height = 21 Height = 19
Top = 429 Top = 402
Width = 179 Width = 152
BorderSpacing.Top = 6 BorderSpacing.Top = 6
Caption = 'OverwriteBlockCheckBox' Caption = 'OverwriteBlockCheckBox'
OnChange = OverwriteBlockCheckBoxChange OnChange = OverwriteBlockCheckBoxChange
@ -380,9 +381,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideLeft.Control = CursorSkipsSelectionCheckBox AnchorSideLeft.Control = CursorSkipsSelectionCheckBox
AnchorSideTop.Control = PersistentCursorCheckBox AnchorSideTop.Control = PersistentCursorCheckBox
Left = 218 Left = 218
Height = 21 Height = 19
Top = 337 Top = 318
Width = 182 Width = 154
Caption = 'CursorSkipsTabCheckBox' Caption = 'CursorSkipsTabCheckBox'
OnChange = CursorSkipsTabCheckBoxChange OnChange = CursorSkipsTabCheckBoxChange
TabOrder = 22 TabOrder = 22
@ -393,9 +394,9 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Cursor = crHandPoint Cursor = crHandPoint
Left = 24 Left = 24
Height = 18 Height = 16
Top = 186 Top = 208
Width = 96 Width = 83
BorderSpacing.Left = 18 BorderSpacing.Left = 18
Caption = 'AutoIndentLink' Caption = 'AutoIndentLink'
Font.Color = clBlue Font.Color = clBlue
@ -420,7 +421,7 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 0 Left = 0
Height = 17 Height = 15
Top = 0 Top = 0
Width = 434 Width = 434
Caption = 'UndoGroupDivider' Caption = 'UndoGroupDivider'
@ -436,8 +437,8 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 0 Left = 0
Height = 17 Height = 15
Top = 71 Top = 65
Width = 434 Width = 434
Caption = 'ScrollGroupDivider' Caption = 'ScrollGroupDivider'
Autosize = True Autosize = True
@ -453,8 +454,8 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 0 Left = 0
Height = 17 Height = 15
Top = 142 Top = 130
Width = 434 Width = 434
Caption = 'IndentsTabsGroupDivider' Caption = 'IndentsTabsGroupDivider'
Autosize = True Autosize = True
@ -465,13 +466,13 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
end end
object CaretGroupDivider: TDividerBevel[32] object CaretGroupDivider: TDividerBevel[32]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = BlockIndentTypeComboBox AnchorSideTop.Control = BlockIndentComboBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 0 Left = 0
Height = 17 Height = 15
Top = 293 Top = 278
Width = 434 Width = 434
Caption = 'CaretGroupDivider' Caption = 'CaretGroupDivider'
Autosize = True Autosize = True
@ -487,8 +488,8 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 0 Left = 0
Height = 17 Height = 15
Top = 406 Top = 381
Width = 434 Width = 434
Caption = 'BlockGroupDivider' Caption = 'BlockGroupDivider'
Autosize = True Autosize = True
@ -502,10 +503,44 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
AnchorSideTop.Control = ScrollByOneLessCheckBox AnchorSideTop.Control = ScrollByOneLessCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 218 Left = 218
Height = 21 Height = 19
Top = 115 Top = 105
Width = 87 Width = 75
Caption = 'Scroll Hint' Caption = 'Scroll Hint'
TabOrder = 23 TabOrder = 23
end end
object BlockTabIndentComboBox: TComboBox[35]
AnchorSideLeft.Control = UndoLimitComboBox
AnchorSideTop.Control = TabIndentBlocksCheckBox
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = TabWidthsComboBox
Left = 218
Height = 23
Top = 249
Width = 100
BorderSpacing.Top = 3
ItemHeight = 15
Items.Strings = (
'0'
'1'
'2'
)
OnChange = ComboboxOnChange
OnExit = ComboBoxOnExit
OnKeyDown = ComboboxOnKeyDown
TabOrder = 24
end
object BlockTabIndentLabel: TLabel[36]
AnchorSideLeft.Control = BlockTabIndentComboBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = BlockIndentComboBox
AnchorSideTop.Side = asrCenter
Left = 324
Height = 16
Top = 252
Width = 92
BorderSpacing.Around = 6
Caption = 'BlockIndentLabel'
ParentColor = False
end
end end

View File

@ -35,6 +35,8 @@ type
TEditorGeneralOptionsFrame = class(TAbstractIDEOptionsEditor) TEditorGeneralOptionsFrame = class(TAbstractIDEOptionsEditor)
BlockIndentComboBox: TComboBox; BlockIndentComboBox: TComboBox;
BlockTabIndentComboBox: TComboBox;
BlockTabIndentLabel: TLabel;
BlockIndentTypeComboBox: TComboBox; BlockIndentTypeComboBox: TComboBox;
BlockIndentLabel: TLabel; BlockIndentLabel: TLabel;
AutoIndentCheckBox: TCheckBox; AutoIndentCheckBox: TCheckBox;
@ -138,7 +140,8 @@ begin
FDialog := ADialog; FDialog := ADialog;
BlockIndentLabel.Caption := dlgBlockIndent; BlockIndentLabel.Caption := dlgBlockIndent;
BlockIndentTypeLabel.Caption := dlgBlockIndent; BlockTabIndentLabel.Caption := dlgBlockTabIndent;
BlockIndentTypeLabel.Caption := dlgAutoIndentType;
BlockIndentTypeComboBox.Items.Add(dlgBlockIndentTypeSpace); BlockIndentTypeComboBox.Items.Add(dlgBlockIndentTypeSpace);
BlockIndentTypeComboBox.Items.Add(dlgBlockIndentTypeCopy); BlockIndentTypeComboBox.Items.Add(dlgBlockIndentTypeCopy);
BlockIndentTypeComboBox.Items.Add(dlgBlockIndentTypePos); BlockIndentTypeComboBox.Items.Add(dlgBlockIndentTypePos);
@ -189,6 +192,7 @@ begin
with AOptions as TEditorOptions do with AOptions as TEditorOptions do
begin begin
SetComboBoxText(BlockIndentComboBox, IntToStr(BlockIndent), cstCaseInsensitive); SetComboBoxText(BlockIndentComboBox, IntToStr(BlockIndent), cstCaseInsensitive);
SetComboBoxText(BlockTabIndentComboBox, IntToStr(BlockTabIndent), cstCaseInsensitive);
SetComboBoxText(TabWidthsComboBox, IntToStr(TabWidth), cstCaseInsensitive); SetComboBoxText(TabWidthsComboBox, IntToStr(TabWidth), cstCaseInsensitive);
BlockIndentTypeComboBox.ItemIndex := ord(BlockIndentType); BlockIndentTypeComboBox.ItemIndex := ord(BlockIndentType);
@ -283,11 +287,19 @@ begin
TabWidth := i; TabWidth := i;
i := StrToIntDef(BlockIndentComboBox.Text, 2); i := StrToIntDef(BlockIndentComboBox.Text, 2);
if i < 1 then if i < 0 then
i := 1; i := 0;
if i > 20 then if i > 20 then
i := 20; i := 20;
BlockIndent := i; BlockIndent := i;
i := StrToIntDef(BlockTabIndentComboBox.Text, 0);
if i < 0 then
i := 0;
if i > 20 then
i := 20;
BlockTabIndent := i;
BlockIndentType := TSynBeautifierIndentType(BlockIndentTypeComboBox.ItemIndex); BlockIndentType := TSynBeautifierIndentType(BlockIndentTypeComboBox.ItemIndex);
// cursor // cursor
@ -405,12 +417,23 @@ begin
if Sender = BlockIndentComboBox then if Sender = BlockIndentComboBox then
begin begin
NewVal := StrToIntDef(BlockIndentComboBox.Text, PreviewEdits[1].BlockIndent); NewVal := StrToIntDef(BlockIndentComboBox.Text, PreviewEdits[1].BlockIndent);
// Todo: min/max
SetComboBoxText(BlockIndentComboBox, IntToStr(NewVal), cstCaseInsensitive); SetComboBoxText(BlockIndentComboBox, IntToStr(NewVal), cstCaseInsensitive);
for a := Low(PreviewEdits) to High(PreviewEdits) do for a := Low(PreviewEdits) to High(PreviewEdits) do
if PreviewEdits[a] <> nil then if PreviewEdits[a] <> nil then
PreviewEdits[a].BlockIndent := NewVal; PreviewEdits[a].BlockIndent := NewVal;
end end
else else
if Sender = BlockTabIndentComboBox then
begin
NewVal := StrToIntDef(BlockTabIndentComboBox.Text, PreviewEdits[1].BlockTabIndent);
// Todo: min/max
SetComboBoxText(BlockTabIndentComboBox, IntToStr(NewVal), cstCaseInsensitive);
for a := Low(PreviewEdits) to High(PreviewEdits) do
if PreviewEdits[a] <> nil then
PreviewEdits[a].BlockTabIndent := NewVal;
end
else
if Sender = TabWidthsComboBox then if Sender = TabWidthsComboBox then
begin begin
NewVal := StrToIntDef(TabWidthsComboBox.Text, PreviewEdits[1].TabWidth); NewVal := StrToIntDef(TabWidthsComboBox.Text, PreviewEdits[1].TabWidth);

View File

@ -1407,7 +1407,9 @@ resourcestring
dlgHighlightLeftOfCursor = 'Left Of Cursor'; dlgHighlightLeftOfCursor = 'Left Of Cursor';
dlgHighlightRightOfCursor = 'Right Of Cursor'; dlgHighlightRightOfCursor = 'Right Of Cursor';
gldHighlightBothSidesOfCursor = 'On Both Sides'; gldHighlightBothSidesOfCursor = 'On Both Sides';
dlgBlockIndent = 'Block indent'; dlgBlockIndent = 'Block indent (spaces)';
dlgBlockTabIndent = 'Block indent (tabs)';
dlgAutoIndentType = 'Auto indent';
dlgBlockIndentType = 'Indent method'; dlgBlockIndentType = 'Indent method';
dlgBlockIndentTypeSpace = 'Spaces'; dlgBlockIndentTypeSpace = 'Spaces';
dlgBlockIndentTypeCopy = 'Space/tab as prev Line'; dlgBlockIndentTypeCopy = 'Space/tab as prev Line';