From af73c2186ca518fb6f59648448ac6b3a0909832f Mon Sep 17 00:00:00 2001 From: martin Date: Tue, 19 Feb 2013 03:07:50 +0000 Subject: [PATCH] IDE: added string auto-continue mode git-svn-id: trunk@40352 - --- ide/editoroptions.pp | 14 ++ ide/frames/editor_indent_options.lfm | 257 ++++++++++++++++++--------- ide/frames/editor_indent_options.pas | 29 +++ ide/lazarusidestrconsts.pas | 4 + 4 files changed, 217 insertions(+), 87 deletions(-) diff --git a/ide/editoroptions.pp b/ide/editoroptions.pp index c8b76a7af9..c93ea8d40c 100644 --- a/ide/editoroptions.pp +++ b/ide/editoroptions.pp @@ -1367,6 +1367,10 @@ type FSlashCommentExtend: TSynCommentExtendMode; FSlashIndentAlignMax: integer; + FStringBreakAppend: String; + FStringBreakEnabled: Boolean; + FStringBreakPrefix: String; + FDefaultValues: TEditorOptions; public @@ -1605,6 +1609,10 @@ type read FSlashCommentExtend write FSlashCommentExtend; property SlashIndentAlignMax: integer read FSlashIndentAlignMax write FSlashIndentAlignMax; + + property StringBreakEnabled: Boolean read FStringBreakEnabled write FStringBreakEnabled; + property StringBreakAppend: String read FStringBreakAppend write FStringBreakAppend; + property StringBreakPrefix: String read FStringBreakPrefix write FStringBreakPrefix; end; const @@ -4385,6 +4393,9 @@ begin FSlashCommentExtend := sceMatching; FSlashIndentAlignMax := 40; + FStringBreakEnabled := False; + FStringBreakAppend := ' +'; + FStringBreakPrefix := ''; end; @@ -5367,6 +5378,9 @@ begin b.SlashIndentMode := []; end; + b.StringBreakEnabled := FStringBreakEnabled; + b.StringBreakAppend := FStringBreakAppend; + b.StringBreakPrefix := FStringBreakPrefix; end; diff --git a/ide/frames/editor_indent_options.lfm b/ide/frames/editor_indent_options.lfm index bb5c8e149b..33e8f8b5b6 100644 --- a/ide/frames/editor_indent_options.lfm +++ b/ide/frames/editor_indent_options.lfm @@ -15,9 +15,9 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Control = BlockIndentComboBox AnchorSideTop.Side = asrCenter Left = 322 - Height = 13 - Top = 125 - Width = 81 + Height = 15 + Top = 137 + Width = 91 BorderSpacing.Around = 6 Caption = 'BlockIndentLabel' ParentColor = False @@ -28,9 +28,9 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Control = TabWidthsComboBox AnchorSideTop.Side = asrCenter Left = 322 - Height = 13 - Top = 29 - Width = 76 + Height = 15 + Top = 31 + Width = 85 BorderSpacing.Around = 6 Caption = 'TabWidthsLabel' ParentColor = False @@ -41,9 +41,9 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Control = BlockIndentTypeComboBox AnchorSideTop.Side = asrCenter Left = 322 - Height = 13 - Top = 82 - Width = 104 + Height = 15 + Top = 90 + Width = 114 BorderSpacing.Around = 6 Caption = 'AutoIndentTypeLabel' ParentColor = False @@ -53,11 +53,11 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Control = lblBlockIndentKeys AnchorSideBottom.Control = TabWidthsComboBox Left = 216 - Height = 21 - Top = 121 + Height = 23 + Top = 133 Width = 100 BorderSpacing.Top = 3 - ItemHeight = 13 + ItemHeight = 15 Items.Strings = ( '0' '1' @@ -77,11 +77,11 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideBottom.Control = Owner AnchorSideBottom.Side = asrBottom Left = 216 - Height = 21 - Top = 25 + Height = 23 + Top = 27 Width = 100 BorderSpacing.Top = 6 - ItemHeight = 13 + ItemHeight = 15 Items.Strings = ( '1' '2' @@ -100,8 +100,8 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideRight.Control = CenterLabel1 AnchorSideRight.Side = asrBottom Left = 6 - Height = 17 - Top = 78 + Height = 19 + Top = 86 Width = 201 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 @@ -117,8 +117,8 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideRight.Control = CenterLabel1 AnchorSideRight.Side = asrBottom Left = 6 - Height = 17 - Top = 150 + Height = 19 + Top = 166 Width = 201 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 @@ -135,8 +135,8 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideRight.Control = CenterLabel1 AnchorSideRight.Side = asrBottom Left = 6 - Height = 17 - Top = 42 + Height = 19 + Top = 46 Width = 201 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 @@ -152,8 +152,8 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideRight.Control = CenterLabel1 AnchorSideRight.Side = asrBottom Left = 6 - Height = 17 - Top = 25 + Height = 19 + Top = 27 Width = 201 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 @@ -168,10 +168,10 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Control = AutoIndentCheckBox AnchorSideBottom.Control = TabWidthsComboBox Left = 216 - Height = 21 - Top = 78 + Height = 23 + Top = 86 Width = 100 - ItemHeight = 13 + ItemHeight = 15 ItemWidth = 200 OnChange = ComboboxOnChange OnExit = ComboBoxOnExit @@ -185,9 +185,9 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Side = asrBottom Cursor = crHandPoint Left = 24 - Height = 13 - Top = 95 - Width = 73 + Height = 15 + Top = 105 + Width = 82 BorderSpacing.Left = 18 Caption = 'AutoIndentLink' Font.Color = clBlue @@ -212,7 +212,7 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Left = 0 - Height = 13 + Height = 15 Top = 6 Width = 433 Caption = 'TabsGroupDivider' @@ -228,11 +228,11 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Side = asrBottom AnchorSideBottom.Control = TabWidthsComboBox Left = 216 - Height = 21 - Top = 145 + Height = 23 + Top = 159 Width = 100 BorderSpacing.Top = 3 - ItemHeight = 13 + ItemHeight = 15 Items.Strings = ( '0' '1' @@ -249,9 +249,9 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Control = BlockTabIndentComboBox AnchorSideTop.Side = asrCenter Left = 322 - Height = 13 - Top = 149 - Width = 81 + Height = 15 + Top = 163 + Width = 91 BorderSpacing.Around = 6 Caption = 'BlockIndentLabel' ParentColor = False @@ -261,10 +261,10 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = lblBlockIndentKeys Cursor = crHandPoint - Left = 101 - Height = 13 - Top = 118 - Width = 74 + Left = 112 + Height = 15 + Top = 130 + Width = 85 BorderSpacing.Left = 6 Caption = 'BlockIndentLink' Font.Color = clBlue @@ -279,9 +279,9 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Control = AutoIndentLink AnchorSideTop.Side = asrBottom Left = 6 - Height = 13 - Top = 118 - Width = 89 + Height = 15 + Top = 130 + Width = 100 BorderSpacing.Left = 6 BorderSpacing.Top = 10 Caption = 'lblBlockIndentKeys' @@ -294,8 +294,8 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Left = 0 - Height = 13 - Top = 65 + Height = 15 + Top = 71 Width = 433 Caption = 'IndentsGroupDivider' Autosize = True @@ -309,9 +309,9 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Control = lblBlockIndentKeys AnchorSideTop.Side = asrBottom Left = 6 - Height = 13 - Top = 134 - Width = 107 + Height = 15 + Top = 148 + Width = 121 BorderSpacing.Left = 6 BorderSpacing.Top = 3 Caption = 'lblBlockIndentShortcut' @@ -324,8 +324,8 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Left = 0 - Height = 13 - Top = 173 + Height = 15 + Top = 191 Width = 433 Caption = 'CommentsGroupDivider' Autosize = True @@ -341,8 +341,8 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Left = 0 - Height = 24 - Top = 186 + Height = 25 + Top = 206 Width = 433 Align = alNone Anchors = [akTop, akLeft, akRight] @@ -363,7 +363,7 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame end object tbCurly: TToolButton Tag = 1 - Left = 39 + Left = 43 Top = 0 AutoSize = True Caption = 'tbCurly' @@ -373,7 +373,7 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame end object tbShlash: TToolButton Tag = 2 - Left = 82 + Left = 90 Top = 0 AutoSize = True Caption = 'tbShlash' @@ -381,6 +381,16 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame OnClick = tbAnsiClick Style = tbsCheck end + object tbString: TToolButton + Tag = 3 + Left = 143 + Top = 0 + AutoSize = True + Caption = 'tbString' + Grouped = True + OnClick = tbAnsiClick + Style = tbsCheck + end end object CenterLabel1: TLabel AnchorSideLeft.Control = Owner @@ -398,8 +408,8 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Left = 0 - Height = 189 - Top = 210 + Height = 203 + Top = 231 Width = 433 PageIndex = 0 AutoSize = True @@ -411,9 +421,9 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideLeft.Control = AnsiPage AnchorSideRight.Side = asrBottom Left = 6 - Height = 17 + Height = 19 Top = 3 - Width = 147 + Width = 166 BorderSpacing.Left = 6 BorderSpacing.Top = 3 Caption = 'cbAnsiEnableAutoContinue' @@ -425,9 +435,9 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Control = edAnsiMatch AnchorSideTop.Side = asrCenter Left = 6 - Height = 13 - Top = 34 - Width = 57 + Height = 15 + Top = 36 + Width = 67 BorderSpacing.Left = 6 Caption = 'lbAnsiMatch' ParentColor = False @@ -439,10 +449,10 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Side = asrBottom AnchorSideRight.Control = AnsiPage AnchorSideRight.Side = asrBottom - Left = 69 - Height = 21 - Top = 30 - Width = 354 + Left = 79 + Height = 23 + Top = 32 + Width = 344 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 BorderSpacing.Top = 10 @@ -455,9 +465,9 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Control = edAnsiPrefix AnchorSideTop.Side = asrCenter Left = 6 - Height = 13 - Top = 98 - Width = 56 + Height = 15 + Top = 104 + Width = 62 BorderSpacing.Left = 6 Caption = 'lbAnsiPrefix' ParentColor = False @@ -469,10 +479,10 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Side = asrBottom AnchorSideRight.Control = AnsiPage AnchorSideRight.Side = asrBottom - Left = 68 - Height = 21 - Top = 94 - Width = 355 + Left = 74 + Height = 23 + Top = 100 + Width = 349 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 BorderSpacing.Top = 16 @@ -486,14 +496,14 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Side = asrBottom AnchorSideRight.Control = AnsiPage AnchorSideRight.Side = asrBottom - Left = 69 - Height = 21 - Top = 57 - Width = 354 + Left = 79 + Height = 23 + Top = 61 + Width = 344 Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 6 BorderSpacing.Right = 10 - ItemHeight = 13 + ItemHeight = 15 Style = csDropDownList TabOrder = 3 end @@ -503,14 +513,14 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Side = asrBottom AnchorSideRight.Control = AnsiPage AnchorSideRight.Side = asrBottom - Left = 68 - Height = 21 - Top = 121 - Width = 355 + Left = 74 + Height = 23 + Top = 129 + Width = 349 Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 6 BorderSpacing.Right = 10 - ItemHeight = 13 + ItemHeight = 15 OnChange = cbAnsiIndentModeChange Style = csDropDownList TabOrder = 4 @@ -521,8 +531,8 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Side = asrBottom AnchorSideBottom.Side = asrBottom Left = 6 - Height = 21 - Top = 168 + Height = 23 + Top = 180 Width = 100 BorderSpacing.Left = 6 BorderSpacing.Top = 3 @@ -535,9 +545,9 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame AnchorSideTop.Side = asrBottom AnchorSideRight.Side = asrBottom Left = 6 - Height = 13 - Top = 152 - Width = 71 + Height = 15 + Top = 162 + Width = 83 BorderSpacing.Left = 6 BorderSpacing.Top = 10 Caption = 'lbAnsiAlignMax' @@ -836,5 +846,78 @@ object EditorIndentOptionsFrame: TEditorIndentOptionsFrame WordWrap = True end end + object StringPage: TPage + object cbStringEnableAutoContinue: TCheckBox + AnchorSideLeft.Control = StringPage + AnchorSideTop.Control = StringPage + Left = 6 + Height = 19 + Top = 3 + Width = 174 + BorderSpacing.Left = 6 + BorderSpacing.Top = 3 + Caption = 'cbStringEnableAutoContinue' + OnChange = cbStringEnableAutoContinueChange + TabOrder = 0 + end + object lbStringAutoAppend: TLabel + AnchorSideLeft.Control = StringPage + AnchorSideTop.Control = edStringAutoAppend + AnchorSideTop.Side = asrCenter + Left = 6 + Height = 15 + Top = 32 + Width = 109 + BorderSpacing.Left = 6 + Caption = 'lbStringAutoAppend' + ParentColor = False + end + object lbStringAutoPrefix: TLabel + AnchorSideLeft.Control = StringPage + AnchorSideTop.Control = edStringAutoPrefix + AnchorSideTop.Side = asrCenter + Left = 6 + Height = 15 + Top = 61 + Width = 96 + BorderSpacing.Left = 6 + Caption = 'lbStringAutoPrefix' + ParentColor = False + end + object edStringAutoAppend: TEdit + AnchorSideLeft.Control = lbStringAutoAppend + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = cbStringEnableAutoContinue + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = StringPage + AnchorSideRight.Side = asrBottom + Left = 121 + Height = 23 + Top = 28 + Width = 306 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 6 + BorderSpacing.Top = 6 + BorderSpacing.Right = 6 + TabOrder = 1 + end + object edStringAutoPrefix: TEdit + AnchorSideLeft.Control = lbStringAutoPrefix + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = edStringAutoAppend + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = StringPage + AnchorSideRight.Side = asrBottom + Left = 108 + Height = 23 + Top = 57 + Width = 319 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 6 + BorderSpacing.Top = 6 + BorderSpacing.Right = 6 + TabOrder = 2 + end + end end end diff --git a/ide/frames/editor_indent_options.pas b/ide/frames/editor_indent_options.pas index 7719bc4cff..b64f07391c 100644 --- a/ide/frames/editor_indent_options.pas +++ b/ide/frames/editor_indent_options.pas @@ -45,7 +45,12 @@ type AutoIndentTypeLabel: TLabel; cbSlashExtend: TComboBox; CenterLabel1: TLabel; + cbStringEnableAutoContinue: TCheckBox; CommentsGroupDivider: TDividerBevel; + edStringAutoAppend: TEdit; + edStringAutoPrefix: TEdit; + lbStringAutoAppend: TLabel; + lbStringAutoPrefix: TLabel; lblBlockIndentShortcut: TLabel; cbAnsiEnableAutoContinue: TCheckBox; @@ -82,6 +87,7 @@ type Notebook1: TNotebook; AnsiPage: TPage; CurlyPage: TPage; + StringPage: TPage; SlashPage: TPage; TabsGroupDivider: TDividerBevel; AutoIndentLink: TLabel; @@ -97,6 +103,7 @@ type tbAnsi: TToolButton; tbCurly: TToolButton; tbShlash: TToolButton; + tbString: TToolButton; procedure AutoIndentCheckBoxChange(Sender: TObject); procedure AutoIndentLinkClick(Sender: TObject); procedure AutoIndentLinkMouseEnter(Sender: TObject); @@ -108,6 +115,7 @@ type procedure cbCurlyIndentModeChange(Sender: TObject); procedure cbSlashEnableAutoContinueChange(Sender: TObject); procedure cbSlashIndentModeChange(Sender: TObject); + procedure cbStringEnableAutoContinueChange(Sender: TObject); procedure ComboboxOnChange(Sender: TObject); procedure ComboboxOnKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); @@ -187,6 +195,7 @@ begin tbAnsi.Caption := dlgAnsiCommentTab; tbCurly.Caption := dlgCurlyCommentTab; tbShlash.Caption := dlgSlashCommentTab; + tbString.Caption := dlgStringBreakIndentTab; Notebook1.AutoSize := True; @@ -244,6 +253,10 @@ begin cbSlashExtend.Items.Add(dlgCommentShlashExtendAlways); cbSlashExtend.Items.Add(dlgCommentShlashExtendAlwaysSplit); + cbStringEnableAutoContinue.Caption := dlgStringEnableAutoContinue; + lbStringAutoAppend.Caption := dlgStringAutoAppend; + lbStringAutoPrefix.Caption := dlgStringAutoPrefix; + end; procedure TEditorIndentOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions); @@ -319,6 +332,10 @@ begin cbSlashEnableAutoContinueChange(nil); cbSlashIndentModeChange(nil); + cbStringEnableAutoContinue.Checked := StringBreakEnabled; + edStringAutoAppend.Text := StringBreakAppend; + edStringAutoPrefix.Text := StringBreakPrefix; + cbStringEnableAutoContinueChange(nil); end; end; @@ -425,6 +442,9 @@ begin SlashCommentExtend := IdxToExtendMode[cbSlashExtend.ItemIndex]; + StringBreakEnabled := cbStringEnableAutoContinue.Checked; + StringBreakAppend := edStringAutoAppend.Text; + StringBreakPrefix := edStringAutoPrefix.Text; end; end; @@ -522,6 +542,7 @@ begin edAnsiPrefix.Enabled := cbAnsiEnableAutoContinue.Checked; cbAnsiMatchMode.Enabled := cbAnsiEnableAutoContinue.Checked; cbAnsiIndentMode.Enabled := cbAnsiEnableAutoContinue.Checked; + edAnsiAlignMax.Enabled := cbAnsiEnableAutoContinue.Checked; end; procedure TEditorIndentOptionsFrame.cbAnsiIndentModeChange(Sender: TObject); @@ -538,6 +559,7 @@ begin edCurlyPrefix.Enabled := cbCurlyEnableAutoContinue.Checked; cbCurlyMatchMode.Enabled := cbCurlyEnableAutoContinue.Checked; cbCurlyIndentMode.Enabled := cbCurlyEnableAutoContinue.Checked; + edCurlyAlignMax.Enabled := cbCurlyEnableAutoContinue.Checked; end; procedure TEditorIndentOptionsFrame.cbCurlyIndentModeChange(Sender: TObject); @@ -555,6 +577,7 @@ begin cbSlashMatchMode.Enabled := cbSlashEnableAutoContinue.Checked; cbSlashIndentMode.Enabled := cbSlashEnableAutoContinue.Checked; cbSlashExtend.Enabled := cbSlashEnableAutoContinue.Checked; + edSlashAlignMax.Enabled := cbSlashEnableAutoContinue.Checked; end; procedure TEditorIndentOptionsFrame.cbSlashIndentModeChange(Sender: TObject); @@ -565,6 +588,12 @@ begin end; end; +procedure TEditorIndentOptionsFrame.cbStringEnableAutoContinueChange(Sender: TObject); +begin + edStringAutoAppend.Enabled := cbStringEnableAutoContinue.Checked; + edStringAutoPrefix.Enabled := cbStringEnableAutoContinue.Checked; +end; + procedure TEditorIndentOptionsFrame.ComboboxOnKeyDown( Sender: TObject; var Key: Word; Shift: TShiftState); begin diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 1ebb4c92d1..875f787d75 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -1387,6 +1387,7 @@ resourcestring dlgAnsiCommentTab = 'Ansi (* *)'; dlgCurlyCommentTab = 'Curly { }'; dlgSlashCommentTab = 'Slash //'; + dlgStringBreakIndentTab = 'String '''''; dlgCommentContinue = 'Prefix comments on linebreak'; dlgCommentContinueMatch = 'Match current line'; @@ -1404,6 +1405,9 @@ resourcestring dlgCommentShlashExtendMatchSplit = 'Extend, if matched and caret in the middle of text (not at EOL)'; dlgCommentShlashExtendAlways = 'Extend, if matched or not matched'; dlgCommentShlashExtendAlwaysSplit = 'Extend, if matched or not matched (not at EOL)'; + dlgStringEnableAutoContinue = 'Extend strings on linebreak'; + dlgStringAutoAppend = 'Append text to close string'; + dlgStringAutoPrefix = 'Prefix string on new line'; dlgUndoAfterSave = 'Undo after save'; dlgFindTextatCursor = 'Find text at cursor';