mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-17 05:54:59 +02:00
show_key kitten: In kitty mode show the actual bytes sent by the terminal rather than a re-encoding of the parsed key event
Also port the kitten to Go
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"kitty/kittens/hints"
|
||||
"kitty/kittens/hyperlinked_grep"
|
||||
"kitty/kittens/icat"
|
||||
"kitty/kittens/show_key"
|
||||
"kitty/kittens/ssh"
|
||||
"kitty/kittens/themes"
|
||||
"kitty/kittens/unicode_input"
|
||||
@@ -41,6 +42,8 @@ func KittyToolEntryPoints(root *cli.Command) {
|
||||
ssh.EntryPoint(root)
|
||||
// unicode_input
|
||||
unicode_input.EntryPoint(root)
|
||||
// show_key
|
||||
show_key.EntryPoint(root)
|
||||
// hyperlinked_grep
|
||||
hyperlinked_grep.EntryPoint(root)
|
||||
// ask
|
||||
|
||||
@@ -105,6 +105,9 @@ type KeyEvent struct {
|
||||
AlternateKey string
|
||||
Text string
|
||||
Handled bool
|
||||
|
||||
// The CSI string this key event was decoded from. Empty if not decoded from CSI.
|
||||
CSI string
|
||||
}
|
||||
|
||||
func (self *KeyEvent) String() string {
|
||||
@@ -133,6 +136,7 @@ func KeyEventFromCSI(csi string) *KeyEvent {
|
||||
if len(csi) == 0 {
|
||||
return nil
|
||||
}
|
||||
orig_csi := csi
|
||||
last_char := csi[len(csi)-1:]
|
||||
if !strings.Contains("u~ABCDEHFPQRS", last_char) || (last_char == "~" && (csi == "200~" || csi == "201~")) {
|
||||
return nil
|
||||
@@ -165,7 +169,7 @@ func KeyEventFromCSI(csi string) *KeyEvent {
|
||||
if len(sections) > 2 {
|
||||
third_section = get_sub_sections(sections[2], 0)
|
||||
}
|
||||
var ans = KeyEvent{Type: PRESS}
|
||||
var ans = KeyEvent{Type: PRESS, CSI: orig_csi}
|
||||
var keynum int
|
||||
if val, ok := letter_trailer_to_csi_number_map[last_char]; ok {
|
||||
keynum = val
|
||||
|
||||
Reference in New Issue
Block a user