cronvel / terminal-kit

Terminal utilities for node.js
MIT License
3.08k stars 198 forks source link

Cannot input after using term.inputField() #229

Closed Gandalf1783 closed 1 year ago

Gandalf1783 commented 1 year ago

Hey, my Terminal (in this case, SSH-Session in VS-Code terminal window) will not allow any inputs. I assume that on the node-app, the inputField does not give back the "focus" to where inputs are directed?

I have the follwing code:

const logger = require("../console");

async function setup() {
    logger.logInfo("SETUP", "Setup started");
    logger.term("Please input the HID (HostID) for this host: ");
    var input = await logger.term.inputField({}).promise;
    logger.term.green("\nThe HID is \""+input+"\"");

}   

module.exports = {
    setup: setup
}

Running this from my main js file via

const setup = require("./commands/setup");

[...]

async function test() {
    setup.setup();
}

test();

lets me input (like intended). After pressing ENTER, it does display the result, but after this, refuses any further input. I cannot use CTRL+C or CTRL+Z, what I eventually did was open another SSH session and just kill the app.

It seems like this is not intended? Do I have to "free" the input manually? Or am I just not getting some kind of "default" behaviour when supplying an empty object to the inputField function?

Gandalf1783 commented 1 year ago

Update: I have added a second inputField() below the first input, and I can input there again.

Gandalf1783 commented 1 year ago

Yes, as it seems this is intended :)

mikesir87 commented 3 months ago

Commenting on here, as I ran into a similar thing. Using .inputField or .yesOrNo, the function will call .grabInput() to start grabbing input. But, it doesn't stop grabbing the input. So, to clear it, you can run term.grabInput(false) to reset.

Gandalf1783 commented 3 months ago

Ahh, good to know. Thanks, I think this is the fix I will apply :)