A textBox is box area containing a text. The text can have attributes (colors, styles), it can be wrapped (line-wrapping, word-wrapping), the whole textBox can be scrollable (both horizontal and vertical). The text content source may have markup or ansi code (if so, the contentHasMarkup option should be set accordingly, see below).
When scrollable, it is sensible to mouse-wheel (anywhere) and click on the scrollbar. It supports text-selection, and copy to clipboard (Linux only at the moment, it needs xclipboard).
It is backed by a TextBuffer.
-
Constructor:
-
Methods:
-
Properties:
-
Inherit methods and properties from Element
See Element's key event.
- tinyScrollUp: scroll up a bit, default: UP
- tinyScrollDown: scroll down a bit, default: DOWN
- scrollUp: scroll up, default: PAGE_UP
- scrollDown: scroll down, default: PAGE_DOWN, space
- scrollTop: scroll to the top, default: HOME
- scrollBottom: scroll to the bottom, default: END
- scrollLeft: scroll left, default: LEFT
- scrollRight: scroll right, default: RIGHT
- copyClipboard: copy to clipboard, default: CTRL_Y
- options
Object, where:- all the base class Element constructor's options
- contentHasMarkup
booleanorstringwhen set to true or the string 'markup', the content contains Terminal Kit's markup, used to set attributes of parts of the content, when set to the string 'ansi', the content contains ANSI escape sequence, default: false. - attr
objectgeneral attribute for the textBox - textAttr
objectattribute for the text content, default to{ bgColor: 'default' } - altTextAttr
objectalternate attribute for the text, default totextAttr+{ color: 'gray' , italic: true } - voidAttr
objectattribute for the area of the textBox without any text content, default to{ bgColor: 'default' } - emptyAttr
objectalias ofvoidAttr - scrollable
booleanif set, the textBox is scrollable (default: false) - hasHScrollBar
booleanif set and if scrollable, the textBox has a horizontal scrollbar - hasVScrollBar
booleanif set and if scrollable, the textBox has a vertical scrollbar - scrollX
numberthe initial horizontal scroll value, default: 0 - scrollY
numberthe initial vertical scroll value, default: 0 - extraScrolling
booleanif unset (the default), it is possible to scroll down until both the content bottom and textBox bottom are on the same line, if set, it is possible to scroll down until the bottom of the content reaches the top of the textBox - tabWidth
number(default: 4) number of cells (=spaces) for the tab character - lineWrap
booleanwhen set, the text content is wrapped to the next line instead of being clipped by the textBox border - wordWrap
booleanlikelineWrapbut is word-aware, i.e. it doesn't split words - firstLineRightShift
numberif set (default: 0) , the first-line of content is right-shifted from this amount of cells, may be useful for prompt, or continuing another box in the flow - hiddenContent
stringornull, if set, the content is hidden, using this string as a replacement for all chars (useful for password) - stateMachine
object(TODOC)
This creates a TextBox element.
- options
Object, where:- x, y, width, height: see the super-class Element constructor's options*
This set the size and position of the textBox, updating line-wrapping and scrollbar.
- x, y
numberthe new scrolling coordinates
This scrolls the textBox to the x,y coordinates and updates scrollbars.
- dx, dy
numberthe delta of the scroll
This scrolls the textBox from this x,y delta and updates scrollbars.
This scrolls the textBox to the top and updates scrollbars.
This scrolls the textBox to the bottom and updates scrollbars.
It returns the current text-content.
It returns the current text-content size, an object with a width and height property.
- content
stringthe text-content to prepend - dontDraw
booleanif set, don't outerDraw the widget (default: false, outerDraw)
Prepend text-content at the begining of the current content. It supports markup or ansi if the textBox was instanciated with the contentHasMarkup options on.
- content
stringthe text-content to append - dontDraw
booleanif set, don't outerDraw the widget (default: false, outerDraw)
Append text-content at the end of the current content. It supports markup or ansi if the textBox was instanciated with the contentHasMarkup options on.
- content
stringthe text-content to append - dontDraw
booleanif set, don't outerDraw the widget (default: false, outerDraw)
This method is almost like .appendContent(), but more suitable for logging.
It appends a new line of text-content at the end of the current content.
Then it performs an intelligent scroll of the textBox: if the scrolling was already at the bottom,
it will scroll down so that new content will be in the viewport.
It supports markup or ansi if the textBox was instanciated with the contentHasMarkup options on.
It returns the alternate text-content.
- content
stringthe alternate text-content - hasMarkup
booleanorstringwhen set to true or the string 'markup', the content contains Terminal Kit's markup, used to set attributes of parts of the content, when set to the string 'ansi', the content contains ANSI escape sequence, default: false. - dontDraw
booleanif set, don't outerDraw the widget (default: false, outerDraw)
It set the alternate text-content, work like its .setContent() counterpart.
This property holds the underlying TextBuffer object. It can be used to achieve more complex stuffs.