Skip to content

Instantly share code, notes, and snippets.

@tcyrus
Forked from risacher/main.js
Last active December 13, 2018 22:16
Show Gist options
  • Save tcyrus/fb7872b0cccf842d63a581889d8273f1 to your computer and use it in GitHub Desktop.
Save tcyrus/fb7872b0cccf842d63a581889d8273f1 to your computer and use it in GitHub Desktop.
glue to make blessed (low-level API) work in browserify with xterm.js
const blessed = require("blessed");
window.onload = function () {
const term = new Terminal({
cols: 80,
rows: 24
});
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);
const 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