NAME

TUI::Editors::Util - Utility functions for editor buffers

SYNOPSIS

use TUI::Editors::Util qw(
  countLines
  iScan
  scan
);

my $lines = countLines($buffer);
my $count = countLines($buffer, $length);

my $pos = scan($block, $size, $string);
my $ipos = iScan($block, $size, $string);

DESCRIPTION

TUI::Editors::Util provides low-level line-counting and search functions used by TUI::Editors::Editor.

The functions preserve the buffer-and-length calling convention of the original Turbo Vision editor utilities while using native Perl strings. Positions and lengths refer to Perl characters rather than encoded byte offsets.

All functions are available for explicit import. Nothing is exported by default. The :all tag imports all functions.

FUNCTIONS

countLines

my $lines = countLines($buffer);
my $lines = countLines($buffer, $count);

Counts the line-ending sequences in $buffer.

When $count is supplied, only the first $count Perl characters are examined. When $count is omitted or is greater than the available length, the complete buffer is examined.

An empty buffer contains no line endings and returns zero.

Line endings follow Perl's \R semantics. A CR LF pair therefore counts as one line ending.

The function corresponds to the original Turbo Vision countLines utility, whose arguments are a buffer address and a character count.

iScan

my $pos = iScan($block, $size, $string);

Searches for the first case-insensitive occurrence of $string within the first $size Perl characters of $block.

The search string is treated as literal text rather than as a regular expression. Matching uses Perl's case-insensitive Unicode rules when the arguments contain decoded Unicode strings.

The returned position is relative to the beginning of $block.

sfSearchFailed is returned when $string is empty or no match is found.

scan

my $pos = scan($block, $size, $string);

Searches for the first exact occurrence of $string within the first $size Perl characters of $block.

The comparison is case-sensitive. The returned position is relative to the beginning of $block.

sfSearchFailed is returned when $string is empty or no match is found.

SEE ALSO

TUI::Editors::Editor

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).