JSPM

cycle-blessed

0.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q21135F
  • License MIT

Cycle.js Blessed Driver.

Package Exports

  • cycle-blessed

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cycle-blessed) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

cycle-blessed

Cycle.js drivers for Blessed.

example/writer.js: http://i.imgur.com/NE2AcK4.gif

Installing

$ npm i -S cycle-blessed

Getting Started

example/basic.js:

import { run } from '@cycle/core';
import blessed from 'blessed';
import { makeTermDriver, box } from 'cycle-blessed';
import { Observable as $ } from 'rx';

let screen = blessed.screen({ smartCSR: true, useBCE: true, title: 'Hello, World!' });

let PlainText = text => box({ border: { type: 'line', fg: 'blue' } }, text);

run(({ term: { on } }) => ({
    term: $.just(PlainText('Hello, World!')),
    exit: on('key C-c')
}), {
    term: makeTermDriver(screen),
    exit: exit$ => exit$.forEach(::process.exit)
});

http://i.imgur.com/WL4RaiN.png

API

###makeTermDriver(screen) => CycleDriver

Takes a stream of Blessed Elements.

Produces an object containing stream creators on and onGlobal.

#####on(event) => Observable

Takes all events supported by the Blessed EventEmitter. Emits events from the root element.

The Observable emits an array of arguments per event (an array is necessary because of a limitation of the RxJS pipeline).

on('key a').forEach(([el, ch, key]) => console.log('pressed [a]'))

#####onGlobal(event) => 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.

h('box', { content: 'Hello!' });

###factory(name) => (options = {}, children = []) => Element

Creates a helper function.

let box = factory('box');

box({ content: 'Hello!' });

###x(options = {}, children = []) => Element

Where x is any one of box, element, text, layout, form, textarea, button.