add a goto line command, close #170

This commit is contained in:
Basile Burg 2017-07-11 08:25:05 +02:00
parent 35ae9193bc
commit d22ff41d14
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
3 changed files with 60 additions and 22 deletions

View File

@ -93,43 +93,44 @@ inherited CEEditorWidget: TCEEditorWidget
Caption = 'Previous location'
OnClick = mnuedPrevClick
end
object mnuedNext: TMenuItem
Caption = 'Next location'
OnClick = mnuedNextClick
end
object MenuItem10: TMenuItem
Caption = '-'
end
object mnuedPrevCarea: TMenuItem
Caption = 'Previous changed area'
OnClick = mnuedPrevCareaClick
end
object mnuedNextCarea: TMenuItem
Caption = 'Next changed area'
OnClick = mnuedNextCareaClick
end
object MenuItem9: TMenuItem
Caption = '-'
end
object mnuedPrevProtGrp: TMenuItem
Caption = 'Previous protection attribute'
OnClick = mnuedPrevProtGrpClick
end
object mnuedNextProtGrp: TMenuItem
Caption = 'Next protection attribute'
OnClick = mnuedNextProtGrpClick
end
object MenuItem14: TMenuItem
Caption = '-'
end
object mnuedPrevWarn: TMenuItem
Caption = 'Previous warning'
OnClick = mnuedPrevWarnClick
end
object MenuItem10: TMenuItem
Caption = '-'
end
object mnuedNext: TMenuItem
Caption = 'Next location'
OnClick = mnuedNextClick
end
object mnuedNextCarea: TMenuItem
Caption = 'Next changed area'
OnClick = mnuedNextCareaClick
end
object mnuedNextProtGrp: TMenuItem
Caption = 'Next protection attribute'
OnClick = mnuedNextProtGrpClick
end
object mnuedNextWarn: TMenuItem
Caption = 'Next warning'
OnClick = mnuedNextWarnClick
end
object MenuItem9: TMenuItem
Caption = '-'
end
object mnuedGotoline: TMenuItem
Caption = 'Goto line...'
OnClick = mnuedGotolineClick
end
object MenuItem2: TMenuItem
Caption = '-'
end

View File

@ -58,7 +58,7 @@ type
MenuItem10: TMenuItem;
MenuItem11: TMenuItem;
MenuItem12: TMenuItem;
MenuItem14: TMenuItem;
mnuedGotoline: TMenuItem;
mnuedPrevWarn: TMenuItem;
mnuedNextWarn: TMenuItem;
mnuedDdocTmp: TMenuItem;
@ -94,6 +94,7 @@ type
editorStatus: TStatusBar;
mnuEditor: TPopupMenu;
procedure mnuedDdocTmpClick(Sender: TObject);
procedure mnuedGotolineClick(Sender: TObject);
procedure mnuedNextWarnClick(Sender: TObject);
procedure mnuedPrevProtGrpClick(Sender: TObject);
procedure mnuedNextProtGrpClick(Sender: TObject);
@ -921,6 +922,12 @@ begin
fDoc.insertDdocTemplate;
end;
procedure TCEEditorWidget.mnuedGotolineClick(Sender: TObject);
begin
if fDoc.isNotNil then
fDoc.gotoLinePrompt;
end;
procedure TCEEditorWidget.mnuedNextWarnClick(Sender: TObject);
begin
if fDoc.isNotNil then

View File

@ -343,6 +343,7 @@ type
procedure removeCurLineBreakPoint;
procedure toggleCurLineBreakpoint;
procedure insertDdocTemplate;
procedure gotoLinePrompt;
function implementMain: THasMain;
procedure replaceUndoableContent(const value: string);
procedure setDscannerOptions(dsEnabled: boolean; dsDelay: integer);
@ -429,6 +430,7 @@ const
ecInsertDdocTemplate = ecUserFirst + 25;
ecNextWarning = ecUserFirst + 26;
ecPrevWarning = ecUserFirst + 27;
ecGotoLine = ecUserFirst + 28;
var
D2Syn: TSynD2Syn; // used as model to set the options when no editor exists.
@ -1195,6 +1197,7 @@ begin
AddKey(ecInsertDdocTemplate, 0, [], 0, []);
AddKey(ecPrevWarning, 0, [], 0, []);
AddKey(ecNextWarning, 0, [], 0, []);
AddKey(ecGotoLine, 0, [], 0, []);
end;
end;
@ -1228,6 +1231,7 @@ begin
'ecInsertDdocTemplate': begin Int := ecInsertDdocTemplate; exit(true); end;
'ecPrevWarning': begin Int := ecPrevWarning; exit(true); end;
'ecNextWarning': begin Int := ecNextWarning; exit(true); end;
'ecGotoLine': begin Int := ecGotoLine; exit(true); end;
else exit(false);
end;
end;
@ -1262,6 +1266,7 @@ begin
ecInsertDdocTemplate: begin Ident := 'ecInsertDdocTemplate'; exit(true); end;
ecPrevWarning: begin Ident := 'ecPrevWarning'; exit(true); end;
ecNextWarning: begin Ident := 'ecNextWarning'; exit(true); end;
ecGotoLine: begin Ident := 'ecGotoLine'; exit(true); end;
else exit(false);
end;
end;
@ -1338,6 +1343,8 @@ begin
goToWarning(false);
ecNextWarning:
goToWarning(true);
ecGotoLine:
gotoLinePrompt;
end;
if fOverrideColMode and not SelAvail then
begin
@ -1786,6 +1793,29 @@ begin
goToWarning(true);
end;
procedure TCESynMemo.gotoLinePrompt;
var
d: string;
v: string;
i: integer;
begin
d := caretY.ToString;
v := InputBox('Goto line', 'line number', d);
if v.isNotEmpty and not v.Equals(d) then
begin
i := v.toIntNoExcept;
if i <> -1 then
begin
if i < 1 then
i := 1
else if i > lines.Count then
i := lines.Count;
CaretY:= i;
EnsureCursorPosVisible;
end;
end;
end;
procedure TCESynMemo.goToChangedArea(next: boolean);
var
i: integer;