Git Product home page Git Product logo

Comments (8)

jonschlinkert avatar jonschlinkert commented on May 11, 2024

Can you point to an example of something similar? Even if it's not a prompt, just so I can visualize what you mean. Once I can see it in my mind, I can create it.

from enquirer.

linkjay avatar linkjay commented on May 11, 2024

Imagine you are writing a console app. The idea is to use a prompt that someone can enter into, it gets parsed, then outputted, then a new prompt is made. Now imagine console.log or something is called when the prompt is active, it will draw the output right on the prompt and under it. Ideally, you would want the prompt to always be on the bottom of any output that comes in.

I made an issue about it on V1 here if maybe this can clarify it more: #23

from enquirer.

jonschlinkert avatar jonschlinkert commented on May 11, 2024

I'm still struggling to visualize what you mean. It sounds like you want to dock a message at the bottom of the terminal for the duration of multiple prompts, not just during a single prompt. Is that correct?

from enquirer.

linkjay avatar linkjay commented on May 11, 2024

Either. Generally if you output anything on a prompt, it will not work correctly. The text will go into the prompt and under it and you can't type in it correctly after that.

I want to be able to take any sort of readline prompt and have any outputted text not interfere with the prompt.

Heres an example with enquirer 2.0.7.

https://i.linkjay.io/wbjhkD.png

That's all one prompt. I never hit enter. The prompt will move it the whole thing to a new line and it gets in the way and looks very awkward. Maybe there is a way you could jump on an stdout event or something to move any sort of console.log above the prompt instead of recreating it or whatever is happening. Ideally, it would be nice if the prompt could look like this:

OUTPUT TEXT
OUTPUT TEXT
OUTPUT TEXT

? > can type text here and all OUTPUT TEXT will go above this prompt

from enquirer.

jonschlinkert avatar jonschlinkert commented on May 11, 2024

Sorry that it took me so long to respond. The behavior you're seeing is correct, since you're trying to use console.log() with the prompt. Instead, try using the footer option.

See this example, and please let me know if that's what you meant. Thanks!

from enquirer.

linkjay avatar linkjay commented on May 11, 2024

No, I'm sorry I must be more than confusing here.

I understand that this is desired behavior, and that example does not show my issue. In that example, that shows output being drawn under the prompt, but I am not interested in that. I am asking if there is a way that upon console.log or any stdout, the prompt is moved down so the stdout is actually drawn above that prompt.

Think about having a terminal console. The typing input is always on the bottom, and any stdout that comes will be pasted above that.

from enquirer.

JcBernack avatar JcBernack commented on May 11, 2024

@jonschlinkert Imagine an async process trying to log anything to the console while a prompt is open:

const prompt = new Select({
    name: 'color',
    message: 'Pick a flavor',
    choices: ['apple', 'grape', 'watermelon', 'cherry', 'orange']
});

setInterval(() => console.log('FOO'), 1000);

prompt.run()
    .then(answer => console.log('Answer:', answer))
    .catch(console.error);

The FOO message will be written over the open prompt at the bottom. If you move the cursor within the prompt it will refresh and overwrite the FOOs. Inquirer has exactly the same issue btw.

Ideally there would be a method to write something to the console and make it appear "above" the open prompt so that it won't be overwritten.

image

from enquirer.

linkjay avatar linkjay commented on May 11, 2024

@JcBernack Yes, exactly! Thank you for re-explaining. I hope this clears things up @jonschlinkert

from enquirer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.