docs formatting.
This commit is contained in:
parent
6bf8afb357
commit
3bdbca77a9
266
README.md
266
README.md
|
@ -147,128 +147,128 @@ nasty low-level terminal stuff.
|
|||
|
||||
The base node which everything inherits from.
|
||||
|
||||
Options:
|
||||
##### Options:
|
||||
|
||||
- screen - the screen to be associated with.
|
||||
- parent - the desired parent.
|
||||
- children - an arrray of children.
|
||||
- **screen** - the screen to be associated with.
|
||||
- **parent** - the desired parent.
|
||||
- **children** - an arrray of children.
|
||||
|
||||
Properties:
|
||||
##### Properties:
|
||||
|
||||
- inherits all from EventEmitter.
|
||||
- children - array of node's children.
|
||||
- **children** - array of node's children.
|
||||
|
||||
Events:
|
||||
##### Events:
|
||||
|
||||
- inherits all from EventEmitter.
|
||||
- remove - received when node is removed from it's current parent.
|
||||
- reparent - received when node gains a new parent.
|
||||
- **remove** - received when node is removed from it's current parent.
|
||||
- **reparent** - received when node gains a new parent.
|
||||
|
||||
Methods:
|
||||
##### Methods:
|
||||
|
||||
- inherits all from EventEmitter.
|
||||
- prepend(node) - prepend a node to this node's children.
|
||||
- append(node) - append a node to this node's children.
|
||||
- remove(node) - remove child node from node.
|
||||
- detach() - remove node from its parent.
|
||||
- **prepend(node)** - prepend a node to this node's children.
|
||||
- **append(node)** - append a node to this node's children.
|
||||
- **remove(node)** - remove child node from node.
|
||||
- **detach()** - remove node from its parent.
|
||||
|
||||
#### Screen (from Node)
|
||||
|
||||
The screen on which every other node renders.
|
||||
|
||||
Options:
|
||||
##### Options:
|
||||
|
||||
- program - the blessed Program to be associated with.
|
||||
- **program** - the blessed Program to be associated with.
|
||||
|
||||
Properties:
|
||||
##### Properties:
|
||||
|
||||
- inherits all from Node.
|
||||
- program - the blessed Program object.
|
||||
- tput - the blessed Tput object.
|
||||
- focused - top of the focus history stack.
|
||||
- width - width of the screen (same as `program.cols`).
|
||||
- height - height of the screen (same as `program.rows`).
|
||||
- left - left offset, always zero.
|
||||
- right - right offset, always zero.
|
||||
- top - top offset, always zero.
|
||||
- bottom - bottom offset, always zero.
|
||||
- **program** - the blessed Program object.
|
||||
- **tput** - the blessed Tput object.
|
||||
- **focused** - top of the focus history stack.
|
||||
- **width** - width of the screen (same as `program.cols`).
|
||||
- **height** - height of the screen (same as `program.rows`).
|
||||
- **left** - left offset, always zero.
|
||||
- **right** - right offset, always zero.
|
||||
- **top** - top offset, always zero.
|
||||
- **bottom** - bottom offset, always zero.
|
||||
|
||||
Events:
|
||||
##### Events:
|
||||
|
||||
- inherits all from Node.
|
||||
- mouse - received on mouse events.
|
||||
- keypress - received on key events.
|
||||
- element [name] - global events received for all elements.
|
||||
- **mouse** - received on mouse events.
|
||||
- **keypress** - received on key events.
|
||||
- **element [name]** - global events received for all elements.
|
||||
|
||||
Methods:
|
||||
##### Methods:
|
||||
|
||||
- inherits all from Node.
|
||||
- alloc() - allocate a new pending screen buffer and a new output screen buffer.
|
||||
- draw(start, end) - draw the screen based on the contents of the screen buffer.
|
||||
- render() - render all child elements, writing all data to the screen buffer and drawing the screen.
|
||||
- clearRegion(x1, x2, y1, y2) - clear any region on the screen.
|
||||
- fillRegion(attr, ch, x1, x2, y1, y2) - fill any region with a character of a certain attribute.
|
||||
- focus(offset) - focus element by offset of focusable elements.
|
||||
- focusPrev() - focus previous element in the index.
|
||||
- focusNext() - focus next element in the index.
|
||||
- focusPush(element) - push element on the focus stack (equivalent to `screen.focused = el`).
|
||||
- focusPop()/focusLast() - pop element off the focus stack.
|
||||
- **alloc()** - allocate a new pending screen buffer and a new output screen buffer.
|
||||
- **draw(start, end)** - draw the screen based on the contents of the screen buffer.
|
||||
- **render()** - render all child elements, writing all data to the screen buffer and drawing the screen.
|
||||
- **clearRegion(x1, x2, y1, y2)** - clear any region on the screen.
|
||||
- **fillRegion(attr, ch, x1, x2, y1, y2)** - fill any region with a character of a certain attribute.
|
||||
- **focus(offset)** - focus element by offset of focusable elements.
|
||||
- **focusPrev()** - focus previous element in the index.
|
||||
- **focusNext()** - focus next element in the index.
|
||||
- **focusPush(element)** - push element on the focus stack (equivalent to `screen.focused = el`).
|
||||
- **focusPop()/focusLast()** - pop element off the focus stack.
|
||||
|
||||
#### Element (from Node)
|
||||
|
||||
The base element.
|
||||
|
||||
Options:
|
||||
##### Options:
|
||||
|
||||
- fg, bg, bold, underline - attributes.
|
||||
- border - border object, see below.
|
||||
- content - element's text content.
|
||||
- clickable - element is clickable.
|
||||
- input - element is focusable and can receive key input.
|
||||
- hidden - whether the element is hidden.
|
||||
- label - a simple text label for the element.
|
||||
- **fg, bg, bold, underline** - attributes.
|
||||
- **border** - border object, see below.
|
||||
- **content** - element's text content.
|
||||
- **clickable** - element is clickable.
|
||||
- **input** - element is focusable and can receive key input.
|
||||
- **hidden** - whether the element is hidden.
|
||||
- **label** - a simple text label for the element.
|
||||
|
||||
Properties:
|
||||
##### Properties:
|
||||
|
||||
- inherits all from Node.
|
||||
- border - border object.
|
||||
- type - type of border (`ascii` or `bg`). `bg` by default.
|
||||
- ch - character to use if `bg` type, default is space.
|
||||
- bg, fg - border foreground and background, must be numbers (-1 for default).
|
||||
- bold, underline - border attributes.
|
||||
- position - raw width, height, and offsets.
|
||||
- content - text content.
|
||||
- hidden - whether the element is hidden or not.
|
||||
- fg, bg - foreground and background, must be numbers (-1 for default).
|
||||
- bold, underline - attributes.
|
||||
- width - calculated width.
|
||||
- height - calculated height.
|
||||
- left - calculated absolute left offset.
|
||||
- right - calculated absolute right offset.
|
||||
- top - calculated absolute top offset.
|
||||
- bottom - calculated absolute bottom offset.
|
||||
- rleft - calculated relative left offset.
|
||||
- rright - calculated relative right offset.
|
||||
- rtop - calculated relative top offset.
|
||||
- rbottom - calculated relative bottom offset.
|
||||
- **border** - border object.
|
||||
- **type** - type of border (`ascii` or `bg`). `bg` by default.
|
||||
- **ch* - character to use if `bg` type, default is space.
|
||||
- **bg, fg** - border foreground and background, must be numbers (-1 for default).
|
||||
- **bold, underline** - border attributes.
|
||||
- **position** - raw width, height, and offsets.
|
||||
- **content** - text content.
|
||||
- **hidden** - whether the element is hidden or not.
|
||||
- **fg, bg** - foreground and background, must be numbers (-1 for default).
|
||||
- **bold, underline** - attributes.
|
||||
- **width** - calculated width.
|
||||
- **height** - calculated height.
|
||||
- **left** - calculated absolute left offset.
|
||||
- **right** - calculated absolute right offset.
|
||||
- **top** - calculated absolute top offset.
|
||||
- **bottom** - calculated absolute bottom offset.
|
||||
- **rleft** - calculated relative left offset.
|
||||
- **rright** - calculated relative right offset.
|
||||
- **rtop** - calculated relative top offset.
|
||||
- **rbottom** - calculated relative bottom offset.
|
||||
|
||||
Events:
|
||||
##### Events:
|
||||
|
||||
- inherits all from Node.
|
||||
- mouse - received on mouse events for this element.
|
||||
- keypress - received on key events for this element.
|
||||
- move - received when the element is moved.
|
||||
- resize - received when the element is resized.
|
||||
- **mouse** - received on mouse events for this element.
|
||||
- **keypress** - received on key events for this element.
|
||||
- **move** - received when the element is moved.
|
||||
- **resize** - received when the element is resized.
|
||||
|
||||
Methods:
|
||||
##### Methods:
|
||||
|
||||
- inherits all from Node.
|
||||
- render() - write content and children to the screen buffer.
|
||||
- setContent(text) - set the content.
|
||||
- hide() - hide element.
|
||||
- show() - show element.
|
||||
- toggle() - toggle hidden/shown.
|
||||
- focus() - focus element.
|
||||
- **render()** - write content and children to the screen buffer.
|
||||
- **setContent(text)** - set the content.
|
||||
- **hide()** - hide element.
|
||||
- **show()** - show element.
|
||||
- **toggle()** - toggle hidden/shown.
|
||||
- **focus()** - focus element.
|
||||
|
||||
#### Box (from Element)
|
||||
|
||||
|
@ -280,10 +280,10 @@ Inherits all options, properties, events, and methods from Box.
|
|||
|
||||
An element similar to Box, but geared towards rendering simple text elements.
|
||||
|
||||
Options:
|
||||
##### Options:
|
||||
|
||||
- inherits all from Element.
|
||||
- fill - fill the entire line with chosen bg until parent bg ends, even if
|
||||
- **fill** - fill the entire line with chosen bg until parent bg ends, even if
|
||||
there is not enough text to fill the entire width.
|
||||
|
||||
Inherits all options, properties, events, and methods from Element.
|
||||
|
@ -292,11 +292,11 @@ Inherits all options, properties, events, and methods from Element.
|
|||
|
||||
A simple line which can be `ascii` or `bg` styled.
|
||||
|
||||
Options:
|
||||
##### Options:
|
||||
|
||||
- inherits all from Box.
|
||||
- orientation - can be `vertical` or `horizontal`.
|
||||
- type, bg, fg, ch - treated the same as a border object.
|
||||
- **orientation** - can be `vertical` or `horizontal`.
|
||||
- **type, bg, fg, ch** - treated the same as a border object.
|
||||
|
||||
Inherits all options, properties, events, and methods from Box.
|
||||
|
||||
|
@ -304,79 +304,79 @@ Inherits all options, properties, events, and methods from Box.
|
|||
|
||||
A box with scrollable content.
|
||||
|
||||
Options:
|
||||
##### Options:
|
||||
|
||||
- inherits all from Box.
|
||||
- baseLimit - a limit to the childBase. default is `Infinity`.
|
||||
- alwaysScroll - a option which causes the ignoring of `childOffset`. this in
|
||||
- **baseLimit** - a limit to the childBase. default is `Infinity`.
|
||||
- **alwaysScroll** - a option which causes the ignoring of `childOffset`. this in
|
||||
turn causes the childBase to change every time the element is scrolled.
|
||||
|
||||
Properties:
|
||||
##### Properties:
|
||||
|
||||
- inherits all from Box.
|
||||
- childBase - the offset of the top of the scroll content.
|
||||
- childOffset - the offset of the chosen item (if there is one).
|
||||
- **childBase** - the offset of the top of the scroll content.
|
||||
- **childOffset** - the offset of the chosen item (if there is one).
|
||||
|
||||
Events:
|
||||
##### Events:
|
||||
|
||||
- inherits all from Box.
|
||||
- scroll - received when the element is scrolled.
|
||||
- **scroll** - received when the element is scrolled.
|
||||
|
||||
Methods:
|
||||
##### Methods:
|
||||
|
||||
- scroll(offset) - scroll the content by an offset.
|
||||
- **scroll(offset)** - scroll the content by an offset.
|
||||
|
||||
#### List (from ScrollableBox)
|
||||
|
||||
A scrollable list which can display selectable items.
|
||||
|
||||
Options:
|
||||
##### Options:
|
||||
|
||||
- inherits all from ScrollableBox.
|
||||
- selectFg, selectedBg - foreground and background for selected item, treated
|
||||
- **selectFg, selectedBg** - foreground and background for selected item, treated
|
||||
like fg and bg.
|
||||
- selectedBold, selectedUnderline - character attributes for selected item,
|
||||
- **selectedBold, selectedUnderline** - character attributes for selected item,
|
||||
treated like bold and underline.
|
||||
- mouse - whether to automatically enable mouse support for this list (allows
|
||||
- **mouse** - whether to automatically enable mouse support for this list (allows
|
||||
clicking items).
|
||||
- items - an array of strings which become the list's items.
|
||||
- **items** - an array of strings which become the list's items.
|
||||
|
||||
Properties:
|
||||
##### Properties:
|
||||
|
||||
- inherits all from ScrollableBox.
|
||||
|
||||
Events:
|
||||
##### Events:
|
||||
|
||||
- inherits all from ScrollableBox.
|
||||
- select - received when an item is selected.
|
||||
- **select** - received when an item is selected.
|
||||
|
||||
Methods:
|
||||
##### Methods:
|
||||
|
||||
- inherits all from ScrollableBox.
|
||||
- add(text) - add an item based on a string.
|
||||
- select(index) - select an index of an item.
|
||||
- move(offset) - select item based on current offset.
|
||||
- up(amount) - select item above selected.
|
||||
- down(amount) - select item below selected.
|
||||
- **add(text)** - add an item based on a string.
|
||||
- **select(index)** - select an index of an item.
|
||||
- **move(offset)** - select item based on current offset.
|
||||
- **up(amount)** - select item above selected.
|
||||
- **down(amount)** - select item below selected.
|
||||
|
||||
#### ScrollableText (from ScrollableBox)
|
||||
|
||||
A scrollable text box which can display and scroll text, as well as handle pre-existing newlines and escape codes.
|
||||
|
||||
Options:
|
||||
##### Options:
|
||||
|
||||
- inherits all from ScrollableBox.
|
||||
- mouse - whether to enable automatic mouse support for this element.
|
||||
- **mouse** - whether to enable automatic mouse support for this element.
|
||||
|
||||
Properties:
|
||||
##### Properties:
|
||||
|
||||
- inherits all from ScrollableBox.
|
||||
|
||||
Events:
|
||||
##### Events:
|
||||
|
||||
- inherits all from ScrollableBox.
|
||||
|
||||
Methods:
|
||||
##### Methods:
|
||||
|
||||
- inherits all from ScrollableBox.
|
||||
|
||||
|
@ -388,52 +388,52 @@ A form input.
|
|||
|
||||
A box which allows text input.
|
||||
|
||||
Options:
|
||||
##### Options:
|
||||
|
||||
- inherits all from Input.
|
||||
|
||||
Properties:
|
||||
##### Properties:
|
||||
|
||||
- inherits all from Input.
|
||||
|
||||
Events:
|
||||
##### Events:
|
||||
|
||||
- inherits all from Input.
|
||||
|
||||
Methods:
|
||||
##### Methods:
|
||||
|
||||
- inherits all from Input.
|
||||
- setInput(callback) - grab key events and start reading text from the
|
||||
- **setInput(callback)** - grab key events and start reading text from the
|
||||
keyboard. takes a callback which receives the final value.
|
||||
- setEditor(callback) - open text editor in $EDITOR, read the output from the
|
||||
- **setEditor(callback)** - open text editor in $EDITOR, read the output from the
|
||||
resulting file. takes a callback which receives the final value.
|
||||
|
||||
#### ProgressBar (from Input)
|
||||
|
||||
A progress bar allowing various styles.
|
||||
|
||||
Options:
|
||||
##### Options:
|
||||
|
||||
- inherits all from Input.
|
||||
- barFg, barBg - (completed) bar foreground and background.
|
||||
- ch - the character to fill the bar with (default is space).
|
||||
- filled - the amount filled (0 - 100).
|
||||
- **barFg, barBg** - (completed) bar foreground and background.
|
||||
- **ch** - the character to fill the bar with (default is space).
|
||||
- **filled** - the amount filled (0 - 100).
|
||||
|
||||
Properties:
|
||||
##### Properties:
|
||||
|
||||
- inherits all from Input.
|
||||
|
||||
Events:
|
||||
##### Events:
|
||||
|
||||
- inherits all from Input.
|
||||
- reset - bar was reset.
|
||||
- complete - bar has completely filled.
|
||||
- **reset** - bar was reset.
|
||||
- **complete** - bar has completely filled.
|
||||
|
||||
Methods:
|
||||
##### Methods:
|
||||
|
||||
- inherits all from Input.
|
||||
- progress(amount) - progress the bar by a fill amount.
|
||||
- reset() - reset the bar.
|
||||
- **progress(amount)** - progress the bar by a fill amount.
|
||||
- **reset()** - reset the bar.
|
||||
|
||||
### Positioning
|
||||
|
||||
|
|
Loading…
Reference in New Issue