system.terminal - Palamecia/mint GitHub Wiki

Module

load system.terminal

This module provides tools to manage the terminal I/O.

Packages

Classes

System.Terminal

This class provides an interface to interact with a terminal for command line scripts.

Members

Modifiers Member Description
+ const << Writes data to System.stdin, and returns a reference to the stream.
+ const >> Reads a all remaining data in System.stdin and stores it in data, then retu...
+ const blink Changes the current printer style to blink.
+ const blue Changes the current printer foreground color to blue.
+ const bold Changes the current printer style to bold.
+ const clearLine Clears the current line.
+ const clearToEndOfLine Clears from the terminal's cursor position to the end of the line.
- const clone Disable object copy.
+ const concealed Changes the current printer style to concealed.
+ const crossed Changes the current printer style to crossed.
+ const cyan Changes the current printer foreground color to cyan.
- final d_ptr Object data.
+ const dark Changes the current printer style to dark.
+ const delete Flushes any buffered data.
+ const editLine Starts an interactive edition of a line of text on the terminal. Returns the ...
- @ g_lib Global library handle.
+ @ const getCursorColumn Returns the terminal's cursor current column number.
+ @ const getCursorRow Returns the terminal's cursor current row number.
+ const getHandle Returns the handle used by Event.Watcher.
+ @ const getHeight Returns the terminal height in number of rows.
+ @ const getWidth Returns the terminal width in number of columns.
+ const green Changes the current printer foreground color to green.
+ const grey Changes the current printer foreground color to grey.
+ @ const isTerminal Returns true if the stream described by stream is a terminal; otherwise r...
+ const italic Changes the current printer style to italic.
+ const magenta Changes the current printer foreground color to magenta.
+ @ const moveCursorDown Moves the terminal's cursor position count rows down.
+ @ const moveCursorLeft Moves the terminal's cursor position count columns left.
+ @ const moveCursorRight Moves the terminal's cursor position count columns right.
+ @ const moveCursorToStartOfLine Moves the terminal's cursor position to the begin of the current line.
+ @ const moveCursorUp Moves the terminal's cursor position count rows up.
+ const new Creates a new terminal context instance.
+ const onBlue Changes the current printer background color to blue.
+ const onCyan Changes the current printer background color to cyan.
+ const onGreen Changes the current printer background color to green.
+ const onGrey Changes the current printer background color to grey.
+ const onMagenta Changes the current printer background color to magenta.
+ const onRed Changes the current printer background color to red.
+ const onWhite Changes the current printer background color to white.
+ const onYellow Changes the current printer background color to yellow.
+ const read Reads all remaining data from System.stdin, and returns it as a string.
+ const readChar Reads the next character from System.stdin, and returns it as a string. Data ...
+ const readLine Reads the next line from System.stdin, and returns it as a string. Data is re...
+ const readWord Reads a word from System.stdin, and returns it as a string. Words are separat...
+ const red Changes the current printer foreground color to red.
+ const reset Resets the current printer background and foreground colors and style to defa...
+ const reverse Changes the current printer style to reverse.
+ const setBraceMatcher Sets the callback function used to detect matching barces when calling editLi...
+ const setCompletionGenerator Sets the callback function used to update the completion list when calling ed...
+ @ const setCursorPos Sets the terminal's cursor position to row and column.
+ const setHiglighter Sets the callback function used to highlight the input when calling editLine....
+ const setPrompt Sets the callback function used to generate a prompt when calling editLine. T...
+ const underline Changes the current printer style to underline.
+ const wait Waits until data is available on System.stdin. If timeout is given, the wai...
+ const white Changes the current printer foreground color to white.
+ const write Writes the content of data to System.stdout. Returns an iteraror containing...
+ const writeError Writes the content of data to System.stderr. Returns an iteraror containing...
+ const yellow Changes the current printer foreground color to yellow.

Constants

Descriptions

System.IO

System.Terminal ()

Global terminal instance

System.Terminal.<<

def (const self, data)

Writes data to System.stdin, and returns a reference to the stream.

System.Terminal.>>

def (const self, data)

Reads a all remaining data in System.stdin and stores it in data, then returns a reference to the terminal.

System.Terminal.blink

def (const self)

Changes the current printer style to blink.

System.Terminal.blue

def (const self)

Changes the current printer foreground color to blue.

System.Terminal.bold

def (const self)

Changes the current printer style to bold.

System.Terminal.clearLine

def (const self)

Clears the current line.

System.Terminal.clearToEndOfLine

def (const self)

Clears from the terminal's cursor position to the end of the line.

System.Terminal.clone

none

Disable object copy.

System.Terminal.concealed

def (const self)

Changes the current printer style to concealed.

System.Terminal.crossed

def (const self)

Changes the current printer style to crossed.

System.Terminal.cyan

def (const self)

Changes the current printer foreground color to cyan.

System.Terminal.d_ptr

null

Object data.

System.Terminal.dark

def (const self)

Changes the current printer style to dark.

System.Terminal.delete

def (self)

Flushes any buffered data.

System.Terminal.editLine

def (const self)

Starts an interactive edition of a line of text on the terminal. Returns the whole text if validated using enter; otherwise returns none.

System.Terminal.g_lib

lib ('libmint-system')

Global library handle.

System.Terminal.getCursorColumn

def ()

Returns the terminal's cursor current column number.

System.Terminal.getCursorRow

def ()

Returns the terminal's cursor current row number.

System.Terminal.getHandle

def (const self)

Returns the handle used by Event.Watcher.

System.Terminal.getHeight

def ()

Returns the terminal height in number of rows.

System.Terminal.getWidth

def ()

Returns the terminal width in number of columns.

System.Terminal.green

def (const self)

Changes the current printer foreground color to green.

System.Terminal.grey

def (const self)

Changes the current printer foreground color to grey.

System.Terminal.isTerminal

def (stream)

Returns true if the stream described by stream is a terminal; otherwise returns false.

System.Terminal.italic

def (const self)

Changes the current printer style to italic.

System.Terminal.magenta

def (const self)

Changes the current printer foreground color to magenta.

System.Terminal.moveCursorDown

def (count = 1)

Moves the terminal's cursor position count rows down.

System.Terminal.moveCursorLeft

def (count = 1)

Moves the terminal's cursor position count columns left.

System.Terminal.moveCursorRight

def (count = 1)

Moves the terminal's cursor position count columns right.

System.Terminal.moveCursorToStartOfLine

def ()

Moves the terminal's cursor position to the begin of the current line.

System.Terminal.moveCursorUp

def (count = 1)

Moves the terminal's cursor position count rows up.

System.Terminal.new

def (self)

Creates a new terminal context instance.

System.Terminal.onBlue

def (const self)

Changes the current printer background color to blue.

System.Terminal.onCyan

def (const self)

Changes the current printer background color to cyan.

System.Terminal.onGreen

def (const self)

Changes the current printer background color to green.

System.Terminal.onGrey

def (const self)

Changes the current printer background color to grey.

System.Terminal.onMagenta

def (const self)

Changes the current printer background color to magenta.

System.Terminal.onRed

def (const self)

Changes the current printer background color to red.

System.Terminal.onWhite

def (const self)

Changes the current printer background color to white.

System.Terminal.onYellow

def (const self)

Changes the current printer background color to yellow.

System.Terminal.read

def (const self, delim = '\n')

Reads all remaining data from System.stdin, and returns it as a string.

System.Terminal.readChar

def (const self)

Reads the next character from System.stdin, and returns it as a string. Data is read until a valid character is read or if the end of input is detected.

System.Terminal.readLine

def (const self)

Reads the next line from System.stdin, and returns it as a string. Data is read until a '\n' character is read or if the end of input is detected.

System.Terminal.readWord

def (const self)

Reads a word from System.stdin, and returns it as a string. Words are separated by whitespace (i.e., all characters for which isSpace returns true).

Leading whitespace are skipped.

System.Terminal.red

def (const self)

Changes the current printer foreground color to red.

System.Terminal.reset

def (const self)

Resets the current printer background and foreground colors and style to default.

System.Terminal.reverse

def (const self)

Changes the current printer style to reverse.

System.Terminal.setBraceMatcher

def (self, matcher)

Sets the callback function used to detect matching barces when calling editLine. The matcher parameter must be a function taking the edited string and the current cursor position (as a string index) and returning an iterator containing true if the edited text is balanced or false otherwise and the offset of the matching brace. It can also be a string containing each opening brace directly followed by its clossing brace. Each braces in this string must be an ASCII character.

System.Terminal.setCompletionGenerator

def (self, completer)

Sets the callback function used to update the completion list when calling editLine. The completer parameter must be a function taking the edited string and the current cursor position (as a string index) and returning an iterator of iterators containing the completion token and its start position in the input string.

System.Terminal.setCursorPos

def (row, column)

Sets the terminal's cursor position to row and column.

System.Terminal.setHiglighter

def (self, higlighter)

Sets the callback function used to highlight the input when calling editLine. The higlighter parameter must be a function taking the edited string and the current cursor position (as a string index) and returning the highlighted string. Highlight should be done using ANSI escape codes.

System.Terminal.setPrompt

def (self, prompt)

Sets the callback function used to generate a prompt when calling editLine. The prompt parameter must be a function taking the current input row count as parameter. It can also be a prompt message as a string value.

System.Terminal.underline

def (const self)

Changes the current printer style to underline.

System.Terminal.wait

def (const self, timeout = none)

Waits until data is available on System.stdin. If timeout is given, the wait stop after timeout milliseconds if System.stdin still have no data to read.

Returns true if data is available on System.stdin; otherwise returns false if the wait timed out.

After a call to this method, the event is reseted.

System.Terminal.white

def (const self)

Changes the current printer foreground color to white.

System.Terminal.write

def (const self, data)

Writes the content of data to System.stdout. Returns an iteraror containing true and the amount of sent data in bytes if the data was successfully sent to the peer; otherwise returns false.

An instance of Exception.SystemError is raised on error.

System.Terminal.writeError

def (const self, data)

Writes the content of data to System.stderr. Returns an iteraror containing true and the amount of sent data in bytes if the data was successfully sent to the peer; otherwise returns false.

An instance of Exception.SystemError is raised on error.

System.Terminal.yellow

def (const self)

Changes the current printer foreground color to yellow.

System.stderr

2

File descriptor for standard error output

System.stdin

0

File descriptor for standard input

System.stdout

1

File descriptor for standard output