go-terminput icon indicating copy to clipboard operation
go-terminput copied to clipboard

feat: add ctrl-a to ctrl-z to key enums

Open chyroc opened this issue 5 years ago • 4 comments

Please open an issue and discuss changes before spending time on them, unless the change is trivial or an issue already exists.

chyroc avatar Dec 15 '20 05:12 chyroc

hi, thanks for you terminal input read repo.

i found some feat need to add to this repo.

i try to check if input is ctrl + a , i try to use e.Ctrl() && e.Rune() == 'a', but e.Ctrl() is not true, and i fail.

i try to print ctrl a to ctrl z, i found it is 1 to 26, so i create this pr.

thanks for your review my pr.

thanks

image

chyroc avatar Dec 15 '20 05:12 chyroc

@tj can you take some minutes to review my pr, thanks.

chyroc avatar Dec 15 '20 05:12 chyroc

ahh yea the "control characters" already have names & constants, so I'm not sure about adding more.

We could detect if those are pressed and add ModCtrl and populate the rune so Rune() returns what you'd expect, as well as Ctrl(), if that makes sense.

If you run man ascii in the terminal you should see the list, we should be able to just add 140 to the control character's numeric value to get the lowercase letter character

tj avatar Dec 15 '20 16:12 tj

hi, i click ctrl a, but ,.Ctrl() is not true, so i do this pr, to fix this

chyroc avatar Dec 18 '20 09:12 chyroc