.section Widgets
.topic widget.ansiterm
.title AnsiTerm
.toc 0 AnsiTerm
.index AnsiTerm
.index wgtAnsiTerm
.index Terminal
.index VT100

.h2 AnsiTerm

A VT100/ANSI-compatible terminal emulator widget designed for connecting to BBS systems over the serial link. Uses a traditional text-mode cell buffer (character + attribute byte pairs) with the CP437 character set and 16-color CGA palette. Supports cursor movement, screen/line erase, scrolling regions, SGR colors, and scrollback history. Communication is abstracted through read/write function pointers, allowing the terminal to work with raw serial ports, the secLink encrypted channel, or any other byte-oriented transport.

Header: widgets/widgetAnsiTerm.h

.h3 Creation

.code
WidgetT *term = wgtAnsiTerm(parent, 80, 25);
.endcode

.h3 Macros

.index wgtAnsiTermWrite
.index wgtAnsiTermClear
.index wgtAnsiTermSetComm
.index wgtAnsiTermSetScrollback
.index wgtAnsiTermPoll
.index wgtAnsiTermRepaint

.table
  Macro                                              Description
  -----                                              -----------
  wgtAnsiTerm(parent, cols, rows)                    Create an ANSI terminal widget with the given column and row dimensions.
  wgtAnsiTermWrite(w, data, len)                     Write raw bytes into the terminal's ANSI parser. data is a const uint8_t * buffer, len is the byte count.
  wgtAnsiTermClear(w)                                Clear the terminal screen and reset the cursor to the home position.
  wgtAnsiTermSetComm(w, ctx, readFn, writeFn)        Attach a communication channel. readFn and writeFn are I/O callbacks; ctx is passed as their first argument.
  wgtAnsiTermSetScrollback(w, maxLines)              Set the maximum number of scrollback lines. Lines scrolled off the top are saved in a circular buffer.
  wgtAnsiTermPoll(w)                                 Poll the communication channel for incoming data and feed it into the ANSI parser.
  wgtAnsiTermRepaint(w, outY, outH)                  Fast repaint path that renders dirty rows directly into the window's content buffer, bypassing the widget pipeline. Returns the dirty region via outY/outH.
.endtable

.h3 Properties (BASIC Interface)

.table
  Property     Type       Access       Description
  --------     ----       ------       -----------
  Cols         Integer    Read-only    Number of columns.
  Rows         Integer    Read-only    Number of rows.
  Scrollback   Integer    Write-only   Maximum scrollback lines.
.endtable

.h3 Methods (BASIC Interface)

.table
  Method       Description
  ------       -----------
  Clear        Clear the terminal screen.
  Write        Write a string into the terminal.
.endtable

.h3 Events

AnsiTerm uses the common events only. No widget-specific events are defined.
