An object for any miscellaneous user data.
Get's the child element implementing the current label of this node.
If true, the element won't be filled.
Calculated absolute bottom offset.
Calculated absolute left offset.
Calculated absolute right offset.
Calculated absolute top offset.
Border foreground and background, must be numbers (-1 for default).
Border attributes.
Border object.
Calculated relative bottom offset.
The offset of the top of the scroll content.
The offset of the chosen item/line.
Array of node's children.
An object for any miscellaneous user data.
Whether the element is draggable. Set to true to allow dragging.
If true, screen.focusNext()
and methods related to focus will consider this Element.
Calculated height.
Calculated height taking into account padding and boder.
Calculated left coordinate taking into account padding and boder.
Render index (document order index) of the last render call.
Calculated top coordinate taking into account padding and boder.
Calculated width taking into account padding and boder.
Calculated relative left offset.
Name of the element. Useful for form submission.
Current element padding
Parent node. If null it means the element is not attached to any screen or program, or the node is a Screen.
Calculated relative right offset.
Parent screen.
Calculated relative top offset.
Givesthe total padding on any direction.
Type of the node (e.g. box).
Unique identifier for Node instances. @internal
Calculated width.
if true it will force to recalculate.
if true it will force to recalculate.
if true it will force to recalculate.
if true it will force to recalculate.
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).
if true it will force to recalculate.
if true it will force to recalculate.
if true it will force to recalculate.
if true it will force to recalculate.
if true it will force to recalculate.
Converts {red-fg}foo{/red-fg}
to \x1b[31mfoo\x1b[39m
. @internal.
Append a node to this node's children.
Clear a line from the box's content from the visible top.
Clear a line from the box's content.
Cleans the rectangle of this element on the screen. Useful for subclasses before rendering.
it's passed to _getCoords
it's passed to Screen.clearRegion
Delete a line at the bottom of the box.
Delete a line from the box's content.
Delete a line at the top of the box.
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().
Remove node from its parent.
Disable dragging of the element.
Emit event for element, and recursively emit same event for all descendants. If s
is provided it will call [[iter]] on self first.
Enable dragging of the element.
Enable key and mouse events. Calls bot enableMouse and enableKeys.
Enable keypress events for the element (automatically called when a form of on('keypress') is bound).
Enable mouse events for the element (automatically called when a form of on('mouse') is bound).
Focus element.
Visit each node's descendants, with [[iter]] function, parents first.
If s
is provided it will call [[iter]] on self first.
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().
Get user property with a potential default value.
Get a line from the box's content from the visible top.
Return content, slightly different from el.content. Assume the above formatting.
Get a line from the box's content.
An array containing the content lines.
An array containing the lines as they are displayed on the screen.
Get the current scroll index in lines.
Get the actual height of the scrolling area.
Get the current scroll index in percentage.
Similar to getContent, but return content with tags and escape codes removed.
Hide element, clear the element's region on the screen and triggers hide event.
Insert a node to this node's children at index i.
Insert a line at the bottom of the box.
Insert a line into the box's content.
Insert a line at the top of the box.
Bind a keypress listener for a specific key.
Received when the element is scrolled.
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().
Bind a keypress listener for a specific key once.
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.
Pop a line off the bottom of the content.
Prepend a node to this node's children.
Push a line onto the bottom of the content.
Remove child node from node.
Remove the hover label completely.
Remove a keypress listener for a specific key.
Remove the label completely.
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().
Write content and children to the screen buffer.
Reset the scroll index to its initial state.
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.
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.
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.
Scroll the content by a relative offset.
Scroll the content to an absolute index.
Set user property to value.
Put the element in back of its siblings.
Set a line in the box's content from the visible top.
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).
Put the element in front of its siblings. Uses setIndex
text/options - Set a hover text box to follow the cursor. Similar to the "title" DOM attribute in the browser. Example options: {text:'foo'}
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.
text/options - Set the label text for the top-left corner. Example options: {text:'foo',side:'left'}
Set a line in the box's content.
Same as scrollTo.
Set the current scroll index in percentage (0-100).
Similar to setContent, but ignore tags and remove escape codes.
Shift a line off the top of the content.
Show element.
Get a string's displayed width, taking into account double-width, surrogate pairs, combining characters, tags, and SGR escape codes.
Toggle hidden/shown.
Remove a keypress listener for a specific key.
Unshift a line onto the top of the content.
An object for any miscellaneous user data.