mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-16 12:09:32 +02:00
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:
parent
dcc5e60570
commit
19be7391db
@ -33,7 +33,8 @@ LCLProc,
|
||||
|
||||
type
|
||||
|
||||
TSynEditStringTrimmingType = (settLeaveLine, settEditLine, settMoveCaret);
|
||||
TSynEditStringTrimmingType = (settLeaveLine, settEditLine, settMoveCaret,
|
||||
settIgnoreAll);
|
||||
|
||||
{ TSynEditStringTrimmingList }
|
||||
|
||||
@ -314,7 +315,8 @@ begin
|
||||
end;
|
||||
FIsTrimming := True;
|
||||
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));
|
||||
fSpaces := '';
|
||||
end else begin
|
||||
@ -629,7 +631,7 @@ procedure TSynEditStringTrimmingList.EditInsertTrim(LogX, LogY: Integer;
|
||||
var
|
||||
s: string;
|
||||
begin
|
||||
if AText = '' then
|
||||
if (AText = '') or (FTrimType = settIgnoreAll) then
|
||||
exit;
|
||||
s := Spaces(LogY - 1);
|
||||
StoreSpacesForLine(LogY - 1,
|
||||
@ -643,7 +645,7 @@ function TSynEditStringTrimmingList.EditDeleteTrim(LogX, LogY, ByteLen:
|
||||
var
|
||||
s: string;
|
||||
begin
|
||||
if ByteLen <= 0 then
|
||||
if (ByteLen <= 0) or (FTrimType = settIgnoreAll) then
|
||||
exit('');
|
||||
s := Spaces(LogY - 1);
|
||||
Result := copy(s, LogX, ByteLen);
|
||||
|
@ -1401,7 +1401,7 @@ begin
|
||||
FShowGutterHints := True;
|
||||
fBlockIndent := 2;
|
||||
fBlockIndentType := sbitSpace;
|
||||
FTrimSpaceType := settLeaveLine;
|
||||
FTrimSpaceType := settEditLine;
|
||||
fUndoLimit := 32767;
|
||||
fTabWidth := 8;
|
||||
FBracketHighlightStyle := sbhsBoth;
|
||||
@ -1526,7 +1526,7 @@ begin
|
||||
'SpaceIndent'));
|
||||
FTrimSpaceType := GetTrimSpaceType
|
||||
(XMLConfig.GetValue('EditorOptions/General/Editor/SpaceTrimType',
|
||||
'LeaveLine'));
|
||||
'EditLine'));
|
||||
fUndoLimit :=
|
||||
XMLConfig.GetValue('EditorOptions/General/Editor/UndoLimit', 32767);
|
||||
fTabWidth :=
|
||||
@ -1702,7 +1702,7 @@ begin
|
||||
XMLConfig.SetDeleteValue('EditorOptions/General/Editor/BlockIndentType'
|
||||
, GetSynBeautifierIndentName(fBlockIndentType), 'SpaceIndent');
|
||||
XMLConfig.SetDeleteValue('EditorOptions/General/Editor/SpaceTrimType'
|
||||
, GetTrimSpaceName(FTrimSpaceType), 'LeaveLine');
|
||||
, GetTrimSpaceName(FTrimSpaceType), 'EditLine');
|
||||
XMLConfig.SetDeleteValue('EditorOptions/General/Editor/UndoLimit'
|
||||
, fUndoLimit, 32767);
|
||||
XMLConfig.SetDeleteValue('EditorOptions/General/Editor/TabWidth'
|
||||
@ -1884,6 +1884,8 @@ begin
|
||||
Result := 'EditLine';
|
||||
settMoveCaret:
|
||||
Result := 'MoveCaret';
|
||||
settIgnoreAll:
|
||||
Result := 'PosOnly';
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1893,7 +1895,9 @@ begin
|
||||
if IndentName = 'EditLine' then
|
||||
Result := settEditLine
|
||||
else if IndentName = 'MoveCaret' then
|
||||
Result := settMoveCaret;
|
||||
Result := settMoveCaret
|
||||
else if IndentName = 'PosOnly' then
|
||||
Result := settIgnoreAll;
|
||||
end;
|
||||
|
||||
function TEditorOptions.CreateSyn(LazSynHilighter: TLazSyntaxHighlighter):
|
||||
|
@ -80,6 +80,7 @@ begin
|
||||
EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeLeaveLine);
|
||||
EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeEditLine);
|
||||
EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeCaretMove);
|
||||
EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypePosOnly);
|
||||
EditorTrimSpaceTypeLabel.Caption := dlgTrimSpaceTypeCaption;
|
||||
end;
|
||||
|
||||
|
@ -1154,6 +1154,7 @@ resourcestring
|
||||
dlgTrimSpaceTypeLeaveLine = 'Leave line';
|
||||
dlgTrimSpaceTypeEditLine = 'Line Edited';
|
||||
dlgTrimSpaceTypeCaretMove = 'Caret or Edit';
|
||||
dlgTrimSpaceTypePosOnly = 'Position Only';
|
||||
dlgUndoLimit = 'Undo limit';
|
||||
dlgTabWidths = 'Tab widths';
|
||||
dlgMarginGutter = 'Margin and gutter';
|
||||
|
Loading…
Reference in New Issue
Block a user