Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Console] Support a set of control keys and key combinations inQuestionHelper#48287

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
maxbeckers wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
frommaxbeckers:patch-36657

Conversation

maxbeckers
Copy link
Contributor

@maxbeckersmaxbeckers commentedNov 22, 2022
edited
Loading

QA
Branch?6.4
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#36657
LicenseMIT
Doc PR-

Add support for using arrow keys in the QuestionHelper.

There was already a try#36700 to fix the issue.

The approach here does not depend onreadline at all (removed in#17669)

This key combinations are added:

Key combinationComment
Backward one character
CTRL +BBackward one character
Forward one character
CTRL +FForward one character
CTRL +Backward one word
ALT +BBackward one word
CTRL +SHIFT +Backward one word
CTRL +Forward one word
ALT +FForward one word
CTRL +SHIFT +Forward one word
CTRL +HDelete previous character
BackspaceDelete previous character
DeleteDelete next character
CTRL +ABeginning of input
HomeBeginning of input
CTRL +EEnd of input
EndEnd of input

Feel free to test it out and leave comments about the experience.

UPDATE For better testing i now created a repohttps://github.com/maxbeckers/symfony-cli-input-handling

GromNaN, chalasr, julien-boudry, Chi-teck, and linaori reacted with thumbs up emojiOskarStark, obstschale, and bigfoot90 reacted with rocket emoji
@carsonbotcarsonbot added Status: Needs Review Status: Needs Work Console DXDX = Developer eXperience (anything that improves the experience of using Symfony) Feature RFCRFC = Request For Comments (proposals about features that you want to be discussed) labelsNov 22, 2022
@carsonbotcarsonbot added this to the6.2 milestoneNov 22, 2022
@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "6.2" but it seems your PR description refers to branch "6.3".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@carsonbotcarsonbot changed the title[WIP][RFC][DX][Console] Support left and right arrow for QuestionHelper[Console] [WIP] Support left and right arrow for QuestionHelperNov 22, 2022
@fabpotfabpot modified the milestones:6.2,6.3Nov 23, 2022
@maxbeckersmaxbeckersforce-pushed thepatch-36657 branch 3 times, most recently from6d3e73c to51b434dCompareNovember 24, 2022 13:17
@maxbeckersmaxbeckers changed the title[Console] [WIP] Support left and right arrow for QuestionHelper[Console] Support left and right arrow for QuestionHelperNov 24, 2022
@maxbeckers
Copy link
ContributorAuthor

maxbeckers commentedNov 24, 2022
edited
Loading

Now I have a stand that needs to be reviewed.

I add a zip for easier testing. Feel free to test and try it and find all the bugs.
test-48287.zip

The solution might not be perfect, but for me it seems to work fine. Only with ESC the solution has it's problems. Maybe someone has for that an idea. ESC is "\033" and ctrl buttons as well start with this char.

Current Test failures seem not to be related to the PR.

Copy link
Member

@GromNaNGromNaN left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is a great improvement for user experience in interactive commands.

I understand that is a proof-of-concept. There is other key and key combination to get the same experience than the shell.

  • Key HOME and END (same as Ctrl+A and Ctrl+E)
  • Key Alt+Right Arrow and Alt+Left Arrow move from word to word (I just discovered that the behavior is not the same on bash or zsh, the- is a word-breaker on bash, not on zsh)

https://stackoverflow.com/questions/5029118/bash-ctrl-to-move-cursor-between-words-strings

@maxbeckers
Copy link
ContributorAuthor

@GromNaN thanks for your input. Yes, you're right, it's a proof of concept. Because of that i ask for comments on this approach. Now there is a solid base and i need feedback to optimize it.

I'll have a look to the other key combinations you mentioned.

@maxbeckersmaxbeckers changed the title[Console] Support left and right arrow for QuestionHelper[Console] Support a set of control keys and key combinations in QuestionHelperNov 25, 2022
@maxbeckers
Copy link
ContributorAuthor

Added the mentioned:

  • Key HOME and END
  • move from word to word

Test zip:test-48287-2.zip

@maxbeckers
Copy link
ContributorAuthor

maxbeckers commentedNov 26, 2022
edited
Loading

One problem for now is with a question in a output section withSymfonyStyle ... I'll try to find a solution for that.

UPDATE found a solution for the section input. not very nice, maybe someone has a good idea here. I create a newConsoleOutput because the input for the question in section in handled after the section with the stdin/stdout.
test-48287.zip

@Chi-teck
Copy link
Contributor

I think the keys should match default readline configuration.
https://github.com/chzyer/readline/blob/v1.5.1/doc/shortcut.md

Though we might not need to cover all readline features.

@maxbeckers
Copy link
ContributorAuthor

hi@Chi-teck and thanks for the link. I'll have a look to that the next days in detail. But i guess some of the keys are already implemented the way readline has implemented it as well. But of course we'll only have a set of this keys.

@maxbeckers
Copy link
ContributorAuthor

maxbeckers commentedJan 23, 2023
edited
Loading

Hi@Chi-teck,

I updated the description of this PR including all of the currently supported key combinations. It matches the keys of readline and has just some bash additions added.

I of course only added key combinations making sense to the question helper input.

@Chi-teck
Copy link
Contributor

Chi-teck commentedNov 29, 2023
edited
Loading

The question helper used in Symfony console looks so outdated. Especially when compared with Laravel prompts and some JS implementations. I wonder if it possible to make it swappable. So a third party packages could provide a replacement for it.

bigfoot90 reacted with rocket emoji

@xabbuhxabbuh modified the milestones:7.1,7.2May 15, 2024
@Seldaek
Copy link
Member

@maxbeckers could you add support for CTRL-C as well here or is that another problem? Seecomposer/composer#12106 for example.

@maxbeckers
Copy link
ContributorAuthor

Hi@Seldaek,

good idea. I'm currently on vacation. Afterwards I'll have a look on that.

@maxbeckers
Copy link
ContributorAuthor

Hi@Seldaek,

I tried to reproduce that. When I use composer, then I can reproduce your problem:
Screenshot 2024-10-02 151343
and i can only exit, when i pressenter forno.
But with a simple php script that runs a test command, I can't reproduce that:
Screenshot 2024-10-02 151431
There theCtrl + C exits the application. (Tested with symfony 5.4 and 7.2)

So it seems to be a bug in relation to run the composer script. => No need to change anything forCtrl + C in the symfony console componenet from my POV.

@OskarStarkOskarStark changed the title[Console] Support a set of control keys and key combinations in QuestionHelper[Console] Support a set of control keys and key combinations inQuestionHelperOct 2, 2024
@Seldaek
Copy link
Member

@maxbeckers ah you're right sorry about that. Figured out some more details herecomposer/composer#12106 (comment)

@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@GromNaNGromNaNGromNaN left review comments

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

Assignees
No one assigned
Labels
ConsoleDXDX = Developer eXperience (anything that improves the experience of using Symfony)FeatureRFCRFC = Request For Comments (proposals about features that you want to be discussed)Status: Needs ReviewStatus: Needs Work
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

Console: Support Left/Right Arrow Keys
8 participants
@maxbeckers@carsonbot@Chi-teck@Seldaek@GromNaN@fabpot@nicolas-grekas@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp