cycle-blessed
example/writer.js
:
Installing
$ npm i -S cycle-blessed
Getting Started
example/basic.js
:
;;;; let screen = blessed; let ; ;
API
makeTermDriver(screen) => CycleDriver
Takes a stream of Blessed Element
s.
Produces an object containing stream creators on
and onGlobal
.
on(event, transform = []) => Observable
Takes all events supported by the Blessed EventEmitter
. Emits events from the root element. Optionally, you can specify arbitrary stream transformers as transform
. See API/transform for a list of available transformers.
All nested events in the form of element event
can be abbreviated to *event
.
The Observable emits an array of arguments per event (an array is necessary because of a limitation of the RxJS pipeline).
onGlobal(event, transform = []) => Observable
Takes all events supported by the Blessed EventEmitter
. Emits events from the screen
object. See on
.
makeScreenDriver(screen) => CycleDriver
Takes a stream of operations to the screen
object (e.g. screen => screen.realloc()
). Produces a stream of the operations' results.
h(name, options = {}, children = []) => Element
Creates a Blessed Element. If children
or one of its elements is a String
, it will be converted into a text
node.
;
factory(name) => (options = {}, children = []) => Element
Creates a helper function for Blessed Elemets.
let box = ; ;
x(options = {}, children = []) => Element
Where x
is any one of box
, element
, text
, layout
, form
, textarea
, button
.
API/transform
Transforms are helper functions that help to reduce boilerplate for common UI and data idioms.
id(i) => stream => Stream
Emits all clicks on elements that have an id
of 'Submit'
.
view(...v) => stream => Stream
Emits all clicks, plucking the first element and then the value
property.
key(k) => stream => Stream
Emits all keypresses in which 'C-c'
was entered.
constant(i) => stream => Stream
Emits true
for every click.
init(...i) => stream => Stream
Emits every keypress, starting with {}
.
toggle(init) => stream => Stream
Toggles between true and false for every click, starting with false
.
Examples
example/basic.js
example/click.js
example/input.js
example/writer.js
TODO
- implement diffing to fix defocusing bugs
- current workaround is to implement custom elements (not that hard)