a few more changes

This commit is contained in:
2024-10-13 16:32:05 +02:00
parent 905bb6711e
commit 553804ec51
12 changed files with 392 additions and 310 deletions
+4 -3
View File
@@ -9,6 +9,7 @@ import (
"strings"
"github.com/nathan-fiscaletti/consolesize-go"
"github.com/orus-dev/osui/keys"
)
var re = regexp.MustCompile(`(\x1b\[([0-9;]*)[a-zA-Z])+`)
@@ -67,13 +68,13 @@ func RenderOnFrame(c Component, frame *[]string) {
}
}
func ReadKey() (string, error) {
func ReadKey() Key {
var b [3]byte
n, err := os.Stdin.Read(b[:])
if err != nil {
return "", err
return Key{Chars: [3]rune{'E', 'r', 'r'}, Name: err.Error()}
}
return string(b[:n]), nil
return Key{Chars: [3]rune{rune(b[0]), rune(b[1]), rune(b[2])}, Name: keys.GetKeyName(string(b[:n]))}
}
func NewFrame(width, height int) []string {