chjj / blessed

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

Using with repl #179

Open aphorise opened 9 years ago

aphorise commented 9 years ago

I'm starting a repl like:

mBlessed = require("blessed");
mREPL = require("repl");
var blsScreen = mBlessed.screen({"autoPadding": false});
mREPL.start(
{
    prompt: "vtui>", useGlobal: true,
    useColors: false, terminal: true, 
    input: process.stdin, output: process.stdout, ignoreUndefined: true
});

blsScreen.render();
blsScreen.title = "node.js vtui";
blsScreen.key(["C-c"], function(ch, key){ return; });

I'd like a way of preventing CTRL+C or any other form of .exit from repl. Is this possible or can you advise of any possible approach to be able to dynamically step into repl mode & back?

Currently I have a working model which is close where I start repl in the application (with shortcut) - however even though the first C-c is intercepted by blessed I'm not able to stop the repl from exiting where its pressed again.

Ideally I'd like a way to be able to switch between repl & blessed as required / on demand without the risk of the main process being closed.

Thanks very much.

piranna commented 8 years ago

I think this is the behaviour how Node.js REPL is implemented...

aphorise commented 8 years ago

Indeed it is how REPL is implemented in Node.js though I was wondering if there was any way of intercepting / preventing this? Perhaps by over-writting a specific function? Thus far I've had no luck with streams or other hacks that I've tried such as delete-ing REPL module object or specifics of its child REPL.repl

piranna commented 8 years ago

Try looking at the source code. El 03/11/2015 23:39, "aphorise" notifications@github.com escribió:

Indeed it is how REPL is implemented in Node.js though I was wondering if there was any way of intercepting / preventing this? Perhaps by over-writting a specific function? Thus far I've had no luck with streams or other hacks that I've tried such as delete-ing REPL module object or specifics of its child REPL.repl

— Reply to this email directly or view it on GitHub https://github.com/chjj/blessed/issues/179#issuecomment-153511699.