diff options
-rw-r--r-- | src/HelpFile.pas | 21 | ||||
-rw-r--r-- | src/frm_main.pas | 8 |
2 files changed, 18 insertions, 11 deletions
diff --git a/src/HelpFile.pas b/src/HelpFile.pas index 806fd042..6be78261 100644 --- a/src/HelpFile.pas +++ b/src/HelpFile.pas @@ -240,7 +240,7 @@ begin for EntryIndex := 0 to _Header.ntoc-1 do begin pEntry := _Data + tocarray[EntryIndex]; - Topic := TTopic.Create( _Data, + Topic := TTopic.Create(_Data, _Header, _Dictionary, pEntry ); @@ -288,49 +288,50 @@ begin Inc(p, sizeof(b)); // move pointer Move(p^, c, b-1); // read string of dictionary Inc(p, b-1); // move pointer - s := StrPas(@c); + s := c; _Dictionary.Add(s); end; end; type - TIndexEntryHeader = record + TIndexEntryHeader = packed record TextLength: int8; Flags: int8; NumberOfRoots: int8; TOCIndex: int16; end; + procedure THelpFile.ReadIndex; var IndexIndex: longint; pEntryHeader: ^TIndexEntryHeader; EntryText: string; - IndexTitleLen: longint; + IndexTitleLen: byte; p: pointer; + iword: array[0..255] of char; begin p := _Data + _Header.indexstart; - + ProfileEvent('Number of indexes = ' + IntToStr(_Header.nindex)); for IndexIndex:= 0 to longint( _Header.nindex ) - 1 do begin pEntryHeader := p; IndexTitleLen:= pEntryHeader^.TextLength; inc( p, sizeof( TIndexEntryHeader ) ); - { TODO -oGraeme : Double check this later } - EntryText := PChar(p); -// GetMemString( p, EntryText, IndexTitleLen ); + FillChar(iword, Length(iword), 0); + Move(p^, iword, IndexTitleLen); + EntryText := iword; if ( pEntryHeader^.flags and 2 ) > 0 then EntryText:= '- ' + EntryText; if pEntryHeader^.TOCIndex < _Topics.Count then _Index.AddObject( EntryText, TTopic(_Topics[ pEntryHeader^.TOCIndex ]) ) else -// raise EHelpFileException.Create( 'Error reading help file index - out of range topic reference' ); + //raise EHelpFileException.Create( 'Error reading help file index - out of range topic reference' ); ; // pass! something special inc( p, IndexTitleLen + pEntryHeader^.NumberOfRoots ); // skip 'roots' for index search end; - end; type diff --git a/src/frm_main.pas b/src/frm_main.pas index 18e2603b..e02cfc87 100644 --- a/src/frm_main.pas +++ b/src/frm_main.pas @@ -189,8 +189,14 @@ var Count: integer; i: integer; s: TfpgString; + f: THelpFile; begin -// + f := THelpFile(Files[0]); + tvIndex.RootNode.Clear; + for i := 0 to f.Index.Count-1 do + begin + tvIndex.RootNode.AppendText(f.Index[i]); + end; end; procedure TMainForm.btnGoClicked(Sender: TObject); |