Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TextareaElement<Options>

Type parameters

Hierarchy

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

$

$: object

An object for any miscellanous user data.

Type declaration

  • [index: string]: any

_

_: object

An object for any miscellanous user data.

Type declaration

  • [index: string]: any

Optional _done

_done: function

Called when reading input has finished which happens when the user blur or closes editor. @internal

Type declaration

    • (err: Error | undefined, value: string): void
    • Parameters

      • err: Error | undefined
      • value: string

      Returns void

Optional _label

_label: BlessedElement | undefined

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

internal

Optional _listener

_listener: KeyEventListener

Listener that receives key events. Could be overrided to customize the behavior. @internal

_reading

_reading: boolean

Is it currently capturing user input keys ? @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 miscellanous 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

height

height: number | string

Calculated height.

hidden

hidden: boolean

iheight

iheight: TPosition

ileft

ileft: TTopLeft

index

index: number

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

itop

itop: TTopLeft

iwidth

iwidth: TPosition

left

left: number | string

Calculated relative left offset.

lpos

name

name: string

Name of the element. Useful for form submission.

options

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.

right

right: number | string

Calculated relative right offset.

rleft

rleft: TTopLeft

Calculated relative left offset.

rright

rright: TPosition

Calculated relative right offset.

rtop

rtop: TTopLeft

Calculated relative top offset.

screen

screen: Screen

Parent screen.

shrink

shrink: boolean

style

style: TStyle

top

top: number | string

Calculated relative top offset.

type

type: string

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

uid

uid: number

Unique identifier for Node instances. @internal

underline

underline: string

value

value: string

The input text. read-only.

width

width: number | string

Calculated width.

Static defaultMaxListeners

defaultMaxListeners: number

Methods

_align

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

_getCoords

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

_getHeight

  • _getHeight(get?: boolean): number

_getLeft

  • _getLeft(get?: boolean): number

_getPos

  • _getPos(): Pos

_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

cancel

  • cancel(): void

clearBaseLine

  • clearBaseLine(i: number): void

clearLine

  • clearLine(i: number): void

clearPos

  • clearPos(): void

clearValue

  • clearValue(): 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

editor

  • editor(callback: function): void
  • Open text editor in $EDITOR, read the output from the resulting file. Takes a callback which receives the final value.

    Parameters

    • callback: function
        • (err: any, value?: string): void
        • Parameters

          • err: any
          • Optional value: string

          Returns void

    Returns 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(): 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
  • Get user property with a potential default value.

    Type parameters

    • T

    Parameters

    • name: string
    • def: T

    Returns 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

getValue

  • getValue(): string

hasAncestor

hasDescendant

hide

  • hide(): void

input

  • input(callback: function): void
  • Grab key events and start reading text from the keyboard. Takes a callback which receives the final value.

    Parameters

    • callback: function
        • (err: any, value?: string): void
        • Parameters

          • err: any
          • Optional value: string

          Returns void

    Returns void

insert

  • insert(node: Node, index: number): void
  • Insert a node to this node's children at index i.

    Parameters

    • node: Node
    • index: number

    Returns 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

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: "error", callback: function): this
  • on(event: "submit", callback: function): this
  • on(event: "action", callback: function): this
  • on(event: "cancel", 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
  • internal

    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.

    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

pushLine

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

rawListeners

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

    • event: string | symbol

    Returns Function[]

readEditor

  • readEditor(callback: function): void
  • Open text editor in $EDITOR, read the output from the resulting file. Takes a callback which receives the final value.

    Parameters

    • callback: function
        • (err: any, value?: string): void
        • Parameters

          • err: any
          • Optional value: string

          Returns void

    Returns void

readInput

  • readInput(callback?: function): void
  • Grab key events and start reading text from the keyboard. Takes a callback which receives the final value.

    Parameters

    • Optional callback: function
        • (err: any, value?: string): void
        • Parameters

          • err: any
          • Optional value: string

          Returns void

    Returns void

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(): void
  • 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 void

scroll

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

scrollTo

  • scrollTo(index: number): void

set

  • set(name: string, value: any): void
  • Set user property to value.

    Parameters

    • name: string
    • value: any

    Returns 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

setEditor

  • setEditor(callback: function): void
  • Open text editor in $EDITOR, read the output from the resulting file. Takes a callback which receives the final value.

    Parameters

    • callback: function
        • (err: any, value?: string): void
        • Parameters

          • err: any
          • Optional value: string

          Returns void

    Returns void

setFront

  • setFront(): void

setHover

  • text/options - Set a hover text box to follow the cursor. Similar to the "title" DOM attribute in the browser. Example options: {text:'foo'}

    Parameters

    Returns void

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

setInput

  • setInput(callback: function): void
  • Grab key events and start reading text from the keyboard. Takes a callback which receives the final value.

    Parameters

    • callback: function
        • (err: any, value?: string): void
        • Parameters

          • err: any
          • Optional value: string

          Returns void

    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
  • Similar to setContent, but ignore tags and remove escape codes.

    Parameters

    • text: string
    • Optional noClear: boolean

    Returns void

setValue

  • setValue(text: string): void

shiftLine

  • shiftLine(i: number): void

show

  • show(): void

strWidth

  • strWidth(text: string): string
  • Get a string's displayed width, taking into account double-width, surrogate pairs, combining characters, tags, and SGR escape codes.

    Parameters

    • text: string

    Returns string

submit

  • submit(): void

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

Generated using TypeDoc