From 03bd6f043e2a6cda9ddc94e56fd1d39eccb348d7 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Wed, 13 Mar 2013 17:10:42 +0000 Subject: ide: Implements a "Go to line" search option. Finally the IDE is starting to become useful now. :) --- examples/apps/ide/src/frm_main.pas | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'examples/apps') diff --git a/examples/apps/ide/src/frm_main.pas b/examples/apps/ide/src/frm_main.pas index 6d4e81b7..6dd31a31 100644 --- a/examples/apps/ide/src/frm_main.pas +++ b/examples/apps/ide/src/frm_main.pas @@ -76,6 +76,7 @@ type procedure miFindClicked(Sender: TObject); procedure miFindNextClicked(Sender: TObject); procedure miFindPrevClicked(Sender: TObject); + procedure miGoToLineClick(Sender: TObject); procedure miSearchProcedureList(Sender: TObject); procedure miAboutFPGuiClicked(Sender: TObject); procedure miAboutIDE(Sender: TObject); @@ -262,6 +263,27 @@ begin edt.SetFocus; end; +procedure TMainForm.miGoToLineClick(Sender: TObject); +var + sValue: string; + i: integer; + edt: TfpgTextEdit; +begin + edt := TfpgTextEdit(pcEditor.ActivePage.Components[0]); + if not Assigned(edt) then + Exit; + if fpgInputQuery('Go to line', 'Go to line number?', sValue) then + begin + try + i := StrToInt(sValue); + edt.GotoLine(i); + except + on E: Exception do + ShowMessage('Invalid line number.' + LineEnding + E.Message); + end; + end; +end; + procedure TMainForm.miSearchProcedureList(Sender: TObject); var s: TfpgString; @@ -1493,6 +1515,7 @@ begin AddMenuItem('Replace...', rsKeyCtrl+'R', nil).Enabled := False; AddMenuItem('-', '', nil); AddMenuItem('Procedure List...', rsKeyCtrl+'G', @miSearchProcedureList); + AddMenuItem('Go to line...', rsKeyAlt+'G', @miGoToLineClick); end; mnuView := TfpgPopupMenu.Create(self); -- cgit v1.2.3-70-g09d2