Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Externally triggered prompt redraw or write above the prompt #229

Closed
flxo opened this issue May 19, 2019 · 11 comments
Closed

Externally triggered prompt redraw or write above the prompt #229

flxo opened this issue May 19, 2019 · 11 comments

Comments

@flxo
Copy link

flxo commented May 19, 2019

Hi,

I really struggled with the title for this issue - so let me describe what I need:

I want to write a console application that provide s some kind of command line that is always present at the bottom of the terminal. The text above this is updated from events happening somewhere else and have no influence on the prompt.

abc
def
>> asdf
abc
def
ghi
>> asdf

Currently the readline blocks and I haven't found a way to kind of interrupt that and print some lines and resume the input operation. Is that possible with rustyline?

I got this working with linefeed that allows to clone a handle to the prompter that implements write and internally synchronises writing to stdout. A example is here.

For sure this topics gets complicated when it comes to paged display of the history etc...
Did this topic already raise in the past and if yes - what's the conclusion?

Thanks,

flxo

@gwenn
Copy link
Collaborator

gwenn commented May 19, 2019

I don't know how to do this!
I should investigate how python-prompt-toolkit or linefeed do this.
I will look at your example.

@gwenn
Copy link
Collaborator

gwenn commented May 19, 2019

@neonphog
Copy link

+1 I need this too. Looks like https://github.com/Dhole/rustylinez is trying to add this functionality, but didn't compile for me

@gwenn
Copy link
Collaborator

gwenn commented May 26, 2019

Just for reference:

I am not sure but I guess we should give priority to user input for example while doing completion/listing completion candidates.

@gwenn gwenn mentioned this issue Jun 2, 2019
@gwenn
Copy link
Collaborator

gwenn commented Jun 10, 2019

Could you please give #235 a try ?

@flxo
Copy link
Author

flxo commented Jun 14, 2019

@gwenn Thanks. I will try that!

@gwenn
Copy link
Collaborator

gwenn commented Jul 4, 2019

Should work on windows now.
Only tested with:

$ wineconsole --backend=curses target/x86_64-pc-windows-gnu/debug/examples/external_print.exe

@gwenn gwenn removed the question label Jul 4, 2019
@tailhook
Copy link
Contributor

I've just got a very similar issue: I want asynchronous completion. I don't think that waiting on <tab> for too long makes sense as well as putting completion in front of the user if they already don't expect it.

So what I think I'm going to do is:

  1. Wait 100ms in completion handler, if it's not ready put -- loading completions to the hint
  2. Fetch completions in background
  3. Change the hint to -- completions loaded (user can now press tab and that will work)

The problem is to update hint on (3). While #235 helps there if I also print a line into the external printer that line will bother users.

We can probably apply #235 which sets up some async infrastructure, and then add another pipe to signal refresh.

Alternatively, we can introduce some simple signal to refresh instead of #235, and use that as a basis for the external printer.

@vi
Copy link

vi commented Nov 22, 2021

Are there any updates on async and/or printing while readlining?

@JanBeh
Copy link

JanBeh commented May 1, 2022

Are there any updates on async and/or printing while readlining?

In the master branch, there has been support added for printing while reading, see example.

On my terminal, this appears to be buggy yet, so I filed a bug report.

A longer thread on URLO: Text-mode (terminal) application with asynchronous input/output.

@gwenn
Copy link
Collaborator

gwenn commented Jul 17, 2022

Version 10.0.0 released.

@gwenn gwenn closed this as completed Jul 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants