NAME
TUI::Dialogs::Util - Utility functions for Turbo Vision dialogs
SYNOPSIS
use TUI::Dialogs::Util qw(hotKey prevWord nextWord);
my $hk = hotKey("~Save");
my $prev = prevWord("Hello world", 6);
my $next = nextWord("Hello world", 0);
DESCRIPTION
This module provides helper functions commonly used in text-based user interface components: extracting marked hotkeys from strings, locating the previous word boundary, and locating the next word boundary within a string. These functions are intended to support navigation and keyboard-interaction logic.
These functions are intentionally small and side-effect free.
FUNCTIONS
hotKey
my $hotkey = hotKey($s);
Extracts a hotkey indicator from the given string.
A hotkey is defined as the character immediately following a tilde (~). If such a marker exists, the character is returned in uppercase. If no hotkey marker is found, the function returns ''.
Example:
my $key = hotKey("~S~ave");
# $key is 'S'
nextWord
my $index = nextWord($s, $pos);
Returns the index of the beginning of the next word in the string.
A word is any sequence of non-space characters. The function searches forward from $pos and returns the index where a space transitions into a non-space character. If no next word exists, the function returns length($s).
prevWord
my $index = prevWord($s, $pos);
Returns the index of the beginning of the previous word in the string.
A word is considered any sequence of non-space characters. The function searches backwards from $pos - 1 and returns the index where a space transitions into a non-space character. If no previous word exists, the function returns 0.
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).