Comments (8)
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.
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.
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.
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.
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.
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.
@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 FOO
s. 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.
from enquirer.
@JcBernack Yes, exactly! Thank you for re-explaining. I hope this clears things up @jonschlinkert
from enquirer.
Related Issues (20)
- select prompt's choices value not working. (only name field does.) HOT 1
- customizing the style of input prompts HOT 2
- Mocking prompt answers without access to the specific enquirer instance used to prompt HOT 3
- typescript: to infer ReturnType after calling prompt(questions) HOT 3
- Input prompt moves on keydown HOT 1
- Is this project still under maintenance?
- when visible list only has disabled choice (by search), press up/down throw RangeError
- AutoComplete prompt - improve highlighting
- press ESC -> error
- Poor terminal and implementation causing issues with rendering HOT 4
- Multiselect clips prompt message and some items when scrolling HOT 4
- Cannot create custom prompt that extends MultiSelect HOT 2
- Validation in Form HOT 2
- Error with webpack HOT 4
- v2.4.0 contains changes that are not compatible with Node 14 HOT 2
- 2.4 changelog HOT 3
- In select or autocomplete mode, can hint support to display only when selected, but not normally?
- list not working when using nodemon HOT 1
- NPM dependency requests ^2.3.6 but seems to resolve 2.4.1? HOT 4
- engines.node in package.json needs to be updated HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enquirer.