-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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