Skip to main content

Class: ProgressBar

Defined in: packages/core/src/widgets/progressbar.ts:21

ProgressBar

Extends

Constructors

Constructor

new ProgressBar(options): ProgressBar

Defined in: packages/core/src/widgets/progressbar.ts:29

Parameters

options

ProgressBarOptions = {}

Returns

ProgressBar

Overrides

Input.constructor

Properties

_events

_events: any

Defined in: packages/core/src/lib/events.ts:10

Inherited from

Input._events


_maxListeners?

optional _maxListeners: number

Defined in: packages/core/src/lib/events.ts:11

Inherited from

Input._maxListeners


options

options: ElementOptions

Defined in: packages/core/src/widgets/element.ts:48

Inherited from

Input.options


name?

optional name: string

Defined in: packages/core/src/widgets/element.ts:50

Inherited from

Input.name


position

position: any

Defined in: packages/core/src/widgets/element.ts:55

Position specification. Can be relative coordinates or keywords. Kept as any due to complex internal position calculation system.

Inherited from

Input.position


noOverflow?

optional noOverflow: boolean

Defined in: packages/core/src/widgets/element.ts:56

Inherited from

Input.noOverflow


dockBorders?

optional dockBorders: boolean

Defined in: packages/core/src/widgets/element.ts:57

Inherited from

Input.dockBorders


shadow?

optional shadow: boolean

Defined in: packages/core/src/widgets/element.ts:58

Inherited from

Input.shadow


hidden

hidden: boolean

Defined in: packages/core/src/widgets/element.ts:61

Inherited from

Input.hidden


fixed

fixed: boolean

Defined in: packages/core/src/widgets/element.ts:62

Inherited from

Input.fixed


align

align: string

Defined in: packages/core/src/widgets/element.ts:63

Inherited from

Input.align


valign

valign: string

Defined in: packages/core/src/widgets/element.ts:64

Inherited from

Input.valign


wrap

wrap: boolean

Defined in: packages/core/src/widgets/element.ts:65

Inherited from

Input.wrap


shrink?

optional shrink: boolean

Defined in: packages/core/src/widgets/element.ts:66

Inherited from

Input.shrink


ch

ch: string

Defined in: packages/core/src/widgets/element.ts:67

Inherited from

Input.ch


padding

padding: Padding

Defined in: packages/core/src/widgets/element.ts:69

Padding configuration for all sides

Inherited from

Input.padding


border?

optional border: Border

Defined in: packages/core/src/widgets/element.ts:71

Border configuration

Inherited from

Input.border


parseTags?

optional parseTags: boolean

Defined in: packages/core/src/widgets/element.ts:72

Inherited from

Input.parseTags


content

content: string = ""

Defined in: packages/core/src/widgets/element.ts:73

Inherited from

Input.content


lpos?

optional lpos: RenderCoords

Defined in: packages/core/src/widgets/element.ts:75

Last rendered position coordinates

Inherited from

Input.lpos


_clines?

optional _clines: any

Defined in: packages/core/src/widgets/element.ts:76

Inherited from

Input._clines


_pcontent?

optional _pcontent: string

Defined in: packages/core/src/widgets/element.ts:77

Inherited from

Input._pcontent


_slisteners?

optional _slisteners: any[]

Defined in: packages/core/src/widgets/element.ts:78

Inherited from

Input._slisteners


_label?

optional _label: any

Defined in: packages/core/src/widgets/element.ts:79

Inherited from

Input._label


_labelScroll()?

optional _labelScroll: () => void

Defined in: packages/core/src/widgets/element.ts:80

Returns

void

Inherited from

Input._labelScroll


_labelResize()?

optional _labelResize: () => void

Defined in: packages/core/src/widgets/element.ts:81

Returns

void

Inherited from

Input._labelResize


_hoverOptions?

optional _hoverOptions: any

Defined in: packages/core/src/widgets/element.ts:82

Inherited from

Input._hoverOptions


_draggable?

optional _draggable: boolean

Defined in: packages/core/src/widgets/element.ts:83

Inherited from

Input._draggable


_dragMD()?

optional _dragMD: (data) => void

Defined in: packages/core/src/widgets/element.ts:84

Parameters

data

MouseEvent

Returns

void

Inherited from

Input._dragMD


_dragM()?

optional _dragM: (data) => void

Defined in: packages/core/src/widgets/element.ts:85

Parameters

data

MouseEvent

Returns

void

Inherited from

Input._dragM


_drag?

optional _drag: any

Defined in: packages/core/src/widgets/element.ts:86

Inherited from

Input._drag


_noFill?

optional _noFill: boolean

Defined in: packages/core/src/widgets/element.ts:87

Inherited from

Input._noFill


_isLabel?

optional _isLabel: boolean

Defined in: packages/core/src/widgets/element.ts:88

Inherited from

Input._isLabel


_isList?

optional _isList: boolean

Defined in: packages/core/src/widgets/element.ts:89

Inherited from

Input._isList


childBase?

optional childBase: number

Defined in: packages/core/src/widgets/element.ts:90

Inherited from

Input.childBase


childOffset?

optional childOffset: number

Defined in: packages/core/src/widgets/element.ts:91

Inherited from

Input.childOffset


alwaysScroll?

optional alwaysScroll: boolean

Defined in: packages/core/src/widgets/element.ts:92

Inherited from

Input.alwaysScroll


baseLimit?

optional baseLimit: number

Defined in: packages/core/src/widgets/element.ts:93

Inherited from

Input.baseLimit


track?

optional track: TrackConfig

Defined in: packages/core/src/widgets/element.ts:94

Inherited from

Input.track


scrollbar?

optional scrollbar: ScrollbarConfig

Defined in: packages/core/src/widgets/element.ts:95

Inherited from

Input.scrollbar


items?

optional items: any[]

Defined in: packages/core/src/widgets/element.ts:96

Inherited from

Input.items


scrollable?

optional scrollable: boolean

Defined in: packages/core/src/widgets/element.ts:99

Inherited from

Input.scrollable


scroll()?

optional scroll: (offset, always?) => any

Defined in: packages/core/src/widgets/element.ts:102

Scroll the content by a relative offset.

Parameters

offset

number

The number of lines/items to scroll (positive = down, negative = up)

always?

boolean

Force the scroll operation even if position hasn't changed

Returns

any

Inherited from

Input.scroll


scrollTo()?

optional scrollTo: (offset, always?) => void

Defined in: packages/core/src/widgets/element.ts:103

Scroll the content to an absolute index.

Parameters

offset

number

The absolute scroll position (line/item index)

always?

boolean

Force the scroll operation even if position hasn't changed

Returns

void

Inherited from

Input.scrollTo


setScroll()?

optional setScroll: (offset, always?) => void

Defined in: packages/core/src/widgets/element.ts:104

Scroll the content to an absolute index (alias for scrollTo).

Parameters

offset

number

The absolute scroll position (line/item index)

always?

boolean

Force the scroll operation even if position hasn't changed

Returns

void

Inherited from

Input.setScroll


getScroll()?

optional getScroll: () => number

Defined in: packages/core/src/widgets/element.ts:105

Get the current scroll index in lines.

Returns

number

The current absolute scroll position

Inherited from

Input.getScroll


getScrollHeight()?

optional getScrollHeight: () => number

Defined in: packages/core/src/widgets/element.ts:106

Get the actual height of the scrolling area (total content height).

Returns

number

The total scrollable content height in lines

Inherited from

Input.getScrollHeight


getScrollPerc()?

optional getScrollPerc: (s?) => number

Defined in: packages/core/src/widgets/element.ts:107

Get the current scroll index in percentage (0-100).

Parameters

s?

boolean

Internal flag for special return values

Returns

number

The scroll position as a percentage (0-100), or -1 if not scrollable

Inherited from

Input.getScrollPerc


setScrollPerc()?

optional setScrollPerc: (i) => void

Defined in: packages/core/src/widgets/element.ts:108

Set the current scroll index in percentage (0-100).

Parameters

i

number

The target scroll percentage (0-100)

Returns

void

Inherited from

Input.setScrollPerc


resetScroll()?

optional resetScroll: () => any

Defined in: packages/core/src/widgets/element.ts:109

Reset the scroll index to its initial state (top).

Returns

any

Inherited from

Input.resetScroll


_scrollBottom()?

optional _scrollBottom: () => number

Defined in: packages/core/src/widgets/element.ts:110

Returns

number

Inherited from

Input._scrollBottom


_recalculateIndex()?

optional _recalculateIndex: () => number

Defined in: packages/core/src/widgets/element.ts:111

Returns

number

Inherited from

Input._recalculateIndex


keyable

keyable: boolean

Defined in: packages/core/src/widgets/input.ts:18

Inherited from

Input.keyable


uid

static uid: number = 0

Defined in: packages/core/src/widgets/node.ts:30

Inherited from

Input.uid


ScreenRegistry

static ScreenRegistry: any

Defined in: packages/core/src/widgets/node.ts:31

Inherited from

Input.ScreenRegistry


screen

screen: any

Defined in: packages/core/src/widgets/node.ts:47

Reference to the parent Screen instance. Type: Screen (subclass of Node)

Kept as any due to circular dependency between Node and Screen, and to preserve access to Screen-specific methods like clearRegion(), render(), and the program property without complex generic typing.

Inherited from

Input.screen


parent

parent: any

Defined in: packages/core/src/widgets/node.ts:56

Reference to the parent element in the widget tree. Type: Node (can be any Element/Box/List/etc subclass)

Kept as any to avoid complex generic typing and preserve access to subclass-specific methods. Attempting to type as Node loses methods from subclasses like Box, List, Form, etc.

Inherited from

Input.parent


children

children: any[]

Defined in: packages/core/src/widgets/node.ts:63

Array of child elements. Type: Node[] (can contain any Node subclasses)

Kept as any[] to preserve flexibility with mixed widget types.

Inherited from

Input.children


$

$: Record<string, unknown>

Defined in: packages/core/src/widgets/node.ts:68

An object for any miscellaneous user data.

Inherited from

Input.$


_

_: Record<string, unknown>

Defined in: packages/core/src/widgets/node.ts:73

An object for any miscellaneous user data.

Inherited from

Input._


data

data: Record<string, unknown>

Defined in: packages/core/src/widgets/node.ts:78

An object for any miscellaneous user data.

Inherited from

Input.data


uid

uid: number

Defined in: packages/core/src/widgets/node.ts:80

Inherited from

Input.uid


index

index: number = -1

Defined in: packages/core/src/widgets/node.ts:86

Render index (document order index) of the last render call. Indicates the order in which this element was rendered relative to others. Set to -1 initially, updated during rendering.

Inherited from

Input.index


detached?

optional detached: boolean

Defined in: packages/core/src/widgets/node.ts:87

Inherited from

Input.detached


destroyed?

optional destroyed: boolean

Defined in: packages/core/src/widgets/node.ts:88

Inherited from

Input.destroyed


runtime

runtime: Runtime

Defined in: packages/core/src/widgets/node.ts:90

Inherited from

Input.runtime


type

type: string = "progress-bar"

Defined in: packages/core/src/widgets/progressbar.ts:22

Type of the node (e.g. box, list, form, etc.). Used to identify the widget type at runtime.

Overrides

Input.type


style

style: ProgressBarStyle

Defined in: packages/core/src/widgets/progressbar.ts:23

Element style configuration (colors, attributes, hover/focus effects)

Overrides

Input.style


filled

filled: number

Defined in: packages/core/src/widgets/progressbar.ts:24


value

value: number

Defined in: packages/core/src/widgets/progressbar.ts:25


pch

pch: string

Defined in: packages/core/src/widgets/progressbar.ts:26


orientation

orientation: string

Defined in: packages/core/src/widgets/progressbar.ts:27

Accessors

focused

Get Signature

get focused(): boolean

Defined in: packages/core/src/widgets/element.ts:113

Returns

boolean

Inherited from

Input.focused


visible

Get Signature

get visible(): boolean

Defined in: packages/core/src/widgets/element.ts:924

Returns

boolean

Inherited from

Input.visible


_detached

Get Signature

get _detached(): boolean

Defined in: packages/core/src/widgets/element.ts:935

Returns

boolean

Inherited from

Input._detached


draggable

Get Signature

get draggable(): boolean

Defined in: packages/core/src/widgets/element.ts:968

Returns

boolean

Set Signature

set draggable(draggable): void

Defined in: packages/core/src/widgets/element.ts:972

Parameters
draggable

any

Returns

void

Inherited from

Input.draggable


width

Get Signature

get width(): number

Defined in: packages/core/src/widgets/element.ts:1369

Returns

number

Set Signature

set width(val): void

Defined in: packages/core/src/widgets/element.ts:1573

Position Setters

Parameters
val

any

Returns

void

Inherited from

Input.width


height

Get Signature

get height(): number

Defined in: packages/core/src/widgets/element.ts:1420

Returns

number

Set Signature

set height(val): void

Defined in: packages/core/src/widgets/element.ts:1581

Parameters
val

any

Returns

void

Inherited from

Input.height


aleft

Get Signature

get aleft(): number

Defined in: packages/core/src/widgets/element.ts:1457

Returns

number

Set Signature

set aleft(val): void

Defined in: packages/core/src/widgets/element.ts:1589

Parameters
val

any

Returns

void

Inherited from

Input.aleft


aright

Get Signature

get aright(): number

Defined in: packages/core/src/widgets/element.ts:1482

Returns

number

Set Signature

set aright(val): void

Defined in: packages/core/src/widgets/element.ts:1610

Parameters
val

any

Returns

void

Inherited from

Input.aright


atop

Get Signature

get atop(): number

Defined in: packages/core/src/widgets/element.ts:1519

Returns

number

Set Signature

set atop(val): void

Defined in: packages/core/src/widgets/element.ts:1618

Parameters
val

any

Returns

void

Inherited from

Input.atop


abottom

Get Signature

get abottom(): number

Defined in: packages/core/src/widgets/element.ts:1544

Returns

number

Set Signature

set abottom(val): void

Defined in: packages/core/src/widgets/element.ts:1639

Parameters
val

any

Returns

void

Inherited from

Input.abottom


rleft

Get Signature

get rleft(): number

Defined in: packages/core/src/widgets/element.ts:1548

Returns

number

Set Signature

set rleft(val): void

Defined in: packages/core/src/widgets/element.ts:1647

Parameters
val

any

Returns

void

Inherited from

Input.rleft


rright

Get Signature

get rright(): number

Defined in: packages/core/src/widgets/element.ts:1552

Returns

number

Set Signature

set rright(val): void

Defined in: packages/core/src/widgets/element.ts:1655

Parameters
val

any

Returns

void

Inherited from

Input.rright


rtop

Get Signature

get rtop(): number

Defined in: packages/core/src/widgets/element.ts:1556

Returns

number

Set Signature

set rtop(val): void

Defined in: packages/core/src/widgets/element.ts:1662

Parameters
val

any

Returns

void

Inherited from

Input.rtop


rbottom

Get Signature

get rbottom(): number

Defined in: packages/core/src/widgets/element.ts:1560

Returns

number

Set Signature

set rbottom(val): void

Defined in: packages/core/src/widgets/element.ts:1670

Parameters
val

any

Returns

void

Inherited from

Input.rbottom


ileft

Get Signature

get ileft(): number

Defined in: packages/core/src/widgets/element.ts:1677

Returns

number

Inherited from

Input.ileft


itop

Get Signature

get itop(): number

Defined in: packages/core/src/widgets/element.ts:1682

Returns

number

Inherited from

Input.itop


iright

Get Signature

get iright(): number

Defined in: packages/core/src/widgets/element.ts:1687

Returns

number

Inherited from

Input.iright


ibottom

Get Signature

get ibottom(): number

Defined in: packages/core/src/widgets/element.ts:1692

Returns

number

Inherited from

Input.ibottom


iwidth

Get Signature

get iwidth(): number

Defined in: packages/core/src/widgets/element.ts:1697

Returns

number

Inherited from

Input.iwidth


iheight

Get Signature

get iheight(): number

Defined in: packages/core/src/widgets/element.ts:1704

Returns

number

Inherited from

Input.iheight


tpadding

Get Signature

get tpadding(): number

Defined in: packages/core/src/widgets/element.ts:1711

Returns

number

Inherited from

Input.tpadding


left

Get Signature

get left(): number

Defined in: packages/core/src/widgets/element.ts:1724

Relative coordinates as default properties

Returns

number

Set Signature

set left(val): void

Defined in: packages/core/src/widgets/element.ts:1740

Parameters
val

any

Returns

void

Inherited from

Input.left


Get Signature

get right(): number

Defined in: packages/core/src/widgets/element.ts:1728

Returns

number

Set Signature

set right(val): void

Defined in: packages/core/src/widgets/element.ts:1744

Parameters
val

any

Returns

void

Inherited from

Input.right


top

Get Signature

get top(): number

Defined in: packages/core/src/widgets/element.ts:1732

Returns

number

Set Signature

set top(val): void

Defined in: packages/core/src/widgets/element.ts:1748

Parameters
val

any

Returns

void

Inherited from

Input.top


bottom

Get Signature

get bottom(): number

Defined in: packages/core/src/widgets/element.ts:1736

Returns

number

Set Signature

set bottom(val): void

Defined in: packages/core/src/widgets/element.ts:1752

Parameters
val

any

Returns

void

Inherited from

Input.bottom

Methods

setMaxListeners()

setMaxListeners(n): void

Defined in: packages/core/src/lib/events.ts:19

Parameters

n

number

Returns

void

Inherited from

Input.setMaxListeners


addListener()

addListener(type, listener): void

Defined in: packages/core/src/lib/events.ts:23

Parameters

type

string

listener

Function

Returns

void

Inherited from

Input.addListener


on()

on(type, listener): any

Defined in: packages/core/src/lib/events.ts:34

Parameters

type

string

listener

Function

Returns

any

Inherited from

Input.on


removeListener()

removeListener(type, listener): void

Defined in: packages/core/src/lib/events.ts:38

Parameters

type

string

listener

Function

Returns

void

Inherited from

Input.removeListener


off()

off(type, listener): any

Defined in: packages/core/src/lib/events.ts:57

Parameters

type

string

listener

Function

Returns

any

Inherited from

Input.off


removeAllListeners()

removeAllListeners(type?): void

Defined in: packages/core/src/lib/events.ts:61

Parameters

type?

string

Returns

void

Inherited from

Input.removeAllListeners


once()

once(type, listener): any

Defined in: packages/core/src/lib/events.ts:69

Parameters

type

string

listener

Function

Returns

any

Inherited from

Input.once


listeners()

listeners(type): Function[]

Defined in: packages/core/src/lib/events.ts:79

Parameters

type

string

Returns

Function[]

Inherited from

Input.listeners


_emit()

_emit(type, args): any

Defined in: packages/core/src/lib/events.ts:85

Parameters

type

string

args

any[]

Returns

any

Inherited from

Input._emit


emit()

emit(type, ...rest): boolean

Defined in: packages/core/src/lib/events.ts:113

Parameters

type

string

rest

...any[]

Returns

boolean

Inherited from

Input.emit


sattr()

sattr(style, fg?, bg?): number

Defined in: packages/core/src/widgets/element.ts:320

Parameters

style

any

fg?

any

bg?

any

Returns

number

Inherited from

Input.sattr


onScreenEvent()

onScreenEvent(type, handler): void

Defined in: packages/core/src/widgets/element.ts:363

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

Event type

handler

(...args) => void

Event handler function

Returns

void

Inherited from

Input.onScreenEvent


onceScreenEvent()

onceScreenEvent(type, handler): void

Defined in: packages/core/src/widgets/element.ts:374

Same as onScreenEvent() but fires only once.

Parameters

type

string

Event type

handler

(...args) => void

Event handler function

Returns

void

Inherited from

Input.onceScreenEvent


removeScreenEvent()

removeScreenEvent(type, handler): void

Defined in: packages/core/src/widgets/element.ts:391

Same as el.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

Event type

handler

(...args) => void

Event handler function

Returns

void

Inherited from

Input.removeScreenEvent


free()

free(): void

Defined in: packages/core/src/widgets/element.ts:411

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

Inherited from

Input.free


hide()

hide(): void

Defined in: packages/core/src/widgets/element.ts:423

Hide element.

Returns

void

Inherited from

Input.hide


show()

show(): void

Defined in: packages/core/src/widgets/element.ts:436

Show element.

Returns

void

Inherited from

Input.show


toggle()

toggle(): void

Defined in: packages/core/src/widgets/element.ts:445

Toggle hidden/shown.

Returns

void

Inherited from

Input.toggle


focus()

focus(): any

Defined in: packages/core/src/widgets/element.ts:452

Focus element.

Returns

any

Inherited from

Input.focus


isFocusable()

isFocusable(): boolean

Defined in: packages/core/src/widgets/element.ts:460

Check if this element can receive keyboard focus. Elements are focusable if they have tabIndex >= -1 and are visible/attached.

Returns

boolean

Inherited from

Input.isFocusable


isInTabOrder()

isInTabOrder(): boolean

Defined in: packages/core/src/widgets/element.ts:469

Check if element participates in Tab key navigation. Elements with tabIndex=-1 are focusable but excluded from Tab order.

Returns

boolean

Inherited from

Input.isInTabOrder


getTabIndex()

getTabIndex(): number

Defined in: packages/core/src/widgets/element.ts:478

Get effective tab index for focus navigation ordering.

Returns

number

Inherited from

Input.getTabIndex


setContent()

setContent(content, noClear?, noTags?): void

Defined in: packages/core/src/widgets/element.ts:490

Set or get 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

content

string

noClear?

boolean

noTags?

boolean

Returns

void

Inherited from

Input.setContent


getContent()

getContent(): string

Defined in: packages/core/src/widgets/element.ts:500

Return content, slightly different from el.content. Assume the above formatting.

Returns

string

Inherited from

Input.getContent


setText()

setText(content, noClear?): void

Defined in: packages/core/src/widgets/element.ts:508

Similar to setContent, but ignore tags and remove escape codes.

Parameters

content

string

noClear?

boolean

Returns

void

Inherited from

Input.setText


getText()

getText(): string

Defined in: packages/core/src/widgets/element.ts:517

Similar to getContent, but return content with tags and escape codes removed.

Returns

string

Inherited from

Input.getText


parseContent()

parseContent(noTags?): boolean

Defined in: packages/core/src/widgets/element.ts:521

Parameters

noTags?

boolean

Returns

boolean

Inherited from

Input.parseContent


_parseTags()

_parseTags(text): string

Defined in: packages/core/src/widgets/element.ts:588

Parameters

text

string

Returns

string

Inherited from

Input._parseTags


_parseAttr()

_parseAttr(lines): any

Defined in: packages/core/src/widgets/element.ts:693

Parameters

lines

any

Returns

any

Inherited from

Input._parseAttr


_align()

_align(line, width, align?): string

Defined in: packages/core/src/widgets/element.ts:722

Parameters

line

string

width

number

align?

string

Returns

string

Inherited from

Input._align


_wrapContent()

_wrapContent(content, width): WrappedContent

Defined in: packages/core/src/widgets/element.ts:754

Parameters

content

string

width

number

Returns

WrappedContent

Inherited from

Input._wrapContent


enableMouse()

enableMouse(): void

Defined in: packages/core/src/widgets/element.ts:948

Enable mouse events for the element (automatically called when a form of on('mouse') is bound). Registers the element as clickable with the screen.

Returns

void

Inherited from

Input.enableMouse


enableKeys()

enableKeys(): void

Defined in: packages/core/src/widgets/element.ts:956

Enable keypress events for the element (automatically called when a form of on('keypress') is bound). Registers the element as keyable with the screen.

Returns

void

Inherited from

Input.enableKeys


enableInput()

enableInput(): void

Defined in: packages/core/src/widgets/element.ts:963

Enable key and mouse events. Calls both enableMouse() and enableKeys().

Returns

void

Inherited from

Input.enableInput


enableDrag()

enableDrag(verify?): boolean

Defined in: packages/core/src/widgets/element.ts:986

Enable dragging of the element. Allows the element to be dragged with the mouse. Automatically calls enableMouse().

Parameters

verify?

any

Optional callback function to verify if dragging should start (receives mouse data)

Returns

boolean

True if dragging was enabled

Inherited from

Input.enableDrag


disableDrag()

disableDrag(): boolean

Defined in: packages/core/src/widgets/element.ts:1060

Disable dragging of the element. Removes drag event handlers and resets dragging state.

Returns

boolean

True if dragging was disabled

Inherited from

Input.disableDrag


key()

key(...args): any

Defined in: packages/core/src/widgets/element.ts:1074

Bind a key event handler.

Parameters

args

...any[]

Arguments to pass to program.key()

Returns

any

The bound key handler

Inherited from

Input.key


onceKey()

onceKey(...args): any

Defined in: packages/core/src/widgets/element.ts:1083

Bind a key event handler that fires only once.

Parameters

args

...any[]

Arguments to pass to program.onceKey()

Returns

any

The bound key handler

Inherited from

Input.onceKey


unkey()

unkey(...args): any

Defined in: packages/core/src/widgets/element.ts:1092

Unbind a key event handler.

Parameters

args

...any[]

Arguments to pass to program.unkey()

Returns

any

Result of unbinding

Inherited from

Input.unkey


removeKey()

removeKey(...args): any

Defined in: packages/core/src/widgets/element.ts:1102

Remove a key event handler. Alias for unkey().

Parameters

args

...any[]

Arguments to pass to program.unkey()

Returns

any

Result of removing

Inherited from

Input.removeKey


setIndex()

setIndex(index): void

Defined in: packages/core/src/widgets/element.ts:1111

Set the z-index of the element (changes rendering order). Higher indices are rendered later (on top). Negative indices count from the end.

Parameters

index

number

New z-index value

Returns

void

Inherited from

Input.setIndex


setFront()

setFront(): void

Defined in: packages/core/src/widgets/element.ts:1132

Put the element in front of its siblings. Sets the element's z-index to the highest value (renders last/on top).

Returns

void

Inherited from

Input.setFront


setBack()

setBack(): void

Defined in: packages/core/src/widgets/element.ts:1140

Put the element in back of its siblings. Sets the element's z-index to the lowest value (renders first/at bottom).

Returns

void

Inherited from

Input.setBack


clearPos()

clearPos(get?, override?): void

Defined in: packages/core/src/widgets/element.ts:1150

Clear the element's position in the screen buffer. Fills the region with spaces, used when moving or hiding elements.

Parameters

get?

boolean

Whether to use _getCoords (default: false)

override?

any

If true, always clear even if cell hasn't changed

Returns

void

Inherited from

Input.clearPos


setLabel()

setLabel(options): void

Defined in: packages/core/src/widgets/element.ts:1165

Set the label text for the top-left (or top-right) corner. Creates or updates a label that appears on the top border of the element.

Parameters

options

any

Label text (string) or options object with text and side properties

Returns

void

Example

element.setLabel('My Label');
element.setLabel({ text: 'My Label', side: 'right' });

Inherited from

Input.setLabel


removeLabel()

removeLabel(): void

Defined in: packages/core/src/widgets/element.ts:1244

Remove the label completely. Detaches the label element and removes associated event listeners.

Returns

void

Inherited from

Input.removeLabel


setHover()

setHover(options): void

Defined in: packages/core/src/widgets/element.ts:1261

Set a hover text box to follow the cursor. Similar to the "title" DOM attribute in the browser.

Parameters

options

any

Hover text (string) or options object with text property

Returns

void

Example

element.setHover('Hover text here');
element.setHover({ text: 'Hover text here' });

Inherited from

Input.setHover


removeHover()

removeHover(): void

Defined in: packages/core/src/widgets/element.ts:1275

Remove the hover label completely. Detaches the hover text box if it's currently displayed.

Returns

void

Inherited from

Input.removeHover


_getPos()

_getPos(): any

Defined in: packages/core/src/widgets/element.ts:1301

Positioning

Returns

any

Inherited from

Input._getPos


_getWidth()

_getWidth(get?): number

Defined in: packages/core/src/widgets/element.ts:1322

Position Getters

Parameters

get?

boolean

Returns

number

Inherited from

Input._getWidth


_getHeight()

_getHeight(get?): number

Defined in: packages/core/src/widgets/element.ts:1373

Parameters

get?

boolean

Returns

number

Inherited from

Input._getHeight


_getLeft()

_getLeft(get?): number

Defined in: packages/core/src/widgets/element.ts:1424

Parameters

get?

boolean

Returns

number

Inherited from

Input._getLeft


_getRight()

_getRight(get?): number

Defined in: packages/core/src/widgets/element.ts:1461

Parameters

get?

boolean

Returns

number

Inherited from

Input._getRight


_getTop()

_getTop(get?): number

Defined in: packages/core/src/widgets/element.ts:1486

Parameters

get?

boolean

Returns

number

Inherited from

Input._getTop


_getBottom()

_getBottom(get?): number

Defined in: packages/core/src/widgets/element.ts:1523

Parameters

get?

boolean

Returns

number

Inherited from

Input._getBottom


_getShrinkBox()

_getShrinkBox(xi, xl, yi, yl, get?): any

Defined in: packages/core/src/widgets/element.ts:1760

Rendering - here be dragons

Parameters

xi

number

xl

number

yi

number

yl

number

get?

boolean

Returns

any

Inherited from

Input._getShrinkBox


_getShrinkContent()

_getShrinkContent(xi, xl, yi, yl, _get?): any

Defined in: packages/core/src/widgets/element.ts:1911

Parameters

xi

number

xl

number

yi

number

yl

number

_get?

boolean

Returns

any

Inherited from

Input._getShrinkContent


_getShrink()

_getShrink(xi, xl, yi, yl, get?): any

Defined in: packages/core/src/widgets/element.ts:1947

Parameters

xi

number

xl

number

yi

number

yl

number

get?

boolean

Returns

any

Inherited from

Input._getShrink


_getCoords()

_getCoords(get?, noscroll?): RenderCoords | undefined

Defined in: packages/core/src/widgets/element.ts:1992

Parameters

get?

boolean

noscroll?

boolean

Returns

RenderCoords | undefined

Inherited from

Input._getCoords


_render()

_render(): any

Defined in: packages/core/src/widgets/element.ts:2703

Internal alias for render().

Returns

any

Rendered coordinates object

Inherited from

Input._render


insertLine()

insertLine(i, line): void

Defined in: packages/core/src/widgets/element.ts:2717

Insert a line into the box's content. Handles wrapped content by inserting at the specified fake line index.

Parameters

i

number

Line index to insert at (fake line number)

line

Line or array of lines to insert

string | string[]

Returns

void

Inherited from

Input.insertLine


deleteLine()

deleteLine(i, n?): void

Defined in: packages/core/src/widgets/element.ts:2778

Delete a line from the box's content. Handles wrapped content by deleting at the specified fake line index.

Parameters

i

number

Line index to delete (fake line number)

n?

number

Number of lines to delete (default: 1)

Returns

void

Inherited from

Input.deleteLine


insertTop()

insertTop(line): void

Defined in: packages/core/src/widgets/element.ts:2834

Insert a line at the top of the box. Inserts at the first visible line based on childBase.

Parameters

line

Line or array of lines to insert

string | string[]

Returns

void

Inherited from

Input.insertTop


insertBottom()

insertBottom(line): void

Defined in: packages/core/src/widgets/element.ts:2844

Insert a line at the bottom of the box. Inserts after the last visible line based on height and childBase.

Parameters

line

Line or array of lines to insert

string | string[]

Returns

void

Inherited from

Input.insertBottom


deleteTop()

deleteTop(n?): void

Defined in: packages/core/src/widgets/element.ts:2857

Delete a line at the top of the box. Deletes from the first visible line based on childBase.

Parameters

n?

number

Number of lines to delete (default: 1)

Returns

void

Inherited from

Input.deleteTop


deleteBottom()

deleteBottom(n?): void

Defined in: packages/core/src/widgets/element.ts:2867

Delete a line at the bottom of the box. Deletes from the last visible line based on height and childBase.

Parameters

n?

number

Number of lines to delete (default: 1)

Returns

void

Inherited from

Input.deleteBottom


setLine()

setLine(i, line): void

Defined in: packages/core/src/widgets/element.ts:2882

Set a line in the box's content.

Parameters

i

number

Line index to set (fake line number)

line

string

Line content to set

Returns

void

Inherited from

Input.setLine


setBaseLine()

setBaseLine(i, line): void

Defined in: packages/core/src/widgets/element.ts:2896

Set a line in the box's content from the visible top.

Parameters

i

number

Line offset from visible top

line

string

Line content to set

Returns

void

Inherited from

Input.setBaseLine


getLine()

getLine(i): string

Defined in: packages/core/src/widgets/element.ts:2906

Get a line from the box's content.

Parameters

i

number

Line index to get (fake line number)

Returns

string

Line content

Inherited from

Input.getLine


getBaseLine()

getBaseLine(i): string

Defined in: packages/core/src/widgets/element.ts:2917

Get a line from the box's content from the visible top.

Parameters

i

number

Line offset from visible top

Returns

string

Line content

Inherited from

Input.getBaseLine


clearLine()

clearLine(i): void

Defined in: packages/core/src/widgets/element.ts:2926

Clear a line from the box's content.

Parameters

i

number

Line index to clear (fake line number)

Returns

void

Inherited from

Input.clearLine


clearBaseLine()

clearBaseLine(i): void

Defined in: packages/core/src/widgets/element.ts:2935

Clear a line from the box's content from the visible top.

Parameters

i

number

Line offset from visible top

Returns

void

Inherited from

Input.clearBaseLine


unshiftLine()

unshiftLine(line): void

Defined in: packages/core/src/widgets/element.ts:2944

Unshift a line onto the top of the content.

Parameters

line

Line or array of lines to insert

string | string[]

Returns

void

Inherited from

Input.unshiftLine


shiftLine()

shiftLine(i?, n?): void

Defined in: packages/core/src/widgets/element.ts:2953

Shift a line off the top of the content.

Parameters

i?

number

Line index to remove (default: 0)

n?

number

Number of lines to remove (default: 1)

Returns

void

Inherited from

Input.shiftLine


pushLine()

pushLine(line): void

Defined in: packages/core/src/widgets/element.ts:2961

Push a line onto the bottom of the content.

Parameters

line

Line or array of lines to insert

string | string[]

Returns

void

Inherited from

Input.pushLine


popLine()

popLine(n?): void

Defined in: packages/core/src/widgets/element.ts:2970

Pop a line off the bottom of the content.

Parameters

n?

number

Number of lines to remove (default: 1)

Returns

void

Inherited from

Input.popLine


getLines()

getLines(): string[]

Defined in: packages/core/src/widgets/element.ts:2978

An array containing the content lines.

Returns

string[]

Array of fake (unwrapped) lines

Inherited from

Input.getLines


getScreenLines()

getScreenLines(): string[]

Defined in: packages/core/src/widgets/element.ts:2986

An array containing the lines as they are displayed on the screen.

Returns

string[]

Array of real (wrapped) lines

Inherited from

Input.getScreenLines


strWidth()

strWidth(text): number

Defined in: packages/core/src/widgets/element.ts:2996

Get a string's displayed width, taking into account double-width, surrogate pairs, combining characters, tags, and SGR escape codes.

Parameters

text

string

Text to measure

Returns

number

Displayed width in cells

Inherited from

Input.strWidth


screenshot()

screenshot(xi?, xl?, yi?, yl?): string

Defined in: packages/core/src/widgets/element.ts:3012

Take an SGR screenshot of the element 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

Left X offset from element's inner left (default: 0)

xl?

number

Right X offset from element's inner left (default: element width)

yi?

number

Top Y offset from element's inner top (default: 0)

yl?

number

Bottom Y offset from element's inner top (default: element height)

Returns

string

SGR-encoded screenshot string

Inherited from

Input.screenshot


insert()

insert(element, i): void

Defined in: packages/core/src/widgets/node.ts:154

Insert a node to this node's children at index i.

Parameters

element

any

i

number

Returns

void

Inherited from

Input.insert


prepend()

prepend(element): void

Defined in: packages/core/src/widgets/node.ts:191

Prepend a node to this node's children.

Parameters

element

any

Returns

void

Inherited from

Input.prepend


append()

append(element): void

Defined in: packages/core/src/widgets/node.ts:198

Append a node to this node's children.

Parameters

element

any

Returns

void

Inherited from

Input.append


insertBefore()

insertBefore(element, other): void

Defined in: packages/core/src/widgets/node.ts:205

Insert a node to this node's children before the reference node.

Parameters

element

any

other

any

Returns

void

Inherited from

Input.insertBefore


insertAfter()

insertAfter(element, other): void

Defined in: packages/core/src/widgets/node.ts:213

Insert a node from node after the reference node.

Parameters

element

any

other

any

Returns

void

Inherited from

Input.insertAfter


remove()

remove(element): void

Defined in: packages/core/src/widgets/node.ts:221

Remove child node from node.

Parameters

element

any

Returns

void

Inherited from

Input.remove


detach()

detach(): void

Defined in: packages/core/src/widgets/node.ts:255

Remove node from its parent.

Returns

void

Inherited from

Input.detach


destroy()

destroy(): void

Defined in: packages/core/src/widgets/node.ts:271

Same as the detach() method, except this will automatically call free() and unbind any screen events to prevent memory leaks. For use with onScreenEvent(), removeScreenEvent(), and free().

Returns

void

Inherited from

Input.destroy


forDescendants()

forDescendants(iter, s?): void

Defined in: packages/core/src/widgets/node.ts:283

Iterate over all descendants, calling iter(el) for each.

Parameters

iter

(el) => void

s?

any

Returns

void

Inherited from

Input.forDescendants


forAncestors()

forAncestors(iter, s?): void

Defined in: packages/core/src/widgets/node.ts:294

Iterate over all ancestors, calling iter(el) for each.

Parameters

iter

(el) => void

s?

any

Returns

void

Inherited from

Input.forAncestors


collectDescendants()

collectDescendants(s?): any[]

Defined in: packages/core/src/widgets/node.ts:305

Collect all descendants into an array.

Parameters

s?

any

Returns

any[]

Inherited from

Input.collectDescendants


collectAncestors()

collectAncestors(s?): any[]

Defined in: packages/core/src/widgets/node.ts:316

Collect all ancestors into an array.

Parameters

s?

any

Returns

any[]

Inherited from

Input.collectAncestors


emitDescendants()

emitDescendants(...args): void

Defined in: packages/core/src/widgets/node.ts:327

Emit event for element, and recursively emit same event for all descendants.

Parameters

args

...any[]

Returns

void

Inherited from

Input.emitDescendants


emitAncestors()

emitAncestors(...args): void

Defined in: packages/core/src/widgets/node.ts:343

Emit event for element, and recursively emit same event for all ancestors.

Parameters

args

...any[]

Returns

void

Inherited from

Input.emitAncestors


hasDescendant()

hasDescendant(target): boolean

Defined in: packages/core/src/widgets/node.ts:359

Check if target is a descendant of this node.

Parameters

target

any

Returns

boolean

Inherited from

Input.hasDescendant


hasAncestor()

hasAncestor(target): boolean

Defined in: packages/core/src/widgets/node.ts:377

Check if target is an ancestor of this node.

Parameters

target

any

Returns

boolean

Inherited from

Input.hasAncestor


get()

get(name, value?): any

Defined in: packages/core/src/widgets/node.ts:388

Get user property with a potential default value.

Parameters

name

string

value?

any

Returns

any

Inherited from

Input.get


set()

set(name, value): any

Defined in: packages/core/src/widgets/node.ts:398

Set user property to value.

Parameters

name

string

value

any

Returns

any

Inherited from

Input.set


render()

render(): any

Defined in: packages/core/src/widgets/progressbar.ts:107

Write content and children to the screen buffer. This is the main rendering method that draws the element, its border, scrollbar, and all child elements to the screen buffer. Returns the rendered coordinates.

Returns

any

Rendered coordinates object, or undefined if hidden/invalid

Overrides

Input.render


progress()

progress(filled): void

Defined in: packages/core/src/widgets/progressbar.ts:156

Progress the bar by a fill amount. Increments the filled amount and emits 'complete' event if filled reaches 100.

Parameters

filled

number

Amount to increment (positive or negative)

Returns

void

Example

// Increase by 10%
progressBar.progress(10);
// Decrease by 5%
progressBar.progress(-5);

setProgress()

setProgress(filled): void

Defined in: packages/core/src/widgets/progressbar.ts:174

Set progress to a specific amount. Resets to 0 then progresses to the specified amount.

Parameters

filled

number

Amount to set (0-100)

Returns

void

Example

progressBar.setProgress(50);

reset()

reset(): void

Defined in: packages/core/src/widgets/progressbar.ts:186

Reset the bar to 0. Emits 'reset' event and sets filled and value to 0.

Returns

void

Example

progressBar.reset();