term

The Terminal API provides functions for writing text to the terminal and monitors, and drawing ASCII graphics.

nativePaletteColour(colour)Get the default palette value for a colour.
nativePaletteColor(colour)Get the default palette value for a colour.
write(text)
scroll(lines)
setCursorPos(x, y)
setCursorBlink(blink)
getCursorPos()
getSize()
clear()
clearLine()
setTextColour(colour)
setTextColor(colour)
setBackgroundColour(colour)
setBackgroundColor(colour)
isColour()
isColor()
getTextColour()
getTextColor
getBackgroundColour()
getBackgroundColor()
blit(text, text_colours, background_colours)
setPaletteColour(colour, ...)
setPaletteColor(colour, ...)
getPaletteColour(colour, ...)
getPaletteColor(colour, ...)
redirect(target)Redirects terminal output to a monitor, a window, or any other custom terminal object.
current()Returns the current terminal object of the computer.
native()Get the native terminal object of the current computer.
nativePaletteColour(colour)Source

Get the default palette value for a colour.

Parameters

  1. colour number The colour whose palette should be fetched.

Returns

  1. number The red channel, will be between 0 and 1.
  2. number The green channel, will be between 0 and 1.
  3. number The blue channel, will be between 0 and 1.

Throws

  • When given an invalid colour.

nativePaletteColor(colour)Source

Get the default palette value for a colour.

Parameters

  1. colour number The colour whose palette should be fetched.

Returns

  1. number The red channel, will be between 0 and 1.
  2. number The green channel, will be between 0 and 1.
  3. number The blue channel, will be between 0 and 1.

Throws

  • When given an invalid colour.

write(text)Source

Parameters

  1. text
scroll(lines)Source

Parameters

  1. lines
setCursorPos(x, y)Source

Parameters

  1. x
  2. y
setCursorBlink(blink)Source

Parameters

  1. blink
getCursorPos()Source
getSize()Source
clear()Source
clearLine()Source
setTextColour(colour)Source

Parameters

  1. colour
setTextColor(colour)Source

Parameters

  1. colour
setBackgroundColour(colour)Source

Parameters

  1. colour
setBackgroundColor(colour)Source

Parameters

  1. colour
isColour()Source
isColor()Source
getTextColour()Source
getTextColorSource
getBackgroundColour()Source
getBackgroundColor()Source
blit(text, text_colours, background_colours)Source

Parameters

  1. text
  2. text_colours
  3. background_colours
setPaletteColour(colour, ...)Source

Parameters

  1. colour
  2. ...
setPaletteColor(colour, ...)Source

Parameters

  1. colour
  2. ...
getPaletteColour(colour, ...)Source

Parameters

  1. colour
  2. ...
getPaletteColor(colour, ...)Source

Parameters

  1. colour
  2. ...
redirect(target)Source

Redirects terminal output to a monitor, a window, or any other custom terminal object. Once the redirect is performed, any calls to a "term" function - or to a function that makes use of a term function, as print - will instead operate with the new terminal object.

A "terminal object" is simply a table that contains functions with the same names - and general features - as those found in the term table. For example, a wrapped monitor is suitable.

The redirect can be undone by pointing back to the previous terminal object (which this function returns whenever you switch).

Parameters

  1. target Redirect The terminal redirect the term API will draw to.

Returns

  1. Redirect The previous redirect object, as returned by term.current.

Usage

  • Redirect to a monitor on the right of the computer.

    term.redirect(peripheral.wrap("right"))
current()Source

Returns the current terminal object of the computer.

Returns

  1. Redirect The current terminal redirect

Usage

  • Create a new window which draws to the current redirect target

    window.create(term.current(), 1, 1, 10, 10)
native()Source

Get the native terminal object of the current computer.

It is recommended you do not use this function unless you absolutely have to. In a multitasked environment, term.native will not be the current terminal object, and so drawing may interfere with other programs.

Returns

  1. Redirect The native terminal redirect.

Types

Redirect

Redirect.write(text)Source

Parameters

  1. text
Redirect.scroll(lines)Source

Parameters

  1. lines
Redirect.setCursorPos(x, y)Source

Parameters

  1. x
  2. y
Redirect.setCursorBlink(blink)Source

Parameters

  1. blink
Redirect.getCursorPos()Source
Redirect.getSize()Source
Redirect.clear()Source
Redirect.clearLine()Source
Redirect.setTextColour(colour)Source

Parameters

  1. colour
Redirect.setTextColor(colour)Source

Parameters

  1. colour
Redirect.setBackgroundColour(colour)Source

Parameters

  1. colour
Redirect.setBackgroundColor(colour)Source

Parameters

  1. colour
Redirect.isColour()Source
Redirect.isColor()Source
Redirect.getTextColour()Source
Redirect.getTextColorSource
Redirect.getBackgroundColour()Source
Redirect.getBackgroundColor()Source
Redirect.blit(text, text_colours, background_colours)Source

Parameters

  1. text
  2. text_colours
  3. background_colours
Redirect.setPaletteColour(colour, ...)Source

Parameters

  1. colour
  2. ...
Redirect.setPaletteColor(colour, ...)Source

Parameters

  1. colour
  2. ...
Redirect.getPaletteColour(colour, ...)Source

Parameters

  1. colour
  2. ...
Redirect.getPaletteColor(colour, ...)Source

Parameters

  1. colour
  2. ...