IDE: code templates: auto indent and option to disable it for each template, bug #17632

git-svn-id: trunk@28876 -
This commit is contained in:
mattias 2011-01-06 17:14:35 +00:00
parent 36d4591e7e
commit e2a2b1c57f
5 changed files with 468 additions and 133 deletions

View File

@ -56,6 +56,7 @@ uses
const const
CodeTemplateMacroMagic = '$(EnableMakros)'; CodeTemplateMacroMagic = '$(EnableMakros)';
CodeTemplateEnableMacros = 'EnableMakros'; CodeTemplateEnableMacros = 'EnableMakros';
CodeTemplateKeepSubIndent = 'KeepSubIndent';
CodeTemplateAttributesStartMagic = '$(AttributesStart)'; CodeTemplateAttributesStartMagic = '$(AttributesStart)';
CodeTemplateAttributesEndMagic = '$(AttributesEnd)'; CodeTemplateAttributesEndMagic = '$(AttributesEnd)';
{$ENDIF} {$ENDIF}

View File

@ -32,6 +32,7 @@ interface
uses uses
Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs,
BasicCodeTools,
SynEditAutoComplete, SynPluginTemplateEdit, SynPluginSyncronizedEditBase, SynEdit, SynEditAutoComplete, SynPluginTemplateEdit, SynPluginSyncronizedEditBase, SynEdit,
MacroIntf, LazIDEIntf, SrcEditorIntf; MacroIntf, LazIDEIntf, SrcEditorIntf;
@ -64,6 +65,7 @@ type
FEditCellList: TSynPluginSyncronizedEditList; FEditCellList: TSynPluginSyncronizedEditList;
FEnableMacros: Boolean; FEnableMacros: Boolean;
FIndent: String; FIndent: String;
FKeepSubIndent: Boolean;
FSrcTemplate: String; FSrcTemplate: String;
FDestTemplate: String; FDestTemplate: String;
FSrcPosition: Integer; FSrcPosition: Integer;
@ -72,6 +74,7 @@ type
FDestPosY: Integer; FDestPosY: Integer;
FLevel: Integer; FLevel: Integer;
FSrcEdit: TSourceEditorInterface; FSrcEdit: TSourceEditorInterface;
FSubIndent: integer;
protected protected
// nested macros, get the X pos of the outer macro // nested macros, get the X pos of the outer macro
function GetSrcPosition: Integer; override; function GetSrcPosition: Integer; override;
@ -92,7 +95,9 @@ type
procedure TrimEOTChar(eot: Char); procedure TrimEOTChar(eot: Char);
property EnableMacros: Boolean read FEnableMacros write FEnableMacros; property EnableMacros: Boolean read FEnableMacros write FEnableMacros;
property KeepSubIndent: Boolean read FKeepSubIndent write FKeepSubIndent;
property Indent: String read FIndent write FIndent; property Indent: String read FIndent write FIndent;
property SubIndent: integer read FSubIndent write FSubIndent;
property DestCaret: TPoint read FCaret; property DestCaret: TPoint read FCaret;
property EditCellList: TSynPluginSyncronizedEditList read FEditCellList; property EditCellList: TSynPluginSyncronizedEditList read FEditCellList;
@ -202,13 +207,21 @@ begin
end; end;
function TLazTemplateParser.SubstituteMacros(var Template: String): boolean; function TLazTemplateParser.SubstituteMacros(var Template: String): boolean;
const
TemplateTabWidth = 8;
var
IndentLevel: Integer;
LastLineIndent: Integer;
procedure AppentToDest(S: String); procedure AppentToDest(S: String);
var var
i, i2: Integer; i, LastCopy: Integer;
CurLineIndent: LongInt;
SpaceStart: LongInt;
begin begin
i := 1; i := 1;
i2 := 1; LastCopy := 1;
//debugln(['AppentToDest START S="',dbgstr(S),'" Indent="',dbgstr(Indent),'"']);
while i <= length(S) do begin while i <= length(S) do begin
case s[i] of case s[i] of
#10, #13: #10, #13:
@ -216,18 +229,39 @@ function TLazTemplateParser.SubstituteMacros(var Template: String): boolean;
inc(i); inc(i);
if (i <= length(S)) and (s[i] in [#10,#13]) and (s[i] <> s[i-1]) then if (i <= length(S)) and (s[i] in [#10,#13]) and (s[i] <> s[i-1]) then
inc(i); inc(i);
if (FDestTemplate <> '') and (i > i2) and FDestTemplate := FDestTemplate + copy(s, LastCopy, i - LastCopy) + FIndent;
(FDestTemplate[length(FDestTemplate)] in [#10, #13]) LastCopy := i;
then
FDestTemplate := FDestTemplate + FIndent;
FDestTemplate := FDestTemplate + copy(s, i2, i - i2);
i2 := i;
FDestPosX := 1 + length(FIndent); FDestPosX := 1 + length(FIndent);
inc(FDestPosY); inc(FDestPosY);
end; end;
else else // case else
begin begin
if (s[i] = '|') and (FCaret.y < 0) then begin if (s[i] in [' ',#9])
and (not KeepSubIndent)
and (FDestTemplate<>'')
and ((i=1) or (S[i-1] in [#10,#13]))
then begin
// space at start of template line (not first line)
FDestTemplate:=FDestTemplate+copy(S,LastCopy,i-LastCopy);
LastCopy:=i;
SpaceStart:=i;
while (i<=length(S)) and (S[i] in [' ',#9]) do inc(i);
// compare the indentation of the current and the last line of the template
CurLineIndent:=GetLineIndentWithTabs(S,SpaceStart,TemplateTabWidth);
if CurLineIndent>LastLineIndent then
inc(IndentLevel)
else if (IndentLevel>0) and (CurLineIndent<LastLineIndent) then
dec(IndentLevel);
LastLineIndent:=CurLineIndent;
// append space
CurLineIndent:=IndentLevel*SubIndent;
//debugln(['AppentToDest CurLineIndent=',CurLineIndent,' ',IndentLevel,'*',SubIndent]);
FDestTemplate:=FDestTemplate+StringOfChar(' ',CurLineIndent);
LastCopy:=i;
inc(FDestPosX,CurLineIndent);
end else if (s[i] = '|') and (FCaret.y < 0) then
begin
// place cursor
System.Delete(s, i, 1); System.Delete(s, i, 1);
FCaret.y := FDestPosY; FCaret.y := FDestPosY;
FCaret.x := FDestPosX; FCaret.x := FDestPosX;
@ -239,12 +273,13 @@ function TLazTemplateParser.SubstituteMacros(var Template: String): boolean;
end; end;
end; end;
end; end;
if (FDestTemplate <> '') and (i > i2) and if (FDestTemplate <> '') and (i > LastCopy) and
(FDestTemplate[length(FDestTemplate)] in [#10, #13]) (FDestTemplate[length(FDestTemplate)] in [#10, #13])
then then
FDestTemplate := FDestTemplate + FIndent; FDestTemplate := FDestTemplate + FIndent;
FDestTemplate := FDestTemplate + copy(s, i2, i - i2); FDestTemplate := FDestTemplate + copy(s, LastCopy, i - LastCopy);
FDestPosition := length(FDestTemplate); FDestPosition := length(FDestTemplate);
//debugln(['AppentToDest END FDestTemplate=',dbgstr(FDestTemplate)]);
end; end;
var var
@ -266,6 +301,8 @@ begin
p:=1; p:=1;
SrcCopiedPos := 1; SrcCopiedPos := 1;
len:=length(Template); len:=length(Template);
IndentLevel:=0;
LastLineIndent:=0;
while p <= len do begin while p <= len do begin
case Template[p] of case Template[p] of
'$': '$':
@ -371,17 +408,16 @@ begin
System.Delete(FDestTemplate, length(FDestTemplate), 1); System.Delete(FDestTemplate, length(FDestTemplate), 1);
end; end;
function ExecuteCodeTemplate(SrcEdit: TSourceEditorInterface; function ExecuteCodeTemplate(SrcEdit: TSourceEditorInterface;
const TemplateName, TemplateValue, TemplateComment, const TemplateName, TemplateValue, TemplateComment,
EndOfTokenChr: string; Attributes: TStrings; EndOfTokenChr: string; Attributes: TStrings;
IndentToTokenStart: boolean): boolean; IndentToTokenStart: boolean): boolean;
var var
AEditor: TCustomSynEdit; AEditor: TSynEdit;
p: TPoint; p: TPoint;
TokenStartX: LongInt; TokenStartX: LongInt;
s: string; s: string;
IndentLen: Integer; BaseIndent: Integer;
i: Integer; i: Integer;
j: LongInt; j: LongInt;
Pattern: String; Pattern: String;
@ -390,31 +426,33 @@ var
begin begin
Result:=false; Result:=false;
//debugln('ExecuteCodeTemplate ',dbgsName(SrcEdit),' ',dbgsName(SrcEdit.EditorControl)); //debugln('ExecuteCodeTemplate ',dbgsName(SrcEdit),' ',dbgsName(SrcEdit.EditorControl));
AEditor:=SrcEdit.EditorControl as TCustomSynEdit; AEditor:=SrcEdit.EditorControl as TSynEdit;
Pattern:=TemplateValue; Pattern:=TemplateValue;
Parser := TLazTemplateParser.Create(Pattern); Parser := TLazTemplateParser.Create(Pattern);
AEditor.BeginUpdate; AEditor.BeginUpdate;
try try
Parser.SubIndent:=AEditor.BlockIndent;
p := AEditor.LogicalCaretXY; p := AEditor.LogicalCaretXY;
TokenStartX:=p.x; TokenStartX:=p.x;
if IndentToTokenStart then begin if IndentToTokenStart then begin
IndentLen := TokenStartX - 1; BaseIndent := TokenStartX - 1;
end else begin end else begin
// indent the same as the first line // indent the same as the first line
IndentLen:=1; BaseIndent:=1;
if (p.y>0) and (p.y<=AEditor.Lines.Count) then begin if (p.y>0) and (p.y<=AEditor.Lines.Count) then begin
s:=AEditor.Lines[p.y-1]; s:=AEditor.Lines[p.y-1];
while (IndentLen<p.x) while (BaseIndent<p.x)
and ((IndentLen>length(s)) or (s[IndentLen] in [#9,' '])) do and ((BaseIndent>length(s)) or (s[BaseIndent] in [#9,' '])) do
inc(IndentLen); inc(BaseIndent);
end; end;
IndentLen:=AEditor.LogicalToPhysicalCol(s, p.y - 1, IndentLen);// consider tabs BaseIndent:=AEditor.LogicalToPhysicalCol(s, p.y - 1, BaseIndent);// consider tabs
dec(IndentLen); dec(BaseIndent);
end; end;
Parser.EnableMacros := Attributes.IndexOfName(CodeTemplateEnableMacros)>=0; Parser.EnableMacros := Attributes.IndexOfName(CodeTemplateEnableMacros)>=0;
Parser.Indent := StringOfChar(' ', IndentLen); Parser.KeepSubIndent := Attributes.IndexOfName(CodeTemplateKeepSubIndent)>=0;
Parser.Indent := StringOfChar(' ', BaseIndent);
LazarusIDE.SaveSourceEditorChangesToCodeCache(nil); LazarusIDE.SaveSourceEditorChangesToCodeCache(nil);
if not Parser.SubstituteCodeMacros(SrcEdit) then exit; if not Parser.SubstituteCodeMacros(SrcEdit) then exit;

View File

@ -1,7 +1,7 @@
object CodeTemplateDialog: TCodeTemplateDialog object CodeTemplateDialog: TCodeTemplateDialog
Left = 285 Left = 332
Height = 542 Height = 542
Top = 122 Top = 224
Width = 497 Width = 497
ActiveControl = FilenameEdit ActiveControl = FilenameEdit
BorderIcons = [biSystemMenu] BorderIcons = [biSystemMenu]
@ -11,7 +11,7 @@ object CodeTemplateDialog: TCodeTemplateDialog
OnClose = FormClose OnClose = FormClose
OnCreate = FormCreate OnCreate = FormCreate
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '0.9.27' LCLVersion = '0.9.31'
object FilenameGroupBox: TGroupBox object FilenameGroupBox: TGroupBox
Left = 6 Left = 6
Height = 51 Height = 51
@ -20,13 +20,13 @@ object CodeTemplateDialog: TCodeTemplateDialog
Align = alTop Align = alTop
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'FilenameGroupBox' Caption = 'FilenameGroupBox'
ClientHeight = 33 ClientHeight = 32
ClientWidth = 481 ClientWidth = 481
TabOrder = 0 TabOrder = 0
object FilenameEdit: TEdit object FilenameEdit: TEdit
AnchorSideRight.Control = FilenameButton AnchorSideRight.Control = FilenameButton
Left = 9 Left = 9
Height = 23 Height = 27
Top = 4 Top = 4
Width = 435 Width = 435
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
@ -41,7 +41,7 @@ object CodeTemplateDialog: TCodeTemplateDialog
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 449 Left = 449
Height = 23 Height = 23
Top = 4 Top = 8
Width = 26 Width = 26
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
BorderSpacing.Right = 6 BorderSpacing.Right = 6
@ -58,7 +58,7 @@ object CodeTemplateDialog: TCodeTemplateDialog
Align = alTop Align = alTop
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'TemplatesGroupBox' Caption = 'TemplatesGroupBox'
ClientHeight = 149 ClientHeight = 148
ClientWidth = 481 ClientWidth = 481
TabOrder = 1 TabOrder = 1
object TemplateListBox: TListBox object TemplateListBox: TListBox
@ -68,7 +68,7 @@ object CodeTemplateDialog: TCodeTemplateDialog
AnchorSideBottom.Control = TemplatesGroupBox AnchorSideBottom.Control = TemplatesGroupBox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 6 Left = 6
Height = 137 Height = 136
Top = 6 Top = 6
Width = 315 Width = 315
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
@ -79,6 +79,7 @@ object CodeTemplateDialog: TCodeTemplateDialog
ItemHeight = 0 ItemHeight = 0
OnSelectionChange = TemplateListBoxSelectionChange OnSelectionChange = TemplateListBoxSelectionChange
TabOrder = 0 TabOrder = 0
TopIndex = -1
end end
object AddButton: TButton object AddButton: TButton
AnchorSideTop.Control = TemplateListBox AnchorSideTop.Control = TemplateListBox
@ -129,27 +130,27 @@ object CodeTemplateDialog: TCodeTemplateDialog
end end
object EditTemplateGroupBox: TGroupBox object EditTemplateGroupBox: TGroupBox
AnchorSideTop.Control = TemplatesGroupBox AnchorSideTop.Control = TemplatesGroupBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = FilenameGroupBox AnchorSideBottom.Control = FilenameGroupBox
Left = 6 Left = 6
Height = 268 Height = 262
Top = 236 Top = 236
Width = 485 Width = 485
Align = alClient Align = alClient
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'EditTemplateGroupBox' Caption = 'EditTemplateGroupBox'
ClientHeight = 250 ClientHeight = 243
ClientWidth = 481 ClientWidth = 481
TabOrder = 2 TabOrder = 2
object UseMacrosCheckBox: TCheckBox object UseMacrosCheckBox: TCheckBox
Left = 6 Left = 6
Height = 17 Height = 22
Top = 6 Top = 6
Width = 121 Width = 161
BorderSpacing.Bottom = 7 BorderSpacing.Bottom = 7
Caption = 'UseMacrosCheckBox' Caption = 'UseMacrosCheckBox'
ParentShowHint = False
ShowHint = True
TabOrder = 0 TabOrder = 0
end end
object InsertMacroButton: TButton object InsertMacroButton: TButton
@ -158,10 +159,10 @@ object CodeTemplateDialog: TCodeTemplateDialog
AnchorSideTop.Control = UseMacrosCheckBox AnchorSideTop.Control = UseMacrosCheckBox
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 153 Left = 193
Height = 23 Height = 29
Top = 3 Top = 3
Width = 113 Width = 132
AutoSize = True AutoSize = True
BorderSpacing.Left = 20 BorderSpacing.Left = 20
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -169,7 +170,7 @@ object CodeTemplateDialog: TCodeTemplateDialog
OnClick = InsertMacroButtonClick OnClick = InsertMacroButtonClick
TabOrder = 2 TabOrder = 2
end end
object TemplateSynEdit: TSynEdit inline TemplateSynEdit: TSynEdit
AnchorSideTop.Control = AutoOnOptionsCheckGroup AnchorSideTop.Control = AutoOnOptionsCheckGroup
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = EditTemplateGroupBox AnchorSideRight.Control = EditTemplateGroupBox
@ -177,8 +178,8 @@ object CodeTemplateDialog: TCodeTemplateDialog
AnchorSideBottom.Control = EditTemplateGroupBox AnchorSideBottom.Control = EditTemplateGroupBox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 6 Left = 6
Height = 176 Height = 138
Top = 68 Top = 99
Width = 469 Width = 469
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
@ -190,337 +191,508 @@ object CodeTemplateDialog: TCodeTemplateDialog
ParentFont = False ParentFont = False
TabOrder = 1 TabOrder = 1
Gutter.Width = 57 Gutter.Width = 57
Gutter.MouseActions = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 13
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end>
RightGutter.Width = 0
RightGutter.MouseActions = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 13
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end>
Keystrokes = < Keystrokes = <
item item
Command = 3 Command = ecUp
ShortCut = 38 ShortCut = 38
end end
item item
Command = 103 Command = ecSelUp
ShortCut = 8230 ShortCut = 8230
end end
item item
Command = 211 Command = ecScrollUp
ShortCut = 16422 ShortCut = 16422
end end
item item
Command = 4 Command = ecDown
ShortCut = 40 ShortCut = 40
end end
item item
Command = 104 Command = ecSelDown
ShortCut = 8232 ShortCut = 8232
end end
item item
Command = 212 Command = ecScrollDown
ShortCut = 16424 ShortCut = 16424
end end
item item
Command = 1 Command = ecLeft
ShortCut = 37 ShortCut = 37
end end
item item
Command = 101 Command = ecSelLeft
ShortCut = 8229 ShortCut = 8229
end end
item item
Command = 5 Command = ecWordLeft
ShortCut = 16421 ShortCut = 16421
end end
item item
Command = 105 Command = ecSelWordLeft
ShortCut = 24613 ShortCut = 24613
end end
item item
Command = 2 Command = ecRight
ShortCut = 39 ShortCut = 39
end end
item item
Command = 102 Command = ecSelRight
ShortCut = 8231 ShortCut = 8231
end end
item item
Command = 6 Command = ecWordRight
ShortCut = 16423 ShortCut = 16423
end end
item item
Command = 106 Command = ecSelWordRight
ShortCut = 24615 ShortCut = 24615
end end
item item
Command = 10 Command = ecPageDown
ShortCut = 34 ShortCut = 34
end end
item item
Command = 110 Command = ecSelPageDown
ShortCut = 8226 ShortCut = 8226
end end
item item
Command = 14 Command = ecPageBottom
ShortCut = 16418 ShortCut = 16418
end end
item item
Command = 114 Command = ecSelPageBottom
ShortCut = 24610 ShortCut = 24610
end end
item item
Command = 9 Command = ecPageUp
ShortCut = 33 ShortCut = 33
end end
item item
Command = 109 Command = ecSelPageUp
ShortCut = 8225 ShortCut = 8225
end end
item item
Command = 13 Command = ecPageTop
ShortCut = 16417 ShortCut = 16417
end end
item item
Command = 113 Command = ecSelPageTop
ShortCut = 24609 ShortCut = 24609
end end
item item
Command = 7 Command = ecLineStart
ShortCut = 36 ShortCut = 36
end end
item item
Command = 107 Command = ecSelLineStart
ShortCut = 8228 ShortCut = 8228
end end
item item
Command = 15 Command = ecEditorTop
ShortCut = 16420 ShortCut = 16420
end end
item item
Command = 115 Command = ecSelEditorTop
ShortCut = 24612 ShortCut = 24612
end end
item item
Command = 8 Command = ecLineEnd
ShortCut = 35 ShortCut = 35
end end
item item
Command = 108 Command = ecSelLineEnd
ShortCut = 8227 ShortCut = 8227
end end
item item
Command = 16 Command = ecEditorBottom
ShortCut = 16419 ShortCut = 16419
end end
item item
Command = 116 Command = ecSelEditorBottom
ShortCut = 24611 ShortCut = 24611
end end
item item
Command = 223 Command = ecToggleMode
ShortCut = 45 ShortCut = 45
end end
item item
Command = 201 Command = ecCopy
ShortCut = 16429 ShortCut = 16429
end end
item item
Command = 604 Command = ecPaste
ShortCut = 8237 ShortCut = 8237
end end
item item
Command = 502 Command = ecDeleteChar
ShortCut = 46 ShortCut = 46
end end
item item
Command = 603 Command = ecCut
ShortCut = 8238 ShortCut = 8238
end end
item item
Command = 501 Command = ecDeleteLastChar
ShortCut = 8 ShortCut = 8
end end
item item
Command = 501 Command = ecDeleteLastChar
ShortCut = 8200 ShortCut = 8200
end end
item item
Command = 504 Command = ecDeleteLastWord
ShortCut = 16392 ShortCut = 16392
end end
item item
Command = 601 Command = ecUndo
ShortCut = 32776 ShortCut = 32776
end end
item item
Command = 602 Command = ecRedo
ShortCut = 40968 ShortCut = 40968
end end
item item
Command = 509 Command = ecLineBreak
ShortCut = 13 ShortCut = 13
end end
item item
Command = 199 Command = ecSelectAll
ShortCut = 16449 ShortCut = 16449
end end
item item
Command = 201 Command = ecCopy
ShortCut = 16451 ShortCut = 16451
end end
item item
Command = 610 Command = ecBlockIndent
ShortCut = 24649 ShortCut = 24649
end end
item item
Command = 509 Command = ecLineBreak
ShortCut = 16461 ShortCut = 16461
end end
item item
Command = 510 Command = ecInsertLine
ShortCut = 16462 ShortCut = 16462
end end
item item
Command = 503 Command = ecDeleteWord
ShortCut = 16468 ShortCut = 16468
end end
item item
Command = 611 Command = ecBlockUnindent
ShortCut = 24661 ShortCut = 24661
end end
item item
Command = 604 Command = ecPaste
ShortCut = 16470 ShortCut = 16470
end end
item item
Command = 603 Command = ecCut
ShortCut = 16472 ShortCut = 16472
end end
item item
Command = 507 Command = ecDeleteLine
ShortCut = 16473 ShortCut = 16473
end end
item item
Command = 506 Command = ecDeleteEOL
ShortCut = 24665 ShortCut = 24665
end end
item item
Command = 601 Command = ecUndo
ShortCut = 16474 ShortCut = 16474
end end
item item
Command = 602 Command = ecRedo
ShortCut = 24666 ShortCut = 24666
end end
item item
Command = 301 Command = ecGotoMarker0
ShortCut = 16432 ShortCut = 16432
end end
item item
Command = 302 Command = ecGotoMarker1
ShortCut = 16433 ShortCut = 16433
end end
item item
Command = 303 Command = ecGotoMarker2
ShortCut = 16434 ShortCut = 16434
end end
item item
Command = 304 Command = ecGotoMarker3
ShortCut = 16435 ShortCut = 16435
end end
item item
Command = 305 Command = ecGotoMarker4
ShortCut = 16436 ShortCut = 16436
end end
item item
Command = 306 Command = ecGotoMarker5
ShortCut = 16437 ShortCut = 16437
end end
item item
Command = 307 Command = ecGotoMarker6
ShortCut = 16438 ShortCut = 16438
end end
item item
Command = 308 Command = ecGotoMarker7
ShortCut = 16439 ShortCut = 16439
end end
item item
Command = 309 Command = ecGotoMarker8
ShortCut = 16440 ShortCut = 16440
end end
item item
Command = 310 Command = ecGotoMarker9
ShortCut = 16441 ShortCut = 16441
end end
item item
Command = 351 Command = ecSetMarker0
ShortCut = 24624 ShortCut = 24624
end end
item item
Command = 352 Command = ecSetMarker1
ShortCut = 24625 ShortCut = 24625
end end
item item
Command = 353 Command = ecSetMarker2
ShortCut = 24626 ShortCut = 24626
end end
item item
Command = 354 Command = ecSetMarker3
ShortCut = 24627 ShortCut = 24627
end end
item item
Command = 355 Command = ecSetMarker4
ShortCut = 24628 ShortCut = 24628
end end
item item
Command = 356 Command = ecSetMarker5
ShortCut = 24629 ShortCut = 24629
end end
item item
Command = 357 Command = ecSetMarker6
ShortCut = 24630 ShortCut = 24630
end end
item item
Command = 358 Command = ecSetMarker7
ShortCut = 24631 ShortCut = 24631
end end
item item
Command = 359 Command = ecSetMarker8
ShortCut = 24632 ShortCut = 24632
end end
item item
Command = 360 Command = ecSetMarker9
ShortCut = 24633 ShortCut = 24633
end end
item item
Command = 231 Command = ecNormalSelect
ShortCut = 24654 ShortCut = 24654
end end
item item
Command = 232 Command = ecColumnSelect
ShortCut = 24643 ShortCut = 24643
end end
item item
Command = 233 Command = ecLineSelect
ShortCut = 24652 ShortCut = 24652
end end
item item
Command = 612 Command = ecTab
ShortCut = 9 ShortCut = 9
end end
item item
Command = 613 Command = ecShiftTab
ShortCut = 8201 ShortCut = 8201
end end
item item
Command = 250 Command = ecMatchBracket
ShortCut = 24642 ShortCut = 24642
end> end>
MouseActions = <
item
Shift = []
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 1
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = [ssShift]
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 1
MoveCaret = True
Option = 1
Priority = 0
end
item
Shift = [ssAlt]
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 3
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = [ssShift, ssAlt]
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 3
MoveCaret = True
Option = 1
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccDouble
ClickDir = cdDown
Command = 6
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccTriple
ClickDir = cdDown
Command = 7
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccQuad
ClickDir = cdDown
Command = 8
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbMiddle
ClickCount = ccSingle
ClickDir = cdDown
Command = 10
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = [ssCtrl]
ShiftMask = [ssShift, ssAlt, ssCtrl]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdUp
Command = 11
MoveCaret = False
Option = 0
Priority = 0
end>
MouseSelActions = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 9
MoveCaret = False
Option = 0
Priority = 0
end>
Lines.Strings = ( Lines.Strings = (
'TemplateSynEdit' 'TemplateSynEdit'
) )
BracketHighlightStyle = sbhsBoth BracketHighlightStyle = sbhsBoth
object TSynGutterPartList inline TSynGutterPartList
object TSynGutterMarks object TSynGutterMarks
Width = 23 Width = 24
end end
object TSynGutterLineNumber object TSynGutterLineNumber
Width = 17 Width = 17
MouseActions = <>
MarkupInfo.Background = clBtnFace MarkupInfo.Background = clBtnFace
MarkupInfo.Foreground = clNone MarkupInfo.Foreground = clNone
DigitCount = 2 DigitCount = 2
@ -537,20 +709,100 @@ object CodeTemplateDialog: TCodeTemplateDialog
Width = 2 Width = 2
end end
object TSynGutterCodeFolding object TSynGutterCodeFolding
MouseActions = <
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 16
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = [ssShift]
Button = mbMiddle
ClickCount = ccAny
ClickDir = cdDown
Command = 14
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = [ssShift]
ShiftMask = [ssShift]
Button = mbMiddle
ClickCount = ccAny
ClickDir = cdDown
Command = 14
MoveCaret = False
Option = 1
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 0
MoveCaret = False
Option = 0
Priority = 0
end>
MarkupInfo.Background = clNone MarkupInfo.Background = clNone
MarkupInfo.Foreground = clGray MarkupInfo.Foreground = clGray
MouseActionsExpanded = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 14
MoveCaret = False
Option = 0
Priority = 0
end>
MouseActionsCollapsed = <
item
Shift = [ssCtrl]
ShiftMask = [ssCtrl]
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 15
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = [ssCtrl]
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 15
MoveCaret = False
Option = 1
Priority = 0
end>
end end
end end
end end
object AutoOnOptionsCheckGroup: TCheckGroup object AutoOnOptionsCheckGroup: TCheckGroup
AnchorSideLeft.Control = EditTemplateGroupBox AnchorSideLeft.Control = EditTemplateGroupBox
AnchorSideTop.Control = InsertMacroButton AnchorSideTop.Control = KeepSubIndentCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = EditTemplateGroupBox AnchorSideRight.Control = EditTemplateGroupBox
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 6 Left = 6
Height = 30 Height = 30
Top = 32 Top = 63
Width = 469 Width = 469
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoFill = True AutoFill = True
@ -569,18 +821,52 @@ object CodeTemplateDialog: TCodeTemplateDialog
Constraints.MinHeight = 30 Constraints.MinHeight = 30
TabOrder = 3 TabOrder = 3
end end
object KeepSubIndentCheckBox: TCheckBox
AnchorSideLeft.Control = UseMacrosCheckBox
AnchorSideTop.Control = UseMacrosCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 22
Top = 35
Width = 186
BorderSpacing.Top = 6
Caption = 'KeepSubIndentCheckBox'
ParentShowHint = False
ShowHint = True
TabOrder = 4
end
end end
object ButtonPanel: TButtonPanel object ButtonPanel: TButtonPanel
Left = 6 Left = 6
Height = 26 Height = 32
Top = 510 Top = 504
Width = 485 Width = 485
OKButton.Name = 'OKButton'
OKButton.Caption = '&OK'
HelpButton.Name = 'HelpButton'
HelpButton.Caption = '&Help'
CloseButton.Name = 'CloseButton'
CloseButton.Caption = '&Close'
CloseButton.Enabled = False
CancelButton.Name = 'CancelButton'
CancelButton.Caption = 'Cancel'
TabOrder = 3 TabOrder = 3
ShowButtons = [pbOK, pbCancel, pbHelp] ShowButtons = [pbOK, pbCancel, pbHelp]
ShowBevel = False ShowBevel = False
end end
object ASynPasSyn: TSynFreePascalSyn object ASynPasSyn: TSynFreePascalSyn
Enabled = False Enabled = False
AsmAttri.FrameEdges = sfeAround
CommentAttri.FrameEdges = sfeAround
IDEDirectiveAttri.FrameEdges = sfeAround
IdentifierAttri.FrameEdges = sfeAround
KeyAttri.FrameEdges = sfeAround
NumberAttri.FrameEdges = sfeAround
SpaceAttri.FrameEdges = sfeAround
StringAttri.FrameEdges = sfeAround
SymbolAttri.FrameEdges = sfeAround
CaseLabelAttri.FrameEdges = sfeAround
DirectiveAttri.FrameEdges = sfeAround
CompilerMode = pcmObjFPC CompilerMode = pcmObjFPC
NestedComments = True NestedComments = True
left = 304 left = 304

View File

@ -71,6 +71,7 @@ type
ButtonPanel: TButtonPanel; ButtonPanel: TButtonPanel;
EditTemplateGroupBox: TGroupBox; EditTemplateGroupBox: TGroupBox;
InsertMacroButton: TButton; InsertMacroButton: TButton;
KeepSubIndentCheckBox: TCheckBox;
UseMacrosCheckBox: TCheckBox; UseMacrosCheckBox: TCheckBox;
EditButton: TButton; EditButton: TButton;
DeleteButton: TButton; DeleteButton: TButton;
@ -217,7 +218,7 @@ begin
end; end;
function AddCodeTemplate(ASynAutoComplete:TSynEditAutoComplete; function AddCodeTemplate(ASynAutoComplete:TSynEditAutoComplete;
var Token,Comment:ansistring):TModalResult; var Token,Comment: string):TModalResult;
var var
CodeTemplateEditForm:TCodeTemplateEditForm; CodeTemplateEditForm:TCodeTemplateEditForm;
begin begin
@ -944,6 +945,8 @@ begin
FilenameGroupBox.Caption:=lisDebugOptionsFrmModule; FilenameGroupBox.Caption:=lisDebugOptionsFrmModule;
UseMacrosCheckBox.Caption:=lisEnableMacros; UseMacrosCheckBox.Caption:=lisEnableMacros;
InsertMacroButton.Caption:=lisInsertMacro; InsertMacroButton.Caption:=lisInsertMacro;
KeepSubIndentCheckBox.Caption:=lisKeepSubIndentation;
KeepSubIndentCheckBox.Hint:=lisKeepRelativeIndentationOfMultiLineTemplate;
AutoOnOptionsCheckGroup.Caption:=lisCodeTemplAutoCompleteOn; AutoOnOptionsCheckGroup.Caption:=lisCodeTemplAutoCompleteOn;
AutoOnOptionsCheckGroup.Items.Add(lisAutomaticallyOnLineBreak); AutoOnOptionsCheckGroup.Items.Add(lisAutomaticallyOnLineBreak);
AutoOnOptionsCheckGroup.Items.Add(lisAutomaticallyOnSpace); AutoOnOptionsCheckGroup.Items.Add(lisAutomaticallyOnSpace);
@ -1190,7 +1193,7 @@ end;
procedure TCodeTemplateDialog.ShowCurCodeTemplate; procedure TCodeTemplateDialog.ShowCurCodeTemplate;
var var
EnableMacros: boolean; EnableMacros, KeepSubIndent: boolean;
LineCount: integer; LineCount: integer;
procedure AddLine(const s: string); procedure AddLine(const s: string);
@ -1207,6 +1210,7 @@ var
c: TAutoCompleteOption; c: TAutoCompleteOption;
begin begin
EnableMacros:=false; EnableMacros:=false;
KeepSubIndent:=false;
for c:=Low(TAutoCompleteOption) to High(TAutoCompleteOption) do for c:=Low(TAutoCompleteOption) to High(TAutoCompleteOption) do
AutoOnCat[c]:=false; AutoOnCat[c]:=false;
@ -1227,6 +1231,7 @@ begin
+' - '+dbgstr(SynAutoComplete.CompletionComments[a]); +' - '+dbgstr(SynAutoComplete.CompletionComments[a]);
Attributes:=SynAutoComplete.CompletionAttributes[a]; Attributes:=SynAutoComplete.CompletionAttributes[a];
EnableMacros:=Attributes.IndexOfName(CodeTemplateEnableMacros)>=0; EnableMacros:=Attributes.IndexOfName(CodeTemplateEnableMacros)>=0;
KeepSubIndent:=Attributes.IndexOfName(CodeTemplateKeepSubIndent)>=0;
for c:=Low(TAutoCompleteOption) to High(TAutoCompleteOption) do for c:=Low(TAutoCompleteOption) to High(TAutoCompleteOption) do
AutoOnCat[c]:=Attributes.IndexOfName(AutoCompleteOptionNames[c])>=0; AutoOnCat[c]:=Attributes.IndexOfName(AutoCompleteOptionNames[c])>=0;
LastTemplate := -1; LastTemplate := -1;
@ -1252,6 +1257,7 @@ begin
TemplateSynEdit.Lines.EndUpdate; TemplateSynEdit.Lines.EndUpdate;
TemplateSynEdit.Invalidate; TemplateSynEdit.Invalidate;
UseMacrosCheckBox.Checked:=EnableMacros; UseMacrosCheckBox.Checked:=EnableMacros;
KeepSubIndentCheckBox.Checked:=KeepSubIndent;
for c:=Low(TAutoCompleteOption) to High(TAutoCompleteOption) do for c:=Low(TAutoCompleteOption) to High(TAutoCompleteOption) do
AutoOnOptionsCheckGroup.Checked[ord(c)]:=AutoOnCat[c]; AutoOnOptionsCheckGroup.Checked[ord(c)]:=AutoOnCat[c];
end; end;
@ -1298,6 +1304,7 @@ begin
SynAutoComplete.CompletionValues[a]:=NewValue; SynAutoComplete.CompletionValues[a]:=NewValue;
SetBooleanAttribute(CodeTemplateEnableMacros,UseMacrosCheckBox.Checked); SetBooleanAttribute(CodeTemplateEnableMacros,UseMacrosCheckBox.Checked);
SetBooleanAttribute(CodeTemplateKeepSubIndent,KeepSubIndentCheckBox.Checked);
for c:=low(TAutoCompleteOption) to High(TAutoCompleteOption) do for c:=low(TAutoCompleteOption) to High(TAutoCompleteOption) do
SetBooleanAttribute(AutoCompleteOptionNames[c],AutoOnOptionsCheckGroup.Checked[ord(c)]); SetBooleanAttribute(AutoCompleteOptionNames[c],AutoOnOptionsCheckGroup.Checked[ord(c)]);

View File

@ -4473,6 +4473,7 @@ resourcestring
lisAutomaticallyOnSpace = 'space'; lisAutomaticallyOnSpace = 'space';
lisAutomaticallyOnWordEnd = 'word end'; lisAutomaticallyOnWordEnd = 'word end';
lisAutomaticallyRemoveCharacter = 'do not add character'; lisAutomaticallyRemoveCharacter = 'do not add character';
lisKeepSubIndentation = 'Keep indentation';
lisPckOptsThisPackageProvidesTheSameAsTheFollowingPackages = 'This package ' lisPckOptsThisPackageProvidesTheSameAsTheFollowingPackages = 'This package '
+'provides the same as the following packages:'; +'provides the same as the following packages:';
lisPLDPackageLinks = 'Package Links'; lisPLDPackageLinks = 'Package Links';
@ -5090,6 +5091,8 @@ resourcestring
//Disassembler dialog //Disassembler dialog
lisDisAssAssembler = 'Assembler'; lisDisAssAssembler = 'Assembler';
lisApplyConventions = 'Apply conventions'; lisApplyConventions = 'Apply conventions';
lisKeepRelativeIndentationOfMultiLineTemplate = 'Keep relative indentation '
+'of multi line template';
implementation implementation