chjj / blessed

A high-level terminal interface library for node.js.
Other
11.25k stars 531 forks source link

how do you redirect stdin and stdout to a box? #202

Open Nejat opened 8 years ago

Nejat commented 8 years ago

I am using Inquirer.js to prompt the user with a series of questions.

Inquirer allows you to override it's stdin and stdout with the following code ...

let redirect = {
    input  : someWriteableStream,
    output : someReadableStream
};

let redirectedPrompts = inquirer.createPromptModule(redirect);

redirectedPrompts(questions, processAnswers);

Is there a way to do this with a box?

thanks for the advice

ndelangen commented 7 years ago

I'm interested in this as well, this question on stack-overflow seems related: http://stackoverflow.com/questions/29848217/how-do-i-redirect-stdout-in-blessed

pt300 commented 7 years ago

I believe terminal widget can help you https://github.com/chjj/blessed#terminal-from-box

ndelangen commented 7 years ago

Yeah I've actually made some progress on this!

gbogard commented 7 years ago

I'm interessed in this as well ! @ndelangen did you manage to do this ?

ndelangen commented 7 years ago

@gouyou88 I'll try and get a repo up as a demo, with what I have, hopefully tonight.

gbogard commented 7 years ago

@ndelangen Alright, thanks, no hurry :)

I have managed to come with an acceptable result in my project by using winston as my logger. By using winston as logger, and never using console.log and console.error I can disable the "console" transport when I need to use blessed, and use the events emitted by winston to intercept every log and print them in the box.

ndelangen commented 7 years ago

AHGH finally found this issue again. Seriously I forgot where it was, and notifications / news was of not help.. Anyway..

This is something of a little side-project I'm doing: https://github.com/ndelangen/jest-dashboard

It's running a TTY terminal in a sidebox in blessed. I'm trying to write a jest + webpack dashboard sort of thing. I hope this helps you.. Cheers!