2 RRLL: ANSI Buffers
Racket Rogue-Like Library: ANSI Buffers
Manipulating rectangular character buffers with foreground and background color.
(require rrll/abuf) | package: rrll-abuf |
This module provides constructor bindings from rrll/abuf/private/core and all bindings from rrll/abuf/output and rrll/abuf/drawing.
2.1 Core ANSI Buffers Functions
(require rrll/abuf/private/core) | package: rrll-abuf |
struct
(struct abuf (width height cells offset stride buffer))
width : fixnum? height : fixnum? cells : (vectorof acell?) offset : fixnum? stride : fixnum? buffer : bytes?
procedure
ab : abuf? x : fixnum? y : fixnum? width : fixnum? height : fixnum?
2.2 ANSI Cells
(require rrll/abuf/private/acell) | package: rrll-abuf |
struct
(struct acell (char fg bg dirty) #:mutable #:transparent) char : char? fg : fixnum? bg : fixnum? dirty : boolean?
procedure
(update-acell! cell char [ #:fg fg #:bg bg #:set-dirty set-dirty]) → void? cell : acell? char : char? fg : (or/c fixnum? #f) = #f bg : (or/c fixnum? #f) = #f set-dirty : boolean? = #t
If only-dirty is #t, the copy is performed only if the src cell is dirty.
If anything changed, clear-dirty is #t and the source cell was dirty its dirty flag is set back to #f.
If anything changed and set-dirty is #t, the destination cell dirty flag is set to #t.
2.3 Output to Terminal
(require rrll/abuf/output) | package: rrll-abuf |
procedure
(display-abuf ab [ x0 y0 #:only-dirty only-dirty #:clear-dirty clear-dirty #:linear linear]) → void? ab : abuf? x0 : fixnum? = 0 y0 : fixnum? = 0 only-dirty : boolean? = #t clear-dirty : boolean? = #t linear : boolean = #f
The picture is positioned at coordinates [x0,y0] with [0,0] being the upper left corner of the terminal and X coordinate growing to the right and Y coordinate growing down.
If only-dirty is #t then only cells marked dirty as identified by acell-dirty? are displayed.
For each cell output with clear-dirty being #t and the source cell was dirty its dirty flag is set back to #f.
If linear is #t, cursor movement is restricted to newlines and forward movement on the current line.
2.4 ANSI Pictures Drawing
(require rrll/abuf/drawing) | package: rrll-abuf |
procedure
(abuf-putchar! ab x y ch [ #:fg fg #:bg bg #:set-dirty set-dirty]) → void? ab : abuf? x : fixnum? y : fixnum? ch : char? fg : fixnum? = #x7f7f7f bg : fixnum? = #x0 set-dirty : boolean? = #t
procedure
(abuf-putstring! ab x y str [ #:fg fg #:bg bg #:set-dirty set-dirty]) → void? ab : abuf? x : fixnum? y : fixnum? str : string? fg : fixnum? = #x7f7f7f bg : fixnum? = #x0 set-dirty : boolean? = #t
If set-dirty is #t, sets the acell-dirty? flag on the destination cells if they have been changed.
procedure
(abuf-clear! ab ch [ #:fg fg #:bg bg #:set-dirty set-dirty]) → void? ab : abuf? ch : char? fg : fixnum? = #x7f7f7f bg : fixnum? = #x0 set-dirty : boolean? = #t
If set-dirty is #t, sets the acell-dirty? flag on the destination cells if they have been changed.
procedure
(abuf-bar! dst x y w h [ #:fg fg #:bg bg #:set-dirty set-dirty]) → void? dst : abuf? x : fixnum? y : fixnum? w : fixnum? h : fixnum? fg : fixnum? = #x7f7f7f bg : fixnum? = #x0 set-dirty : boolean? = #t
If set-dirty is #t, sets the acell-dirty? flag on the destination cells if they have been changed.
procedure
(abuf-box! dst x y w h [ type #:fg fg #:bg bg #:set-dirty set-dirty]) → void? dst : abuf? x : fixnum? y : fixnum? w : fixnum? h : fixnum? type : (or/c 'ascii 'single 'dashed 'thick 'double) = 'single fg : fixnum? = #x7f7f7f bg : fixnum? = #x0 set-dirty : boolean? = #t
If set-dirty is #t, sets the acell-dirty? flag on the destination cells if they have been changed.
procedure
(abuf-overlay! dst src [ dx dy #:w sw #:h sh #:sx sx #:sy sy #:only-dirty only-dirty #:clear-dirty clear-dirty #:set-dirty set-dirty]) → void? dst : abuf? src : abuf? dx : fixnum? = 0 dy : fixnum? = 0 sw : (or/c fixnum? #f) = #f sh : (or/c fixnum? #f) = #f sx : fixnum? = 0 sy : fixnum? = 0 only-dirty : boolean? = #f clear-dirty : boolean? = #f set-dirty : boolean? = #t