Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.