tpae / node-repl

JavaScript Read-Eval-Print-Loop (REPL) for Atom
MIT License
11 stars 3 forks source link

Keyboard Input Support #5

Open tpae opened 7 years ago

tpae commented 7 years ago

On most REPL, the input should also come from direct input, in our case, the keyboard.

The challenge of adding this, is that we need to listen on keyboard events, rather than using a traditional input field.

tbremer commented 7 years ago

This is a really interesting idea. It makes me wonder though if we'd want two different modes, basically a live mode for watching keyboard input and a read mode (which is how the package currently works)

tpae commented 7 years ago

Yeah. I'm wondering if it's possible to do both at the same time, or support configurations (to turn one or the other off).

1) read mode: user can listen to the file changes on local, and reload REPL with latest changes. 2) live mode: user can directly interact with REPL.

I think the benefit of live mode is to have the ability to interact with my code directly, without having to change my code in my filesystem. For example:

function sample(input1, input2) {
    return input1 + input2;
}

function myApp() {
    return sample('foo', 'bar');
}

console.log(myApp());

The output should give me: foobar

But I should also be able to do this in live mode:

> sample('coo', 'lio');

and output should give me: coolio

This way, when I'm writing code, I can quickly verify/test each functions without having to modify my existing code. I can just call the function inside my REPL. It's like a mini playground/debug area.