NAME

TUI::Drivers::Util - utility functions for keyboard and event handling

SYNOPSIS

use TUI::Drivers::Util qw(
  cstrlen
  ctrlToArrow
  getAltChar
  getAltCode
  getCtrlChar
  getCtrlCode
);

my $len = cstrlen($string);
my $arrow = ctrlToArrow($keyCode);

my $altCode = getAltCode('X');
my $altChar = getAltChar($altCode);

my $ctrlCode = getCtrlCode('C');
my $ctrlChar = getCtrlChar($ctrlCode);

DESCRIPTION

TUI::Drivers::Util provides a collection of low-level helper functions used by the TUI::Vision driver and event system.

The functions in this module operate on key codes and character values and are used to translate between control, alternate, and normal key representations. They are intended for internal use by event processing and input handling code.

This module is purely functional and does not define any objects.

Commonly Used Features

Typical usage falls into three groups: converting control-key navigation shortcuts to arrow/navigation key codes via ctrlToArrow(), translating between Alt key codes and characters via getAltCode()/getAltChar(), and translating between Ctrl key codes and characters via getCtrlCode()/getCtrlChar().

cstrlen() is commonly used when text contains TUI::Vision marker characters ~ and a marker-aware length is needed.

FUNCTIONS

cstrlen

my $len = cstrlen($string);

Returns the length of a string up to the first null character.

This function behaves like the C runtime strlen and is useful when working with strings that may contain embedded null characters.

ctrlToArrow

my $keyCode = ctrlToArrow($keyCode);

Maps certain control key codes to their corresponding arrow key codes.

If the key code does not represent a convertible control key, it is returned unchanged.

getAltChar

my $char = getAltChar($keyCode);

Returns the character associated with an Alt-modified key code.

If the key code does not represent an Alt-modified character, the return value is undefined.

getAltCode

my $keyCode = getAltCode($char);

Returns the Alt-modified key code corresponding to the given character.

getCtrlChar

my $char = getCtrlChar($keyCode);

Returns the character associated with a Ctrl-modified key code.

getCtrlCode

my $keyCode = getCtrlCode($char);

Returns the Ctrl-modified key code corresponding to the given character.

SEE ALSO

TUI::Drivers::Const, TUI::Drivers::Event

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) 2021-2026 the "AUTHORS" as listed above.

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