Make dashboard updateable

This commit is contained in:
2026-07-28 12:44:31 +02:00
parent 72e1eb1fda
commit bb8e91039f
21 changed files with 3482 additions and 43 deletions

52
terminal_cursor_test.go Normal file
View File

@@ -0,0 +1,52 @@
package main
import (
"os"
"strings"
"testing"
"github.com/charmbracelet/x/ansi"
)
func TestTerminalCursorOutputPositionsHardwareBarAfterFrame(t *testing.T) {
file, err := os.CreateTemp(t.TempDir(), "cursor-output")
if err != nil {
t.Fatal(err)
}
defer file.Close()
output := newTerminalCursorOutput(file)
output.SetCursor(true, 7, 4)
if _, err := output.Write([]byte("frame")); err != nil {
t.Fatal(err)
}
content, err := os.ReadFile(file.Name())
if err != nil {
t.Fatal(err)
}
wantSuffix := ansi.SetCursorStyle(5) + ansi.CursorPosition(7, 4) + ansi.ShowCursor
if !strings.HasSuffix(string(content), wantSuffix) {
t.Fatalf("cursor output = %q, want suffix %q", content, wantSuffix)
}
}
func TestTerminalCursorOutputHidesCursorOutsideInsertMode(t *testing.T) {
file, err := os.CreateTemp(t.TempDir(), "cursor-output")
if err != nil {
t.Fatal(err)
}
defer file.Close()
output := newTerminalCursorOutput(file)
output.SetCursor(false, 0, 0)
if _, err := output.Write([]byte("frame")); err != nil {
t.Fatal(err)
}
content, err := os.ReadFile(file.Name())
if err != nil {
t.Fatal(err)
}
if !strings.HasSuffix(string(content), ansi.HideCursor) {
t.Fatalf("cursor output did not hide cursor: %q", content)
}
}