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

dynamic / live prompt/prefix string. #22

Closed
jesseward opened this issue Nov 17, 2017 · 4 comments
Closed

dynamic / live prompt/prefix string. #22

jesseward opened this issue Nov 17, 2017 · 4 comments

Comments

@jesseward
Copy link

jesseward commented Nov 17, 2017

hey @c-bata , awesome package..

I have logged a pull request and opening this issue to discuss a potential feature enhancement or suggestions for this change.

PR #21 introduces a new option 'prompt.OptionLivePrefix' that accepts a function (signature = func() string). This function would be called each time Render() is executed.

The goal here is to enable a "live" (or dynamic) prompt, as an alternative to the current static Prefix/prompt.

@warpfork
Copy link

warpfork commented Nov 29, 2017

Hi there @c-bata, +1 to awesome work and also +1 for interest in an ability to set additional prefix material.

I wrote something very simple for this once before. The user experience that library had in mind is roughly:

scrollback 1          each of these
scrollback 2          is a regular log line
scrollback 3          scrolling back forever (until your terminal gui runs out of scrollback anyway)
scrollback 4          and it's exposed as another io.Writer of course
scrollback ...n       
┌──────────────────────────────────────────────────────┐
│  you could make a "banner" here                      │
│  providing` some sort of service status, clock, etc  │
│  the height is also variable; why not                │
└──────────────────────────────────────────────────────┘
>>> user prompt would stick at the very bottom

I'd love to add something like this "Banner" feature to go-prompt. The hacks I scraped together in the past do the banner part (implementation is simply setting the cursor back to the top of the banner area after every update and some ANSI clear codes -- very similar to what go-prompt does) work fine, but I never added user input, and go-prompts features for input are out of this world and I want to use it :D

Do you have any opinions on the API? go-slog's API was just a simple SetBanner method (with a mutex internally). I also tried a callback approach in an earlier draft, but scrapped it, because an imperative SetBanner was much easier to integrate with other actors in my programs.

Would be quite happy to make PRs if there's a design in mind!

@mozillazg
Copy link

+1 for dynamic prefix.

@c-bata
Copy link
Owner

c-bata commented Feb 5, 2018

Hi guys. I reopened #21 and add some comments for supporting live prefix.

@c-bata
Copy link
Owner

c-bata commented Feb 12, 2018

added at #30

@c-bata c-bata closed this as completed Feb 12, 2018
Guttz pushed a commit to Guttz/go-prompt that referenced this issue Dec 8, 2023
* feat: support async completions

* feat: sync read/write access to suggestions
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

4 participants