Skip to content

Latest commit

 

History

History
435 lines (314 loc) · 20.8 KB

docs.md

File metadata and controls

435 lines (314 loc) · 20.8 KB

tty-events

Terminal ⏏

Emits terminal-related events.

Kind: Exported class

new Terminal(input, output, options)

Param Type Description
input ReadableStream The input stream. (Normally stdin.)
output WritableStream The output stream for activating mouse support and bracketed paste mode. (Normally stdout.) Optional.
options TermOptions

terminal.pause(pauseStream)

Removes the data listener from the input stream.

Kind: instance method of Terminal

Param Type Default Description
pauseStream boolean true Whether to pause the input stream. This will allow Node.js to exit.

terminal.resume(resumeStream)

Attaches the data listener to the input stream.

Kind: instance method of Terminal

Param Type Default Description
resumeStream boolean true Determines if the underlying input stream is also resumed.

terminal.enableMouse(mode, sgr)

Enables mouse events.

Kind: instance method of Terminal

Param Type Default Description
mode number 0 The mouse mode (one of the constants)
sgr boolean true Whether to try to activate SGR extended mode

terminal.disableMouse()

Disables mouse events.

Kind: instance method of Terminal

terminal.enableBPM()

Enables bracketed paste mode.

Kind: instance method of Terminal

terminal.disableBPM()

Disables bracketed paste mode.

Kind: instance method of Terminal

terminal.enableFocus()

Enables focus events.

Kind: instance method of Terminal

terminal.disableFocus()

Disables focus events.

Kind: instance method of Terminal

"keypress"

Event fired when a key (or key combination) is pressed.

Kind: event emitted by Terminal

"mousedown"

Event fired when a mouse button is pressed down.

Kind: event emitted by Terminal

"mouseup"

Event fired when a mouse button is released.

Kind: event emitted by Terminal

"mousemove"

Event fired when the cursor moves.

Kind: event emitted by Terminal

"wheel"

Event fired when the mouse wheel is moved or when the scroll action is triggered (for example, using two fingers on a trackpad).

Kind: event emitted by Terminal

"mouse"

Event fired with any mouse event.

Kind: event emitted by Terminal
See: module:tty-events.MouseEvent#type

"paste"

Event fired when text is pasted while bracketed paste mode is activated.

Kind: event emitted by Terminal

"focusin"

Event fired when the terminal window receives focus.

Kind: event emitted by Terminal

"focusout"

Event fired when the terminal window loses focus.

Kind: event emitted by Terminal

"highlight"

Event fired when text is selected using highlight tracking. This event may not fire if the selection was empty.

Kind: event emitted by Terminal

"unknownSequence"

Event fired when the terminal receives an unrecognized or broken escape sequence.

Kind: event emitted by Terminal

Terminal.KeyboardEvent

Represents a keyboard event (key or key combination).

Kind: static class of Terminal

keyboardEvent.name : string

The key name (for special keys) or character produced by the key.

Kind: instance property of KeyboardEvent

keyboardEvent.sequence : string

The sequence produced by the key / key combination.

Kind: instance property of KeyboardEvent

keyboardEvent.isSpecial : boolean

Determines if the key is a special key. Special keys have names like f2 or backspace or are a combination of Ctrl+symbol / Ctrl+letter.

Kind: instance property of KeyboardEvent

keyboardEvent.ctrl : boolean

Determines if the Ctrl modifier was being pressed with the key. If the key is not a special key, this is always false.

Kind: instance property of KeyboardEvent

keyboardEvent.alt : boolean

Determines if the Alt modifier was being pressed with the key.

Kind: instance property of KeyboardEvent

keyboardEvent.shift : boolean

Determines if the Shift modifier was being pressed with the key. If the key is not a special key, this is always false.

Kind: instance property of KeyboardEvent

keyboardEvent.meta : boolean

Determines if the Alt modifier was being pressed with the key. Present for compatibility with the readline module.

Kind: instance property of KeyboardEvent

keyboardEvent.toString()

Represents the key combination with a string in the format ["Ctrl+"]["Alt+"]["Shift+"]key.name. For example: "b", "B", "Ctrl+e", "Ctrl+Shift+home", "+".

Kind: instance method of KeyboardEvent

Terminal.MouseEvent

Represents a mouse event (click, wheel, etc.).

Kind: static class of Terminal

mouseEvent.x : number

The x coordinate of where the mouse event happened (1 = leftmost column).

Kind: instance property of MouseEvent

mouseEvent.y : number

The y coordinate of where the mouse event happened (1 = topmost row).

Kind: instance property of MouseEvent

mouseEvent.button : number

The button number, in the range 1-11. This property might be undefined for mouseup and mousemove events. If undefined in a mousemove event, no button was pressed when the cursor moved.

List of mouse buttons (from http://xahlee.info/linux/linux_x11_mouse_button_number.html):

  • 1: Left button
  • 2: Middle (wheel) button
  • 3: Right button
  • 4: Rotate wheel up
  • 5: Rotate wheel down
  • 6: Push wheel left
  • 7: Push wheel right
  • 8: 4th button or XButton1 (browser back)
  • 9: 5th button or XButton2 (browser forward)

Kind: instance property of MouseEvent

mouseEvent.ctrl : boolean

Determines if the Ctrl modifier was being pressed when the mouse event occurred.

Kind: instance property of MouseEvent

mouseEvent.alt : boolean

Determines if the Alt modifier was being pressed when the mouse event occurred.

Kind: instance property of MouseEvent

mouseEvent.shift : boolean

Determines if the Shift modifier was being pressed when the mouse event occurred.

Kind: instance property of MouseEvent

mouseEvent.type : string

Type of mouse event (mousedown, mouseup, mousemove or wheel).

Kind: instance property of MouseEvent

mouseEvent.direction : number

Only for wheel events. Direction of the wheel turn (1 = down; -1 = up).

Kind: instance property of MouseEvent

Terminal.HighlightEvent

Represents a highlight selection.

Kind: static class of Terminal

highlightEvent.startX : number

The x coordinate of the first character of the selection.

Kind: instance property of HighlightEvent

highlightEvent.startY : number

The y coordinate of the first character of the selection.

Kind: instance property of HighlightEvent

highlightEvent.endX : number

The x coordinate of the first character after the selection.

Kind: instance property of HighlightEvent

highlightEvent.endY : number

The y coordinate of the first character after the selection.

Kind: instance property of HighlightEvent

highlightEvent.mouseX : number

The x coordinate of the mouse position.

Kind: instance property of HighlightEvent

highlightEvent.mouseY : number

The y coordinate of the mouse position.

Kind: instance property of HighlightEvent

Terminal.VT200_MOUSE

Constant used for enableMouse(): Only mousedown, mouseup and wheel events.

Kind: static constant of Terminal

Terminal.VT200_HIGHLIGHT_MOUSE

Constant used for enableMouse(): Mouse highlight tracking. If you use this constant, make sure to respond to mousedown events with a proper escape sequence, otherwise the terminal may hang.

Kind: static constant of Terminal

Terminal.BTN_EVENT_MOUSE

Constant used for enableMouse(): Motion events only when buttons are down.

Kind: static constant of Terminal

Terminal.ANY_EVENT_MOUSE

Constant used for enableMouse(): All events.

Kind: static constant of Terminal

Terminal~TermOptions

Kind: inner typedef of Terminal
Properties

Name Type Default Description
timeout number 500 The escape sequence timeout, in milliseconds. tty-events will stop waiting for the rest of an escape sequence when the timeout fires. Infinity = no timeout.
encoding string "utf-8" The encoding of the input stream.