SynEdit: implemented Caret skips tabs

git-svn-id: trunk@21587 -
This commit is contained in:
martin 2009-09-05 13:30:13 +00:00
parent 570d3db2fa
commit 194d83f7a8
7 changed files with 78 additions and 32 deletions

View File

@ -232,6 +232,7 @@ type
TSynEditorOption2 = (
eoCaretSkipsSelection, // Caret skips selection on VK_LEFT/VK_RIGHT
eoCaretSkipTab, // Caret can not enter tabs
eoAlwaysVisibleCaret, // Move caret to be always visible when scrolling
eoEnhanceEndKey, // end key jumps to visual/hard line end whichever is nearer
eoFoldedCopyPaste, // Remember folds in copy/paste operations
@ -6946,6 +6947,7 @@ begin
MoveCaretToVisibleArea;
if eoPersistentBlock in ChangedOptions then
FBlockSelection.Persistent := eoPersistentBlock in fOptions2;
FCaret.SkipTabs := (eoCaretSkipTab in fOptions2);
if (eoAutoHideCursor in ChangedOptions) and not(eoAutoHideCursor in fOptions2) then
UpdateCursor;
end;

View File

@ -179,6 +179,7 @@ type
FAdjustToNextChar: Boolean;
FMaxLeftChar: PInteger;
FChangeOnTouch: Boolean;
FSkipTabs: Boolean;
FTouched: Boolean;
procedure AdjustToChar;
@ -197,6 +198,7 @@ type
procedure SetLineBytePos(const AValue: TPoint);
function GetLineText: string;
procedure SetLineText(const AValue : string);
procedure SetSkipTabs(const AValue: Boolean);
protected
procedure DoLock; override;
Procedure DoUnlock; override;
@ -222,6 +224,7 @@ type
property LineBytePos: TPoint read GetLineBytePos write SetLineBytePos;
property LineText: string read GetLineText write SetLineText;
property AdjustToNextChar: Boolean read FAdjustToNextChar write FAdjustToNextChar;
property SkipTabs: Boolean read FSkipTabs write SetSkipTabs;
property AllowPastEOL: Boolean read FAllowPastEOL write SetAllowPastEOL;
property KeepCaretX: Boolean read FKeepCaretX write SetKeepCaretX;
property MaxLeftChar: PInteger write FMaxLeftChar;
@ -386,7 +389,7 @@ begin
while LogPos < LogLen do begin
if ScreenPos = FCharPos then exit;
if ScreenPos + CharWidths[LogPos] > FCharPos then begin
if L[LogPos+1] = #9 then exit;
if (L[LogPos+1] = #9) and (not FSkipTabs) then exit;
if FAdjustToNextChar or (FForceAdjustToNextChar > 0) then
FCharPos := ScreenPos + CharWidths[LogPos]
else
@ -505,6 +508,17 @@ begin
FLines[LinePos - 1] := AValue;
end;
procedure TSynEditCaret.SetSkipTabs(const AValue: Boolean);
begin
if FSkipTabs = AValue then exit;
FSkipTabs := AValue;
if FSkipTabs then begin
Lock;
AdjustToChar;
Unlock;
end;
end;
procedure TSynEditCaret.DoLock;
begin
FTouched := False;

View File

@ -2535,6 +2535,8 @@ begin
case SynEditOpt2 of
eoCaretSkipsSelection:
SynEditOptName := 'CaretSkipsSelection';
eoCaretSkipTab:
SynEditOptName := 'CaretSkipTab';
eoAlwaysVisibleCaret:
SynEditOptName := 'AlwaysVisibleCaret';
eoEnhanceEndKey:
@ -2777,6 +2779,8 @@ begin
case SynEditOpt2 of
eoCaretSkipsSelection:
SynEditOptName := 'CaretSkipsSelection';
eoCaretSkipTab:
SynEditOptName := 'CaretSkipTab';
eoAlwaysVisibleCaret:
SynEditOptName := 'AlwaysVisibleCaret';
eoEnhanceEndKey:

View File

@ -518,10 +518,10 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
end
object HomeKeyJumpsToNearestStartCheckBox: TCheckBox[36]
AnchorSideLeft.Control = CursorSkipsSelectionCheckBox
AnchorSideTop.Control = PersistentCursorCheckBox
AnchorSideTop.Control = AlwaysVisibleCursorCheckBox
Left = 236
Height = 19
Top = 291
Top = 310
Width = 236
Caption = 'HomeKeyJumpsToNearestStartCheckBox'
OnChange = HomeKeyJumpsToNearestStartCheckBoxChange
@ -529,10 +529,10 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
end
object EndKeyJumpsToNearestStartCheckBox: TCheckBox[37]
AnchorSideLeft.Control = HomeKeyJumpsToNearestStartCheckBox
AnchorSideTop.Control = AlwaysVisibleCursorCheckBox
AnchorSideTop.Control = ScrollPastEndLineCheckBox
Left = 236
Height = 19
Top = 310
Top = 329
Width = 223
Caption = 'EndKeyJumpsToNearestStartCheckBox'
OnChange = EndKeyJumpsToNearestStartCheckBoxChange
@ -585,4 +585,15 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
OnChange = OverwriteBlockCheckBoxChange
TabOrder = 21
end
object CursorSkipsTabCheckBox: TCheckBox[41]
AnchorSideLeft.Control = CursorSkipsSelectionCheckBox
AnchorSideTop.Control = PersistentCursorCheckBox
Left = 236
Height = 19
Top = 291
Width = 154
Caption = 'CursorSkipsTabCheckBox'
OnChange = CursorSkipsTabCheckBoxChange
TabOrder = 22
end
end

View File

@ -191,31 +191,35 @@ LazarusResources.Add('TEditorGeneralOptionsFrame','FORMDATA',[
+'und'#2#6#7'Caption'#6#28'CursorSkipsSelectionCheckBox'#8'OnChange'#7'"Curso'
+'rSkipsSelectionCheckBoxChange'#8'TabOrder'#2#16#0#0#242#2'$'#9'TCheckBox"Ho'
+'meKeyJumpsToNearestStartCheckBox'#22'AnchorSideLeft.Control'#7#28'CursorSki'
+'psSelectionCheckBox'#21'AnchorSideTop.Control'#7#24'PersistentCursorCheckBo'
+'x'#4'Left'#3#236#0#6'Height'#2#19#3'Top'#3'#'#1#5'Width'#3#236#0#7'Caption'
,#6'"HomeKeyJumpsToNearestStartCheckBox'#8'OnChange'#7'(HomeKeyJumpsToNearest'
+'StartCheckBoxChange'#8'TabOrder'#2#17#0#0#242#2'%'#9'TCheckBox!EndKeyJumpsT'
+'oNearestStartCheckBox'#22'AnchorSideLeft.Control'#7'"HomeKeyJumpsToNearestS'
+'tartCheckBox'#21'AnchorSideTop.Control'#7#27'AlwaysVisibleCursorCheckBox'#4
+'Left'#3#236#0#6'Height'#2#19#3'Top'#3'6'#1#5'Width'#3#223#0#7'Caption'#6'!E'
+'ndKeyJumpsToNearestStartCheckBox'#8'OnChange'#7'''EndKeyJumpsToNearestStart'
+'CheckBoxChange'#8'TabOrder'#2#18#0#0#242#2'&'#9'TComboBox'#23'BlockIndentTy'
+'peComboBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'
+#7#19'BlockIndentComboBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#24'AnchorSi'
+'deBottom.Control'#7#17'TabWidthsComboBox'#4'Left'#2#6#6'Height'#2#23#3'Top'
+#3#221#0#5'Width'#2'd'#18'BorderSpacing.Left'#2#6#17'BorderSpacing.Top'#2#3
+#10'ItemHeight'#2#15#9'ItemWidth'#3#200#0#8'OnChange'#7#16'ComboboxOnChange'
+#6'OnExit'#7#14'ComboBoxOnExit'#9'OnKeyDown'#7#17'ComboboxOnKeyDown'#5'Style'
+#7#14'csDropDownList'#8'TabOrder'#2#19#0#0#242#2''''#9'TCheckBox'#23'Persist'
+'entBlockCheckBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Co'
+'ntrol'#7#15'BlockGroupLabel'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2
+#6#6'Height'#2#19#3'Top'#3'x'#1#5'Width'#3#152#0#18'BorderSpacing.Left'#2#6
+#17'BorderSpacing.Top'#2#6#7'Caption'#6#23'PersistentBlockCheckBox'#8'OnChan'
+'ge'#7#29'PersistentBlockCheckBoxChange'#8'TabOrder'#2#20#0#0#242#2'('#9'TCh'
+'eckBox'#22'OverwriteBlockCheckBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21
+'AnchorSideTop.Control'#7#15'BlockGroupLabel'#18'AnchorSideTop.Side'#7#9'asr'
+'Bottom'#4'Left'#3#236#0#6'Height'#2#19#3'Top'#3'x'#1#5'Width'#3#152#0#18'Bo'
+'rderSpacing.Left'#3#230#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#22'Over'
+'writeBlockCheckBox'#8'OnChange'#7#28'OverwriteBlockCheckBoxChange'#8'TabOrd'
+'er'#2#21#0#0#0
+'psSelectionCheckBox'#21'AnchorSideTop.Control'#7#27'AlwaysVisibleCursorChec'
+'kBox'#4'Left'#3#236#0#6'Height'#2#19#3'Top'#3'6'#1#5'Width'#3#236#0#7'Capti'
,'on'#6'"HomeKeyJumpsToNearestStartCheckBox'#8'OnChange'#7'(HomeKeyJumpsToNea'
+'restStartCheckBoxChange'#8'TabOrder'#2#17#0#0#242#2'%'#9'TCheckBox!EndKeyJu'
+'mpsToNearestStartCheckBox'#22'AnchorSideLeft.Control'#7'"HomeKeyJumpsToNear'
+'estStartCheckBox'#21'AnchorSideTop.Control'#7#25'ScrollPastEndLineCheckBox'
+#4'Left'#3#236#0#6'Height'#2#19#3'Top'#3'I'#1#5'Width'#3#223#0#7'Caption'#6
+'!EndKeyJumpsToNearestStartCheckBox'#8'OnChange'#7'''EndKeyJumpsToNearestSta'
+'rtCheckBoxChange'#8'TabOrder'#2#18#0#0#242#2'&'#9'TComboBox'#23'BlockIndent'
+'TypeComboBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Contro'
+'l'#7#19'BlockIndentComboBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#24'Ancho'
+'rSideBottom.Control'#7#17'TabWidthsComboBox'#4'Left'#2#6#6'Height'#2#23#3'T'
+'op'#3#221#0#5'Width'#2'd'#18'BorderSpacing.Left'#2#6#17'BorderSpacing.Top'#2
+#3#10'ItemHeight'#2#15#9'ItemWidth'#3#200#0#8'OnChange'#7#16'ComboboxOnChang'
+'e'#6'OnExit'#7#14'ComboBoxOnExit'#9'OnKeyDown'#7#17'ComboboxOnKeyDown'#5'St'
+'yle'#7#14'csDropDownList'#8'TabOrder'#2#19#0#0#242#2''''#9'TCheckBox'#23'Pe'
+'rsistentBlockCheckBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideT'
+'op.Control'#7#15'BlockGroupLabel'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'L'
+'eft'#2#6#6'Height'#2#19#3'Top'#3'x'#1#5'Width'#3#152#0#18'BorderSpacing.Lef'
+'t'#2#6#17'BorderSpacing.Top'#2#6#7'Caption'#6#23'PersistentBlockCheckBox'#8
+'OnChange'#7#29'PersistentBlockCheckBoxChange'#8'TabOrder'#2#20#0#0#242#2'('
+#9'TCheckBox'#22'OverwriteBlockCheckBox'#22'AnchorSideLeft.Control'#7#5'Owne'
+'r'#21'AnchorSideTop.Control'#7#15'BlockGroupLabel'#18'AnchorSideTop.Side'#7
+#9'asrBottom'#4'Left'#3#236#0#6'Height'#2#19#3'Top'#3'x'#1#5'Width'#3#152#0
+#18'BorderSpacing.Left'#3#230#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#22
+'OverwriteBlockCheckBox'#8'OnChange'#7#28'OverwriteBlockCheckBoxChange'#8'Ta'
+'bOrder'#2#21#0#0#242#2')'#9'TCheckBox'#22'CursorSkipsTabCheckBox'#22'Anchor'
+'SideLeft.Control'#7#28'CursorSkipsSelectionCheckBox'#21'AnchorSideTop.Contr'
+'ol'#7#24'PersistentCursorCheckBox'#4'Left'#3#236#0#6'Height'#2#19#3'Top'#3
+'#'#1#5'Width'#3#154#0#7'Caption'#6#22'CursorSkipsTabCheckBox'#8'OnChange'#7
+#28'CursorSkipsTabCheckBoxChange'#8'TabOrder'#2#22#0#0#0
]);

View File

@ -50,6 +50,7 @@ type
AutoIndentCheckBox: TCheckBox;
BlockIndentTypeLabel: TLabel;
BlockGroupLabel: TLabel;
CursorSkipsTabCheckBox: TCheckBox;
EndKeyJumpsToNearestStartCheckBox: TCheckBox;
KeepCursorXCheckBox: TCheckBox;
OverwriteBlockCheckBox: TCheckBox;
@ -82,6 +83,7 @@ type
Shift: TShiftState);
procedure CursorSkipsSelectionCheckBoxChange(Sender: TObject);
procedure ComboBoxOnExit(Sender: TObject);
procedure CursorSkipsTabCheckBoxChange(Sender: TObject);
procedure EndKeyJumpsToNearestStartCheckBoxChange(Sender: TObject);
procedure GroupUndoCheckBoxChange(Sender: TObject);
procedure HalfPageScrollCheckBoxChange(Sender: TObject);
@ -157,6 +159,7 @@ begin
PersistentCursorCheckBox.Caption := dlgPersistentCursor;
AlwaysVisibleCursorCheckBox.Caption := dlgAlwaysVisibleCursor;
CursorSkipsSelectionCheckBox.Caption := dlgCursorSkipsSelection;
CursorSkipsTabCheckBox.Caption := dlgCursorSkipsTab;
HomeKeyJumpsToNearestStartCheckBox.Caption := dlgHomeKeyJumpsToNearestStart;
EndKeyJumpsToNearestStartCheckBox.Caption := dlgEndKeyJumpsToNearestStart;
@ -198,6 +201,7 @@ begin
PersistentCursorCheckBox.Checked := eoPersistentCaret in SynEditOptions;
AlwaysVisibleCursorCheckBox.Checked := eoAlwaysVisibleCaret in SynEditOptions2;
CursorSkipsSelectionCheckBox.Checked := eoCaretSkipsSelection in SynEditOptions2;
CursorSkipsTabCheckBox.Checked := eoCaretSkipTab in SynEditOptions2;
HomeKeyJumpsToNearestStartCheckBox.Checked := eoEnhanceHomeKey in SynEditOptions;
EndKeyJumpsToNearestStartCheckBox.Checked := eoEnhanceEndKey in SynEditOptions2;
@ -276,6 +280,7 @@ begin
UpdateOptionFromBool(PersistentCursorCheckBox.Checked, eoPersistentCaret);
UpdateOptionFromBool(AlwaysVisibleCursorCheckBox.Checked, eoAlwaysVisibleCaret);
UpdateOptionFromBool(CursorSkipsSelectionCheckBox.Checked, eoCaretSkipsSelection);
UpdateOptionFromBool(CursorSkipsTabCheckBox.Checked, eoCaretSkipTab);
UpdateOptionFromBool(HomeKeyJumpsToNearestStartCheckBox.Checked, eoEnhanceHomeKey);
UpdateOptionFromBool(EndKeyJumpsToNearestStartCheckBox.Checked, eoEnhanceEndKey);
@ -373,6 +378,11 @@ begin
end
end;
procedure TEditorGeneralOptionsFrame.CursorSkipsTabCheckBoxChange(Sender: TObject);
begin
SetPreviewOption(CursorSkipsTabCheckBox.Checked, eoCaretSkipTab);
end;
procedure TEditorGeneralOptionsFrame.EndKeyJumpsToNearestStartCheckBoxChange(
Sender: TObject);
begin

View File

@ -1153,6 +1153,7 @@ resourcestring
dlgPersistentBlock = 'Persistent Block';
dlgOverwriteBlock = 'Overwrite Block';
dlgCursorSkipsSelection = 'Cursor skips selection';
dlgCursorSkipsTab = 'Cursor skips tabs';
dlgScrollByOneLess = 'Scroll by one less';
dlgScrollPastEndFile = 'Scroll past end of file';
dlgScrollPastEndLine = 'Caret past end of line';