diff --git a/components/synedit/synedit.pp b/components/synedit/synedit.pp index e34211ba48..7e76256506 100644 --- a/components/synedit/synedit.pp +++ b/components/synedit/synedit.pp @@ -473,6 +473,7 @@ type function GetSelectedColor : TSynSelectedColor; function GetBracketMatchColor : TSynSelectedColor; function GetMouseLinkColor : TSynSelectedColor; + function GetTrimSpaceType: TSynEditStringTrimmingType; procedure SetBracketHighlightStyle( const AValue: TSynEditBracketHighlightStyle); procedure SetOnGutterClick(const AValue : TGutterClickEvent); @@ -494,6 +495,7 @@ type function GetMaxUndo: Integer; function GetSelAvail: Boolean; function GetSelText: string; + procedure SetTrimSpaceType(const AValue: TSynEditStringTrimmingType); function SynGetText: string; {$IFDEF SYN_LAZARUS} procedure SetTabChar(const AValue: Char); @@ -884,6 +886,8 @@ type read GetMarkup; property MarkupByClass[Index: TSynEditMarkupClass]: TSynEditMarkup read GetMarkupByClass; + property TrimSpaceType: TSynEditStringTrimmingType + read GetTrimSpaceType write SetTrimSpaceType; protected property BookMarkOptions: TSynBookMarkOpt read fBookMarkOpt write fBookMarkOpt; @@ -1787,6 +1791,11 @@ begin Result := fMarkupCtrlMouse.MarkupInfo; end; +function TCustomSynEdit.GetTrimSpaceType: TSynEditStringTrimmingType; +begin + Result := FTrimmedLinesView.TrimType; +end; + function TCustomSynEdit.GetTheLinesView: TStrings; begin Result := FTheLinesView; @@ -1880,6 +1889,11 @@ begin Result := FBlockSelection.SelText; end; +procedure TCustomSynEdit.SetTrimSpaceType(const AValue: TSynEditStringTrimmingType); +begin + FTrimmedLinesView.TrimType := AValue; +end; + function TCustomSynEdit.SynGetText: string; begin Result := fLines.Text; diff --git a/components/synedit/synedittexttrimmer.pas b/components/synedit/synedittexttrimmer.pas index b453c107d9..a9ef5c47cf 100644 --- a/components/synedit/synedittexttrimmer.pas +++ b/components/synedit/synedittexttrimmer.pas @@ -33,12 +33,15 @@ LCLProc, type + TSynEditStringTrimmingType = (settLeaveLine, settEditLine, settMoveCaret); + { TSynEditStringTrimmingList } TSynEditStringTrimmingList = class(TSynEditStringsLinked) private fCaret: TSynEditCaret; FIsTrimming: Boolean; + FTrimType: TSynEditStringTrimmingType; fUndoList: TSynEditUndoList; fSpaces: String; fLineText: String; @@ -47,8 +50,10 @@ type FUndoTrimmedSpaces: Boolean; fLockCount: Integer; fLockList : TStringList; + FLineEdited: Boolean; procedure DoCaretChanged(Sender : TObject); procedure SetEnabled(const AValue : Boolean); + procedure SetTrimType(const AValue: TSynEditStringTrimmingType); function TrimLine(const S : String; Index: Integer; RealUndo: Boolean = False) : String; function Spaces(Index: Integer) : String; procedure DoLinesChanged(Index, N: integer); @@ -84,6 +89,7 @@ type property UndoTrimmedSpaces: Boolean read FUndoTrimmedSpaces write FUndoTrimmedSpaces; property UndoList: TSynEditUndoList read fUndoList write fUndoList; property IsTrimming: Boolean read FIsTrimming; + property TrimType: TSynEditStringTrimmingType read FTrimType write SetTrimType; end; implementation @@ -101,6 +107,8 @@ begin fEnabled:=false; FUndoTrimmedSpaces := False; FIsTrimming := False; + FLineEdited := False; + FTrimType := settLeaveLine; Inherited Create(ASynStringSource); end; @@ -114,21 +122,41 @@ end; procedure TSynEditStringTrimmingList.DoCaretChanged(Sender : TObject); var s: String; + i, j: Integer; begin if (not fEnabled) then exit; - if (fLineIndex = TSynEditCaret(Sender).LinePos - 1) then exit; + if (fLockCount > 0) or (length(fSpaces) = 0) or (fLineIndex < 0) + or (fLineIndex >= fSynStrings.Count) + or ((FTrimType in [settLeaveLine]) AND (fLineIndex = TSynEditCaret(Sender).LinePos - 1)) + or ((FTrimType in [settEditLine]) and not FLineEdited) + then begin + if (fLineIndex <> TSynEditCaret(Sender).LinePos - 1) then + fSpaces := ''; + fLineIndex := TSynEditCaret(Sender).LinePos - 1; + exit; + end; FIsTrimming := True; - if (length(fSpaces) > 0) and (fLineIndex > 0) - and (fLineIndex <= fSynStrings.Count) - and (fLockCount = 0) then begin - s := fSynStrings[fLineIndex]; - fSynStrings[fLineIndex] := s; // trigger OnPutted, so the line gets repainted + s := fSynStrings[fLineIndex]; + fSynStrings[fLineIndex] := s; // trigger OnPutted, so the line gets repainted + if (fLineIndex <> TSynEditCaret(Sender).LinePos - 1) then begin fUndoList.AppendToLastChange(crTrimSpace, Point(1+length(s), fLineIndex+1), Point(1+length(s)+length(fSpaces), fLineIndex+1), fSpaces, smNormal); + fSpaces := ''; + end else begin + // same line, only right of caret + i := TSynEditCaret(Sender).BytePos; + if i <= length(s) + 1 then + j := 0 + else + j := i - length(s) - 1; + s := copy(FSpaces, j + 1, MaxInt); + FSpaces := copy(FSpaces, 1, j); + fUndoList.AppendToLastChange(crTrimSpace, Point(i, fLineIndex+1), + Point(i + length(s), fLineIndex+1), s, smNormal); end; FIsTrimming := False; + FLineEdited := False; fLineIndex := TSynEditCaret(Sender).LinePos - 1; - fSpaces := ''; end; procedure TSynEditStringTrimmingList.SetEnabled(const AValue : Boolean); @@ -141,11 +169,18 @@ begin FLineIndex := -1; FLockList.Clear; FIsTrimming := True; + FLineEdited := False; if fEnabled and (fLineIndex >= 0) and (fLineIndex < fSynStrings.Count) then fSynStrings[fLineIndex] := TrimLine(fSynStrings[fLineIndex], fLineIndex); FIsTrimming := False; end; +procedure TSynEditStringTrimmingList.SetTrimType(const AValue: TSynEditStringTrimmingType); +begin + if FTrimType = AValue then exit; + FTrimType := AValue; +end; + procedure TSynEditStringTrimmingList.UndoRealSpaces(Item: TSynEditUndoItem); var i: Integer; @@ -246,8 +281,10 @@ end; procedure TSynEditStringTrimmingList.Lock; begin - if (fLockCount = 0) and (fLineIndex >= 0) and Enabled then + if (fLockCount = 0) and (fLineIndex >= 0) and Enabled then begin fLockList.AddObject(Spaces(fLineIndex), TObject(Pointer(fLineIndex))); + FLineEdited := False; + end; inc(fLockCount); end; @@ -270,7 +307,9 @@ begin if (fLineIndex >= 0) and (fLineIndex < fSynStrings.Count) then fLineText := fSynStrings[fLineIndex]; fLockList.Delete(i); + DoCaretChanged(fCaret); end; + FIsTrimming := True; for i := 0 to fLockList.Count-1 do begin index := Integer(Pointer(fLockList.Objects[i])); slen := length(fLockList[i]); @@ -283,6 +322,7 @@ begin end; end; FIsTrimming := False; + FLineEdited := False; fLockList.Clear; end; @@ -320,11 +360,13 @@ end; procedure TSynEditStringTrimmingList.Put(Index : integer; const S : string); begin + FLineEdited := True; fSynStrings.Strings[Index]:= TrimLine(S, Index, True); end; procedure TSynEditStringTrimmingList.PutObject(Index : integer; AObject : TObject); begin + FLineEdited := True; fSynStrings.Objects[Index]:= AObject; end; @@ -332,6 +374,7 @@ function TSynEditStringTrimmingList.Add(const S : string) : integer; var c : Integer; begin + FLineEdited := True; c := fSynStrings.Count; DoLinesChanged(c, 1); Result := fSynStrings.Add(TrimLine(S, c)); @@ -356,6 +399,7 @@ end; procedure TSynEditStringTrimmingList.Delete(Index : integer); begin + FLineEdited := True; TrimLine('', Index, True); fSynStrings.Delete(Index); DoLinesChanged(Index, -1); @@ -365,6 +409,7 @@ procedure TSynEditStringTrimmingList.DeleteLines(Index, NumLines : integer); var i: Integer; begin + FLineEdited := True; for i := 0 to NumLines-1 do TrimLine('', Index+i, True); fSynStrings.DeleteLines(Index, NumLines); @@ -373,12 +418,14 @@ end; procedure TSynEditStringTrimmingList.Insert(Index : integer; const S : string); begin + FLineEdited := True; DoLinesChanged(Index, 1); fSynStrings.Insert(Index, TrimLine(S, Index)); end; procedure TSynEditStringTrimmingList.InsertLines(Index, NumLines : integer); begin + FLineEdited := True; DoLinesChanged(Index, NumLines); fSynStrings.InsertLines(Index, NumLines); end; @@ -387,6 +434,7 @@ procedure TSynEditStringTrimmingList.InsertStrings(Index : integer; NewStrings : var i : Integer; begin + FLineEdited := True; DoLinesChanged(Index, NewStrings.Count); for i := 0 to NewStrings.Count-1 do NewStrings[i] := TrimLine(NewStrings[i], Index+i, True); @@ -395,6 +443,7 @@ end; procedure TSynEditStringTrimmingList.Exchange(Index1, Index2 : integer); begin + FLineEdited := True; fSynStrings.Exchange(Index1, Index2); if fLineIndex = Index1 then fLineIndex := Index2 diff --git a/ide/editoroptions.pp b/ide/editoroptions.pp index 719cb9791c..85e474f636 100644 --- a/ide/editoroptions.pp +++ b/ide/editoroptions.pp @@ -44,7 +44,7 @@ uses SynHighlighterCPP, SynHighlighterHTML, SynHighlighterJava, SynHighlighterLFM, SynHighlighterPas, SynHighlighterPerl, SynHighlighterPHP, SynHighlighterSQL, SynHighlighterPython, SynHighlighterUNIXShellScript, SynHighlighterXML, - SynHighlighterJScript, SynEditMiscClasses, SynBeautifier, + SynHighlighterJScript, SynEditMiscClasses, SynBeautifier, SynEditTextTrimmer, // codetools LinkScanner, CodeToolManager, Laz_XMLCfg, // IDEIntf @@ -435,6 +435,7 @@ type FShowGutterHints: Boolean; fBlockIndent: Integer; fBlockIndentType: TSynBeautifierIndentType; + FTrimSpaceType: TSynEditStringTrimmingType; fUndoLimit: Integer; fTabWidth: Integer; FBracketHighlightStyle: TSynEditBracketHighlightStyle; @@ -493,6 +494,8 @@ type function GetSynEditOptionName(SynOption: TSynEditorOption): string; function GetSynBeautifierIndentName(IndentType: TSynBeautifierIndentType): string; function GetSynBeautifierIndentType(IndentName: String): TSynBeautifierIndentType; + function GetTrimSpaceName(IndentType: TSynEditStringTrimmingType): string; + function GetTrimSpaceType(IndentName: String): TSynEditStringTrimmingType; procedure GetHighlighterSettings(Syn: TSrcIDEHighlighter); // read highlight settings from config file procedure SetHighlighterSettings(Syn: TSrcIDEHighlighter); // write highlight settings to config file @@ -546,6 +549,8 @@ type read fBlockIndent write fBlockIndent default 2; property BlockIndentType: TSynBeautifierIndentType read fBlockIndentType write fBlockIndentType default sbitCopySpaceTab; + property TrimSpaceType: TSynEditStringTrimmingType + read FTrimSpaceType write FTrimSpaceType default settLeaveLine; property UndoLimit: Integer read fUndoLimit write fUndoLimit default 32767; property TabWidth: Integer read fTabWidth write fTabWidth default 8; property BracketHighlightStyle: TSynEditBracketHighlightStyle read FBracketHighlightStyle write FBracketHighlightStyle default sbhsBoth; @@ -1392,6 +1397,7 @@ begin FShowGutterHints := True; fBlockIndent := 2; fBlockIndentType := sbitSpace; + FTrimSpaceType := settLeaveLine; fUndoLimit := 32767; fTabWidth := 8; FBracketHighlightStyle := sbhsBoth; @@ -1515,6 +1521,9 @@ begin fBlockIndentType := GetSynBeautifierIndentType (XMLConfig.GetValue('EditorOptions/General/Editor/BlockIndentType', 'SpaceIndent')); + FTrimSpaceType := GetTrimSpaceType + (XMLConfig.GetValue('EditorOptions/General/Editor/SpaceTrimType', + 'LeaveLine')); fUndoLimit := XMLConfig.GetValue('EditorOptions/General/Editor/UndoLimit', 32767); fTabWidth := @@ -1692,6 +1701,8 @@ begin , fBlockIndent, 2); XMLConfig.SetDeleteValue('EditorOptions/General/Editor/BlockIndentType' , GetSynBeautifierIndentName(fBlockIndentType), 'SpaceIndent'); + XMLConfig.SetDeleteValue('EditorOptions/General/Editor/SpaceTrimType' + , GetTrimSpaceName(FTrimSpaceType), 'LeaveLine'); XMLConfig.SetDeleteValue('EditorOptions/General/Editor/UndoLimit' , fUndoLimit, 32767); XMLConfig.SetDeleteValue('EditorOptions/General/Editor/TabWidth' @@ -1859,14 +1870,34 @@ end; function TEditorOptions.GetSynBeautifierIndentType(IndentName: String): TSynBeautifierIndentType; begin - if IndentName = 'SpaceIndent' then - Result := sbitSpace - else if IndentName = 'CopySpaceTabIndent' then + Result := sbitSpace; + if IndentName = 'CopySpaceTabIndent' then Result := sbitCopySpaceTab else if IndentName = 'PositionIndent' then Result := sbitPositionCaret; end; +function TEditorOptions.GetTrimSpaceName(IndentType: TSynEditStringTrimmingType): string; +begin + case IndentType of + settLeaveLine: + Result := 'LeaveLine'; + settEditLine: + Result := 'EditLine'; + settMoveCaret: + Result := 'MoveCaret'; + end; +end; + +function TEditorOptions.GetTrimSpaceType(IndentName: String): TSynEditStringTrimmingType; +begin + Result := settLeaveLine; + if IndentName = 'EditLine' then + Result := settEditLine + else if IndentName = 'MoveCaret' then + Result := settMoveCaret; +end; + function TEditorOptions.CreateSyn(LazSynHilighter: TLazSyntaxHighlighter): TSrcIDEHighlighter; begin @@ -2340,6 +2371,7 @@ begin ASynEdit.Options2 := fSynEditOptions2; ASynEdit.BlockIndent := fBlockIndent; (ASynEdit.Beautifier as TSynBeautifier).IndentType := fBlockIndentType; + ASynEdit.TrimSpaceType := FTrimSpaceType; ASynEdit.TabWidth := fTabWidth; ASynEdit.BracketHighlightStyle := FBracketHighlightStyle; @@ -2406,6 +2438,7 @@ begin fSynEditOptions2 := ASynEdit.Options2; fBlockIndent := ASynEdit.BlockIndent; fBlockIndentType := (ASynEdit.Beautifier as TSynBeautifier).IndentType; + FTrimSpaceType := ASynEdit.TrimSpaceType; fTabWidth := ASynEdit.TabWidth; FBracketHighlightStyle := ASynEdit.BracketHighlightStyle; diff --git a/ide/frames/editor_general_misc_options.lfm b/ide/frames/editor_general_misc_options.lfm index cde8f4e8cb..858b91da0d 100644 --- a/ide/frames/editor_general_misc_options.lfm +++ b/ide/frames/editor_general_misc_options.lfm @@ -3,10 +3,24 @@ inherited EditorGeneralMiscOptionsFrame: TEditorGeneralMiscOptionsFrame Width = 459 ClientHeight = 186 ClientWidth = 459 + TabOrder = 0 Visible = False - DesignLeft = 521 - DesignTop = 247 - object EditorOptionsGroupBox: TCheckGroup[0] + DesignLeft = 138 + DesignTop = 138 + object EditorTrimSpaceTypeLabel: TLabel[0] + AnchorSideLeft.Control = EditorTrimSpaceTypeCheckBox + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = EditorTrimSpaceTypeCheckBox + AnchorSideTop.Side = asrCenter + Left = 156 + Height = 16 + Top = 160 + Width = 142 + BorderSpacing.Left = 6 + Caption = 'EditorTrimSpaceTypeLabel' + ParentColor = False + end + object EditorOptionsGroupBox: TCheckGroup[1] AnchorSideLeft.Control = Owner AnchorSideTop.Control = Owner AnchorSideRight.Control = Owner @@ -17,22 +31,12 @@ inherited EditorGeneralMiscOptionsFrame: TEditorGeneralMiscOptionsFrame Height = 152 Top = 0 Width = 459 - HelpContext = 0 Anchors = [akTop, akLeft, akRight] AutoFill = True AutoSize = True - BorderSpacing.Left = 0 - BorderSpacing.Top = 0 - BorderSpacing.Right = 0 - BorderSpacing.Bottom = 0 - BorderSpacing.Around = 0 - BorderSpacing.CellAlignHorizontal = ccaFill - BorderSpacing.CellAlignVertical = ccaFill Caption = 'EditorOptionsGroupBox' ChildSizing.LeftRightSpacing = 6 ChildSizing.TopBottomSpacing = 6 - ChildSizing.HorizontalSpacing = 0 - ChildSizing.VerticalSpacing = 0 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeVertical = crsHomogenousChildResize ChildSizing.ShrinkHorizontal = crsScaleChilds @@ -45,4 +49,20 @@ inherited EditorGeneralMiscOptionsFrame: TEditorGeneralMiscOptionsFrame OnItemClick = EditorOptionsGroupBoxItemClick TabOrder = 0 end + object EditorTrimSpaceTypeCheckBox: TComboBox[2] + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = EditorOptionsGroupBox + AnchorSideTop.Side = asrBottom + Left = 0 + Height = 21 + Top = 158 + Width = 150 + AutoComplete = False + BorderSpacing.Top = 6 + Ctl3D = False + ItemHeight = 13 + ItemWidth = 0 + Style = csDropDownList + TabOrder = 1 + end end diff --git a/ide/frames/editor_general_misc_options.lrs b/ide/frames/editor_general_misc_options.lrs index d21e6f17ed..cff9fce377 100644 --- a/ide/frames/editor_general_misc_options.lrs +++ b/ide/frames/editor_general_misc_options.lrs @@ -3,23 +3,29 @@ LazarusResources.Add('TEditorGeneralMiscOptionsFrame','FORMDATA',[ 'TPF0'#241#30'TEditorGeneralMiscOptionsFrame'#29'EditorGeneralMiscOptionsFram' +'e'#6'Height'#3#186#0#5'Width'#3#203#1#12'ClientHeight'#3#186#0#11'ClientWid' - +'th'#3#203#1#7'Visible'#8#10'DesignLeft'#3#9#2#9'DesignTop'#3#247#0#0#242#2#0 - +#11'TCheckGroup'#21'EditorOptionsGroupBox'#22'AnchorSideLeft.Control'#7#5'Ow' - +'ner'#21'AnchorSideTop.Control'#7#5'Owner'#23'AnchorSideRight.Control'#7#5'O' - +'wner'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorSideBottom.Control'#7 - +#5'Owner'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#3 - +#152#0#3'Top'#2#0#5'Width'#3#203#1#11'HelpContext'#2#0#7'Anchors'#11#5'akTop' - +#6'akLeft'#7'akRight'#0#8'AutoFill'#9#8'AutoSize'#9#18'BorderSpacing.Left'#2 - +#0#17'BorderSpacing.Top'#2#0#19'BorderSpacing.Right'#2#0#20'BorderSpacing.Bo' - +'ttom'#2#0#20'BorderSpacing.Around'#2#0'!BorderSpacing.CellAlignHorizontal'#7 - +#7'ccaFill'#31'BorderSpacing.CellAlignVertical'#7#7'ccaFill'#7'Caption'#6#21 - +'EditorOptionsGroupBox'#28'ChildSizing.LeftRightSpacing'#2#6#28'ChildSizing.' - +'TopBottomSpacing'#2#6#29'ChildSizing.HorizontalSpacing'#2#0#27'ChildSizing.' - +'VerticalSpacing'#2#0#29'ChildSizing.EnlargeHorizontal'#7#24'crsHomogenousCh' - +'ildResize'#27'ChildSizing.EnlargeVertical'#7#24'crsHomogenousChildResize'#28 - +'ChildSizing.ShrinkHorizontal'#7#14'crsScaleChilds'#26'ChildSizing.ShrinkVer' - +'tical'#7#14'crsScaleChilds'#18'ChildSizing.Layout'#7#29'cclTopToBottomThenL' - +'eftToRight'#27'ChildSizing.ControlsPerLine'#2#1#12'ColumnLayout'#7#24'clVer' - +'ticalThenHorizontal'#7'Columns'#2#2#5'Ctl3D'#8#11'OnItemClick'#7#30'EditorO' - +'ptionsGroupBoxItemClick'#8'TabOrder'#2#0#0#0#0 + +'th'#3#203#1#8'TabOrder'#2#0#7'Visible'#8#10'DesignLeft'#3#138#0#9'DesignTop' + +#3#138#0#0#242#2#0#6'TLabel'#24'EditorTrimSpaceTypeLabel'#22'AnchorSideLeft.' + +'Control'#7#27'EditorTrimSpaceTypeCheckBox'#19'AnchorSideLeft.Side'#7#9'asrB' + +'ottom'#21'AnchorSideTop.Control'#7#27'EditorTrimSpaceTypeCheckBox'#18'Ancho' + +'rSideTop.Side'#7#9'asrCenter'#4'Left'#3#156#0#6'Height'#2#16#3'Top'#3#160#0 + +#5'Width'#3#142#0#18'BorderSpacing.Left'#2#6#7'Caption'#6#24'EditorTrimSpace' + +'TypeLabel'#11'ParentColor'#8#0#0#242#2#1#11'TCheckGroup'#21'EditorOptionsGr' + +'oupBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#5 + +'Owner'#23'AnchorSideRight.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9 + +'asrBottom'#24'AnchorSideBottom.Control'#7#5'Owner'#21'AnchorSideBottom.Side' + +#7#9'asrBottom'#4'Left'#2#0#6'Height'#3#152#0#3'Top'#2#0#5'Width'#3#203#1#7 + +'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'AutoFill'#9#8'AutoSize'#9#7'C' + +'aption'#6#21'EditorOptionsGroupBox'#28'ChildSizing.LeftRightSpacing'#2#6#28 + +'ChildSizing.TopBottomSpacing'#2#6#29'ChildSizing.EnlargeHorizontal'#7#24'cr' + +'sHomogenousChildResize'#27'ChildSizing.EnlargeVertical'#7#24'crsHomogenousC' + +'hildResize'#28'ChildSizing.ShrinkHorizontal'#7#14'crsScaleChilds'#26'ChildS' + +'izing.ShrinkVertical'#7#14'crsScaleChilds'#18'ChildSizing.Layout'#7#29'cclT' + +'opToBottomThenLeftToRight'#27'ChildSizing.ControlsPerLine'#2#1#12'ColumnLay' + +'out'#7#24'clVerticalThenHorizontal'#7'Columns'#2#2#5'Ctl3D'#8#11'OnItemClic' + +'k'#7#30'EditorOptionsGroupBoxItemClick'#8'TabOrder'#2#0#0#0#242#2#2#9'TComb' + +'oBox'#27'EditorTrimSpaceTypeCheckBox'#22'AnchorSideLeft.Control'#7#5'Owner' + +#21'AnchorSideTop.Control'#7#21'EditorOptionsGroupBox'#18'AnchorSideTop.Side' + +#7#9'asrBottom'#4'Left'#2#0#6'Height'#2#21#3'Top'#3#158#0#5'Width'#3#150#0#12 + +'AutoComplete'#8#17'BorderSpacing.Top'#2#6#5'Ctl3D'#8#10'ItemHeight'#2#13#9 + +'ItemWidth'#2#0#5'Style'#7#14'csDropDownList'#8'TabOrder'#2#1#0#0#0 ]); diff --git a/ide/frames/editor_general_misc_options.pas b/ide/frames/editor_general_misc_options.pas index acda946b06..7da770db56 100644 --- a/ide/frames/editor_general_misc_options.pas +++ b/ide/frames/editor_general_misc_options.pas @@ -28,13 +28,15 @@ uses Classes, SysUtils, FileUtil, LResources, Forms, Graphics, LCLProc, LCLType, StdCtrls, SynEdit, Controls, ExtCtrls, EditorOptions, LazarusIDEStrConsts, IDEProcs, IDEOptionsIntf, - editor_general_options; + editor_general_options, SynEditTextTrimmer; type { TEditorGeneralMiscOptionsFrame } TEditorGeneralMiscOptionsFrame = class(TAbstractIDEOptionsEditor) + EditorTrimSpaceTypeCheckBox: TComboBox; EditorOptionsGroupBox: TCheckGroup; + EditorTrimSpaceTypeLabel: TLabel; procedure EditorOptionsGroupBoxItemClick(Sender: TObject; Index: integer); private FDialog: TAbstractOptionsEditorDialog; @@ -75,6 +77,10 @@ begin Items.Add(dlgFindTextatCursor); Items.Add(dlgCopyWordAtCursorOnCopyNone); end; + EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeLeaveLine); + EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeEditLine); + EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeCaretMove); + EditorTrimSpaceTypeLabel.Caption := dlgTrimSpaceTypeCaption; end; procedure TEditorGeneralMiscOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions); @@ -91,6 +97,7 @@ begin Checked[Items.IndexOf(dlgFindTextatCursor)] := FindTextAtCursor; Checked[Items.IndexOf(dlgCopyWordAtCursorOnCopyNone)] := CopyWordAtCursorOnCopyNone; end; + EditorTrimSpaceTypeCheckBox.ItemIndex := ord(TrimSpaceType); end; end; @@ -122,6 +129,7 @@ begin CopyWordAtCursorOnCopyNone := CheckGroupItemChecked(EditorOptionsGroupBox, dlgCopyWordAtCursorOnCopyNone); ShowGutterHints := CheckGroupItemChecked(EditorOptionsGroupBox, dlgShowGutterHints); FindTextAtCursor := CheckGroupItemChecked(EditorOptionsGroupBox, dlgFindTextatCursor); + TrimSpaceType := TSynEditStringTrimmingType(EditorTrimSpaceTypeCheckBox.ItemIndex); end; end; diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index b61e92c194..faeef1e7a5 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -1149,6 +1149,10 @@ resourcestring dlgBlockIndentTypeSpace = 'Spaces'; dlgBlockIndentTypeCopy = 'Space/tab as prev Line'; dlgBlockIndentTypePos = 'Position only'; + dlgTrimSpaceTypeCaption = 'Trim Spaces Style'; + dlgTrimSpaceTypeLeaveLine = 'Leave line'; + dlgTrimSpaceTypeEditLine = 'Line Edited'; + dlgTrimSpaceTypeCaretMove = 'Caret or Edit'; dlgUndoLimit = 'Undo limit'; dlgTabWidths = 'Tab widths'; dlgMarginGutter = 'Margin and gutter';