Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

Hierarchy

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

$

$: object

An object for any miscellaneous user data.

Type declaration

  • [index: string]: any

_

_: object

An object for any miscellaneous user data.

Type declaration

  • [index: string]: any

Optional _label

_label: BlessedElement | undefined

Get's the child element implementing the current label of this node.

internal

Optional _noFill

_noFill: boolean

If true, the element won't be filled.

internal

abottom

abottom: number

Calculated absolute bottom offset.

aleft

aleft: number

Calculated absolute left offset.

aright

aright: number

Calculated absolute right offset.

atop

atop: number

Calculated absolute top offset.

bg

bg: number

Border foreground and background, must be numbers (-1 for default).

bold

bold: string

Border attributes.

border

border: TBorder

Border object.

bottom

bottom: number | string

Calculated relative bottom offset.

childBase

childBase: number

The offset of the top of the scroll content.

childOffset

childOffset: number

The offset of the chosen item/line.

children

children: Node[]

Array of node's children.

content

content: string

data

data: object

An object for any miscellaneous user data.

Type declaration

  • [index: string]: any

detached

detached: boolean

draggable

draggable: boolean

Whether the element is draggable. Set to true to allow dragging.

fg

fg: number

focusable

focusable: boolean

If true, screen.focusNext() and methods related to focus will consider this Element.

height

height: number | string

Calculated height.

hidden

hidden: boolean

iheight

iheight: number

Calculated height taking into account padding and boder.

ileft

ileft: number

Calculated left coordinate taking into account padding and boder.

index

index: number

Render index (document order index) of the last render call.

itop

itop: number

Calculated top coordinate taking into account padding and boder.

iwidth

iwidth: number

Calculated width taking into account padding and boder.

left

left: number | string

Calculated relative left offset.

lpos

name

name: string

Name of the element. Useful for form submission.

options

options: ButtonOptions

Original options object.

padding

padding: Required<Padding>

Current element padding

Optional parent

parent: Node

Parent node. If null it means the element is not attached to any screen or program, or the node is a Screen.

position

position: Position

rbottom

rbottom: TPosition

Calculated relative bottom offset.

Setting this property will cause the element to change element's position property and emit move event.

right

right: number | string

Calculated relative right offset.

rleft

rleft: TTopLeft

Setting this property will cause the element to change element's position property and emit move event.

rright

rright: TPosition

Calculated relative bottom offset.

Setting this property will cause the element to change element's position property and emit move event.

rtop

rtop: TTopLeft

Setting this property will cause the element to change element's position property and emit move event.

screen

screen: Screen

Parent screen.

shrink

shrink: boolean

style

style: TStyle

top

top: number | string

Calculated relative top offset.

tpadding

tpadding: number

Givesthe total padding on any direction.

type

type: string

Type of the node (e.g. box).

uid

uid: number

Unique identifier for Node instances. @internal

underline

underline: string

visible

visible: boolean

width

width: number | string

Calculated width.

Static defaultMaxListeners

defaultMaxListeners: number

Methods

_align

  • _align(line: string, width: number, align: string): void

_getBottom

  • _getBottom(get?: boolean): number

_getCoords

  • _getCoords(get?: boolean, noscroll?: boolean): Coords | undefined

_getHeight

  • _getHeight(get?: boolean): number

_getLeft

  • _getLeft(get?: boolean): number

_getPos

  • _getPos(): Pos
  • whenever Box.render is called lpos gets set on the element, an object containing the rendered coordinates. Since these don't update if the element is moved somehow, they're unreliable in that situation. However, if we can guarantee that lpos is good and up to date, it can be more accurate than the calculated positions below. In this case, if the element is being rendered, it's guaranteed that the parent will have been rendered first, in which case we can use the parant's lpos instead of recalculating it's position (since that might be wrong because it doesn't handle content shrinkage).

    internal

    Returns Pos

_getRight

  • _getRight(get?: boolean): number

_getShrink

  • _getShrink(xi: number, xl: number, yi: number, yl: number, get?: boolean): SimpleCoords | undefined

_getShrinkBox

  • _getShrinkBox(xi: number, xl: number, yi: number, yl: number, get?: boolean): SimpleCoords | undefined

_getTop

  • _getTop(get?: boolean): number

_getWidth

  • _getWidth(get?: boolean): number

_parseAttr

  • _parseAttr(ines: string[]): string[]

_parseTags

  • _parseTags(s: string): string

_wrapContent

  • _wrapContent(content: string, width: number): void

addListener

  • addListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

append

  • append(node: Node): void

clearBaseLine

  • clearBaseLine(i: number): void

clearLine

  • clearLine(i: number): void

clearPos

  • clearPos(get?: boolean, override?: boolean): void

collectAncestors

  • collectAncestors(s?: boolean): void

collectDescendants

  • collectDescendants(s?: boolean): void

deleteBottom

  • deleteBottom(): void

deleteLine

  • deleteLine(i: number): void

deleteTop

  • deleteTop(): void

destroy

  • destroy(): void

detach

  • detach(): void

disableDrag

  • disableDrag(): void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

emitAncestors

  • emitAncestors(): void

emitDescendants

  • emitDescendants(type?: string, ...args: any[]): void
  • Emit event for element, and recursively emit same event for all descendants. If s is provided it will call [[iter]] on self first.

    Parameters

    • Optional type: string
    • Rest ...args: any[]

    Returns void

enableDrag

  • enableDrag(cb: function): void

enableInput

  • enableInput(): void

enableKeys

  • enableKeys(): void

enableMouse

  • enableMouse(): void

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

focus

  • focus(): void

forAncestors

  • forAncestors(iter: function, s?: boolean): void

forDescendants

  • forDescendants(iter: function, s?: boolean): void
  • Visit each node's descendants, with [[iter]] function, parents first. If s is provided it will call [[iter]] on self first.

    Parameters

    • iter: function
        • (node: Node): void
        • Parameters

          Returns void

    • Optional s: boolean

    Returns void

free

  • free(): void
  • Free up the element. Automatically unbind all events that may have been bound to the screen object. This prevents memory leaks. For use with onScreenEvent(), removeScreenEvent(), and destroy().

    Returns void

get

  • get<T>(name: string, def: T): T

getBaseLine

  • getBaseLine(i: number): string

getContent

  • getContent(): string

getLine

  • getLine(i: number): string

getLines

  • getLines(): string[]

getMaxListeners

  • getMaxListeners(): number
  • Returns number

getScreenLines

  • getScreenLines(): string[]

getScroll

  • getScroll(): number

getScrollHeight

  • getScrollHeight(): number

getScrollPerc

  • getScrollPerc(): number

getText

  • getText(): string

hasAncestor

hasDescendant

hide

  • hide(): void

insert

  • insert(node: Node, index: number): void

insertAfter

  • insertAfter(node: Node, refNode: Node): void

insertBefore

  • insertBefore(node: Node, refNode: Node): void

insertBottom

  • insertBottom(lines: string | string[]): void

insertLine

  • insertLine(i: number, lines: string | string[]): void

insertTop

  • insertTop(lines: string | string[]): void

key

kill

  • kill(): any

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string, listener: function): this
  • on(event: "press", callback: function): this

onScreenEvent

  • onScreenEvent(type: string, handler: function): void
  • Same as el.on('screen', ...) except this will automatically keep track of which listeners are bound to the screen object. For use with removeScreenEvent(), free(), and destroy().

    Parameters

    • type: string
    • handler: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

once

  • once(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

onceKey

parseContent

  • parseContent(noTags: string): boolean
  • Parses given content string with no tags before rendering. Removes / transform characters that break the output.

    For example, double-width chars will eat the next char after render in this case it creates a blank character after it so it doesn't eat the real next char.

    internal

    Parameters

    • noTags: string

    Returns boolean

popLine

  • popLine(i: number): string

prepend

  • prepend(node: Node): void

prependListener

  • prependListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

press

  • press(): void

pushLine

  • pushLine(lines: string | string[]): void

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

remove

  • remove(node: Node): void

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeHover

  • removeHover(): void

removeKey

removeLabel

  • removeLabel(): any

removeListener

  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

removeScreenEvent

  • removeScreenEvent(type: string, handler: function): void
  • Same asel.removeListener('screen', ...) except this will automatically keep track of which listeners are bound to the screen object. For use with onScreenEvent(), free(), and destroy().

    Parameters

    • type: string
    • handler: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

render

  • render(): Coords | undefined

resetScroll

  • resetScroll(): void

sattr

  • sattr(style: TStyle, fg?: string, bg?: string): any
  • calculates the value for style (could be substyle like style.bar) to paint in the screen according to the rest of the properties and optionally bg and fg.

    Parameters

    • style: TStyle
    • Optional fg: string
    • Optional bg: string

    Returns any

screenshot

  • screenshot(xi: number, xl: number, yi: number, yl: number): string
  • screenshot(): string
  • Take an SGR screenshot of the screen within the region. Returns a string containing only characters and SGR codes. Can be displayed by simply echoing it in a terminal.

    Parameters

    • xi: number
    • xl: number
    • yi: number
    • yl: number

    Returns string

  • Take an SGR screenshot of the whole screen. Returns a string containing only characters and SGR codes. Can be displayed by simply echoing it in a terminal.

    Returns string

scroll

  • scroll(offset: number, always?: boolean): void

scrollTo

  • scrollTo(index: number): void

set

  • set(name: string, value: any): void

setBack

  • setBack(): void

setBaseLine

  • setBaseLine(i: number, line: string | string[]): void

setContent

  • setContent(text: string, noClear?: boolean, noTags?: boolean): void
  • Set the content. Note: When text is input, it will be stripped of all non-SGR escape codes, tabs will be replaced with 8 spaces, and tags will be replaced with SGR codes (if enabled).

    Parameters

    • text: string
    • Optional noClear: boolean
    • Optional noTags: boolean

    Returns void

setFront

  • setFront(): void

setHover

setIndex

  • setIndex(z: number): void
  • Change this element's index in its parent's children array. This will change the rendering order. If all elements are positioned by their selves then this could be similar to CSS z-index property. But if you are using a layout or relaying somhow in the children order then it will change the position of this element and its siblings.

    Parameters

    • z: number

    Returns void

setLabel

setLine

  • setLine(i: number, line: string | string[]): void

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

setScroll

  • setScroll(index: number): void

setScrollPerc

  • setScrollPerc(perc: number): void

setText

  • setText(text: string, noClear?: boolean): void

shiftLine

  • shiftLine(i: number): void

show

  • show(): void

strWidth

  • strWidth(text: string): string

toggle

  • toggle(): void

unkey

unshiftLine

  • unshiftLine(lines: string | string[]): void

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number