summaryrefslogtreecommitdiff
path: root/src/frm_main.pas
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2009-10-21 10:31:30 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2009-10-21 10:31:30 +0200
commit1b0638852d202a17b264b02911341d44a0a81cc2 (patch)
treebdb3ea065533059f73a5ba95070568fda2a0ed63 /src/frm_main.pas
parent3a4a50d655c8c6205b94d315bd83a90e49206498 (diff)
downloadfpGUI-1b0638852d202a17b264b02911341d44a0a81cc2.tar.xz
Improved cmdline parameter handling and sync navigation.
* Parameter handling now handles environment variables expanded to file names. * Parameter handling of Concatenated file names. * When searching and displaying a topic, the Contents treeview is synchronized with that Topic. Signed-off-by: Graeme Geldenhuys <graeme@mastermaths.co.za>
Diffstat (limited to 'src/frm_main.pas')
-rw-r--r--src/frm_main.pas40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/frm_main.pas b/src/frm_main.pas
index f51df9e0..bb37f1b9 100644
--- a/src/frm_main.pas
+++ b/src/frm_main.pas
@@ -77,7 +77,7 @@ type
IndexLoaded: boolean;
ContentsLoaded: boolean;
DisplayedIndex: TStringList; // duplicate of index listbox, for fast case insensitive searching
-
+ CurrentTopic: TTopic; // so we can get easy access to current topic viewed
procedure MainFormShow(Sender: TObject);
procedure MainFormDestroy(Sender: TObject);
@@ -501,7 +501,7 @@ end;
procedure TMainForm.lbSearchResultsDoubleClick(Sender: TObject; AButton: TMouseButton;
AShift: TShiftState; const AMousePos: TPoint);
begin
- DisplayTopic(nil);
+ DisplaySelectedSearchResultTopic;
end;
procedure TMainForm.btnSearchClicked(Sender: TObject);
@@ -510,8 +510,16 @@ begin
end;
procedure TMainForm.DisplaySelectedSearchResultTopic;
+var
+ Topic: TTopic;
begin
- //
+ if lbSearchResults.FocusItem = -1 then
+ exit;
+ if lbSearchResults.Items.Objects[lbSearchResults.FocusItem] = nil then
+ // the "no results" place holder
+ exit;
+ Topic := lbSearchResults.Items.Objects[lbSearchResults.FocusItem] as TTopic;
+ DisplayTopic( Topic );
end;
procedure TMainForm.EnableControls;
@@ -914,11 +922,9 @@ var
tmpFileNames: TStringList;
begin
tmpFileNames := TStringList.Create;
- { TODO -ograemeg -copen files : Implement ParseAndExpandFilenames }
- tmpFileNames.Add(AFileName);
-// ParseAndExpandFileNames(FileName, tmpFileNames);
+ ParseAndExpandFileNames(AFileName, tmpFileNames);
Result := OpenFiles( tmpFileNames, AWindowTitle, DisplayFirstTopic );
- tmpFileNames.Destroy;
+ tmpFileNames.Free;
end;
procedure TMainForm.CloseFile(const ADestroying: boolean = False);
@@ -1328,11 +1334,13 @@ Begin
if Topic = nil then
raise Exception.Create('Unable to locate the Topic');
+ CurrentTopic:= Topic;
+
RichView.Clear;
ImageIndices := TList.Create;
ProfileEvent('Cleared memo...');
- HelpFile := TopicFile(Topic);
+ HelpFile := TopicFile(CurrentTopic);
if HelpFile = nil then
raise Exception.Create('Failed to get active HelpFile from Topic');
@@ -1342,11 +1350,8 @@ Begin
ProfileEvent('Debug show hex values = ' + BoolToStr(Debug));
if ImageIndices <> nil then
ProfileEvent('ImageIndices initialized');
- //Topic.GetText(HelpFile.HighlightWords,
- // Debug,
- // lText,
- // ImageIndices);
- Topic.GetText( nil {HighlightWordSequences},
+
+ CurrentTopic.GetText( nil {HighlightWordSequences},
Debug {ShowCodes},
False {ShowWordIndices},
lText {TopicText},
@@ -1359,6 +1364,8 @@ Begin
//writeln(lText);
//writeln('-----------------------------');
RichView.AddText(PChar(lText));
+
+ tvContents.Selection := tvContents.RootNode.FindSubNode(CurrentTopic, True);
end;
procedure TMainForm.ResetProgress;
@@ -1404,6 +1411,7 @@ var
lHelpFile: THelpFile;
begin
writeln('DEBUG: TMainForm.Destroy >>>>');
+ CurrentTopic := nil; // it was a reference only
FFileOpenRecent := nil; // it was a reference only
DestroyListAndObjects(Files);
DestroyListAndObjects(AllFilesWordSequences);
@@ -1934,11 +1942,13 @@ procedure TMainForm.ProcessCommandLineParams;
var
showtopic: boolean;
begin
- // always load file first, otherwise show help
if ParamCount > 0 then
begin
if gCommandLineParams.IsParam('h') then
- ShowParamHelp
+ begin
+ ShowParamHelp;
+ Exit;
+ end
else
begin
showtopic := not gCommandLineParams.IsParam('s');