Commit graph

97 commits

Author SHA1 Message Date
Ricardo-M-L
dc4b01750c
fix(key): map media record to ultraviolet code (#1757)
Co-authored-by: Ricardo-M-L <XuthodoreveraynWX61@elvisfan.com>
2026-08-11 16:43:12 +04:00
Ayman Bagabas
efd37e6e54
chore: update to use ultraviolet repository name 2025-06-30 11:05:36 -04:00
Ayman Bagabas
31fb5031cc
feat: update to use uv package 2025-05-30 17:44:58 -04:00
Ayman Bagabas
9eb2867725
refactor: use tv package for input events 2025-05-19 13:23:44 -04:00
Ayman Bagabas
f97ba58c0f
fix(key): add Keystroke() method to KeyPressMsg and KeyReleaseMsg 2025-05-09 10:25:42 -04:00
Ayman Bagabas
60b6f30124
feat: add keystroke representation to Key struct (#1399)
This splits the String() method into two methods:
- String() returns the text representation of the key and falls back to
  Keystroke() if there is no text representation
- Keystroke() returns the keystroke representation of the key

Needs: https://github.com/charmbracelet/x/pull/439
2025-04-24 12:25:08 +02:00
Andrey Nering
431cb5cd9f ci(lint): fix all lint issues on v2-exp 2025-02-27 12:04:20 -03:00
Ayman Bagabas
2df9ed00e3 refactor: use x/input for input events
This moves the existing input event handling to the x/input package. All
input events are translated to tea messages in
`tea.translateInputEvent`.
2024-12-12 10:51:58 -05:00
Ayman Bagabas
9d02251b66
fix(key): use the key text value when keycode is multirune 2024-08-30 09:37:23 -04:00
Ayman Bagabas
2f14548625
docs: add godoc examples 2024-08-30 09:37:08 -04:00
Ayman Bagabas
e8903bbd92
feat!: use KeyExtended to signify more than one rune 2024-08-30 09:37:07 -04:00
Ayman Bagabas
16f706ac13
refactor: expose key codes and define key/mouse interfaces 2024-08-30 09:37:07 -04:00
Ayman Bagabas
7b87642c87
refactor!: use key/mouse msg interfaces
Use key and mouse interfaces to catch their respective types as an
interface.
2024-08-30 09:37:07 -04:00
Ayman Bagabas
3f5fb9a3f9
fix(lint): reorder key struct to fix fieldalignment 2024-08-19 10:27:20 -04:00
Ayman Bagabas
e0865cfed3
refactor: simplify key modifier matching
Use bitmap matching to check if a modifier contains another
2024-08-16 16:51:34 -04:00
Ayman Bagabas
eb2eee4d98
refactor: rename KeySym to KeyType and make KeyRunes the default 2024-08-15 13:55:32 -04:00
Ayman Bagabas
f2bdd36fb2
fix: use KeyRunes to indicate text input 2024-08-14 17:08:44 -04:00
Ayman Bagabas
13ffcad06c
refactor: reimplement the event loop with a sequence parser
Currently, Bubble Tea uses a simple lookup table to detect input events.
Here, we're introducing an actual input sequence parser instead of
simply using a lookup table. This will allow Bubble Tea programs to read
all sorts of input events such Kitty keyboard, background color, mode
report, and all sorts of ANSI sequence input events.

Supersedes: https://github.com/charmbracelet/bubbletea/pull/1079
Supersedes: https://github.com/charmbracelet/bubbletea/issues/1014
Related: https://github.com/charmbracelet/bubbletea/issues/869
Related: https://github.com/charmbracelet/bubbletea/issues/163
Related: https://github.com/charmbracelet/bubbletea/issues/918
Related: https://github.com/charmbracelet/bubbletea/issues/850
Related: https://github.com/charmbracelet/bubbletea/issues/207
2024-08-12 17:33:51 -04:00
Christian Rocha
e3c61538ee chore(lint): remove naked returns 2024-05-08 12:17:18 -04:00
Christian Rocha
3e129db31a chore(lint): add various nolint directives 2024-05-08 12:17:18 -04:00
Ayman Bagabas
aaf740e5b7
fix(typo): initial variable during input parsing
This was probably a typo since the `w` gets set again during
`detectOneMsg` it wouldn't make sense to initially set it to `07` and it
makes the code confusing.

Fixes: a154847611 (feat: extended Coordinates mouse reporting & additional buttons support (#594))
2024-03-01 17:23:53 -05:00
Ayman Bagabas
75966e8578
feat: support windows console input buffer (#878)
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: https://github.com/charmbracelet/bubbletea/issues/538
Fixes: https://github.com/charmbracelet/bubbletea/issues/121
2024-02-27 14:21:42 -05:00
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