added Enhance Home to editor options

git-svn-id: trunk@6929 -
This commit is contained in:
mattias 2005-03-09 12:19:26 +00:00
parent 7a5ea9c320
commit ab161e4a33
3 changed files with 53 additions and 30 deletions

View File

@ -164,7 +164,7 @@ type
eoDisableScrollArrows, //TODO Disables the scroll bar arrow buttons when you can't scroll in that direction any more
eoDragDropEditing, // Allows you to select a block of text and drag it within the document to another location
eoDropFiles, //TODO Allows the editor accept file drops
eoEnhanceHomeKey, //TODO enhances home key positioning, similar to visual studio
eoEnhanceHomeKey, // home key jumps to line start if nearer, similar to visual studio
eoGroupUndo, //TODO When undoing/redoing actions, handle all continous changes of the same kind in one call instead undoing/redoing each command separately
eoHalfPageScroll, // When scrolling with page-up and page-down commands, only scroll a half page at a time
eoHideShowScrollbars, //TODO if enabled, then the scrollbars will only show when necessary. If you have ScrollPastEOL, then it the horizontal bar will always be there (it uses MaxLength instead)
@ -9122,38 +9122,40 @@ var
OldPos: TPoint;
NewPos: TPoint;
begin
OldPos:=LogicalCaretXY;
NewPos:=OldPos;
if not (eoEnhanceHomeKey in fOptions) and (CaretX>1) then begin
// not at start of line -> jump to start of line
CaretX:=1;
exit;
end;
// calculate line start position
FirstNonBlank:=-1;
if CaretY<=Lines.Count then begin
s:=fLines[CaretXY.Y-1];
// search first non blank char pos
FirstNonBlank:=1;
while (FirstNonBlank<=length(s)) and (s[FirstNonBlank] in [#32, #9]) do
inc(FirstNonBlank);
if FirstNonBlank>length(s) then
FirstNonBlank:=-1;
end else
s:='';
if FirstNonBlank>=1 then begin
// this line is not blank
LineStart:=FirstNonBlank;
end else begin
// this line is blank
// -> use automatic line indent
LineStart:=GetLineIndentProposal(CaretY,true);
end;
OldPos:=LogicalCaretXY;
NewPos:=Point(LineStart,OldPos.Y);
if (eoEnhanceHomeKey in fOptions) and (OldPos.X<NewPos.X) then begin
NewPos.X:=1;
end else begin
// calculate line start position
FirstNonBlank:=-1;
if CaretY<=Lines.Count then begin
s:=fLines[CaretXY.Y-1];
// search first non blank char pos
FirstNonBlank:=1;
while (FirstNonBlank<=length(s)) and (s[FirstNonBlank] in [#32, #9]) do
inc(FirstNonBlank);
if FirstNonBlank>length(s) then
FirstNonBlank:=-1;
end else
s:='';
if FirstNonBlank>=1 then begin
// this line is not blank
LineStart:=FirstNonBlank;
end else begin
// this line is blank
// -> use automatic line indent
LineStart:=GetLineIndentProposal(CaretY,true);
end;
NewPos.X:=LineStart;
if (eoEnhanceHomeKey in fOptions) and (OldPos.X>1) and (OldPos.X<=NewPos.X)
then begin
NewPos.X:=1;
end;
end;
MoveCaretAndSelection(OldPos, NewPos, Selection);

View File

@ -313,6 +313,7 @@ type
FindTextAtCursorCheckBox:TCheckBox;
UseSyntaxHighlightCheckBox:TCheckBox;
CopyWordAtCursorOnCopyNoneCheckBox:TCheckBox;
EnhanceHomeKeyCheckBox:TCheckBox;
ShowGutterHintsCheckBox:TCheckBox;
MouseLinksCheckBox: TCheckBox;
BlockIndentComboBox:TComboBox;
@ -1191,6 +1192,7 @@ begin
eoDoubleClickSelectsLine:SynEditOptName:='DoubleClickSelectsLine';
eoDragDropEditing:SynEditOptName:='DragDropEditing';
eoDropFiles:SynEditOptName:='DropFiles';
eoEnhanceHomeKey:SynEditOptName:='EnhanceHomeKey';
eoHalfPageScroll:SynEditOptName:='HalfPageScroll';
eoKeepCaretX:SynEditOptName:='KeepCaretX';
eoPersistentCaret:SynEditOptName:='PersistentCaret';
@ -1317,6 +1319,7 @@ begin
eoDoubleClickSelectsLine:SynEditOptName:='DoubleClickSelectsLine';
eoDragDropEditing:SynEditOptName:='DragDropEditing';
eoDropFiles:SynEditOptName:='DropFiles';
eoEnhanceHomeKey:SynEditOptName:='EnhanceHomeKey';
eoHalfPageScroll:SynEditOptName:='HalfPageScroll';
eoKeepCaretX:SynEditOptName:='KeepCaretX';
eoPersistentCaret:SynEditOptName:='PersistentCaret';
@ -2411,6 +2414,7 @@ begin
SetOption(DoubleClickLineCheckBox,eoDoubleClickSelectsLine);
SetOption(DragDropEditingCheckBox,eoDragDropEditing);
SetOption(DropFilesCheckBox,eoDropFiles);
SetOption(EnhanceHomeKeyCheckBox,eoEnhanceHomeKey);
SetOption(HalfPageScrollCheckBox,eoHalfPageScroll);
SetOption(KeepCaretXCheckBox,eoKeepCaretX);
SetOption(PersistentCaretCheckBox,eoPersistentCaret);
@ -3679,6 +3683,17 @@ begin
end;
inc(y,ChkBoxH);
EnhanceHomeKeyCheckBox:=TCheckBox.Create(Self);
with EnhanceHomeKeyCheckBox do begin
Name:='EnhanceHomeKeyCheckBox';
Parent:=EditorOptionsGroupBox;
SetBounds(x,y,ChkBoxW,Height);
Caption:=dlgHomeKeyJumpsToNearestStart;
Checked:=eoEnhanceHomeKey in EditorOpts.SynEditOptions;
OnClick:=@GeneralCheckBoxOnClick;
end;
inc(y,ChkBoxH);
//
BlockIndentComboBox:=TComboBox.Create(Self);
@ -3919,6 +3934,11 @@ begin
end;
inc(y,ChkBoxH);
with EnhanceHomeKeyCheckBox do begin
SetBounds(x,y,ChkBoxW,Height);
end;
inc(y,ChkBoxH);
//
with BlockIndentComboBox do begin

View File

@ -778,6 +778,7 @@ resourcestring
dlgFindTextatCursor = 'Find text at cursor';
dlgUseSyntaxHighlight = 'Use syntax highlight';
dlgCopyWordAtCursorOnCopyNone = 'Copy word on copy none';
dlgHomeKeyJumpsToNearestStart = 'Home key jumps to nearest start';
dlgBlockIndent = 'Block indent:';
dlgUndoLimit = 'Undo limit:';
dlgTabWidths = 'Tab widths:';