term-list-scrollable
Renders an interactive list to the terminal that users can navigate using the arrow keys, similar API with term-list but scrollable, and support header or footer.
Installation
$ npm install term-list-scrollable
Example
A fully interactive scrollablelist demonstrating removal via backspace, and opening of the websites via the return key.
var ScrollableList = ;var exec = exec; var list = marker: '\033[36m› \033[0m' markerLength: 2 viewportSize: 5;list;list;list;list;list;list;liststart; ; ; list; list;
API
- ScrollableList()
- ScrollableList.add()
- ScrollableList.header()
- ScrollableList.footer()
- ScrollableList.remove()
- ScrollableList.at()
- ScrollableList.select()
- ScrollableList.selected()
- ScrollableList.draw()
- ScrollableList.up()
- ScrollableList.down()
- ScrollableList.stop()
- ScrollableList.start()
- ScrollableList.on()
ScrollableList()
Initialize a new ScrollableList
with opts
:
marker
optional marker string defaulting to '› 'markerLength
optional marker length, otherwise marker.length is usedviewportSize
optional scrollable list size, defualt is 16
ScrollableList.add(id: String, label: String)
Add item id
with label
.
ScrollableList.header(lable: String)
Set or get header, set header if label
provided, or return header item. label
with '' will unset it.
ScrollableList.footer(lable: String)
Set or get footer, set footer if label
provided, or return footer item. label
with '' will unset it.
ScrollableList.remove(id: String)
Remove item id
.
ScrollableList.at(i: Number)
Return item at i
.
ScrollableList.select(id: String)
Select item id
.
ScrollableList.selected()
Return seleted item.
ScrollableList.draw()
Re-draw the list.
ScrollableList.up()
Select the previous item if any.
ScrollableList.down()
Select the next item if any.
ScrollableList.stop()
Reset state and stop the list.
ScrollableList.start()
Start the list.
ScrollableList.on(event: String, callback: Function)
Bind event listener
Thanks
License
MIT