Commit Graph

75 Commits

Author SHA1 Message Date
Raphael 'kena' Poss 2b46020ca0
feat: bracketed paste (#397)
* feat: bracketed paste

This introduces support for input via bracketed paste, where escape
characters in the pasted input are not interpreted.

Pasted input are marked as a special field in the KeyMsg. This is
useful because pasted input may need sanitation in individual widgets.

* fix(key): support bracketed paste with short reads

Some terminal emulators feed the bracketed paste data in multiple
chunks, which may not be aligned on a 256 byte boundary. So it's
possible for `input.Read` to return less than 256 bytes read
but while there's still more data to be read to complete a bracketed
paste input.

---------

Co-authored-by: Christian Muehlhaeuser <muesli@gmail.com>
2024-02-05 14:49:09 +01:00
Ayman Bagabas a154847611
feat: extended Coordinates mouse reporting & additional buttons support (#594)
* feat(mouse): add extended mouse & shift key support

Support SGR(1006) mouse mode
Support parsing shift key press
Support additional mouse buttons
Report which button was released
Report button motion

* fix: key.go sgr len missing calculation (#841)

* chore(test): add sgr mouse msg detect test

---------

Co-authored-by: robinsamuel <96998379+robin-samuel@users.noreply.github.com>
2023-12-04 11:50:59 -05:00
Raphael 'kena' Poss 5536bca34e
fix(key): support very long buffered input (#570) 2023-10-18 12:59:26 +02:00
Christian Rocha c284acad9f chore(lint): extract a magic number when parsing X10 mouse events 2023-07-10 09:04:25 -04:00
Christian Rocha 522659d798 chore(lint): wrap various errors 2023-07-10 09:04:25 -04:00
Raphael 'kena' Poss b1e7f42ab0 fix(key): invert the control loop
Instead of reading messages in an array and then sending them into a
channel, this version of key.go writes to the channel directly.
2023-06-20 12:48:13 +02:00
Raphael 'kena' Poss d9c675138c fix(key),test: simplify the input analysis code 2023-06-15 14:51:02 +02:00
Christian Muehlhaeuser b8ef6f85ea feat: support ctrl+page up/down keys
Adds support for ctrl+(alt)+page up/down key events.

Tested in konsole, alacritty, foot, urxvt, and a few other
terminals.

Fixes #369.
2022-10-12 07:11:20 +02:00
Raphael 'kena' Poss 0e76ba142a fix(key): recover the insert key
We started supporting insert in #418, but then accidentally
removed it during a rebase in #396. Oops.
2022-10-07 14:54:27 +02:00
Raphael 'kena' Poss 7e7a729b31 fix: remove the now-unused hexes key mapping
This became unnecessary when we fixed the support for the Alt modifier
on control characters.
2022-10-03 22:43:17 +02:00
Raphael 'kena' Poss b074f6f5a4 fix: properly skip over unrecognized CSI sequences. 2022-10-03 22:43:17 +02:00
Raphael 'kena' Poss 08518987f5 Reorder the function keys in key.go for better troubleshootability
Here the list of keys did not change, I simply re-ordered the lines
in the file.
2022-10-03 19:56:10 +02:00
Raphael 'kena' Poss ce923aabbf Add missing alt+ variant for F13-F16 2022-10-03 19:56:10 +02:00
Raphael 'kena' Poss 290ef8dce5 Add missing alt+ variant for F5-F12 on urxvt 2022-10-03 19:56:10 +02:00
Raphael 'kena' Poss d9b2889cf4 Add support for ctrl+, ctrl+shift+ for home/end keys 2022-10-03 19:56:10 +02:00
Raphael 'kena' Poss 5f76c2036d Reorganize key.go for clarity 2022-10-03 19:56:10 +02:00
Raphael 'kena' Poss 2fe4aad5e6 Fix home/end on vt100 2022-10-03 19:56:10 +02:00
Raphael 'kena' Poss 2fe97e07d0 Support the insert key
This can be used in e.g. textarea / textinput to enable "overwrite
mode".
2022-09-27 04:01:39 +02:00
Raphael 'kena' Poss 624343388b Support linux console F1-F5 2022-09-04 17:52:17 +02:00
Raphael 'kena' Poss 134a930f2d keys: properly support the alt modifier 2022-08-30 11:17:11 +02:00
mattn 6b685056fc
fix: support multi-byte strings on Windows (#343)
* convert locale string to utf-8 on Windows

* update go.mod

* revert go fmt ./...

* fix(lint): use tabs in GoDoc example code

Co-authored-by: Christian Rocha <christian@rocha.is>
2022-08-19 09:25:22 -07:00
Christian Muehlhaeuser 1e1b5f716d chore: gofmt sources 2022-08-15 12:25:55 +02:00
Christian Muehlhaeuser e6dabb3c36 fix: handle batched key msgs 2022-06-08 14:03:28 +02:00
Christian Rocha d301ee0405
change(keys): spacebar sends a `KeySpace` (#315)
* Revert "fix: update tests for space input"

This reverts commit bfb166822e.

* Revert "feat: obliterate type KeySpace"

This reverts commit d3fb1b707a.
2022-05-13 13:24:16 -04:00
Christian Rocha d3fb1b707a feat: obliterate type KeySpace
Treating a space differently from other runes was proving to cause more
confusion that clarity.
2022-05-10 16:56:37 -04:00
Christian Rocha 48cdc1e6c3
feat(keys): add support for shift/ctrl + arrow keys (#292)
* feat(keys): add support for shift/ctrl+arrow keys

* chore(keys): use sequences for shift/ctrl arrow keys

* feat(keys): support ctrl+shift+arrow keys

* chore(keys): use sequences for alt+arrows

* feat(keys): add support for arrow key combinations with alt modifiers

* fix(keys): remove an extreaneous check

* feat(keys): add support for urxvt arrow keys with modfiers

* feat(keys): add support for arrow keys in DECCKM mode

* docs(keys): expand on comment about ctrl+backtick

* chore(keys): migrate various bindings to sequences

* Minor comment improvements to the input parser

Co-authored-by: Bwahharharrr <yitang@tutanota.com>
2022-05-10 16:16:33 -04:00
bashbunni 14e58aa1f9
fix(keys): spacebar now sends a `KeySpace` (#289)
* fix: replace keySP with working KeySpace

* test: update test to meet new reqs

* fix: fix test looking for 'space'

* fix(keys): set type to KeySpace when sending a space

* docs(keys): comments

Co-authored-by: Christian Rocha <christian@rocha.is>
2022-04-12 11:14:35 -04:00
Christian Rocha 5c76027b36
feat: add support for function keys 2022-03-21 09:48:05 -04:00
Christian Muehlhaeuser 6301f93cb2 Support receiving batched mouse events
Mouse events may trigger more than a single events simultaneously.

Fixes #212.
2022-02-13 08:40:04 +01:00
Christian Rocha c5ed2b4a01 Add missing GoDocs 2021-09-07 15:37:14 -04:00
Christian Muehlhaeuser b664dee939 Fix typo 2021-03-12 01:24:38 +01:00
Christian Rocha 65e8067a82 Implement String() on type Key and make key constants type KeyType 2021-03-08 19:11:02 -05:00
Christian Rocha 116a0cfb8f Process alt-modfied keystrokes before normal character input 2020-11-01 08:57:43 -05:00
Christian Rocha 1b5f599f2d Update key usage examples 2020-11-01 08:57:43 -05:00
Christian Rocha 4f2d85494d Remove the excessive Key.IsRune() method 2020-11-01 08:57:43 -05:00
Christian Rocha fc37167e16 Support multi-character input (i.e. Chinese and Japanese IME) 2020-11-01 08:57:43 -05:00
Christian Rocha a1d92e77c5
Correct backspace and delete key mappings 2020-10-22 15:22:07 -04:00
Christian Rocha a85d22cf54
Handle arrows on Powershell on Unix-like systems 2020-10-13 14:42:29 -04:00
Christian Rocha 223519f81f
Add periods after comments to make the godoc linter happy. 2020-08-24 15:22:04 -04:00
Christian Muehlhaeuser d26cfb6b38
Make golint happy 2020-08-22 12:34:03 +02:00
Christian Rocha 6fcdf9908f
Improve examples in docs 2020-07-30 11:30:33 -04:00
Christian Rocha a5e38222c5
Don't expose ReadInput 2020-07-29 20:51:55 -04:00
Christian Rocha c0f67a2927
Improve GoDocs 2020-07-29 20:50:00 -04:00
Christian Rocha eecd6b0612
Fix ctrl+v key mapping 2020-07-21 15:50:07 -04:00
Christian Rocha 2ee871862a
Fix bug where certain keys (pgup/pgdown/home/end/etc) weren't being sent 2020-07-20 11:50:27 -04:00
Christian Rocha d86cb562f0
Add basic mouse support 2020-06-22 20:41:26 -04:00
Christian Rocha 3b8b011b5a
Rename to Bubble Tea (with the import name tea) 2020-05-25 19:48:36 -04:00
Christian Muehlhaeuser e8b7e510bb
Simplify key/sequence map 2020-05-25 14:03:59 +02:00
Christian Muehlhaeuser 0957c58e05
Make type documentation godoc-compliant 2020-05-25 14:02:46 +02:00
Christian Rocha ee5f82579f
Don't treat the space character as a control character
There are drawbacks to both sides of this, but in the end, it seems to make
more sense to treat spaces as regular runes.
2020-05-19 14:41:55 -04:00