Last active
June 8, 2016 18:53
-
-
Save rosko/6616c66c61a44805317bbde0157a2e39 to your computer and use it in GitHub Desktop.
blessed
This file contains hidden or 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'); | |
const {execFile} = require('child_process'); | |
const screen = blessed.screen({ | |
smartCSR: true | |
}); | |
screen.title = 'my window title'; | |
var box = blessed.box({ | |
label: 'Left', | |
top: '0', | |
left: '0', | |
width: '50%', | |
height: '100%', | |
content: 'Hello {bold}world{/bold}!', | |
tags: true, | |
scrollable: true, | |
border: { | |
type: 'line' | |
}, | |
style: { | |
border: { | |
fg: '#f0f0f0' | |
} | |
} | |
}); | |
screen.append(box); | |
const logs = execFile('pm2', ['logs'], { | |
env: Object.assign({DEBUG_COLORS: true}, process.env) | |
}); | |
logs.stdout.on('data', (data) => { | |
box.setContent(box.content + data); | |
screen.render(); | |
}); | |
logs.stderr.on('data', (data) => { | |
box.setContent(box.content + data); | |
screen.render(); | |
}); | |
var box2 = blessed.log({ | |
label: 'Right', | |
top: '0', | |
left: '50%', | |
width: '50%', | |
height: '100%', | |
content: 'Hello {bold}world{/bold}!', | |
tags: true, | |
scrollable: true, | |
border: { | |
type: 'line' | |
}, | |
style: { | |
border: { | |
fg: '#f0f0f0' | |
} | |
} | |
}); | |
screen.append(box2); | |
const logs2 = execFile('top', [], { | |
env: Object.assign({DEBUG_COLORS: true}, process.env) | |
}); | |
logs2.stdout.on('data', (data) => { | |
box2.setContent(box2.content + data); | |
screen.render(); | |
}); | |
logs2.stderr.on('data', (data) => { | |
box2.setContent(box2.content + data); | |
screen.render(); | |
}); | |
screen.key(['escape', 'q', 'C-c'], function (ch, key) { | |
return process.exit(0); | |
}); | |
box.focus(); | |
screen.render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment