pistacchio pistacchio - 3 months ago 21
Node.js Question

Node blessed library: how to set a single character?

Maybe I miss something from the documentation. Blessed.js (the curses-like library for node) comes with any kind of boxes / input / output / mouse utilities and seems wonderful, but how can I set a single character on the screen?

For example, having created the screen like this:

const blessed = require('blessed');
const screen = blessed.screen({
smartCSR: true
});


how can I use
screen
to display, say, the character 'A' in position [4, 5] (fuorth character of the fifth row)?

Thanks

Answer

Use their text widget. Create one and add it to the screen.

let anA = blessed.text({content:'A', top:4, left:5}) // create a text widget
screen.insert(anA)     // add it to the screen    
screen.render();       // render the screen

I've barely worked with it, there might be a simpler way. But forgetting to render is what me got most of the time.

Comments