SynEdit, Trim-Trailing-Spaces: Added Position-Only mode(no space inserted/looses tabs); changed default to "Edit or Leave line"

git-svn-id: trunk@19121 -
This commit is contained in:
martin 2009-03-26 17:45:54 +00:00
parent dcc5e60570
commit 19be7391db
4 changed files with 16 additions and 8 deletions

View File

@ -33,7 +33,8 @@ LCLProc,
type type
TSynEditStringTrimmingType = (settLeaveLine, settEditLine, settMoveCaret); TSynEditStringTrimmingType = (settLeaveLine, settEditLine, settMoveCaret,
settIgnoreAll);
{ TSynEditStringTrimmingList } { TSynEditStringTrimmingList }
@ -314,7 +315,8 @@ begin
end; end;
FIsTrimming := True; FIsTrimming := True;
SendNotification(senrLineChange, self, fLineIndex, 1); SendNotification(senrLineChange, self, fLineIndex, 1);
if (fLineIndex <> TSynEditCaret(Sender).LinePos - 1) then begin if (fLineIndex <> TSynEditCaret(Sender).LinePos - 1) or
(FTrimType = settIgnoreAll) then begin
UndoList.AppendToLastChange(TSynEditUndoTrimForget.Create(FLineIndex+1, FSpaces)); UndoList.AppendToLastChange(TSynEditUndoTrimForget.Create(FLineIndex+1, FSpaces));
fSpaces := ''; fSpaces := '';
end else begin end else begin
@ -629,7 +631,7 @@ procedure TSynEditStringTrimmingList.EditInsertTrim(LogX, LogY: Integer;
var var
s: string; s: string;
begin begin
if AText = '' then if (AText = '') or (FTrimType = settIgnoreAll) then
exit; exit;
s := Spaces(LogY - 1); s := Spaces(LogY - 1);
StoreSpacesForLine(LogY - 1, StoreSpacesForLine(LogY - 1,
@ -643,7 +645,7 @@ function TSynEditStringTrimmingList.EditDeleteTrim(LogX, LogY, ByteLen:
var var
s: string; s: string;
begin begin
if ByteLen <= 0 then if (ByteLen <= 0) or (FTrimType = settIgnoreAll) then
exit(''); exit('');
s := Spaces(LogY - 1); s := Spaces(LogY - 1);
Result := copy(s, LogX, ByteLen); Result := copy(s, LogX, ByteLen);

View File

@ -1401,7 +1401,7 @@ begin
FShowGutterHints := True; FShowGutterHints := True;
fBlockIndent := 2; fBlockIndent := 2;
fBlockIndentType := sbitSpace; fBlockIndentType := sbitSpace;
FTrimSpaceType := settLeaveLine; FTrimSpaceType := settEditLine;
fUndoLimit := 32767; fUndoLimit := 32767;
fTabWidth := 8; fTabWidth := 8;
FBracketHighlightStyle := sbhsBoth; FBracketHighlightStyle := sbhsBoth;
@ -1526,7 +1526,7 @@ begin
'SpaceIndent')); 'SpaceIndent'));
FTrimSpaceType := GetTrimSpaceType FTrimSpaceType := GetTrimSpaceType
(XMLConfig.GetValue('EditorOptions/General/Editor/SpaceTrimType', (XMLConfig.GetValue('EditorOptions/General/Editor/SpaceTrimType',
'LeaveLine')); 'EditLine'));
fUndoLimit := fUndoLimit :=
XMLConfig.GetValue('EditorOptions/General/Editor/UndoLimit', 32767); XMLConfig.GetValue('EditorOptions/General/Editor/UndoLimit', 32767);
fTabWidth := fTabWidth :=
@ -1702,7 +1702,7 @@ begin
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'
, GetTrimSpaceName(FTrimSpaceType), 'LeaveLine'); , GetTrimSpaceName(FTrimSpaceType), 'EditLine');
XMLConfig.SetDeleteValue('EditorOptions/General/Editor/UndoLimit' XMLConfig.SetDeleteValue('EditorOptions/General/Editor/UndoLimit'
, fUndoLimit, 32767); , fUndoLimit, 32767);
XMLConfig.SetDeleteValue('EditorOptions/General/Editor/TabWidth' XMLConfig.SetDeleteValue('EditorOptions/General/Editor/TabWidth'
@ -1884,6 +1884,8 @@ begin
Result := 'EditLine'; Result := 'EditLine';
settMoveCaret: settMoveCaret:
Result := 'MoveCaret'; Result := 'MoveCaret';
settIgnoreAll:
Result := 'PosOnly';
end; end;
end; end;
@ -1893,7 +1895,9 @@ begin
if IndentName = 'EditLine' then if IndentName = 'EditLine' then
Result := settEditLine Result := settEditLine
else if IndentName = 'MoveCaret' then else if IndentName = 'MoveCaret' then
Result := settMoveCaret; Result := settMoveCaret
else if IndentName = 'PosOnly' then
Result := settIgnoreAll;
end; end;
function TEditorOptions.CreateSyn(LazSynHilighter: TLazSyntaxHighlighter): function TEditorOptions.CreateSyn(LazSynHilighter: TLazSyntaxHighlighter):

View File

@ -80,6 +80,7 @@ begin
EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeLeaveLine); EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeLeaveLine);
EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeEditLine); EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeEditLine);
EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeCaretMove); EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeCaretMove);
EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypePosOnly);
EditorTrimSpaceTypeLabel.Caption := dlgTrimSpaceTypeCaption; EditorTrimSpaceTypeLabel.Caption := dlgTrimSpaceTypeCaption;
end; end;

View File

@ -1154,6 +1154,7 @@ resourcestring
dlgTrimSpaceTypeLeaveLine = 'Leave line'; dlgTrimSpaceTypeLeaveLine = 'Leave line';
dlgTrimSpaceTypeEditLine = 'Line Edited'; dlgTrimSpaceTypeEditLine = 'Line Edited';
dlgTrimSpaceTypeCaretMove = 'Caret or Edit'; dlgTrimSpaceTypeCaretMove = 'Caret or Edit';
dlgTrimSpaceTypePosOnly = 'Position Only';
dlgUndoLimit = 'Undo limit'; dlgUndoLimit = 'Undo limit';
dlgTabWidths = 'Tab widths'; dlgTabWidths = 'Tab widths';
dlgMarginGutter = 'Margin and gutter'; dlgMarginGutter = 'Margin and gutter';