NAME

TUI::Drivers::HardwareInfo::Termbox - Termbox hardware backend for THardwareInfo

DESCRIPTION

This module provides the Termbox-based implementation of the THardwareInfo hardware interface used by the Turbo Vision driver layer.

The module maps keyboard, mouse, screen, caret, timer, and terminal services to the facilities provided by Termbox.

On non-Windows systems, the backend normally uses the optional native Termbox FFI implementation. It falls back to Termbox::PP when the native implementation is unavailable. The pure Perl implementation can also be selected explicitly through the environment, as described in "ENVIRONMENT".

On Windows, Termbox::PP is the only supported backend.

This module is not instantiated. All interaction is performed through class-level method calls.

Terminal resources are initialized automatically when the module is loaded and released automatically when the program terminates.

VARIABLES

The following variables are internal to the Termbox backend implementation and are not part of the portable THardwareInfo interface.

$insertState

Tracks the current insert mode state (Bool).

$platform

Contains the platform classification string (Str) determined at module initialization.

$pendingEvent

Indicates whether a Termbox input event has been buffered (PositiveOrZeroInt).

$lastButtons

Stores the most recently observed mouse button state (PositiveOrZeroInt).

IMPLEMENTATION

This module contains the Termbox-specific implementation behind THardwareInfo. Public API semantics and usage are documented in THardwareInfo.

In this backend, those methods are mapped to Termbox facilities for terminal input handling, screen output, cursor management, timing, and mouse support.

The implementation provides translation between TUI::Vision key codes, character codes, mouse events, and the corresponding Termbox event model.

When Termbox::PP is used, an additional input hook distinguishes a standalone Esc key press from the beginning of an escape sequence. This hook requires access to the pure Perl implementation's input state and is not installed when the native FFI-based Termbox implementation is used.

The native Termbox FFI implementation is available only on non-Windows systems.

The exact implementation details here are backend-specific and may differ from other platform implementations.

ENVIRONMENT

The environment variables in this section affect backend selection, input handling, terminal capability detection, or the initial screen mode.

Variables that affect backend selection or Termbox library features must be set before this module is loaded.

PERL_ONLY

On non-Windows systems, a true value selects Termbox::PP instead of the native Termbox FFI implementation.

Without this setting, the native implementation is preferred when Termbox version 2 or later can be loaded. Termbox::PP is used as the fallback when the native implementation is unavailable.

On Windows, Termbox::PP is always required because the native Termbox FFI implementation does not support Windows. Setting PERL_ONLY explicitly is therefore unnecessary on Windows.

The value is interpreted according to normal Perl truth semantics. In particular, an empty string and 0 are false.

ESCDELAY

Specifies the time, in milliseconds, used by Termbox::PP to distinguish a standalone Esc key press from the beginning of an escape sequence.

A true value also selects Termbox::PP, because the additional input hook requires access to input state that is not available through the native Termbox FFI implementation.

A positive value is used as the delay. If the value is not greater than zero, the delay defaults to 100 milliseconds.

Backend selection uses Perl truth semantics independently of the numeric delay check. Consequently, a true but non-positive value still selects Termbox::PP while the delay falls back to 100 milliseconds.

NO_COLOR

When this variable exists and has a true Perl value, the initial screen mode is smMono instead of smCO80.

This setting controls the initial TUI::Vision screen mode. It does not change the terminal color count reported by getColorCount.

COLORTERM

On non-Windows systems, a value of truecolor or 24bit, matched case-insensitively, indicates a TrueColor terminal.

The setting is honored only when the loaded Termbox implementation reports TrueColor support. Otherwise, color detection continues with the terminal capability database and the TERM fallback rules.

TERM

On non-Windows systems, the terminal capability database is consulted before TERM is used as a fallback for color detection.

A value containing 256color, matched case-insensitively, selects at least 256 colors. A value containing xterm selects at least 16 colors. Other values, including an undefined value, fall back to 8 colors.

The exact value linux also selects Linux VGA console cursor control. Other non-empty values use DEC cursor-style control sequences.

On Windows, TERM is set to xterm-256color before Termbox::PP is initialized when it is not already defined. The native Termbox FFI implementation is not used on Windows.

TB_LIB_OPTS

This variable is interpreted by Termbox::PP, not directly by this module.

When enabled, Termbox::PP automatically enables all compile-time library features supported by the current Perl interpreter. In particular, TB_OPT_ATTR_W is set to the native integer size of the interpreter.

On typical 64-bit Perl builds this enables TrueColor support together with additional style attributes. On 32-bit Perl builds it enables TrueColor support.

TB_OPT_ATTR_W

This variable is interpreted by Termbox::PP, not directly by this module.

It controls the bit width used for color and attribute storage.

  • 16

    Indexed color modes only.

  • 32

    Enables TrueColor output.

  • 64

    Enables TrueColor output together with additional style attributes.

The selected value influences the capabilities reported by tb_has_truecolor() and therefore affects the maximum color depth detected by this backend.

TB_OPT_TRUECOLOR

Deprecated compatibility option interpreted by Termbox::PP.

When enabled, it sets TB_OPT_ATTR_W to 32 unless that variable has already been configured explicitly.

New applications should prefer TB_OPT_ATTR_W or TB_LIB_OPTS.

SEE ALSO

THardwareInfo, TScreen, THWMouse, TSystemError, Termbox::PP, Termbox

AUTHORS

  • Borland International (original Turbo Vision design)

  • J. Schneider <brickpool@cpan.org>

CONTRIBUTORS

  • magiblot <magiblot@hotmail.com>

COPYRIGHT AND LICENSE

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

Copyright (c) 2019-2026 the "AUTHORS" and "CONTRIBUTORS" as listed above.

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