-
Notifications
You must be signed in to change notification settings - Fork 94
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 Home and End key for list prompt #79
Add Home and End key for list prompt #79
Conversation
I just created a PR to add support for multiple versions of home and end: #87 |
# Conflicts: # src/Key.php # src/SearchPrompt.php # src/SuggestPrompt.php
I merged the current branch into my branch, and it seems that the added changes to The current Home and End keys work fine, if there's anything missing I'd be happy to help. |
@crazywhalecc I think your recent changes cover the issues you described. It is just using the |
@TWithers Oh yeah... My mistake, I forgot about it after long vacation 😵💫 |
a799387
to
63d5ace
Compare
Hey @crazywhalecc, thanks heaps for this! 🙌 I've removed the offset code for now because it's not needed for this specific feature and it was getting pretty complex. I've also centralised the logic into an existing trait related to the scroll behaviour. I've also fixed a small issue where pressing home/end while navigating a list would reset the cursor position of the text input. |
Thank you so much! I'm looking forward to this feature being added. 👍 The original consideration of using |
This PR (Plan A for additional keys) allows list-related prompts to support using Home and End key, which allows us to go to top and bottom. This PR is related to #69 .
The main functions of this PR are:
And I also have two questions:
First, I tested on macOS Terminal and Windows Terminal. They both uses
\e[H
(xterm style) character. I don't know how to be compatible with responses from different terminals.Second, I have written almost identical code many times, but I don't know how to better merge them because different Prompts use different list filters, such as
$this->options
and$this->matches
.In addition, I have plan B, which is simply: write a
trait HighlightList
, including member variables such aspublic ?int $highlighted
, and convert methods such ashighlightNext()
intoupdateHighlight($options , $scroll, $highlighted)
, handles multiple page highlighting options within a common method. But this only separates the dependent variables, and passing in an array increases the complexity of theupdateHighlight
method.