Module shell

Shell library

Functions

stdout () Return the standard output
getX () Return the cursor X position
getY () Return the cursor Y position
setX (x) Set the cursor X position
setY (y) Set the cursor Y position
getCursor () Return the cursor position
isTTY () Returns true if the standard output is a TTY and supports VT100 escape sequences
getWidth () Returns the width of the underlying terminal
getHeight () Returns the height of the underlying terminal
setCursor (x, y) Set the cursor position
clear () Clear the terminal and set cursor position to 1, 1
clearLine () Clear the current line
getKeyboard () Return the keyboard address the terminal is listening from
getScreen () Return the screen address the terminal is printing to
createStdOut (gpu) Internal function used to create a standard output from a GPU object
parse (tab) Function used for parsing command line arguments
resolve (path) Resolve a local or absolute file using PATH, PWD and PATHEXT.
resolveToPwd (path) Resolve to PWD.
write (obj) Write an object to terminal
getAliases ([cmd]) If given, return the aliases corresponding to the given command, otherwise return all aliases.
getCommand (alias) Get command corresponding to an alias
addAlias (alias, cmd) Add an alias to the given command
parseCL (cl) Internal function used for implementing shells.
fileAutocomplete (s, sp) Autocompleter using filesystem
autocompleteFor (input, autocompleter) Compute the available autocomplete options from current input and autocompleter.
read ([options]) Read from standard input


Functions

stdout ()
Return the standard output

Returns:

    stream standard output

See also:

getX ()
Return the cursor X position

Returns:

    int cursor X position
getY ()
Return the cursor Y position

Returns:

    int cursor Y position
setX (x)
Set the cursor X position

Parameters:

  • x int cnew ursor X position
setY (y)
Set the cursor Y position

Parameters:

  • y int new cursor Y position
getCursor ()
Return the cursor position

Returns:

  1. int x cursor X position
  2. int y cursor Y position
isTTY ()
Returns true if the standard output is a TTY and supports VT100 escape sequences

Returns:

    bool whether stdout is a tty
getWidth ()
Returns the width of the underlying terminal

Returns:

    int terminal width
getHeight ()
Returns the height of the underlying terminal

Returns:

    int terminal height
setCursor (x, y)
Set the cursor position

Parameters:

  • x int new cursor X position
  • y int new cursor Y position
clear ()
Clear the terminal and set cursor position to 1, 1

Raises:

not a terminal
clearLine ()
Clear the current line
getKeyboard ()
Return the keyboard address the terminal is listening from

Returns:

    string keyboard address
getScreen ()
Return the screen address the terminal is printing to

Returns:

    string screen address
createStdOut (gpu)
Internal function used to create a standard output from a GPU object

Parameters:

  • gpu driver GPU driver

Returns:

    stream standard output
parse (tab)
Function used for parsing command line arguments

Parameters:

  • tab tab arguments list

Returns:

  1. arguments
  2. options
resolve (path)
Resolve a local or absolute file using PATH, PWD and PATHEXT. This shouldn't be used by CLI programs.

Parameters:

  • path string Path to a file to resolve
resolveToPwd (path)
Resolve to PWD. If the path exists, returns it, otherwise checks if it exists in the PWD. This method should be preferred for CLI programs.

Parameters:

  • path string Path to be resolved
write (obj)
Write an object to terminal

Parameters:

  • obj Object to write

See also:

getAliases ([cmd])
If given, return the aliases corresponding to the given command, otherwise return all aliases.

Parameters:

getCommand (alias)
Get command corresponding to an alias

Parameters:

  • alias
addAlias (alias, cmd)
Add an alias to the given command

Parameters:

  • alias
  • cmd
parseCL (cl)
Internal function used for implementing shells.

Parameters:

  • cl
fileAutocomplete (s, sp)
Autocompleter using filesystem

Parameters:

  • s
  • sp
autocompleteFor (input, autocompleter)
Compute the available autocomplete options from current input and autocompleter.

Parameters:

  • input string
  • autocompleter func
read ([options])
Read from standard input

Parameters:

  • options options
    • history tab The shell history to use (default global history)
    • ontype (optional)
    • autocomplete func (optional)
    • autocompleteHandler func (optional)
    • pwchar (optional)
generated by LDoc 1.4.6 Last updated 2021-12-27 19:58:59