Module TermBox Reference

Termbox is a module for creating cross-platform text-based interfaces

Constants

This section is empty.

Types

Characters

Event = RECORD   type: INTEGER;  

(* One of Event.type constants (see above). *)

  x: INTEGER;  

(* For mouse presses, releases and drags *)

  y: INTEGER;  

(* For mouse presses, releases and drags *)

  w: INTEGER;  

(* Size of screen in cells on resize *)

  h: INTEGER;  

(* Size of screen in cells on resize *)

  button: INTEGER;  

(* Mouse button that is pressed, 0 means release *)

  key: INTEGER;  

(* Physical key code of the key pressed or released *)

  ch: CHAR;  

(* The typed character on key press *)

  mod: SET  

(* Key modifiers set (see above) *)

END
;

Record that holds information on the event occurred

Variables

Done: BOOLEAN;

TRUE on successful initialization, FALSE on error

Procedures

PROCEDURE Clear;

Clears the internal back buffer with a grey foreground and a black background

PROCEDURE ClearTo (fg: INTEGER; bg: INTEGER);

Clears the internal back buffer with foreground fg and background bg

PROCEDURE Close;

Closes TermBox

PROCEDURE Delay (ms: INTEGER);

Delay for ms milliseconds

PROCEDURE Fill (x: INTEGER; y: INTEGER; w: INTEGER; h: INTEGER; ch: CHAR; fg: INTEGER; bg: INTEGER);

Fill a rectangular area of characters with ch using the foreground (fg) and background (bg) colors. The top-left corner of the area is (x; y), width is w and height is h.

PROCEDURE Flush;

Synchronizes the internal back buffer with the terminal.

Nothing will change on the screen until Flush or Sync is called.

PROCEDURE GetCell (x: INTEGER; y: INTEGER; VAR ch: CHAR; VAR fg: INTEGER; VAR bg: INTEGER);

Given the (x; y) coordinate, returns data of the corresponding terminal cell.

PROCEDURE GetWindow (): Graph.Window;

Returns Graph.Window object of the terminal (only when Graph is used).

PROCEDURE HasEvents (): BOOLEAN;

Returns TRUE if there are events in the events queue

PROCEDURE HideCursor;

Hides the text input cursor (moves it off the screen)

PROCEDURE HideMouse;

Hides the mouse cursor

PROCEDURE Init;

Initializes TermBox. Sets Done to TRUE on success, FALSE otherwise.

PROCEDURE IsFS (): BOOLEAN;

Returns TRUE if fullscreen mode is currently used

PROCEDURE PeekEvent (VAR event: Event): BOOLEAN;

Copies the next event in the queue to event but does not remove it from the queue.

PROCEDURE Print (x: INTEGER; y: INTEGER; limit: INTEGER; s: ARRAY OF CHAR; fg: INTEGER; bg: INTEGER);

Writes at most limit characters of s in a line starting at position

(x; y) on to the terminal using the given foreground (fg) and background (bg) colors.

PROCEDURE SetBg (x: INTEGER; y: INTEGER; bg: INTEGER);

Sets background color bg for the cell at position (x; y).

PROCEDURE SetCell (x: INTEGER; y: INTEGER; ch: CHAR; fg: INTEGER; bg: INTEGER);

Fills the cell at (x; y) with character ch and the given foreground (fg) and background (bg) colors.

PROCEDURE SetChar (x: INTEGER; y: INTEGER; ch: CHAR);

Sets the character of the cell at (x; y).

PROCEDURE SetCursor (x: INTEGER; y: INTEGER);

Moves the text input cursor to cell (x; y).

PROCEDURE SetFg (x: INTEGER; y: INTEGER; fg: INTEGER);

Sets foreground color fg for the cell at position (x; y).

PROCEDURE SetFontFile (s: ARRAY OF CHAR);

Sets the font file for the terminal (if Graph is used)

PROCEDURE SetIcon (s: ARRAY OF CHAR);

Sets the terminal icon (if Graph is used)

PROCEDURE SetScale (x: REAL; y: REAL);

Sets horizontal (x) and vertical (y) scale factors.

Call SetScale(2.0, 1.0) to two make pixels times wider.

PROCEDURE SetTitle (title: ARRAY OF CHAR);

Sets the title of the window

PROCEDURE SetZoom (zoom: INTEGER);

Sets zoom as an integer.

SetZoom(2) will make virtual pixels two times bigger in size.

PROCEDURE SetZoomF (zoom: REAL);

Sets zoom as a real number.

PROCEDURE Settings (w: INTEGER; h: INTEGER; flags: SET);

Sets width and height of graphical window and settings flags (for Graph)

PROCEDURE ShowMouse;

Shows the mouse cursor

PROCEDURE Size (VAR width: INTEGER; VAR height: INTEGER);

Returns size of the terminal window in characters

PROCEDURE StartTimer (speed: REAL);

Start TermBox timer. The timer event will be created every speed fraction of a second.

Call StartTimer(1/30) for 30 timer events every second.

PROCEDURE SwitchToFS;

Switch to fullscreen mode

PROCEDURE SwitchToWindow;

Switch to window mode

PROCEDURE Sync;

Sync comes handy when something causes desync between TermBox's understanding of a terminal buffer and the reality. Such as a third party process. Sync forces a complete resync between TermBox and the terminal, it may not be visually pretty though.

PROCEDURE WaitEvent (VAR event: Event);

Waits until the next event, copies it in event and removes it from the queue