From 2ee704d7f92b25783a8a52f11df9b842ce0d391b Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Thu, 5 Nov 2009 17:46:39 +0200 Subject: implemented new command line parameters * Fixed search by topic id * Implement search by topic name * Reworked the available parameters * Added extra debug information for INF file. --- src/frm_main.pas | 67 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/frm_main.pas b/src/frm_main.pas index 310c458e..37d50582 100644 --- a/src/frm_main.pas +++ b/src/frm_main.pas @@ -135,6 +135,8 @@ type procedure ShowParamHelp; function FindTopicForLink( Link: THelpLink ): TTopic; function FindTopicByResourceID( ID: word ): TTopic; + function FindTopicByName(const AName: string): TTopic; + public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -164,7 +166,7 @@ uses const cLongName = 'fpGUI Documentation Viewer'; cCreatedBy = 'Created by Graeme Geldenhuys'; - cVersion = 'Version 1.0 (alpha)'; + cVersion = 'Version 0.7 (alpha)'; {@VFD_NEWFORM_IMPL} @@ -306,6 +308,8 @@ begin Add('Dictionary count: ' + IntToStr(f.DictionaryCount)); Add('Topic count: ' + IntToStr(f.TopicCount)); Add('Index count: ' + IntToStr(f.Index.Count)); + Add('String resource id count: ' + IntToStr(f.StringResourceIDCount)); + Add('Numeric resource id count: ' + IntToStr(f.NumericResourceIDCount)); Add(' '); //Add('Dictionary contents:'); //for i := 0 to f.DictionaryCount-1 do @@ -530,9 +534,7 @@ end; procedure TMainForm.MainFormCloseQuery(Sender: TObject; var CanClose: boolean); begin -writeln('DEBUG: TMainForm.MainFormCloseQuery >>>>>'); CloseFile(True); -writeln('DEBUG: TMainForm.MainFormCloseQuery <<<<<'); end; procedure TMainForm.PageControl1Change(Sender: TObject; NewActiveSheet: TfpgTabSheet); @@ -2035,29 +2037,51 @@ end; procedure TMainForm.ProcessCommandLineParams; var showtopic: boolean; + t: TTopic; begin if ParamCount > 0 then begin if gCommandLineParams.IsParam('h') then begin ShowParamHelp; - Exit; + Exit; //==> end else if gCommandLineParams.IsParam('debuglog') then // do nothing else begin - showtopic := not gCommandLineParams.IsParam('s'); +//writeln('DEBUG: TMainForm.ProcessCommandLineParams - Open file...'); + showtopic := not gCommandLineParams.IsParam('k'); OpenFile(ParamStr(1), '', showtopic); end; end; // now process all other parameters - if gCommandLineParams.IsParam('s') then + if gCommandLineParams.IsParam('k') then begin - edSearchText.Text := gCommandLineParams.GetParam('s'); +//writeln('DEBUG: TMainForm.ProcessCommandLineParams - Keyword Search string'); + { Search for a string } + edSearchText.Text := gCommandLineParams.GetParam('k'); PageControl1.ActivePage := tsSearch; btnSearch.Click; + end + else if gCommandLineParams.IsParam('n') then + begin + { Display topic with numeric topic id } +//writeln('DEBUG: TMainForm.ProcessCommandLineParams - Display numeric topic id'); + t := FindTopicByResourceID(StrToInt(gCommandLineParams.GetParam('n'))); +//if not Assigned(t) then +// writeln(Format('Failed to find topic <%s>', [gCommandLineParams.GetParam('n')])); + DisplayTopic(t); + end + else if gCommandLineParams.IsParam('s') then + begin +//writeln('DEBUG: TMainForm.ProcessCommandLineParams - display string topic id'); + { Display topic with string topic id } + t := FindTopicByName(gCommandLineParams.GetParam('s')); +//if not Assigned(t) then +// writeln(Format('Failed to find topic <%s>', [gCommandLineParams.GetParam('k')])); + DisplayTopic(t); end; end; @@ -2071,10 +2095,11 @@ begin + cVersion + le + le + 'Supported command line parameters:' + le + le + '' - + ' < Load the help file <' + le - + ' -h Show this help' + le - + ' -s< Search for < in open help files' + le - + ' -t< Open Topic with ID equal to <' + le + + ' < Load the help file <' + le + + ' -h Show this help' + le + + ' -k < Search for keyword < in open help files' + le + + ' -n < Open Topic with numeric ID equal to <' + le + + ' -s < Open Topic with string ID equal to <' + le + ' -debuglog < Log information to a file' + le + '' ; @@ -2109,7 +2134,7 @@ var begin for FileIndex := 0 to CurrentOpenFiles.Count - 1 do begin - HelpFile := THelpFile(CurrentOpenFiles[ id ]); + HelpFile := THelpFile(CurrentOpenFiles[ FileIndex ]); Result := HelpFile.FindTopicByResourceID( ID ); if Result <> nil then @@ -2121,5 +2146,23 @@ begin Result := nil; end; +function TMainForm.FindTopicByName(const AName: string): TTopic; +var + FileIndex: longint; + HelpFile: THelpFile; +begin + Result := nil; + for FileIndex := 0 to CurrentOpenFiles.Count - 1 do + begin + HelpFile := THelpFile(CurrentOpenFiles[ FileIndex ]); + Result := HelpFile.FindTopicByLocalName(AName); + if Result <> nil then + // found + exit; //==> + end; + // not found. + Result := nil; +end; + end. -- cgit v1.2.3-70-g09d2