Class: TermState

TermState

new TermState(columns, rows, attributes)

A class which holds the terminals state and content
Parameters:
Name Type Description
columns number number of columns in the terminal
rows number number of rows in the terminal
attributes object initial attributes of the terminal
Properties
Name Type Argument Default Description
fg string <optional>
null initial foreground color
bg string <optional>
null initial background color
bold boolean <optional>
false terminal is bold by default
underline boolean <optional>
false terminal is underlined by default
italic boolean <optional>
false terminal is italic by default
blink boolean <optional>
false terminal blinks by default
inverse boolean <optional>
false terminal has reverse colors by default
Source:

Members

setAttribute

sets a given Attribute
Source:

setMeta

sets a given Meta date
Source:

setMode

sets a given Mode
Source:

Methods

eraseCharacters(count)

truncate characters from buffer at cursor position.
Parameters:
Name Type Description
count number number of characters to truncate
Source:

eraseInDisplay(n)

cleans lines
Parameters:
Name Type Description
n can be one of the following:
  • 0 or "after": cleans below and after cursor
  • 1 or "before": cleans above and before cursor
  • 2 or "all": cleans entire screen
Source:

eraseInLine(n)

cleans one line
Parameters:
Name Type Description
n can be one of the following:
  • 0 or "after": cleans from the cursor to the end of the line
  • 1 or "before": cleans from the start of the line to the cursor
  • 2 or "all": cleans entire screen
Source:

getBufferRowCount()

gets the internal buffer row count. Will be lesser equal than actual number of rows
Source:

getLed(led)

gets the current value of an LED
Parameters:
Name Type Description
led number LED 0 - 3
Source:
Returns:
true if LED is enabled, false otherwise

getLine(n)

gets the line definition
Parameters:
Name Type Description
n number line number starting at 0
Source:
Returns:
line definition

getMode(n)

returns the current value of a given mode
Parameters:
Name Type Description
n string mode
Source:

inject()

Deprecated:
  • since 0.2
    Source:
    See:
    • write

    insertBlank()

    inserts whitespaces at cursor position
    Source:

    insertLine()

    inserts lines at cursor position
    Source:

    ledOn(led)

    enables a LED
    Parameters:
    Name Type Description
    led number LED 0 - 3
    Source:

    mvCursor(x, y)

    moves cursor relative
    Parameters:
    Name Type Description
    x number relative horizontal movement
    y number relative vertical movement
    Source:

    mvTab(n)

    moves Cursor forward or backward a specified amount of tabs
    Parameters:
    Name Type Description
    n number number of tabs to move. <0 moves backward, >0 moves forward
    Source:

    nextLine()

    moves cursor to next line or scrolls down if at bottom
    Source:

    prevLine()

    moves cursor to previous line or scrolls up if at top
    Source:

    removeChar()

    removes characters at cursor position.
    Source:

    removeLine()

    removes lines at cursor position.
    Source:

    removeTab(pos)

    remove a tab
    Parameters:
    Name Type Description
    pos number position to remove a tab. Do nothing if the tab isn't set at this position
    Source:

    reset()

    resets the terminals state.
    Source:

    resetAttribute()

    resets the attributes
    Source:

    resetLeds()

    disables all LEDs
    Source:

    resize(size)

    resizes terminal to a specific dimension
    Parameters:
    Name Type Description
    size object new size of the terminal
    Source:

    restoreCursor()

    restore previously saved cursor position
    Source:

    saveCursor()

    saves cursor position
    Source:

    scroll(scroll)

    scrolls the scroll area of a buffer
    Parameters:
    Name Type Description
    scroll number number of lines to be scrolled (positive: up; negative: down)
    Source:

    setCursor(x, y)

    sets cursor to a specific position
    Parameters:
    Name Type Description
    x number column of cursor starting at 0
    y number row of cursor starting at 0
    Source:

    setLed(led, value)

    enables a LED
    Parameters:
    Name Type Description
    led number LED 0 - 3
    value boolean sets LED to value
    Source:

    setLine()

    sets the line to a value and emits 'linechanged' event
    Source:

    setScrollRegion()

    sets scroll region
    Source:

    setTab(pos)

    set tab at specified position
    Parameters:
    Name Type Description
    pos number position to set a tab at
    Source:

    switchBuffer(alt)

    switches between default and alternative buffer
    Parameters:
    Name Type Description
    alt boolean true for switch to alternative buffer, false for default buffer
    Source:

    tabClear()

    removes a tab at a given index
    Source:

    toString()

    returns plain text representation of the buffer
    Source:

    write()

    Takes a chunk of data and puts it in the buffer
    Source:
    See: