NAME

TUI::Help::HelpIndex - help context position index

HIERARCHY

TObject
  THelpIndex

SYNOPSIS

use TUI::Help;

my $index = new_THelpIndex();

$index->add( 2, 120 );
$index->add( 14, 940 );

my $position = $index->position( 14 );

DESCRIPTION

THelpIndex maps numeric help contexts to positions in a compiled help file.

The class follows the Turbo Vision context-index behavior, using a Perl array for storage. It supports Storable persistence through TStreamable and TStream, preserving every allocated slot, including unused entries.

Contexts without a recorded position return -1.

Context arguments have type Int, but callers must supply non-negative values. Assertions check this precondition when enabled.

Commonly Used Features

Add a file position for a help context with "add", then retrieve that position with "position". The index grows automatically when a context outside the current range is added.

ATTRIBUTES

index

Array reference ArrayRef[Int] containing help-file positions indexed by help context.

Initially empty. Growth allocates slots in blocks of ten and initializes new entries to -1. The existing array reference is retained during growth.

CONSTRUCTOR

new

my $index = THelpIndex->new();

Creates an empty help index.

new_THelpIndex

my $index = new_THelpIndex();

Positional factory for "new".

METHODS

add

$index->add( $i, $val );

Records position $val for context $i.

If $i is beyond the current size, the index grows to the smallest multiple of ten greater than $i. Existing entries are preserved; new entries are initialized to -1 before recording the position.

$i must be non-negative; an assertion checks this precondition.

position

my $position = $index->position( $i );

Returns the position recorded for context $i.

Returns -1 when the context is outside the current index or does not yet have a recorded position.

$i must be non-negative; an assertion checks this precondition.

size

my $size = $index->size();

Returns the number of allocated index slots as PositiveOrZeroInt, computed from the current index array on each call.

SEE ALSO

TUI::Help, THelpFile, 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).