💾 Archived View for rawtext.club › ~sloum › nimf › guide › api › term-module.gmi captured on 2023-01-29 at 04:09:22. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

 ____ ____ ____ ____ 
||n |||i |||m |||f ||
||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|

the nimf guide : api : " term "

The term module provides some simple helpers for working with terminals. Mostly in the form of rendering escape codes. Note that the `winsize` word, which gets the number of rows and cols for the current terminal, is a nimf builtin and is thus not a part of this module. Words in the term module are generally prefixed with `term.`.

Do note that not all terminals support all behaviors or escape codes and the response to the words in this module may vary from system to system, though most should be pretty well supported at time of writing.

Words

term.simple-esc-code

Signature: ( ch n -- _ )

Description: Eats a value and a character from TOS. Outputs an escape code with the [ followed by the value and the char. Leaves nothing on the stack. This is mostly useful for simple escape sequences in the csi block of escapes, such as turning on bold text or the like and is used in many of the helpers found in the term module.

term.string-esc-code

Signature: ( sptr -- _ )

Description: Eats a string pointer from TOS. Outputs an escape code beginning with `[` and followed by the string found at the sptr. Generally useful for csi output, but can be used for more than just a single value. This is a convenience word and the result can easily be achieved, but more broadly for any escape code, by just printing a string containing the escape code.

term.move-cursor

Signature: ( row col -- _ )

Description: Eats a col and a row value from TOS and moves the cursor to those coordinates. Leaves nothing on the stack.

term.clear

Signature: ( _ -- _ )

Description: Clears the terminal screen and moves the cursor to the top left. Takes nothing from the stack and leaves nothing on the stack.

term.bold

Signature: ( _ -- _ )

Description: Outputs an escape code toggling on bold text for the current terminal. Takes nothing from the stack and leaves nothing on the stack.

term.faint

Signature: ( _ -- _ )

Description: Outputs an escape code toggling on faint text for the current terminal. Takes nothing from the stack and leaves nothing on the stack.

term.normal-intensity

Signature: ( _ -- _ )

Description: Outputs an escape code removing bold or faint text for the current terminal. Takes nothing from the stack and leaves nothing on the stack.

term.reverse

Signature: ( _ -- _ )

Description: Outputs an escape code toggling on reverse text for the current terminal. Takes nothing from the stack and leaves nothing on the stack.

term.reverse-off

Signature: ( _ -- _ )

Description: Outputs an escape code toggling off reverse text for the current terminal. Takes nothing from the stack and leaves nothing on the stack.

term.reset-styles

Signature: ( _ -- _ )

Description: Outputs an escape code removing all text styling for the current terminal. Takes nothing from the stack and leaves nothing on the stack.

term.hide-cursor

Signature: ( _ -- _ )

Description: Outputs an escape code toggling off the cursor indicator for the current terminal. Takes nothing from the stack and leaves nothing on the stack.

term.show-cursor

Signature: ( _ -- _ )

Description: Outputs an escape code toggling on the cursor indicator for the current terminal. Takes nothing from the stack and leaves nothing on the stack.

term.bell

Signature: ( _ -- _ )

Description: Rings the terminal bell. Takes nothing from the stack and leaves nothing on the stack.

________________________________________________

the nimf guide