Alcor6L/PicoLisp/term

This module contains functions for accessing ANSI-compatible terminals (and terminal emulators) from PicoLisp.

Functions

edit

term-clrscr

edit

Clear the screen.

(term-clrscr)

term-clreol

edit

Clear from the current cursor position to the end of the line.

(term-clreol)

term-moveto

edit

Move the cursor to the specified coordinates.

(term-moveto x y)
  • x - the column (starting with 1)
  • y - the line (starting with 1)

term-moveup

edit

Move the cursor up.

(term-moveup delta)
  • delta - number of lines to move the cursor up.

term-movedown

edit

Move the cursor down.

(term-movedown delta)
  • delta - number of lines to move the cursor down.

term-moveleft

edit

Move the cursor left.

(term-moveleft delta)
  • delta - number of columns to move the cursor left.

term-moveright

edit

Move the cursor right.

(term-moveright delta)
  • delta - number of columns to move the cursor right.

term-getlines

edit

Get the number of lines in the terminal.

(setq numlines (term-getlines))

Returns:

  • numlines - the number of lines in the terminal.

term-getcols

edit

Get the number of columns in the terminal.

(setq numcols (term-getcols))

Returns:

  • numcols - The number of columns in the terminal.

term-prinl

edit

Write one or more (PicoLisp) values in the terminal.

(term-prinl [x y] any1 [any2 ... anyn])
  • x (optional) - write any PicoLisp value at this column. If x is specified, y must also be specified
  • y (optional) - write any PicoLisp value at this line. If y is specified, x must also be specified
  • any1 - the first PicoLisp value to write (could be a number, a list or a transient symbol).
  • any2 (optional) - the second PicoLisp value to write.
  • anyn (optional) - the nth PicoLisp value to write.

term-getcx

edit

Get the current column of the cursor.

(setq cx (term-getcx))

Returns:

  • cx - The column of the cursor.

term-getcy

edit

Get the current line of the cursor.

(setq cy (term-getcy))

Returns:

  • cy - The line of the cursor.

term-getchar

edit

Read a char (a key press) from the terminal.

(setq ch (term-getchar ['mode]))
  • mode (optional) - terminal input mode. It can be either:
    • *term-wait* - wait for a key to be pressed, then return it. This is the default behavior if mode is not specified.
    • *term-nowait* - if a key was pressed on the terminal return it, otherwise return NIL.

Returns:

  • ch - The char read from a terminal or NIL if no char is available. The 'char' can be an actual ASCII char, or a 'pseudo-char' which encodes special keys on the keyboard. The list of the special chars and their meaning is given in the table below:
Key code Meaning
KC_UP the UP key on the terminal
KC_DOWN the DOWN key on the terminal
KC_LEFT the LEFT key on the terminal
KC_RIGHT the RIGHT key on the terminal
KC_HOME the HOME key on the terminal
KC_END the END key on the terminal
KC_PAGEUP the PAGE UP key on the terminal
KC_PAGEDOWN the PAGE DOWN key on the terminal
KC_ENTER the ENTER (CR) key on the terminal
KC_TAB the TAB key on the terminal
KC_BACKSPACE the BACKSPACE key on the terminal
KC_ESC the ESC (escape) key on the terminal