Implements Text shape which renders the text at specified point.
Kind: global class
Extends: Shape
Since: 1.0.0
- Text ⇐
Shape- new Text(cursor, [options])
- .getWidth() ⇒
Number - .getHeight() ⇒
Number - .isBold() ⇒
Boolean - .setBold([bold]) ⇒
Text - .isDim() ⇒
Boolean - .setDim([dim]) ⇒
Text - .isUnderlined() ⇒
Boolean - .setUnderlined([underlined]) ⇒
Text - .isBlink() ⇒
Boolean - .setBlink([blink]) ⇒
Text - .isReverse() ⇒
Boolean - .setReverse([reverse]) ⇒
Text - .isHidden() ⇒
Boolean - .setHidden([hidden]) ⇒
Text - .getAlign() ⇒
String - .setAlign([align]) ⇒
Text - .render() ⇒
Text - .toObject() ⇒
Object
Create Text shape.
| Param | Type | Description |
|---|---|---|
| cursor | Cursor |
Cursor instance |
| [options] | Object |
Options object |
| [options.bold] | Boolean |
Bold styling |
| [options.dim] | Boolean |
Dim styling |
| [options.underlined] | Boolean |
Underlined styling |
| [options.blink] | Boolean |
Blink styling |
| [options.reverse] | Boolean |
Reverse styling |
| [options.hidden] | Boolean |
Hidden styling |
| [options.align] | String |
Align text in the shape (left, center, right) |
Example
Text.create(cursor, {
bold: true,
dim: false,
underlined: true,
blink: false,
reverse: false,
hidden: false,
align: 'center'
});Returns actual width of the shape. Since text hasn't specified width, we need to override default. It looks for the longest line in your shape and returns its length.
Kind: instance method of Text
Returns actual height of the shape. Since text hasn't specified height, we need to override default. It returns count of lines in our shape.
Kind: instance method of Text
Check if text should be rendered as bold.
Kind: instance method of Text
text.setBold([bold]) ⇒ Text
Toggle bold mode.
Kind: instance method of Text
| Param | Type | Default | Description |
|---|---|---|---|
| [bold] | Boolean |
false |
If true, print bold text |
Check if text should be rendered as dim.
Kind: instance method of Text
text.setDim([dim]) ⇒ Text
Toggle dim mode.
Kind: instance method of Text
| Param | Type | Default | Description |
|---|---|---|---|
| [dim] | Boolean |
false |
If true, print dim text |
Check if text should be rendered as underlined.
Kind: instance method of Text
text.setUnderlined([underlined]) ⇒ Text
Toggle underlined mode.
Kind: instance method of Text
| Param | Type | Default | Description |
|---|---|---|---|
| [underlined] | Boolean |
false |
If true, print underlined text |
Check if text should be rendered as blink.
Kind: instance method of Text
text.setBlink([blink]) ⇒ Text
Toggle blink mode.
Kind: instance method of Text
| Param | Type | Default | Description |
|---|---|---|---|
| [blink] | Boolean |
false |
If true, print blink text |
Check if text should be rendered with reversed colors.
Kind: instance method of Text
text.setReverse([reverse]) ⇒ Text
Toggle reverse mode.
Kind: instance method of Text
| Param | Type | Default | Description |
|---|---|---|---|
| [reverse] | Boolean |
false |
If true, print text with reversed colors |
text.isHidden() ⇒ Boolean
Check if text should be rendered as hidden text.
Kind: instance method of Text
text.setHidden([hidden]) ⇒ Text
Toggle hidden mode.
Kind: instance method of Text
| Param | Type | Default | Description |
|---|---|---|---|
| [hidden] | Boolean |
false |
If true, print hidden text |
Get text align.
Kind: instance method of Text
text.setAlign([align]) ⇒ Text
Set text align. Aligns text in the shape by anchors to the left, center or to the right.
Kind: instance method of Text
| Param | Type | Default | Description |
|---|---|---|---|
| [align] | String |
'center' |
Align value can be left, center or right |
text.render() ⇒ Text
Render the shape based on options.
Kind: instance method of Text
Overrides default toObject() method because we have new fields here.
Kind: instance method of Text