FixIO Documentation

Back to summary

import "io/console/buffer";

ScreenBuffer class

ScreenBuffer provides an off-screen buffer for easy drawing of characters and the associated attributes. It is then possible to put the content to the console in an optimized manner.

The buffer is by default transparent (when the character is '\00').

The buffer can be shared between tasks, the drawing state is not shared.

Constants

+------------+  /-----------\  ┌────────────┐  ╔════════════╗
| SIMPLE_BOX |  | BEVEL_BOX |  │ SINGLE_BOX │  ║ DOUBLE_BOX ║
+------------+  \-----------/  └────────────┘  ╚════════════╝
The pre-defined box styles.

Initialization

static function create(width: Integer, height: Integer): ScreenBuffer
Creates a new screen buffer of given size.
function get_view(): ScreenBuffer
function get_view(x: Integer, y: Integer, width: Integer, height: Integer): ScreenBuffer
Returns a view of the screen buffer. The data is shared, but the drawing state is separate. It can be also shared between tasks.

Properties

function get_width(): Integer
function get_height(): Integer
Returns the width and height of the screen buffer.

State

function reset()
Resets the drawing state (including the stack).
function push()
Pushes the current drawing state to the stack.
function pop()
Pops the drawing state from the stack, making it current.
function clip(x: Integer, y: Integer, width: Integer, height: Integer)
Clips the given rectangle against the current clip rectangle. The function can't make the clip rectangle bigger.
function translate(dx: Integer, dy: Integer)
Translates the subsequent drawing.

Drawing

function put_char(x: Integer, y: Integer, background: Integer, foreground: Integer, char: Integer)
Puts a character at a given position.
function put_text(x: Integer, y: Integer, background: Integer, foreground: Integer, text: String)
function put_text(x: Integer, y: Integer, background: Integer, foreground: Integer, text: String, off: Integer, len: Integer)
Puts a text (or portion of it) at a given position.
function fill(background: Integer, foreground: Integer, char: Integer)
function fill(x: Integer, y: Integer, width: Integer, height: Integer, background: Integer, foreground: Integer, char: Integer)
Fills the given rectangle (or the whole buffer) with the given color and character.
function draw_box(x: Integer, y: Integer, width: Integer, height: Integer, background: Integer, foreground: Integer, box_chars: String)
Draws a box at given rectangle. The box characters are given in a string of 8 characters. Going from the top left to the bottom right (excluding the middle area).
function draw_buffer(x: Integer, y: Integer, buf: ScreenBuffer)
function draw_buffer(dest_x: Integer, dest_y: Integer, src_x: Integer, src_y: Integer, width: Integer, height: Integer, buf: ScreenBuffer)
Draws a buffer (or portion of it) at a given position.

Console update

function update_console()
function update_console(x: Integer, y: Integer)
function update_console(dest_x: Integer, dest_y: Integer, src_x: Integer, src_y: Integer, width: Integer, height: Integer)
Updates the console with the contents of the screen buffer.