Changeset 342
- Timestamp:
- Jun 1, 2009, 2:42:16 PM (16 years ago)
- Location:
- trunk/NewView
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NewView/CmdLineParameterUnit.pas
r259 r342 86 86 end; 87 87 88 89 // add all file name parts of aFileNameString to the result 90 // check for containing environment vars 91 // and include all help files if the environment var points 92 // to a directory 93 PROCEDURE ParseAndExpandFileNames(const aFileNameString: String; aResult: TStrings ); 94 95 88 96 // returns a string containing the whole 89 97 // command line parametes … … 680 688 681 689 690 PROCEDURE ParseAndExpandFileNames(const aFileNameString : String; aResult: TStrings); 691 var 692 i : longint; 693 tmpFileNamesList: TStringList; 694 tmpItem: String; 695 tmpEnvironmentVarValue: string; 696 begin 697 LogEvent(LogDebug, 'ParseAndExpandFileNames "' + aFileNameString + '"'); 698 699 tmpFileNamesList := TStringList.Create; 700 701 StrExtractStrings(tmpFileNamesList, aFileNameString, [HELP_FILE_DELIMITER, PATH_SEPARATOR], #0); 702 for i := 0 to tmpFileNamesList.Count - 1 do 703 begin 704 tmpItem := tmpFileNamesList[i]; 705 706 // is this a environment var 707 tmpEnvironmentVarValue := GetEnv(tmpItem); 708 if DosError = 0 then 709 begin 710 // environment var exists 711 LogEvent(LogStartup, ' Environment var found; translated to: "' + tmpEnvironmentVarValue + '"'); 712 ParseAndExpandFileNames(tmpEnvironmentVarValue, aResult); 713 end 714 else if DirectoryExists(tmpItem) then 715 begin 716 ListFilesInDirectory(tmpItem, '*' + HELP_FILE_EXTENSION, true, aResult); 717 end 718 else 719 begin 720 aResult.Add(tmpItem); 721 end; 722 end; 723 724 tmpFileNamesList.Destroy; 725 end; 726 727 682 728 FUNCTION nativeOS2GetCmdLineParameter : AnsiString; 683 729 VAR -
trunk/NewView/HelpFile.pas
r252 r342 22 22 23 23 type 24 25 TIndexEntry = class 26 private 27 name: String; 28 topic: TTopic; 29 flags: uint8; 30 public 31 CONSTRUCTOR Create(aName: String; aTopic: TTopic; aFlags: uint8); 32 DESTRUCTOR Destroy; override; 33 34 PROPERTY getTopic: TTopic read topic; 35 FUNCTION getLabel: String; 36 FUNCTION isGlobal: boolean; 37 FUNCTION getLevel: integer; 38 end; 39 40 41 TIndex = class 42 private 43 entries: TStringList; 44 // labels: TStringList; 45 public 46 CONSTRUCTOR Create; 47 DESTRUCTOR Destroy; override; 48 49 FUNCTION Count: longint; 50 FUNCTION GetLabels: TStringList; 51 FUNCTION GetTopic(aPos: longint): TTopic; 52 PROCEDURE Add(anIndexEntry: TIndexEntry); 53 end; 54 55 24 56 THelpFile = class 25 57 protected … … 37 69 _Dictionary: TList; // pointers to strings. 38 70 39 _Index: T StringList;71 _Index: TIndex; 40 72 41 73 _SearchTable: TSearchTable; … … 82 114 function GetDictionaryWordPtr( Index: longint ): pstring; 83 115 84 function GetIndexEntryPtr( Index: longint ): pstring;85 116 function GetHighlightWords: UInt32ArrayPointer; 86 117 … … 94 125 95 126 public 96 constructor Create( const FileName: string );127 constructor Create( const aFileName: string ); 97 128 98 129 destructor Destroy; override; 99 130 100 function GetIndex: T StringList;131 function GetIndex: TIndex; 101 132 102 133 property Title: string read _Title; … … 104 135 property TopicList: TList read _Topics; 105 136 property TopicCount: longint read GetTopicCount; 106 property Index: TStringList read GetIndex; 107 property IndexEntryPtr[ index: longint ]: pstring read GetIndexEntryPtr; 137 property Index: TIndex read GetIndex; 108 138 property Filename: string read _FileName; 109 139 … … 170 200 FileErrorInUse: string; 171 201 FileErrorInvalidHeader: string; 202 203 204 // ----------- 205 // TIndexEntry 206 // ----------- 207 208 CONSTRUCTOR TIndexEntry.Create(aName: String; aTopic: TTopic; aFlags: uint8); 209 begin 210 LogEvent(LogObjConstDest, 'TIndexEntry.Create'); 211 name := aName; 212 topic := aTopic; 213 flags := aFlags; 214 end; 215 216 217 DESTRUCTOR TIndexEntry.Destroy; 218 begin 219 LogEvent(LogObjConstDest, 'TIndexEntry.Destroy'); 220 topic := nil; 221 // inherited Destroy; 222 end; 223 224 225 FUNCTION TIndexEntry.getLabel: String; 226 begin 227 result := name; 228 229 // index level check (level 1 or 2) 230 if (getLevel) > 1 then 231 begin 232 result := '- ' + result; 233 end; 234 235 if isGlobal then 236 begin 237 result := result + ' (g)'; 238 end; 239 end; 240 241 242 FUNCTION TIndexEntry.isGlobal: boolean; 243 begin 244 result := (flags and 64) > 0 245 end; 246 247 248 FUNCTION TIndexEntry.getLevel: integer; 249 begin 250 result := 1; 251 252 // index level check (level 1 or 2) 253 if (flags and 2 ) > 0 then 254 begin 255 result := 2; 256 end; 257 end; 258 259 260 261 262 // ----------- 263 // TIndex 264 // ----------- 265 CONSTRUCTOR TIndex.Create; 266 begin 267 inherited Create; 268 269 entries := TStringList.Create; 270 // labels := nil; // lazy 271 end; 272 273 274 DESTRUCTOR TIndex.Destroy; 275 var 276 i : longint; 277 tmpEntry : TIndexEntry; 278 begin 279 LogEvent(LogObjConstDest, 'TIndex.Destroy (size:' + IntToStr(entries.Count) + ')'); 280 281 for i := 0 to entries.Count - 1 do 282 begin 283 tmpEntry := TIndexEntry(entries.Objects[i]); 284 if tmpEntry <> nil then 285 begin 286 tmpEntry.Destroy; 287 entries.Objects[i] := nil; 288 end; 289 end; 290 entries.Destroy; 291 292 inherited Destroy; 293 end; 294 295 296 FUNCTION TIndex.Count: longint; 297 begin 298 result := entries.Count; 299 end; 300 301 302 FUNCTION TIndex.GetLabels: TStringList; 303 begin 304 result := entries; 305 end; 306 307 308 FUNCTION TIndex.GetTopic(aPos: longint): TTopic; 309 begin 310 result := TTopic(entries.Objects[aPos]); 311 end; 312 313 314 PROCEDURE TIndex.add(anIndexEntry: TIndexEntry); 315 begin 316 // LogEvent(LogDebug, 'TIndex.add(' + aName + ', ' + anIndexEntry.ClassName); 317 entries.AddObject(anIndexEntry.getLabel, anIndexEntry); 318 end; 319 320 321 172 322 173 323 Procedure OnLanguageEvent( Language: TLanguageFile; … … 221 371 end; 222 372 223 constructor THelpFile.Create( const FileName: string ); 224 begin 225 LogEvent(LogParse, 'Helpfile Load: ' + FileName); 226 227 _FileName := FileName; 373 374 constructor THelpFile.Create(const aFileName: string); 375 begin 376 LogEvent(LogObjConstDest, 'THelpFile.Create (file:' + aFileName + ')'); 377 LogEvent(LogParse, 'Helpfile Load: ' + aFileName); 378 379 _FileName := aFileName; 228 380 229 381 InitMembers; … … 248 400 end; 249 401 402 250 403 destructor THelpFile.Destroy; 251 404 begin 405 LogEvent(LogObjConstDest, 'THelpFile.Destroy'); 252 406 DeallocateMemory( _pHeader ); 253 407 DeallocateMemory( _pExtendedHeader ); … … 262 416 DeallocateMemory( _pHighlightWords ); 263 417 418 // index entries are pointing to topics 419 // so let us clean them first 420 if Assigned( _Index ) then 421 begin 422 _Index.Destroy; 423 end; 424 264 425 if Assigned( _Topics ) then 426 begin 265 427 DestroyListAndObjects( _Topics ); 266 267 if Assigned( _Index ) then 268 _Index.Destroy; 428 end; 269 429 270 430 _Dictionary.Free; … … 453 613 end; 454 614 455 function THelpFile.GetIndex: TStringList; 615 616 function THelpFile.GetIndex: TIndex; 456 617 begin 457 618 if _Index = nil then … … 477 638 pEnd: pointer; 478 639 pIndexData: pointer; 640 641 tmpIndexEntry: TIndexEntry; 479 642 begin 480 643 LogEvent(LogParse, 'Read index'); 481 644 482 _Index := T StringList.Create;645 _Index := TIndex.Create; 483 646 484 647 if _pHeader^.nindex = 0 then … … 504 667 505 668 GetMemString( p, EntryText, IndexTitleLen ); 506 if ( pEntryHeader^.flags and 2 ) > 0 then 507 EntryText := '- ' + EntryText; 669 508 670 if pEntryHeader^.TOCIndex < _Topics.Count then 509 _Index.AddObject( EntryText, _Topics[ pEntryHeader^.TOCIndex ] ) 671 begin 672 tmpIndexEntry := TIndexEntry.Create(EntryText, _Topics[pEntryHeader^.TOCIndex], pEntryHeader^.flags); 673 _Index.Add(tmpIndexEntry); 674 end 510 675 else 511 676 // raise EHelpFileException.Create( 'Error reading help file index - out of range topic reference' ); … … 666 831 end; 667 832 833 834 // TODO move to index class 668 835 function THelpFile.FindTopicByIndexStartsWith( const SearchText: string ): TTopic; 669 836 var 670 837 i: longint; 671 tmp Index: String;838 tmpLabel: String; 672 839 begin 673 840 result := nil; 674 841 GetIndex; // make sure it's read 842 675 843 for i := 0 to _Index.Count - 1 do 676 844 begin 677 tmp Index := _Index.ValuePtrs[i]^;678 if StrStartsWithIgnoringCase(tmp Index, SearchText) then845 tmpLabel := _Index.GetLabels.ValuePtrs[i]^; 846 if StrStartsWithIgnoringCase(tmpLabel, SearchText) then 679 847 begin 680 848 // found 681 result := TTopic( Index.Objects[ i ]);849 result := Index.getTopic(i); 682 850 exit; 683 851 end; … … 685 853 end; 686 854 687 function THelpFile.FindTopicByIndexContains( const SearchText: string ): TTopic; 855 856 function THelpFile.FindTopicByIndexContains(const SearchText: string): TTopic; 688 857 var 689 858 i: longint; 859 tmpLabel: String; 690 860 begin 691 861 result := nil; 692 862 GetIndex; // make sure it's read 863 693 864 for i := 0 to _Index.Count - 1 do 694 865 begin 695 if CaseInsensitivePos( SearchText, _Index.ValuePtrs[ i ] ^ ) > 0 then 866 tmpLabel := _Index.GetLabels.ValuePtrs[i]^; 867 if CaseInsensitivePos(SearchText, tmpLabel) > 0 then 696 868 begin 697 869 // found 698 result := TTopic( Index.Objects[ i ]);870 result := Index.getTopic(i); 699 871 exit; 700 872 end; 701 873 end; 702 874 end; 875 703 876 704 877 function THelpFile.FindTopicByTitleStartsWith( const SearchText: string ): TTopic; … … 946 1119 begin 947 1120 Result := pstring( _Dictionary[ Index ] ); 948 end;949 950 function THelpFile.GetIndexEntryPtr( Index: longint ): pstring;951 begin952 if _Index = nil then953 ReadIndex;954 Result := _Index.ValuePtrs[ Index ];955 1121 end; 956 1122 -
trunk/NewView/MainForm.pas
r259 r342 383 383 Procedure AddCurrentToMRUFiles; 384 384 385 Function LoadFiles( const FileNames: TStrings; 386 HelpFiles: TList ): boolean; 385 Function LoadFiles(const aFileNames: TStrings; aHelpFiles: TList) : boolean; 387 386 Procedure DisplayFiles( NewFiles: TList; 388 387 Var FirstContentsNode: TNode ); … … 1612 1611 end; 1613 1612 end; 1614 1613 1615 1614 CreateMRUMenuItems; 1616 1615 End; … … 1672 1671 tmpFileNames := TStringList.Create; 1673 1672 1674 StrExtractStringsIgnoreEmpty(tmpFileNames, TextList, [HELP_FILE_DELIMITER], #0);1673 ParseAndExpandFileNames(TextList, tmpFileNames); 1675 1674 if tmpFileNames.Count > 0 then 1676 1675 begin 1677 result := OpenFiles(tmpFileNames, '', DisplayFirstTopic 1676 result := OpenFiles(tmpFileNames, '', DisplayFirstTopic); 1678 1677 end 1679 1678 else … … 2283 2282 CmdLineParameters.writeDetailsTo(Lines); 2284 2283 writeSettingsDetailsTo(Lines); 2284 writeDebugSetupDetailsTo(Lines); 2285 2285 end; 2286 2286 … … 4065 4065 if CmdLineParameters.getOwnerWindow <> NULLHANDLE then 4066 4066 begin 4067 LogEvent(LogStartup, 'Setting owner: ' 4068 + IntToStr( CmdLineParameters.getOwnerWindow)); 4069 WinSetOwner( Frame.Handle, 4070 CmdLineParameters.getOwnerWindow ); 4071 4067 LogEvent(LogStartup, 'Setting owner: ' + IntToStr( CmdLineParameters.getOwnerWindow)); 4068 WinSetOwner( Frame.Handle, CmdLineParameters.getOwnerWindow ); 4072 4069 end; 4073 4070 … … 4085 4082 CoolBar.SetMinConstButtonWidth; 4086 4083 4087 LogEvent(LogStartup, 'Post WM_OPENED');4088 4089 4084 ResetProgress; 4090 4085 … … 4095 4090 AddShortcut( kbCtrlCLeft, kbCtrlCLeft ); // back 4096 4091 4092 LogEvent(LogStartup, 'Post WM_OPENED'); 4097 4093 PostMsg( Handle, WM_OPENED, 0, 0 ); 4098 4094 End; … … 4196 4192 LogEvent(LogStartup, 'Finish paint'); 4197 4193 Update; 4194 LogEvent(LogStartup, 'BringToFront'); 4195 MainForm.BringToFront; 4198 4196 4199 4197 if not CmdLineParameters.getHelpManagerFlag then … … 4222 4220 Filenames := TStringList.Create; 4223 4221 4224 StrExtractStringsIgnoreEmpty(Filenames, tmpFileNames, [HELP_FILE_DELIMITER], #0); 4225 4222 ParseAndExpandFileNames(tmpFileNames, Filenames); 4226 4223 LogEvent(LogStartup, 'Call OpenFiles'); 4227 4224 … … 5722 5719 Tag:= MenuItem.Tag; 5723 5720 MRUItem := Settings.MRUList[ Tag ]; 5721 // RBRi woher kommt die liste? 5724 5722 if OpenFiles( MRUItem.FileNames, '', true ) then 5725 5723 begin … … 6228 6226 procedure TMainForm.LoadIndex; 6229 6227 var 6230 HelpFile: THelpFile;6231 TextCompareResult: integer;6228 tmpHelpFile: THelpFile; 6229 tmpTextCompareResult: integer; 6232 6230 6233 6231 FileIndex: longint; … … 6235 6233 Contents: TList; 6236 6234 ContentsLists: TList; // of tlist 6237 IndexLists: TList; // of tstringlist6235 tmpIndexLists: TList; // of tstringlist 6238 6236 ContentsNextIndex: array[ 0..255 ] of longint; 6239 6237 IndexNextIndex: array[ 0..255 ] of longint; 6240 6238 Topic: TTopic; 6241 6239 6242 ListIndex: longint;6243 6244 6240 pListEntry: pstring; 6245 6241 pLowestEntry: pstring; 6246 6242 pLastEntry: pstring; 6247 6243 6248 LowestEntryListIndex: longint;6249 LowestEntryListType: TListType;6250 LowestEntryTopic: TTopic;6251 6252 Index: TStringList;6244 tmpLowestEntryListIndex: longint; 6245 tmpLowestEntryListType: TListType; 6246 tmpLowestEntryTopic: TTopic; 6247 6248 tmpIndex: TStringList; 6253 6249 6254 6250 i : longint; … … 6264 6260 6265 6261 ContentsLists := TList.Create; 6266 IndexLists := TList.Create;6262 tmpIndexLists := TList.Create; 6267 6263 6268 6264 // collect the contents and index lists from the files 6269 6265 for FileIndex := 0 to CurrentOpenFiles.Count - 1 do 6270 6266 begin 6271 HelpFile := CurrentOpenFiles[ FileIndex ];6267 tmpHelpFile := CurrentOpenFiles[ FileIndex ]; 6272 6268 ProgressBar.Position := 70 + 10 * FileIndex div CurrentOpenFiles.Count; 6273 6269 … … 6275 6271 begin 6276 6272 Contents := TList.Create; 6277 Contents.Capacity := HelpFile.TopicCount;6273 Contents.Capacity := tmpHelpFile.TopicCount; 6278 6274 6279 6275 // copy [contents] topic list 6280 for i := 0 to HelpFile.TopicCount - 1 do6276 for i := 0 to tmpHelpFile.TopicCount - 1 do 6281 6277 begin 6282 Topic := HelpFile.Topics[ i ];6278 Topic := tmpHelpFile.Topics[ i ]; 6283 6279 if Topic.ShowInContents then 6284 6280 Contents.Add( Topic ); … … 6296 6292 if Settings.IndexStyle in [ isFileOnly, isFull ] then 6297 6293 begin 6298 IndexLists.Add( HelpFile.Index);6299 IndexNextIndex[ IndexLists.Count - 1 ] := 0;6294 tmpIndexLists.Add(tmpHelpFile.Index.GetLabels); 6295 IndexNextIndex[ tmpIndexLists.Count - 1 ] := 0; 6300 6296 end; 6301 6297 end; … … 6313 6309 begin 6314 6310 pLowestEntry := NullStr; 6315 LowestEntryListIndex := -1;6311 tmpLowestEntryListIndex := -1; 6316 6312 6317 6313 // Find alphabetically lowest (remaining) topic 6318 6314 6319 6315 // first, look in contents lists 6320 for ListIndex := 0 to ContentsLists.Count - 1 do 6316 LogEvent(LogDebug, ' Merge contents' ); 6317 for i := 0 to ContentsLists.Count - 1 do 6321 6318 begin 6322 Contents := ContentsLists[ ListIndex];6323 if ContentsNextIndex[ ListIndex] < Contents.Count then6319 Contents := ContentsLists[i]; 6320 if ContentsNextIndex[i] < Contents.Count then 6324 6321 begin 6325 6322 // list is not yet finished, get next entry 6326 Topic := Contents[ ContentsNextIndex[ ListIndex] ];6323 Topic := Contents[ ContentsNextIndex[i] ]; 6327 6324 pListEntry := Topic.TitlePtr; 6328 6325 6329 6326 if pLowestEntry^ <> '' then 6330 TextCompareResult := CompareText( pListEntry^, pLowestEntry^ )6327 tmpTextCompareResult := CompareText( pListEntry^, pLowestEntry^ ) 6331 6328 else 6332 TextCompareResult := -1;6333 6334 if TextCompareResult < 0 then6329 tmpTextCompareResult := -1; 6330 6331 if tmpTextCompareResult < 0 then 6335 6332 begin 6336 6333 // this index entry comes before the lowest one so far 6337 6334 pLowestEntry := pListEntry; 6338 LowestEntryListIndex := ListIndex;6339 LowestEntryListType := ltContents;6340 LowestEntryTopic := Topic;6335 tmpLowestEntryListIndex := i; 6336 tmpLowestEntryListType := ltContents; 6337 tmpLowestEntryTopic := Topic; 6341 6338 end; 6342 6339 end; … … 6344 6341 6345 6342 // look in indices 6346 for ListIndex := 0 to IndexLists.Count - 1 do 6343 LogEvent(LogDebug, ' Merge indices' ); 6344 for i := 0 to tmpIndexLists.Count - 1 do 6347 6345 begin 6348 Index := IndexLists[ ListIndex ]; 6349 if IndexNextIndex[ ListIndex ] < Index.Count then 6346 LogEvent(LogDebug, ' Merge indices ' + IntToStr(i) ); 6347 tmpIndex := tmpIndexLists[i]; 6348 if IndexNextIndex[i] < tmpIndex.Count then 6350 6349 begin 6351 6350 // list is not yet finished, get next entry 6352 pListEntry := Index.ValuePtrs[ IndexNextIndex[ ListIndex] ];6351 pListEntry := tmpIndex.ValuePtrs[ IndexNextIndex[i] ]; 6353 6352 6354 6353 if pLowestEntry^ <> '' then 6355 TextCompareResult := CompareText( pListEntry^, pLowestEntry^ )6354 tmpTextCompareResult := CompareText( pListEntry^, pLowestEntry^ ) 6356 6355 else 6357 TextCompareResult := -1;6358 6359 if TextCompareResult < 0 then6356 tmpTextCompareResult := -1; 6357 6358 if tmpTextCompareResult < 0 then 6360 6359 begin 6361 6360 // this index entry comes before the lowest one so far 6362 6361 pLowestEntry := pListEntry; 6363 LowestEntryListIndex := ListIndex; 6364 LowestEntryListType := ltIndex; 6365 LowestEntryTopic := TTopic( Index.Objects[ IndexNextIndex[ ListIndex ] ] ); 6362 tmpLowestEntryListIndex := i; 6363 tmpLowestEntryListType := ltIndex; 6364 6365 LogEvent(LogDebug, ' Merge indices ' + tmpIndex.Objects[ IndexNextIndex[i] ].ClassName); 6366 tmpLowestEntryTopic := TIndexEntry( tmpIndex.Objects[ IndexNextIndex[i] ] ).getTopic; 6366 6367 end; 6367 6368 end; 6368 6369 end; 6369 6370 6370 if LowestEntryListIndex = -1 then6371 if tmpLowestEntryListIndex = -1 then 6371 6372 // we're out 6372 6373 break; … … 6374 6375 if ( pLowestEntry^ ) <> ( pLastEntry^ ) then 6375 6376 // add, if different from last 6376 DisplayedIndex.AddObject( pLowestEntry^, 6377 LowestEntryTopic ); 6377 DisplayedIndex.AddObject( pLowestEntry^, tmpLowestEntryTopic ); 6378 6378 pLastEntry := pLowestEntry; 6379 6379 6380 if LowestEntryListType = ltContents then6380 if tmpLowestEntryListType = ltContents then 6381 6381 begin 6382 inc( ContentsNextIndex[ LowestEntryListIndex ] );6382 inc( ContentsNextIndex[ tmpLowestEntryListIndex ] ); 6383 6383 end 6384 6384 else … … 6386 6386 // found in one of indices. 6387 6387 // Check for subsequent indented strings 6388 Index := IndexLists[LowestEntryListIndex ];6389 6390 i := IndexNextIndex[ LowestEntryListIndex ] + 1;6391 while i < Index.Count do6388 tmpIndex := tmpIndexLists[ tmpLowestEntryListIndex ]; 6389 6390 i := IndexNextIndex[ tmpLowestEntryListIndex ] + 1; 6391 while i < tmpIndex.Count do 6392 6392 begin 6393 pListEntry := Index.ValuePtrs[ i ];6393 pListEntry := tmpIndex.ValuePtrs[ i ]; 6394 6394 if pListEntry^ = '' then 6395 6395 break; … … 6400 6400 6401 6401 // found one, 6402 Topic := Index.Objects[ i ] as TTopic;6402 Topic := TIndexEntry(tmpIndex.Objects[ i ]).getTopic; 6403 6403 DisplayedIndex.AddObject( pListEntry^, 6404 6404 Topic ); 6405 6405 inc( i ); 6406 6406 end; 6407 IndexNextIndex[ LowestEntryListIndex ] := i;6407 IndexNextIndex[ tmpLowestEntryListIndex ] := i; 6408 6408 end; 6409 6409 end; … … 6419 6419 LogEvent(LogStartup, ' Tidy up' ); 6420 6420 6421 IndexLists.Destroy;6421 tmpIndexLists.Destroy; 6422 6422 6423 6423 DestroyListAndObjects( ContentsLists ); … … 6465 6465 const SelectFirstContentsNode: boolean ): boolean; 6466 6466 var 6467 FileNames: TStringList;6468 begin 6469 FileNames := TStringList.Create;6470 FileNames.Add( FileName);6471 Result := OpenFiles( FileNames,6467 tmpFileNames: TStringList; 6468 begin 6469 tmpFileNames := TStringList.Create; 6470 ParseAndExpandFileNames(FileName, tmpFileNames); 6471 Result := OpenFiles( tmpFileNames, 6472 6472 WindowTitle, 6473 6473 DisplayFirstTopic ); 6474 FileNames.Destroy;6474 tmpFileNames.Destroy; 6475 6475 end; 6476 6476 … … 6478 6478 const DisplayFirstTopic: boolean ): boolean; 6479 6479 var 6480 FileNames: TStringList; 6481 begin 6482 FileNames := TStringList.Create; 6483 FileNames.Add( FileName ); 6484 Result := OpenAdditionalFiles( FileNames, 6485 DisplayFirstTopic ); 6486 FileNames.Destroy; 6480 tmpFileNames: TStringList; 6481 begin 6482 tmpFileNames := TStringList.Create; 6483 ParseAndExpandFileNames(FileName, tmpFileNames); 6484 Result := OpenAdditionalFiles(tmpFileNames, DisplayFirstTopic ); 6485 tmpFileNames.Destroy; 6487 6486 end; 6488 6487 … … 6528 6527 6529 6528 // Load the specified set of help files 6530 Function TMainForm.LoadFiles( const FileNames: TStrings; 6531 HelpFiles: TList ): boolean; 6529 Function TMainForm.LoadFiles(const aFileNames: TStrings; aHelpFiles: TList) : boolean; 6532 6530 var 6533 6531 HelpFile: THelpFile; 6534 FileIndex : longint;6532 FileIndex, i: longint; 6535 6533 FileName: string; 6536 6534 FullFilePath: string; … … 6544 6542 LoadingFilenameList := TStringList.Create; 6545 6543 6546 TranslateIPFEnvironmentVars( FileNames, LoadingFilenameList ); 6544 // RBRi TranslateIPFEnvironmentVars( FileNames, LoadingFilenameList ); 6545 for i := 0 to aFileNames.Count - 1 do 6546 begin 6547 LoadingFilenameList.Add(aFileNames[i]); 6548 end; 6547 6549 6548 6550 LogEvent(LogStartup, 'Finding files' ); … … 6609 6611 HelpFile.SetupFontSubstitutes( Settings.FixedFontSubstitutes ); 6610 6612 6611 HelpFiles.Add( HelpFile );6613 aHelpFiles.Add( HelpFile ); 6612 6614 6613 6615 except … … 6631 6633 Result := false; 6632 6634 6633 DestroyListObjects( HelpFiles );6635 DestroyListObjects( aHelpFiles ); 6634 6636 6635 6637 LoadingFilenameList.Destroy; … … 6650 6652 Procedure TMainForm.AddCurrentToMRUFiles; 6651 6653 var 6652 Filenames: TStringList;6654 tmpFilenames: TStringList; 6653 6655 i: longint; 6654 HelpFile: THelpFile; 6655 begin 6656 Filenames := TStringList.Create; 6657 6658 for i := 0 to CurrentOpenFiles.Count - 1 do 6659 begin 6660 HelpFile := CurrentOpenFiles[ i ]; 6661 Filenames.Add( HelpFile.Filename ); 6662 end; 6663 6664 // update most-recently-used file list 6665 HelpFile := CurrentOpenFiles[ 0 ]; 6666 AddToMRUList( HelpFile.Title, 6667 Filenames ); 6656 tmpHelpFile: THelpFile; 6657 begin 6658 tmpFilenames := TStringList.Create; 6659 6660 if CurrentOpenFiles.Count > 0 then 6661 begin 6662 for i := 0 to CurrentOpenFiles.Count - 1 do 6663 begin 6664 tmpHelpFile := CurrentOpenFiles[ i ]; 6665 tmpFilenames.Add(tmpHelpFile.Filename); 6666 end; 6667 6668 // update most-recently-used file list 6669 tmpHelpFile := CurrentOpenFiles[ 0 ]; 6670 AddToMRUList(tmpHelpFile.Title, tmpFilenames); 6671 end; 6668 6672 6669 6673 // recreate menu 6670 6674 CreateMRUMenuItems; 6671 6675 6672 Filenames.Destroy;6676 tmpFilenames.Destroy; 6673 6677 end; 6674 6678 … … 6722 6726 const DisplayFirstTopic: boolean ): boolean; 6723 6727 var 6724 HelpFiles: TList;6728 tmpHelpFiles: TList; 6725 6729 FirstContentsNode: TNode; 6726 6730 begin … … 6732 6736 SetWaitCursor; 6733 6737 6734 HelpFiles := TList.Create; 6735 6736 if not LoadFiles(FileNames, HelpFiles ) then 6738 tmpHelpFiles := TList.Create; 6739 6740 // RBRi Translate 6741 if not LoadFiles(FileNames, tmpHelpFiles) then 6737 6742 begin 6738 6743 ClearWaitCursor; 6739 HelpFiles.Destroy;6744 tmpHelpFiles.Destroy; 6740 6745 exit; 6741 6746 end; … … 6751 6756 CloseFile; 6752 6757 6753 AssignList( 6758 AssignList(tmpHelpFiles, CurrentOpenFiles ); 6754 6759 6755 6760 ProgressBar.Position := 50; … … 6770 6775 ContentsOutline.Clear; 6771 6776 6772 DisplayFiles( HelpFiles,6777 DisplayFiles( tmpHelpFiles, 6773 6778 FirstContentsNode ); 6774 6779 … … 6891 6896 exit; 6892 6897 6898 // no ParseAndExpandFileNames call required here 6899 // this is the result of a file dialog 6900 // no environment vars here 6893 6901 if KeepCurrentFiles then 6894 6902 OpenedOK := OpenAdditionalFiles( FileNames, true ) -
trunk/NewView/SearchUnit.pas
r252 r342 273 273 for IndexIndex := 0 to HelpFile.Index.Count - 1 do 274 274 begin 275 Topic := HelpFile.Index. Objects[ IndexIndex ] as TTopic;276 pIndexEntry := HelpFile.Index EntryPtr[ IndexIndex];275 Topic := HelpFile.Index.getTopic(IndexIndex); 276 pIndexEntry := HelpFile.Index.GetLabels.ValuePtrs[IndexIndex]; 277 277 IndexEntryWordIndex := 0; 278 278 -
trunk/NewView/StartupUnit.pas
r259 r342 19 19 const 20 20 OWN_HELP_MARKER = '[NVHELP]'; 21 HELP_FILE_DELIMITER = '+';22 21 23 22 … … 26 25 // Look for any items that are actually specifiying environment 27 26 // variables, and expand them to the contents of the variables 28 Procedure TranslateIPFEnvironmentVars(const Items: TStrings; ExpandedItems: TStrings );29 27 30 28 // Given a filename, which may or may not contain a path or extension, … … 51 49 FileUtilsUnit; 52 50 53 // Look for any items that are actually specifiying environment54 // variables, and expand them to the contents of the variables55 Procedure TranslateIPFEnvironmentVars(const Items: TStrings; ExpandedItems: TStrings );56 var57 i : longint;58 tmpItem: string;59 tmpEnvironmentVarValue: string;60 begin61 LogEvent(LogStartup, 'Translating environment vars' );62 for i := 0 to Items.Count - 1 do63 begin64 tmpItem := Items[i];65 66 tmpItem := StrTrimChars(tmpItem, [StrSingleQuote]); // remove single quotes67 tmpItem := StrTrimChars(tmpItem, [StrDoubleQuote]); // remove double quotes68 69 LogEvent(LogStartup, ' Checking for environment var: ' + tmpItem );70 tmpEnvironmentVarValue := GetEnv( Uppercase( tmpItem ) );71 if DosError = 0 then72 begin73 // environment var exists - use it's value74 LogEvent(LogStartup, ' Environment var found; translated to: ' + tmpEnvironmentVarValue);75 StrExtractStrings(ExpandedItems, tmpEnvironmentVarValue, [HELP_FILE_DELIMITER], #0);76 end77 else78 begin79 // not an environment var80 ExpandedItems.Add(tmpItem);81 end;82 end;83 end;84 51 85 52 // Given a filename, which may or may not contain a path or extension,
Note:
See TracChangeset
for help on using the changeset viewer.