NAME

TUI::Editors::Editor::Edits - TEditor buffer and line functions

SYNOPSIS

use TUI::Objects;
use TUI::Editors;

my $editor = new_TEditor(
  TRect->new( ax => 0, ay => 0, bx => 80, by => 24 ),
  undef,
  undef,
  undef,
  1024,
);

my $start = $editor->lineStart( $pos );
my $char  = $editor->bufChar( $pos );

DESCRIPTION

TUI::Editors::Editor::Edits implements the low-level buffer, line navigation, formatting, and character movement operations used by TEditor.

The implementation preserves the original Turbo Vision editor API while using native Perl string operations. Buffer positions refer to characters in the logical editor buffer rather than encoded byte offsets, allowing decoded Unicode strings to be handled directly.

Line endings follow Perl's \R semantics. A complete line-ending sequence is treated as one logical unit where appropriate.

METHODS

bufChar

my $char = $editor->bufChar( $pos );

Returns the character at logical buffer position $pos.

The returned value is a Perl character string. For decoded Unicode strings, $pos therefore identifies a character position rather than a UTF-8 byte offset.

bufPtr

my $physical = $editor->bufPtr( $pos );

Returns the physical buffer position corresponding to logical buffer position $pos.

This method preserves the original Turbo Vision abstraction between logical and physical buffer positions. In a contiguous buffer, logical and physical positions may be identical.

formatLine

$editor->formatLine( $buffer, $linePtr, $width, $colors );

Formats one editor line into $buffer, a TDrawBuffer.

$linePtr specifies the logical position at which the line begins. $width specifies the number of screen cells to format. $colors contains the normal and selected text attributes, following the Turbo Vision TAttrPair convention.

Characters inside the current selection use the selected attribute; all other characters use the normal attribute.

Tab characters advance to the next eight-column tab stop. Unicode character width is determined using wcwidth. Combining characters occupy no additional screen cells and may be appended to a character in the final formatted cell. Wide characters occupy their corresponding number of terminal cells.

Control characters which are not line endings occupy one screen cell.

Formatting stops at the logical end of the line or when the requested width has been filled. Remaining cells are filled with spaces using the attribute active at the final logical buffer position.

lineEnd

my $end = $editor->lineEnd( $pos );

Returns the logical position of the line ending at or after $pos.

The returned position identifies the beginning of the line-ending sequence and does not include it. If no line ending follows $pos, the logical buffer length is returned.

Line endings are recognized using Perl's \R semantics.

lineStart

my $start = $editor->lineStart( $pos );

Returns the logical position at which the line containing $pos begins.

The result is the position immediately following the preceding line-ending sequence. Zero is returned when there is no preceding line ending.

Line endings are recognized using Perl's \R semantics.

nextChar

my $next = $editor->nextChar( $pos );

Returns the logical position following the character at $pos.

When $pos points to the beginning of a multi-character line-ending sequence, the complete sequence is treated as one logical unit. Otherwise the position advances by one Perl character.

If $pos is at or beyond the logical end of the buffer, the buffer length is returned.

nextLine

my $next = $editor->nextLine( $pos );

Returns the logical position at which the next line begins.

The method finds the end of the current line and advances over its complete line-ending sequence. If there is no following line, the logical end of the buffer is returned.

prevChar

my $previous = $editor->prevChar( $pos );

Returns the logical position preceding $pos.

A multi-character line-ending sequence ending at $pos is treated as one logical unit. Otherwise the position moves backwards by one Perl character.

Zero is returned when $pos is at the beginning of the buffer.

prevLine

my $previous = $editor->prevLine( $pos );

Returns the logical position at which the preceding line begins.

The method moves to the preceding logical character and then locates the beginning of the line containing that character. Zero is returned when there is no preceding line.

SEE ALSO

TEditor

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