Skip to content

Instantly share code, notes, and snippets.

@risacher
Created July 1, 2014 02:23
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save risacher/b5148900b488192a1719 to your computer and use it in GitHub Desktop.
Save risacher/b5148900b488192a1719 to your computer and use it in GitHub Desktop.
glue to make blessed (low-level API) work in browserify with term.js
var blessed = require("blessed");
window.onload = function () {
var term = new Terminal({
cols: 80,
rows: 24,
useStyle: true,
screenKeys: true
});
term.open(document.body);
term.write('\x1b[31mWelcome to term.js!\x1b[m\r\n');
// glue to make blessed work in browserify
term.columns = term.cols;
term.isTTY = true;
require('readline').emitKeypressEvents = function () { }; // Can I side-affect a module this way? Apparently.
process.listeners = function fakelisteners() { return []; };
term.resize(100,36);
var program = blessed.program({input: term, output: term, tput: false});
program.move(1, 1);
program.bg('black');
program.write('Hello world', 'blue fg');
program.setx((program.cols / 2 | 0) - 4);
program.down(5);
program.write('Hi again!');
program.bg('!black');
program.feed();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment