From 773b740e87e45239ad7cf479b104a1cac262a4fd Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Tue, 8 Nov 2022 13:33:43 +0100 Subject: [PATCH] Named space and backspace keys. --- driver.go | 2 ++ testdata/simple | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/driver.go b/driver.go index 80cd832..6a42327 100644 --- a/driver.go +++ b/driver.go @@ -514,5 +514,7 @@ var allKeys = func() map[string]tea.Key { } result[keyName] = k } + result["space"] = tea.Key{Type: tea.KeySpace, Runes: []rune(" ")} + result["backspace"] = tea.Key{Type: tea.KeyBackspace} return result }() diff --git a/testdata/simple b/testdata/simple index 35f080b..5f8ad22 100644 --- a/testdata/simple +++ b/testdata/simple @@ -114,17 +114,39 @@ TEA PRINT: {MODEL UPDATE} MODEL VIEW🛇 run trace=on +key space +key backspace key ctrl+c key alt+c key alt+ctrl+down ---- +-- trace: before "key space" +-- trace: after "key" +-- view: +MODEL VIEW🛇 +-- trace: before "key backspace" +-- trace: processing 1 messages +-- trace: msg tea.KeyMsg{Type:-12, Runes:[]int32{32}, Alt:false} +-- trace: processing 1 cmds +-- trace: translated cmd: tea.printLineMessage +-- trace: after "key" +-- view: +MODEL VIEW🛇 -- trace: before "key ctrl+c" +-- trace: processing 2 messages +-- trace: msg tea.KeyMsg{Type:127, Runes:[]int32(nil), Alt:false} +-- trace: msg tea.printLineMessage{messageBody:"MODEL UPDATE"} +TEA PRINT: {MODEL UPDATE} +-- trace: processing 1 cmds +-- trace: translated cmd: tea.printLineMessage -- trace: after "key" -- view: MODEL VIEW🛇 -- trace: before "key alt+c" --- trace: processing 1 messages +-- trace: processing 2 messages -- trace: msg tea.KeyMsg{Type:3, Runes:[]int32(nil), Alt:false} +-- trace: msg tea.printLineMessage{messageBody:"MODEL UPDATE"} +TEA PRINT: {MODEL UPDATE} -- trace: processing 1 cmds -- trace: translated cmd: tea.printLineMessage -- trace: after "key"