15 RRLL: Terminal I/O
Racket Rogue-Like Library: Local and Network Virtual Terminal
Unified interface for local and network virtual terminals.
(require rrll/term) | package: rrll-term |
This module provides all bindings from rrll/term/private/ansi-output.
It provides make-tty from rrll/term/private/tty, make-nvt and nvt-tcp-accet from rrll/term/private/nvt and term-resize? and struct term-size bindings from rrll/term/private/size.
syntax
(with-term term body ...)
The current-term parameter is internal to this module only.
procedure
(get-term-size [term]) →
(or/c fixnum? #f) (or/c fixnum? #f) term : term-base? = (current-term)
procedure
(enable-term-read-resize! [term]) → void?
term : term-base? = (current-term)
procedure
(disable-term-read-resize! [term]) → void?
term : term-base? = (current-term)
procedure
(get-mouse-pos [term]) →
(or/c fixnum? #f) (or/c fixnum? #f) term : term-base? = (current-term)
procedure
(get-term-width [term]) → fixnum?
term : term-base? = (current-term)
procedure
(get-term-height [term]) → fixnum?
term : term-base? = (current-term)
15.1 ANSI Terminal Output
(require rrll/term/private/ansi-output) | package: rrll-term |
This module contains various utility functions for directly altering the state of connected ANSI terminal.
procedure
(hide-cursor out) → void?
out : (current-output-port)
procedure
(show-cursor out) → void?
out : (current-output-port)
procedure
out : (current-output-port)
procedure
x : fixnum? y : fixnum? out : (current-output-port)
procedure
(enable-alternate-screen out) → void?
out : (current-output-port)
procedure
(disable-alternate-screen out) → void?
out : (current-output-port)
procedure
(enable-mouse out) → void?
out : (current-output-port)
procedure
(disable-mouse out) → void?
out : (current-output-port)
procedure
(set-window-title title out) → void?
title : string? out : (current-output-port)
15.2 TTY
(require rrll/term/private/tty) | package: rrll-term |
Local terminal representation.
procedure
(make-tty [ in out #:size-poll-interval size-poll-interval]) → tty? in : input-port? = (current-input-port) out : output-port? = (current-output-port) size-poll-interval : fixnum? = 1
Because lack of support for signals (especially SIGWINCH), the terminal is periodically queried for any size changes and the interval between these polls can be set using size-poll-interval.
15.3 NVT - TELNET
(require rrll/term/private/nvt) | package: rrll-term |
Network virtual terminal representation.
procedure
(make-nvt in out) → nvt?
in : input-port? out : output-port?
procedure
(nvt-tcp-accept tcp-listen-socket) → nvt?
tcp-listen-socket : tcp-listener?
15.4 NVT Options Storage
(require rrll/term/private/nvt-options) | package: rrll-term |
Handling of NVT options on both sides of the connection.
value
nvt-code-names : hash?
IAC |
| #xff |
DONT |
| #xfe |
DO |
| #xfd |
WONT |
| #xfc |
WILL |
| #xfb |
SB |
| #xfa |
GA |
| #xf9 |
EL |
| #xf8 |
EC |
| #xf7 |
AYT |
| #xf6 |
AO |
| #xf5 |
IP |
| #xf4 |
BRK |
| #xf3 |
DM |
| #xf2 |
NOP |
| #xf1 |
SE |
| #xf0 |
LINEMODE |
| #x22 |
NAWS |
| #x1f |
TTYPE |
| #x18 |
SGA |
| #x3 |
ECHO |
| #x1 |
BINARY |
| #x0 |
procedure
(set-nvt-option options action option) → hash?
options : hash? action : byte? option : byte?
procedure
(set-nvt-option! options action option) → void?
options : hash? action : byte? option : byte?
15.5 Terminal Size and Resize Reporting
(require rrll/term/private/size) | package: rrll-term |
This module unifies size and resize reporting for any terminal implementation.
15.6 Terminal Base
(require rrll/term/private/base) | package: rrll-term |
Provides basic facilities to implement a terminal backend.
struct
(struct term-base ( in out [size #:mutable] [read-size? #:mutable] mouse)) in : input-port? out : output-port? size : (or/c #f term-size?) read-size? : boolean? mouse : mouse-status?
procedure
(do-term-resize! tb new-columns new-lines) → void?
tb : term-base? new-columns : fixnum? new-lines : fixnum?
15.7 Terminal Resources Garbage Collection
(require rrll/term/private/cleanup) | package: rrll-term |
This module runs a thread that performs cleanup after garbage collected terminals.
value
term-will-executor : will-executor?
15.8 Foreign Function Interface Struct Size Detection
(require rrll/term/private/ffi-struct-size) | |
package: rrll-term |
This module is used by rrll/term/private/termios and rrll/term/private/tiocgwinsz to allocate memory properly.
procedure
(ffi-detect-struct-size procs [size]) → fixnum?
procs : (listof (-> cpointer? any/c)) size : fixnum? = 1024
procedure
(cached-ffi-detect-struct-size procs [size]) → fixnum?
procs : (listof (-> cpointer? any/c)) size : fixnum? = 1024
15.9 Low-Level Termios Interface
(require rrll/term/private/termios) | package: rrll-term |
This module allows direct manipulation of program TTY descriptors. It is used by rrll/term/private/tty to put the terminal into a raw mode.
procedure
(termios? termios) → boolean?
termios : any/c
procedure
(termios-load termios) → void?
termios : termios?
procedure
(termios-make-raw! termios) → void?
termios : termios?
15.10 TTY Window Size I/O Control
(require rrll/term/private/tiocgwinsz) | package: rrll-term |
Falls back to 80x24.
15.11 Queue Input Port
(require rrll/term/private/queue-port) | package: rrll-term |
An implementation of input port with queue-like semantics of adding more data to it.
procedure
(make-queue-port [name]) → input-port?
name : symbol? = 'queue-port
procedure
(queue-port-post! qp v) → void?
qp : queue-port? v : any/c
15.12 NVT Input Port
(require rrll/term/private/iac-input-port) | |
package: rrll-term |
Handles incoming NVT IAC codes.
procedure
(make-iac-input-port in iac-handler) → input-port?
in : input-port? iac-handler : procedure?
procedure
(nvt-iac-handler in options [sb-handler]) → void?
in : input-port? options : hash? sb-handler : procedure? = void
15.13 ANSI Input Port
(require rrll/term/private/ansi-input-port) | |
package: rrll-term |
Implementation of ANSI input decoding on top of another input port.
procedure
(make-ansi-input-port in [ queue-port #:mouse-status mouse-status]) → input-port? in : input-port? queue-port : (or/c queue-port? #f) = #f mouse-status : (or/c mouse-status? #f) = #f
Both the original port and mouse-status struct for mouse reporting are held in weak boxes.
15.14 Mouse Input
(require rrll/term/private/mouse) | package: rrll-term |
This module is used by rrll/term/private/ansi-input-port to store the results of mouse tracking.
struct
(struct mouse-status (x y b1 b2 b3))
x : fixnum? y : fixnum? b1 : boolean? b2 : boolean? b3 : boolean?