diff --git a/examples/print-key/main.go b/examples/print-key/main.go index 7369e1ba64..40c7de22ce 100644 --- a/examples/print-key/main.go +++ b/examples/print-key/main.go @@ -15,7 +15,7 @@ func (m model) Init() (tea.Model, tea.Cmd) { func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.KeyboardEnhancementsMsg: - return m, tea.Printf("Keyboard enhancements enabled! ReleaseKeys: %v\n", msg.SupportsReleaseKeys()) + return m, tea.Printf("Keyboard enhancements enabled! ReleaseKeys: %v\n", msg.SupportsKeyReleases()) case tea.KeyMsg: switch msg := msg.(type) { case tea.KeyPressMsg: @@ -34,7 +34,7 @@ func (m model) View() string { } func main() { - p := tea.NewProgram(model{}, tea.WithKeyboardEnhancements(tea.WithReleaseKeys)) + p := tea.NewProgram(model{}, tea.WithKeyboardEnhancements(tea.WithKeyReleases)) if _, err := p.Run(); err != nil { log.Printf("Error running program: %v", err) } diff --git a/keyboard.go b/keyboard.go index a36499283a..89f9605f40 100644 --- a/keyboard.go +++ b/keyboard.go @@ -41,20 +41,20 @@ type keyboardEnhancements struct { // KeyboardEnhancement is a type that represents a keyboard enhancement. type KeyboardEnhancement func(k *keyboardEnhancements) -// WithReleaseKeys enables support for reporting release key events. This is +// WithKeyReleases enables support for reporting release key events. This is // useful for terminals that support the Kitty keyboard protocol "Report event // types" progressive enhancement feature. // // Note that not all terminals support this feature. -func WithReleaseKeys(k *keyboardEnhancements) { +func WithKeyReleases(k *keyboardEnhancements) { k.kittyFlags |= ansi.KittyReportEventTypes } -// withDisambiguousKeys enables support for disambiguating keyboard escape +// withKeyDisambiguation enables support for disambiguating keyboard escape // codes. This is useful for terminals that support the Kitty keyboard protocol // "Disambiguate escape codes" progressive enhancement feature or the XTerm // modifyOtherKeys mode 1 feature to report ambiguous keys as escape codes. -func withDisambiguousKeys(k *keyboardEnhancements) { +func withKeyDisambiguation(k *keyboardEnhancements) { k.kittyFlags |= ansi.KittyDisambiguateEscapeCodes if k.modifyOtherKeys < 1 { k.modifyOtherKeys = 1 @@ -67,7 +67,7 @@ type enableKeyboardEnhancementsMsg []KeyboardEnhancement // in the terminal. func EnableKeyboardEnhancements(enhancements ...KeyboardEnhancement) Cmd { return func() Msg { - return enableKeyboardEnhancementsMsg(append(enhancements, withDisambiguousKeys)) + return enableKeyboardEnhancementsMsg(append(enhancements, withKeyDisambiguation)) } } @@ -83,9 +83,9 @@ func DisableKeyboardEnhancements() Msg { // supports keyboard enhancements. type KeyboardEnhancementsMsg keyboardEnhancements -// SupportsDisambiguousKeys returns whether the terminal supports reporting +// SupportsKeyDisambiguation returns whether the terminal supports reporting // disambiguous keys as escape codes. -func (k KeyboardEnhancementsMsg) SupportsDisambiguousKeys() bool { +func (k KeyboardEnhancementsMsg) SupportsKeyDisambiguation() bool { if runtime.GOOS == "windows" { // We use Windows Console API which supports reporting disambiguous keys. return true @@ -93,9 +93,9 @@ func (k KeyboardEnhancementsMsg) SupportsDisambiguousKeys() bool { return k.kittyFlags&ansi.KittyDisambiguateEscapeCodes != 0 || k.modifyOtherKeys >= 1 } -// SupportsReleaseKeys returns whether the terminal supports key release +// SupportsKeyReleases returns whether the terminal supports key release // events. -func (k KeyboardEnhancementsMsg) SupportsReleaseKeys() bool { +func (k KeyboardEnhancementsMsg) SupportsKeyReleases() bool { if runtime.GOOS == "windows" { // We use Windows Console API which supports key release events. return true diff --git a/options.go b/options.go index 7e8692f825..d1cb5320f8 100644 --- a/options.go +++ b/options.go @@ -259,7 +259,7 @@ func WithReportFocus() ProgramOption { // enabled by default. func WithKeyboardEnhancements(enhancements ...KeyboardEnhancement) ProgramOption { var ke keyboardEnhancements - for _, e := range append(enhancements, withDisambiguousKeys) { + for _, e := range append(enhancements, withKeyDisambiguation) { e(&ke) } return func(p *Program) { diff --git a/screen_test.go b/screen_test.go index 81c683a3e0..2555264aee 100644 --- a/screen_test.go +++ b/screen_test.go @@ -74,7 +74,7 @@ func TestClearMsg(t *testing.T) { }, { name: "kitty_start", - cmds: []Cmd{DisableKeyboardEnhancements, EnableKeyboardEnhancements(WithReleaseKeys)}, + cmds: []Cmd{DisableKeyboardEnhancements, EnableKeyboardEnhancements(WithKeyReleases)}, expected: "\x1b[?25l\x1b[?2004h\x1b[?2027h\x1b[?2027$p\x1b[>4;1m\x1b[>3u\rsuccess\r\n\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[>4;0m\x1b[>0u", }, }