This manual is for CL-Remi-Slang (v0.2.0, 8 June 2025), a set of bindings to S-Lang for Common Lisp.
Next: Error Handling, Previous: CL-Remi-Slang, Up: CL-Remi-Slang [Contents][Index]
Next: Initializing and Deinitializing CL-Remi-Slang, Up: Basics [Contents][Index]
There are a few core types that you should be aware of in CL-Remi-Slang. Most of these also have some functions associated with them.
This describes how to initialize TTY handling facilities. It is used by the
init-slang
function.
This type defines the various text attributes that can be applied to text on the screen.
Converts a t/color-attribute
to its integer value. Raises an
slang-error
if it’s not a valid t/color-attribute
.
Converts a t/color-attribute
to its integer value. Returns nil
if
it’s not a valid t/color-attribute
.
Converts an integer to a t/color-attribute
. Raises an slang-error
if the value cannot be converted to a t/color-attribute
.
Converts an integer to a t/color-attribute
. Returns nil
if the
value cannot be converted to a t/color-attribute
.
Given a list of t/color-attribute
s, return an integer with their values
logical-ORed together.
Given an integer value, return a list of t/color-attribute
s that are
contained within its bits.
This type defines the various kinds of “drawables” that you can write to the screen. These are extra glyphs, such as box characters, that S-Lang understands and that are commonly used in TUI applications.
Converts a t/drawable
to its integer value. Raises an slang-error
if it’s not a valid t/drawable
.
Converts a t/drawable
to its integer value. Returns nil
if it’s
not a valid t/drawable
.
Converts an integer to a t/drawable
. Raises an slang-error
if the
value cannot be converted to a t/drawable
.
Converts an integer to a t/drawable
. Returns nil
if the value
cannot be converted to a t/drawable
.
This defines what happens when a newline is encountered.
Converts a t/newline-behavior
to its integer value. Raises an
slang-error
if it’s not a valid t/newline-behavior
.
Converts a t/newline-behavior
to its integer value. Returns nil
if it’s not a valid t/newline-behavior
.
Converts an integer to a t/newline-behavior
. Raises an
slang-error
if the value cannot be converted to a
t/newline-behavior
.
Converts an integer to a t/newline-behavior
. Returns nil
if the
value cannot be converted to a t/newline-behavior
.
Next: Other Basic Functions, Previous: Basic Data Types, Up: Basics [Contents][Index]
With only a few exceptions, the CL-Remi-Slang library must first be initialized before using it.
This is the most direct way to initialize the CL-Remi-Slang library. When the
use-screen parameter is truthy, then screen managemetn is enabled, and the
screen-*
functions can be used. Its default is T
.
When the use-utf8 parameter is truthy, then UTF-8 support is enabled. Its
default is T
.
The tty parameter describes how to initialize TTY handling facilities.
This must be of type t/tty-init
.
The abort-char parameter indicates a keyboard character to use for SIGINT.
This is only useful when the TTY is enabled. It must be NIL
or a
character
who’s code is between 0 and 255.
The flow-control? parameter indicates whether or not to enable flow control (XON/XOFF). Disabling flow control is necessary to pass certain characters to the program, such as C-s and C-q.
When the echo-output? parameter is truthy, then typed keys will be printed on the screen.
When finished with the library, you should always call deinit-slang
to
properly deinitialize S-Lang and return the terminal to its original condition.
This deinitializes S-Lang and returns the terminal to its original condition.
This macro initializes the library with init-slang
, then executes
forms. This will ensure that deinit-slang
is called before
returning by wrapping everything in an unwind-protect
.
Previous: Initializing and Deinitializing CL-Remi-Slang, Up: Basics [Contents][Index]
This returns a string containing the version of the underling S-Lang library. The library does not need to be initialized to call this function.
This returns an integer containing the version number of the underling S-Lang library. The library does not need to be initialized to call this function.
The format of this number is meant to be human readable. For example, a version
of 2.3.2 would produce the number 20302
.
Rings the terminal bell.
Next: Screen Manipulation, Previous: Basics, Up: CL-Remi-Slang [Contents][Index]
Class precedence list: simple-error
, simple-condition
, error
, serious-condition
, condition
, t
Base class for errors that occur within CL-Remi-Slang.
Class precedence list: slang-error
, simple-error
, simple-condition
, error
, serious-condition
, condition
, t
An error that occurs while handling input.
A convenience macro to raise an slang-error
, or a subclass of
slang-error
, with a formatted message. The type parameter can be
quoted or unquoted, but must be a symbol indicating a subclass of
slang-error
.
A macro that is used when calling the low-level C bindings. This started by
executing form. If the return value of this form is equal to -1
,
then this raises an slang-error
. If err-msg
is non-nil
,
then it will be appended to the error’s message, otherwise the quoted form
is appended.
Converts a low-level S-Lang error code (like returned from the low-level C bindings) to a string message.
Next: Input Handling, Previous: Error Handling, Up: CL-Remi-Slang [Contents][Index]
The bulk of CL-Remi-Slang is devoted to screen manipulation.
Next: Basic Screen Functions, Up: Screen Manipulation [Contents][Index]
The pre-defined screen color “black”.
The pre-defined screen color “gray”.
The pre-defined screen color “red”.
The pre-defined screen color “bright-red”.
The pre-defined screen color “green”.
The pre-defined screen color “bright-green”.
The pre-defined screen color “brown”.
The pre-defined screen color “yellow”.
The pre-defined screen color “blue”.
The pre-defined screen color “bright-blue”.
The pre-defined screen color “magenta”.
The pre-defined screen color “bright-magenta”.
The pre-defined screen color “cyan”.
The pre-defined screen color “bright-cyan”.
The pre-defined screen color “light-gray”.
The pre-defined screen color “white”.
Next: Screen Reading Functions, Previous: Color Constants, Up: Screen Manipulation [Contents][Index]
Sets the behavior of newline characters. The behavior parameter must be a
t/newline-behavior
. Returns the new value.
Suspends screen management.
Resumes screen management.
Updates the internal screen size data used by S-Lang. You will want to call this before getting the screen dimensions in order to ensure the values are correct.
Returns the last-known width of the screen. Use screen-update-size
first
if you think it may have changed and want to ensure the returned value is up to
date.
Returns the last-known height of the screen. Use screen-update-size
first if you think it may have changed and want to ensure the returned value is
up to date.
Returns the last-known size of the screen as two values, where the width is the first value and the height is the second.
Reinitializes screen management and checks the current size of the screen so that internal values are consistent. This should be called after a SIGWINCH.
Next: Screen Color Functions, Previous: Basic Screen Functions, Up: Screen Manipulation [Contents][Index]
Gets the character at the current cursor position. Returns a character
.
Next: Cursor Movement and Info, Previous: Screen Reading Functions, Up: Screen Manipulation [Contents][Index]
Returns t
if the screen supports ANSI colors, or nil
otherwise.
Defines a new color that can later be referenced by id, where id
must be an integer between 0 and slang-core:sl-smg-max-colors
, inclusive.
This only has an effect if screen-has-ansi-colors-p
returns t
,
otherwise this function does nothing.
The fg and bg parameters must be strings. One of three formats can be used for these parameters:
colorX
, where X
is an integer ANSI 256-color value.
00
and FF
, inclusive.
The attributes parameter should be a set of t/color-attribute
s you
want to apply to text that uses the color.
Changes the current color that is used when writing stuff to the screen.
id must be a color ID that was previously defined with
define-color
.
Goes back to using the default color. This is effectively the same as using the following:
(screen-use-color 0)
Reverses the colors.
Changes the color in the rectangular region starting at the given column
and row. The id parameter must be a color ID that was previously
defined with define-color
.
Temporarily changes the color to id, then executes forms. Before
returning, the color will be changed to the default if old-id is
nil
, or to the color ID in old-id.
The id parameter must be a color ID that was previously defined with
define-color
. Likewise, the old-id parameter must also be a color
ID, or nil
.
Next: Screen Writing, Previous: Screen Color Functions, Up: Screen Manipulation [Contents][Index]
Hides the cursor.
Un-hides the cursor.
Moves the cursor to the given screen coordinates.
Returns two values, the first of which is the cursor’s current column and the second is the cursor’s current row.
Stores the current position of the cursor. Then, if both new-column and new-row are provided, the cursor is then moved to that position, the cursor is not moved. Finally, forms is executed.
Before returning, this will return the cursor to its previous position prior to calling this macro.
When provided, the new-column and new-row parameters must be integers. Both of these parameters must be provided, or neither of them.
Example 1:
;; Assume the cursor is at 4,5 at this point. (with-restored-cursor () ;; Writes "Hello, world!" starting at 4,5 (screen-write-string "Hello, world!")) ;; The cursor is now back at 4,5
Example 2:
;; Assume the cursor is at 4,5 at this point. (with-restored-cursor (:new-column 6 :new-row 9) ;; Writes "Hello, world!" starting at 6,9 (screen-write-string "Hello, world!")) ;; The cursor is now back at 4,5
Next: Screen Clearing and Refreshing, Previous: Cursor Movement and Info, Up: Screen Manipulation [Contents][Index]
Formats str using fmt-args and writes the result to the screen at the current cursor position. The str parameter must be a string.
Internally, this macro will skip calling the Common Lisp function format
if fmt-args is nil
.
Writes string to the screen. The string parameter must be a string.
If color is provided, then it must be a color ID (as defined with
define-color
), and the screen will first change its output color to that
color before writing the string. It will remain that color after the call.
The row and column parameters must both be provided, or not at all. When provided, they must be integers, and the cursor will first seek to that screen position before writing the string.
Writes char to the screen. The char parameter must be a
character
.
If color is provided, then it must be a color ID (as defined with
define-color
), and the screen will first change its output color to that
color before writing the character. It will remain that color after the call.
The row and column parameters must both be provided, or not at all. When provided, they must be integers, and the cursor will first seek to that screen position before writing the character.
Writes thing to the screen.
If color is provided, then it must be a color ID (as defined with
define-color
), and the screen will first change its output color to that
color before writing the character. It will remain that color after the call.
The row and column parameters must both be provided, or not at all. When provided, they must be integers, and the cursor will first seek to that screen position before writing the character.
If you are writing a string or character, then this function is slightly slower
than calling screen-write-string
or screen-write-char
directly
since it must look at the type of thing, possibly calling
write-to-string
on it.
Write a string to the display with wrapping, where it will be confined to the given rectangular region. If fill is truthy, then the last line that gets written will be padded with spaces.
Next: Screen Drawing, Previous: Screen Writing, Up: Screen Manipulation [Contents][Index]
Clears content from the screen. The clear-type parameter defines what gets cleared and can be one of the following:
:full
- Clears the entire screen. This is the default.
:end-of-line
- Clears from the cursor to the end of the line.
:end-of-screen
- Clears from the cursor to the end of the screen.
Updates the physical screen.
Marks num-rows lines starting from row for redisplay the next time
screen-refresh
is called.
Previous: Screen Clearing and Refreshing, Up: Screen Manipulation [Contents][Index]
Draws a vertical line on the screen from the current cursor position. The cursor remains at the end of the line after drawing.
If color is provided, then the screen will first change its output color to that color. It will remain that color after the call. The color parameter must be an integer (a color ID) if it’s provided. The color is not changed back after drawing.
If length is provided, it must be an integer. When provided, the line
will start at the cursor and be length rows long. When length is
not provided or is nil
, then the line starts at the cursor and continues
to the bottom edge of the screen.
Draws a vertical line on the screen from the current cursor position. The cursor remains at the end of the line after drawing.
If color is provided, then the screen will first change its output color to that color. It will remain that color after the call. The color parameter must be an integer (a color ID) if it’s provided. The color is not changed back after drawing.
The row and column parameters must either both be provided, or not at all. If given, the cursor will first seek to that position before drawing the vertical line.
If length is provided, it must be an integer. When provided, the line
will start at the cursor and be length rows long. When length is
not provided or is nil
, then the line starts at the cursor and continues
to the bottom edge of the screen.
Draws a horizontal line on the screen from the current cursor position. The cursor remains at the end of the line after drawing.
If color is provided, then the screen will first change its output color to that color. It will remain that color after the call. The color parameter must be an integer (a color ID) if it’s provided. The color is not changed back after drawing.
If length is provided, it must be an integer. When provided, the line
will start at the cursor and be length columns long. When length is
not provided or is nil
, then the line starts at the cursor and continues
to the right edge of the screen.
Draws a horizontal line on the screen from the current cursor position. The cursor remains at the end of the line after drawing.
If color is provided, then the screen will first change its output color to that color. It will remain that color after the call. The color parameter must be an integer (a color ID) if it’s provided. The color is not changed back after drawing.
The row and column parameters must either both be provided, or not at all. If given, the cursor will first seek to that position before drawing the horizontal line.
If length is provided, it must be an integer. When provided, the line
will start at the cursor and be length columns long. When length is
not provided or is nil
, then the line starts at the cursor and continues
to the right edge of the screen.
Draws a box starting at position given by column and row. The box will be num-cols wide and num-rows tall. The starting position is the upper-left corner.
If color is not nil
, then the color will be switched before
drawing. The color is not changed back after drawing.
Draws obj at the given coordinates, where obj must be a
t/drawable
.
If color is not nil
, then the color will be switched before
drawing. The color is not changed back after drawing.
Fills a rectangular region of the screen with ch.
The ch parameter must either be a character who’s char-code
is
between 0 and 255 inclusive, or an (unsigned-byte 8)
.
Next: Concept Index, Previous: Screen Manipulation, Up: CL-Remi-Slang [Contents][Index]
Check to see if any input is pending. This will wait for up to timeout
tenths of a second. If there is input waiting to be read, this returns
t
, otherwise this returns nil
. On error, this returns nil
.
If timeout is negative, then this instead waits for timeout milliseconds instead of tenths of a second. A timeout of zero means “do not wait”. Note that not all systems support millisecond resolution.
Regardless, timeout must be an integer if provided.
Reads a character from the keyboard. If no input is available, this will block until some becomes available.
This may raise an slang-input-error
if an error occurs while getting the
input.
Reads a character from the keyboard. If no input is available, this will wait
for up to timeout tenths of a second (or timeout milliseconds if
timeout is negative). If there is input waiting to be read, this returns
the inputted character, otherwise this returns nil
. On error, this
returns nil
.
Reads a character from the keyboard. If no input is available, this will wait
for up to timeout tenths of a second (or timeout milliseconds if
timeout is negative). If there is input waiting to be read, this returns
the inputted character code, otherwise this returns nil
. On error, this
returns nil
.
“Ungets” thing from the input. The value will be placed at the end of the input buffer.
This may raise an slang-input-error
if there is not enough room on the
input buffer for the value.
CL-Remi-Slang defines methods where thing can be either a string or a character.
Discard all keyboard input waiting to be read.
Resets the TTY.
Next: Function Index, Previous: Input Handling, Up: CL-Remi-Slang [Contents][Index]
Jump to: | B C D I S |
---|
Jump to: | B C D I S |
---|
Next: Variable Index, Previous: Concept Index, Up: CL-Remi-Slang [Contents][Index]
Jump to: | B C D E F G I R S T U V W |
---|
Jump to: | B C D E F G I R S T U V W |
---|
Next: Type Index, Previous: Function Index, Up: CL-Remi-Slang [Contents][Index]
Jump to: | + |
---|
Jump to: | + |
---|
Previous: Variable Index, Up: CL-Remi-Slang [Contents][Index]
Jump to: | S T |
---|
Jump to: | S T |
---|