chore: import official kitty sources from upstream
Bring the kovidgoyal/kitty codebase in as the base of FWS-Kitty, vendored at upstream commit 91fb38a without its git history.
This commit is contained in:
1134 files changed
+433629
No files matched your search
@@ -0,0 +1,57 @@
|
||||
// License: GPLv3 Copyright: 2026, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||
|
||||
package resize_window
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestResizeCommandEscapeCode(t *testing.T) {
|
||||
ec, err := resize_command_escape_code(-4, "vertical", 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.HasPrefix(ec, "\x1bP@kitty-cmd") || !strings.HasSuffix(ec, "\x1b\\") {
|
||||
t.Fatalf("bad framing: %q", ec)
|
||||
}
|
||||
var cmd struct {
|
||||
Cmd string `json:"cmd"`
|
||||
Version [3]int `json:"version"`
|
||||
Payload struct {
|
||||
Increment int `json:"increment"`
|
||||
Axis string `json:"axis"`
|
||||
Self bool `json:"self"`
|
||||
} `json:"payload"`
|
||||
}
|
||||
body := strings.TrimSuffix(strings.TrimPrefix(ec, "\x1bP@kitty-cmd"), "\x1b\\")
|
||||
if err := json.Unmarshal([]byte(body), &cmd); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cmd.Cmd != "resize-window" || cmd.Payload.Increment != -4 || cmd.Payload.Axis != "vertical" || !cmd.Payload.Self {
|
||||
t.Fatalf("bad command: %+v", cmd)
|
||||
}
|
||||
if cmd.Version == [3]int{} {
|
||||
t.Fatal("version not set")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResizeResetUsesEntrySnapshotOnlyWhenRequested(t *testing.T) {
|
||||
for _, axis := range []string{"restore", "reset"} {
|
||||
ec, err := resize_command_escape_code(2, axis, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var cmd struct {
|
||||
Payload resize_payload `json:"payload"`
|
||||
}
|
||||
body := strings.TrimSuffix(strings.TrimPrefix(ec, "\x1bP@kitty-cmd"), "\x1b\\")
|
||||
if err := json.Unmarshal([]byte(body), &cmd); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cmd.Payload.Axis != "reset" || cmd.Payload.Restore != (axis == "restore") {
|
||||
t.Fatalf("reset source was not preserved: %+v", cmd.Payload)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user