Skip to content

Latest commit

 

History

History
208 lines (150 loc) · 6.74 KB

API.md

File metadata and controls

208 lines (150 loc) · 6.74 KB

Text ⇐ Shape

Implements Text shape which renders the text at specified point.

Kind: global class
Extends: Shape
Since: 1.0.0

new Text(cursor, [options])

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'
});

text.getWidth() ⇒ Number

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

text.getHeight() ⇒ Number

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

text.isBold() ⇒ Boolean

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

text.isDim() ⇒ Boolean

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

text.isUnderlined() ⇒ Boolean

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

text.isBlink() ⇒ Boolean

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

text.isReverse() ⇒ Boolean

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

text.getAlign() ⇒ String

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

text.toObject() ⇒ Object

Overrides default toObject() method because we have new fields here.

Kind: instance method of Text