parent
b314303787
commit
91700b3e42
@ -40,6 +40,8 @@ Detailed list of changes
|
||||
|
||||
- Fix a regression in the previous release that broke the remote file kitten (:iss:`6186`)
|
||||
|
||||
- Fix a regression in the previous release that broke handling of some key board shortcuts in some kittens on some keyboard layouts (:iss:`6189`)
|
||||
|
||||
0.28.0 [2023-04-15]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@ -140,26 +140,30 @@ func KeyEventFromCSI(csi string) *KeyEvent {
|
||||
csi = csi[:len(csi)-1]
|
||||
sections := strings.Split(csi, ";")
|
||||
|
||||
get_sub_sections := func(section string) []int {
|
||||
get_sub_sections := func(section string, missing int) []int {
|
||||
p := strings.Split(section, ":")
|
||||
ans := make([]int, len(p))
|
||||
for i, x := range p {
|
||||
q, err := strconv.Atoi(x)
|
||||
if err != nil {
|
||||
return nil
|
||||
if x == "" {
|
||||
ans[i] = missing
|
||||
} else {
|
||||
q, err := strconv.Atoi(x)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
ans[i] = q
|
||||
}
|
||||
ans[i] = q
|
||||
}
|
||||
return ans
|
||||
}
|
||||
first_section := get_sub_sections(sections[0])
|
||||
second_section := make([]int, 0)
|
||||
third_section := make([]int, 0)
|
||||
first_section := get_sub_sections(sections[0], 0)
|
||||
second_section := []int{}
|
||||
third_section := []int{}
|
||||
if len(sections) > 1 {
|
||||
second_section = get_sub_sections(sections[1])
|
||||
second_section = get_sub_sections(sections[1], 1)
|
||||
}
|
||||
if len(sections) > 2 {
|
||||
third_section = get_sub_sections(sections[2])
|
||||
third_section = get_sub_sections(sections[2], 0)
|
||||
}
|
||||
var ans = KeyEvent{Type: PRESS}
|
||||
var keynum int
|
||||
|
||||
30
tools/tui/loop/key-encoding_test.go
Normal file
30
tools/tui/loop/key-encoding_test.go
Normal file
@ -0,0 +1,30 @@
|
||||
// License: GPLv3 Copyright: 2023, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||
|
||||
package loop
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
func TestKeyEventFromCSI(t *testing.T) {
|
||||
|
||||
test_text := func(csi string, expected, alternate string) {
|
||||
ev := KeyEventFromCSI(csi)
|
||||
if ev == nil {
|
||||
t.Fatalf("Failed to get parse %#v", csi)
|
||||
}
|
||||
if diff := cmp.Diff(expected, ev.Text); diff != "" {
|
||||
t.Fatalf("Failed to get text from %#v:\n%s", csi, diff)
|
||||
}
|
||||
if diff := cmp.Diff(alternate, ev.AlternateKey); diff != "" {
|
||||
t.Fatalf("Failed to get alternate from %#v:\n%s", csi, diff)
|
||||
}
|
||||
}
|
||||
test_text("121;;121u", "y", "")
|
||||
test_text("121::122;;121u", "y", "z")
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user