NAME

TUI::Help::HelpFile - help-source indexing and topic parsing

HIERARCHY

TObject
  THelpFile

SYNOPSIS

use TUI::Help;

open my $source, '<', 'help.txt' or die $!;
my $helpFile = new_THelpFile( $source );
my $topic = $helpFile->getTopic( 3 );

# Topics are read on demand, so close the handle only after the last read.
close $source or die $!;

DESCRIPTION

This module adapts THelpFile to read help source text directly rather than a compiled TVHC file. Construction scans topic headers and records their names, numeric contexts, and source positions. Topic bodies are parsed internally on demand, with references resolved against the complete name table. No compiler output, symbol file, or stream fix-ups are used.

The supplied FileHandle must be open for reading and seekable. Scanning starts at the beginning and stops at EOF or a DOS Ctrl-Z marker. The caller opens and closes the handle; this class does neither and does not require a filename.

The public update methods below remain abstract.

Commonly Used Features

Pass an already open source handle to the constructor. The context index is then available through index. Aliases share a source position, and automatic topic numbering starts at three independently for each instance. Keep the source open and unchanged while the help file is in use. Use "getTopic" to retrieve a topic by its numeric context.

VARIABLES

$invalidContext

$invalidContext is the text used by "invalidTopic". It is a global package variable and is not exported. Its initial value is "\n No help available in this context.".

ATTRIBUTES

The following attributes are read/write:

stream

The caller-owned source FileHandle supplied to the constructor.

modified

Bool modification flag, initially false.

index

The THelpIndex built during construction. It maps context IDs to source positions immediately after their topic headers, not compiled-file offsets.

indexPos

Int, initially zero. Retained from the original help-file interface; source indexing does not use this field.

CONSTRUCTOR

new

my $helpFile = THelpFile->new( stream => $s );

Accepts an open, seekable FileHandle. Scans the source headers and builds the context index without parsing topic bodies. Parser and I/O errors are reported with a message box, not exceptions. If indexing fails, construction still returns an object with its default empty index and name table; no partially collected definitions are retained. The supplied handle remains associated with the object and owned by the caller.

new_THelpFile

my $helpFile = new_THelpFile( $s );

Positional factory for the same constructor.

METHODS

getTopic

my $topic = $helpFile->getTopic( $context );

Accepts an Int context. Reads the indexed topic from the source and returns a THelpTopic. A missing or negative context returns the topic from "invalidTopic". If reading an indexed topic fails, the error is reported and the method returns undef.

invalidTopic

my $topic = $helpFile->invalidTopic();

Returns a new THelpTopic with a single unwrapped paragraph containing "$invalidContext".

putTopic

$helpFile->putTopic( $topic );

Accepts a topic object. This method remains abstract and raises Unimplemented.

recordPositionInIndex

$helpFile->recordPositionInIndex( $context );

Accepts an integer context. This method remains abstract and raises Unimplemented.

SEE ALSO

TUI::Help, TObject

AUTHORS

  • Borland International (original Turbo Vision design)

  • J. Schneider <brickpool@cpan.org> (Perl implementation and maintenance)

COPYRIGHT AND LICENSE

Copyright (c) 1990-1994, 1997 by Borland International

Copyright (c) 2026 the "AUTHORS" as listed above.

This software is licensed under the MIT license (see the LICENSE file, which is part of the distribution).