Class: Element
Defined in: packages/core/src/widgets/element.ts:46
Node
Extends
Extended by
Constructors
Constructor
new Element(
options):Element
Defined in: packages/core/src/widgets/element.ts:117
Parameters
options
ElementOptions = {}
Returns
Element
Overrides
Properties
_events
_events:
any
Defined in: packages/core/src/lib/events.ts:10
Inherited from
_maxListeners?
optional_maxListeners:number
Defined in: packages/core/src/lib/events.ts:11
Inherited from
type
type:
string="element"
Defined in: packages/core/src/widgets/element.ts:47
Type of the node (e.g. box, list, form, etc.). Used to identify the widget type at runtime.
Overrides
options
options:
ElementOptions
Defined in: packages/core/src/widgets/element.ts:48
Overrides
name?
optionalname:string
Defined in: packages/core/src/widgets/element.ts:50
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.
noOverflow?
optionalnoOverflow:boolean
Defined in: packages/core/src/widgets/element.ts:56
dockBorders?
optionaldockBorders:boolean
Defined in: packages/core/src/widgets/element.ts:57
shadow?
optionalshadow:boolean
Defined in: packages/core/src/widgets/element.ts:58
style
style:
Style
Defined in: packages/core/src/widgets/element.ts:60
Element style configuration (colors, attributes, hover/focus effects)
hidden
hidden:
boolean
Defined in: packages/core/src/widgets/element.ts:61
fixed
fixed:
boolean
Defined in: packages/core/src/widgets/element.ts:62
align
align:
string
Defined in: packages/core/src/widgets/element.ts:63
valign
valign:
string
Defined in: packages/core/src/widgets/element.ts:64
wrap
wrap:
boolean
Defined in: packages/core/src/widgets/element.ts:65
shrink?
optionalshrink:boolean
Defined in: packages/core/src/widgets/element.ts:66
ch
ch:
string
Defined in: packages/core/src/widgets/element.ts:67
padding
padding:
Padding
Defined in: packages/core/src/widgets/element.ts:69
Padding configuration for all sides
border?
optionalborder:Border
Defined in: packages/core/src/widgets/element.ts:71
Border configuration
parseTags?
optionalparseTags:boolean
Defined in: packages/core/src/widgets/element.ts:72
content
content:
string=""
Defined in: packages/core/src/widgets/element.ts:73
lpos?
optionallpos:RenderCoords
Defined in: packages/core/src/widgets/element.ts:75
Last rendered position coordinates
_clines?
optional_clines:any
Defined in: packages/core/src/widgets/element.ts:76
_pcontent?
optional_pcontent:string
Defined in: packages/core/src/widgets/element.ts:77
_slisteners?
optional_slisteners:any[]
Defined in: packages/core/src/widgets/element.ts:78
_label?
optional_label:any
Defined in: packages/core/src/widgets/element.ts:79
_labelScroll()?
optional_labelScroll: () =>void
Defined in: packages/core/src/widgets/element.ts:80
Returns
void
_labelResize()?
optional_labelResize: () =>void
Defined in: packages/core/src/widgets/element.ts:81
Returns
void
_hoverOptions?
optional_hoverOptions:any
Defined in: packages/core/src/widgets/element.ts:82
_draggable?
optional_draggable:boolean
Defined in: packages/core/src/widgets/element.ts:83
_dragMD()?
optional_dragMD: (data) =>void
Defined in: packages/core/src/widgets/element.ts:84
Parameters
data
MouseEvent
Returns
void
_dragM()?
optional_dragM: (data) =>void
Defined in: packages/core/src/widgets/element.ts:85
Parameters
data
MouseEvent
Returns
void
_drag?
optional_drag:any
Defined in: packages/core/src/widgets/element.ts:86
_noFill?
optional_noFill:boolean
Defined in: packages/core/src/widgets/element.ts:87
_isLabel?
optional_isLabel:boolean
Defined in: packages/core/src/widgets/element.ts:88
_isList?
optional_isList:boolean
Defined in: packages/core/src/widgets/element.ts:89
childBase?
optionalchildBase:number
Defined in: packages/core/src/widgets/element.ts:90
childOffset?
optionalchildOffset:number
Defined in: packages/core/src/widgets/element.ts:91
alwaysScroll?
optionalalwaysScroll:boolean
Defined in: packages/core/src/widgets/element.ts:92
baseLimit?
optionalbaseLimit:number
Defined in: packages/core/src/widgets/element.ts:93
track?
optionaltrack:TrackConfig
Defined in: packages/core/src/widgets/element.ts:94
scrollbar?
optionalscrollbar:ScrollbarConfig
Defined in: packages/core/src/widgets/element.ts:95
items?
optionalitems:any[]
Defined in: packages/core/src/widgets/element.ts:96
scrollable?
optionalscrollable:boolean
Defined in: packages/core/src/widgets/element.ts:99
scroll()?
optionalscroll: (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
scrollTo()?
optionalscrollTo: (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
setScroll()?
optionalsetScroll: (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
getScroll()?
optionalgetScroll: () =>number
Defined in: packages/core/src/widgets/element.ts:105
Get the current scroll index in lines.
Returns
number
The current absolute scroll position
getScrollHeight()?
optionalgetScrollHeight: () =>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
getScrollPerc()?
optionalgetScrollPerc: (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
setScrollPerc()?
optionalsetScrollPerc: (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
resetScroll()?
optionalresetScroll: () =>any
Defined in: packages/core/src/widgets/element.ts:109
Reset the scroll index to its initial state (top).
Returns
any
_scrollBottom()?
optional_scrollBottom: () =>number
Defined in: packages/core/src/widgets/element.ts:110
Returns
number
_recalculateIndex()?
optional_recalculateIndex: () =>number
Defined in: packages/core/src/widgets/element.ts:111
Returns
number
uid
staticuid:number=0
Defined in: packages/core/src/widgets/node.ts:30
Inherited from
ScreenRegistry
staticScreenRegistry:any
Defined in: packages/core/src/widgets/node.ts:31
Inherited from
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
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
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
$
$:
Record<string,unknown>
Defined in: packages/core/src/widgets/node.ts:68
An object for any miscellaneous user data.
Inherited from
_
_:
Record<string,unknown>
Defined in: packages/core/src/widgets/node.ts:73
An object for any miscellaneous user data.
Inherited from
data
data:
Record<string,unknown>
Defined in: packages/core/src/widgets/node.ts:78
An object for any miscellaneous user data.
Inherited from
uid
uid:
number
Defined in: packages/core/src/widgets/node.ts:80
Inherited from
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
detached?
optionaldetached:boolean
Defined in: packages/core/src/widgets/node.ts:87
Inherited from
destroyed?
optionaldestroyed:boolean
Defined in: packages/core/src/widgets/node.ts:88
Inherited from
runtime
runtime:
Runtime
Defined in: packages/core/src/widgets/node.ts:90
Inherited from
Accessors
focused
Get Signature
get focused():
boolean
Defined in: packages/core/src/widgets/element.ts:113
Returns
boolean
visible
Get Signature
get visible():
boolean
Defined in: packages/core/src/widgets/element.ts:924
Returns
boolean
_detached
Get Signature
get _detached():
boolean
Defined in: packages/core/src/widgets/element.ts:935
Returns
boolean
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
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
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
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
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
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
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
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
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
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
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
ileft
Get Signature
get ileft():
number
Defined in: packages/core/src/widgets/element.ts:1677
Returns
number
itop
Get Signature
get itop():
number
Defined in: packages/core/src/widgets/element.ts:1682
Returns
number
iright
Get Signature
get iright():
number
Defined in: packages/core/src/widgets/element.ts:1687
Returns
number
ibottom
Get Signature
get ibottom():
number
Defined in: packages/core/src/widgets/element.ts:1692
Returns
number
iwidth
Get Signature
get iwidth():
number
Defined in: packages/core/src/widgets/element.ts:1697
Returns
number
iheight
Get Signature
get iheight():
number
Defined in: packages/core/src/widgets/element.ts:1704
Returns
number
tpadding
Get Signature
get tpadding():
number
Defined in: packages/core/src/widgets/element.ts:1711
Returns
number
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
right
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
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
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
Methods
setMaxListeners()
setMaxListeners(
n):void
Defined in: packages/core/src/lib/events.ts:19
Parameters
n
number
Returns
void
Inherited from
addListener()
addListener(
type,listener):void
Defined in: packages/core/src/lib/events.ts:23
Parameters
type
string
listener
Function
Returns
void
Inherited from
on()
on(
type,listener):any
Defined in: packages/core/src/lib/events.ts:34
Parameters
type
string
listener
Function
Returns
any
Inherited from
removeListener()
removeListener(
type,listener):void
Defined in: packages/core/src/lib/events.ts:38
Parameters
type
string
listener
Function
Returns
void
Inherited from
off()
off(
type,listener):any
Defined in: packages/core/src/lib/events.ts:57
Parameters
type
string
listener
Function
Returns
any
Inherited from
removeAllListeners()
removeAllListeners(
type?):void
Defined in: packages/core/src/lib/events.ts:61
Parameters
type?
string
Returns
void
Inherited from
once()
once(
type,listener):any
Defined in: packages/core/src/lib/events.ts:69
Parameters
type
string
listener
Function
Returns
any
Inherited from
listeners()
listeners(
type):Function[]
Defined in: packages/core/src/lib/events.ts:79
Parameters
type
string
Returns
Function[]
Inherited from
_emit()
_emit(
type,args):any
Defined in: packages/core/src/lib/events.ts:85
Parameters
type
string
args
any[]
Returns
any
Inherited from
emit()
emit(
type, ...rest):boolean
Defined in: packages/core/src/lib/events.ts:113
Parameters
type
string
rest
...any[]
Returns
boolean
Inherited from
sattr()
sattr(
style,fg?,bg?):number
Defined in: packages/core/src/widgets/element.ts:320
Parameters
style
any
fg?
any
bg?
any
Returns
number
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
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
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
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
Overrides
hide()
hide():
void
Defined in: packages/core/src/widgets/element.ts:423
Hide element.
Returns
void
show()
show():
void
Defined in: packages/core/src/widgets/element.ts:436
Show element.
Returns
void
toggle()
toggle():
void
Defined in: packages/core/src/widgets/element.ts:445
Toggle hidden/shown.
Returns
void
focus()
focus():
any
Defined in: packages/core/src/widgets/element.ts:452
Focus element.
Returns
any
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
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
getTabIndex()
getTabIndex():
number
Defined in: packages/core/src/widgets/element.ts:478
Get effective tab index for focus navigation ordering.
Returns
number
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
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
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
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
parseContent()
parseContent(
noTags?):boolean
Defined in: packages/core/src/widgets/element.ts:521
Parameters
noTags?
boolean
Returns
boolean
_parseTags()
_parseTags(
text):string
Defined in: packages/core/src/widgets/element.ts:588
Parameters
text
string
Returns
string
_parseAttr()
_parseAttr(
lines):any
Defined in: packages/core/src/widgets/element.ts:693
Parameters
lines
any
Returns
any
_align()
_align(
line,width,align?):string
Defined in: packages/core/src/widgets/element.ts:722
Parameters
line
string
width
number
align?
string
Returns
string
_wrapContent()
_wrapContent(
content,width):WrappedContent
Defined in: packages/core/src/widgets/element.ts:754
Parameters
content
string
width
number
Returns
WrappedContent
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
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
enableInput()
enableInput():
void
Defined in: packages/core/src/widgets/element.ts:963
Enable key and mouse events. Calls both enableMouse() and enableKeys().
Returns
void
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
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
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
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
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
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
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
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
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
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
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' });
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
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' });
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
_getPos()
_getPos():
any
Defined in: packages/core/src/widgets/element.ts:1301
Positioning
Returns
any
_getWidth()
_getWidth(
get?):number
Defined in: packages/core/src/widgets/element.ts:1322
Position Getters
Parameters
get?
boolean
Returns
number
_getHeight()
_getHeight(
get?):number
Defined in: packages/core/src/widgets/element.ts:1373
Parameters
get?
boolean
Returns
number
_getLeft()
_getLeft(
get?):number
Defined in: packages/core/src/widgets/element.ts:1424
Parameters
get?
boolean
Returns
number
_getRight()
_getRight(
get?):number
Defined in: packages/core/src/widgets/element.ts:1461
Parameters
get?
boolean
Returns
number
_getTop()
_getTop(
get?):number
Defined in: packages/core/src/widgets/element.ts:1486
Parameters
get?
boolean
Returns
number
_getBottom()
_getBottom(
get?):number
Defined in: packages/core/src/widgets/element.ts:1523
Parameters
get?
boolean
Returns
number
_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
_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
_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
_getCoords()
_getCoords(
get?,noscroll?):RenderCoords|undefined
Defined in: packages/core/src/widgets/element.ts:1992
Parameters
get?
boolean
noscroll?
boolean
Returns
RenderCoords | undefined
render()
render():
any
Defined in: packages/core/src/widgets/element.ts:2165
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
_render()
_render():
any
Defined in: packages/core/src/widgets/element.ts:2703
Internal alias for render().
Returns
any
Rendered coordinates object
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
detach()
detach():
void
Defined in: packages/core/src/widgets/node.ts:255
Remove node from its parent.
Returns
void
Inherited from
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
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
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
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
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
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
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
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
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
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
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