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

Add support for displaying complete options immediately #130

Open
cipriancraciun opened this issue Apr 12, 2020 · 6 comments
Open

Add support for displaying complete options immediately #130

cipriancraciun opened this issue Apr 12, 2020 · 6 comments

Comments

@cipriancraciun
Copy link

Sometimes, for example when liner is used to allow the user to choose from a few options, it would be useful to immediately print the available options, instead of waiting the user to press the Tab key first.

I think a function like SetTabCompletionImmediate (bool) would enable users to control this.

If this change would be accepted, I could try to provide the implementation.

@peterh
Copy link
Owner

peterh commented Apr 14, 2020

Print the available options? How? I think I need a bit more detail to fully evaluate this proposal.

Printing multiple options probably needs multiple lines, and liner isn't likely to gain any additional options that result in multiple line drawing (SetMultiLineMode notwithstanding).

@cipriancraciun
Copy link
Author

Sorry, I should have been more thorough in my initial request.

Say I want to use liner to ask the user to choose among a few options, say yes / no, or the name of the days, etc. I would like to be able to make liner display the user the few available options so he knows immediately what he can enter.

Now, if the number of available options is too large and don't fit a single line, it's OK to just trim them to the first few options that fit.

(Basically it doesn't change the way completion display works, just the fact that the tab completion is triggered immediately, and doesn't wait for the user to press tab.)

@peterh
Copy link
Owner

peterh commented Apr 19, 2020

I'm still having difficulty visualizing how the proposed multiple options would appear. How do you plan to implement temporary-overstrike-mode? Do you plan to use some sort of delimiter so the user knows where the suggestion ends if they're typing in the middle of a line of input?

@cipriancraciun
Copy link
Author

I don't expect any changes to be made to the way the current completion is performed. (I.e. they are performed as now on a separate line.)

The only change I'm proposing to make is this: when the user is shown the prompt, before it reads any user input, liner behaves just like the user has pressed Tab and displays the possible completion values; then from here on it is business as usual.

Perhaps the feature request could have been better called: "add an option to display auto-completion options immediately without waiting for the user to press Tab".

@peterh
Copy link
Owner

peterh commented Apr 20, 2020

then from here on it is business as usual.

Assuming you mean "behave as if tab was pressed after every keystroke": That would make it impossible to type a non-completed value if the first part of your non-completed value happened to match a tab value.

Assuming you mean "behave as if tab was pressed exactly once, when Prompt is called", that's exactly the same as calling the completion function yourself and then calling PromptWithSuggestion instead of Prompt.

@cipriancraciun
Copy link
Author

Assuming you mean "behave as if tab was pressed exactly once, when Prompt is called", that's exactly the same as calling the completion function yourself and then calling PromptWithSuggestion instead of Prompt.

It's not exactly the same thing, as for example if in a future you would update your code to allow choosing the option with direction keys, or ordering the completions in any way, it would be consistent. If I would have called the completion and displayed it myself, it would be inconsistent with any such future updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants