mirror of
https://github.com/db9979/sshtermy.git
synced 2026-12-06 20:54:09 +01:00
* Leistungsanzeige verständlicher, Zeichnen etwa doppelt so schnell - Anzeige bewertet die Zeichenzeit in Worten (flüssig/gut/etwas träge/ruckelt), zwei Zeilen Balken je Bild statt Braille-Punkte, "möglich"-Bildrate, 1 Bild/s im Leerlauf wird erklärt; im Terminal links neben der F6-Leiste, Toasts weichen darunter aus - Overlays (Toasts, Tooltip, Ausblenden, Leistungsanzeige) ohne Compositor: stamp() fasst nur die überdeckten Zeilen an - Terminalbild wird gemerkt, solange keine neue Ausgabe kam (Term.Gen) - Seitenleiste ohne lipgloss-Umbruch anfügen (beside), Verläufe in einem Render - ViewHL misst bereits aufgefüllte Zeilen nicht noch einmal - Benchmarks: Terminal 2,9 → 0,9 ms, mit F6 + Anzeige 6,5 → 2,3 ms, mit laufender Ausgabe 6,9 → 3,5 ms je Bild Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUk5KxaHH89KrFPon9n * Zeichnen noch einmal fast doppelt so schnell - x/ansi als Fork (third_party/ansi): ASCII-Schnellweg in FirstGraphemeCluster, lipgloss misst jede Zeile jedes Bildes - Terminal-Zeilen unter einer Sperre holen (vt LineCopy), Farbregeln aus denselben Zellen statt jede Zelle zweimal einzeln - Seitenleiste (F6, Ziel, …) gemerkt, solange ihr Inhalt gleich bleibt - Balken der Leistungsanzeige je Farbe in einem Render - Benchmark mit F6, Anzeige und laufender Ausgabe: 3,5 → 1,8 ms je Bild Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUk5KxaHH89KrFPon9n --------- Co-authored-by: Claude <noreply@anthropic.com>
244 lines
4.7 KiB
Go
244 lines
4.7 KiB
Go
package ansi
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestMouseButton(t *testing.T) {
|
|
type test struct {
|
|
name string
|
|
btn MouseButton
|
|
motion, shift, alt, ctrl bool
|
|
want byte
|
|
}
|
|
|
|
cases := []test{
|
|
{
|
|
name: "mouse release",
|
|
btn: MouseNone,
|
|
want: 0b0000_0011,
|
|
},
|
|
{
|
|
name: "mouse release with ctrl",
|
|
btn: MouseNone,
|
|
ctrl: true,
|
|
want: 0b0001_0011,
|
|
},
|
|
{
|
|
name: "mouse left",
|
|
btn: MouseLeft,
|
|
want: 0b0000_0000,
|
|
},
|
|
{
|
|
name: "mouse right",
|
|
btn: MouseRight,
|
|
want: 0b0000_0010,
|
|
},
|
|
{
|
|
name: "mouse wheel up",
|
|
btn: MouseWheelUp,
|
|
want: 0b0100_0000,
|
|
},
|
|
{
|
|
name: "mouse wheel right",
|
|
btn: MouseWheelRight,
|
|
want: 0b0100_0011,
|
|
},
|
|
{
|
|
name: "mouse backward",
|
|
btn: MouseBackward,
|
|
want: 0b1000_0000,
|
|
},
|
|
{
|
|
name: "mouse forward",
|
|
btn: MouseForward,
|
|
want: 0b1000_0001,
|
|
},
|
|
{
|
|
name: "mouse button 10",
|
|
btn: MouseButton10,
|
|
want: 0b1000_0010,
|
|
},
|
|
{
|
|
name: "mouse button 11",
|
|
btn: MouseButton11,
|
|
want: 0b1000_0011,
|
|
},
|
|
{
|
|
name: "mouse middle with motion",
|
|
btn: MouseMiddle,
|
|
motion: true,
|
|
want: 0b0010_0001,
|
|
},
|
|
{
|
|
name: "mouse middle with shift",
|
|
btn: MouseMiddle,
|
|
shift: true,
|
|
want: 0b0000_0101,
|
|
},
|
|
{
|
|
name: "mouse middle with motion and alt",
|
|
btn: MouseMiddle,
|
|
motion: true,
|
|
alt: true,
|
|
want: 0b0010_1001,
|
|
},
|
|
{
|
|
name: "mouse right with shift, alt, and ctrl",
|
|
btn: MouseRight,
|
|
shift: true,
|
|
alt: true,
|
|
ctrl: true,
|
|
want: 0b0001_1110,
|
|
},
|
|
{
|
|
name: "mouse button 10 with motion, shift, alt, and ctrl",
|
|
btn: MouseButton10,
|
|
motion: true,
|
|
shift: true,
|
|
alt: true,
|
|
ctrl: true,
|
|
want: 0b1011_1110,
|
|
},
|
|
{
|
|
name: "mouse left with motion, shift, and ctrl",
|
|
btn: MouseLeft,
|
|
motion: true,
|
|
shift: true,
|
|
ctrl: true,
|
|
want: 0b0011_0100,
|
|
},
|
|
{
|
|
name: "invalid mouse button",
|
|
btn: MouseButton(0xff),
|
|
want: 0b1111_1111,
|
|
},
|
|
{
|
|
name: "mouse wheel down with motion",
|
|
btn: MouseWheelDown,
|
|
motion: true,
|
|
want: 0b0110_0001,
|
|
},
|
|
{
|
|
name: "mouse wheel down with shift and ctrl",
|
|
btn: MouseWheelDown,
|
|
shift: true,
|
|
ctrl: true,
|
|
want: 0b0101_0101,
|
|
},
|
|
{
|
|
name: "mouse wheel left with alt",
|
|
btn: MouseWheelLeft,
|
|
alt: true,
|
|
want: 0b0100_1010,
|
|
},
|
|
{
|
|
name: "mouse middle with all modifiers",
|
|
btn: MouseMiddle,
|
|
motion: true,
|
|
shift: true,
|
|
alt: true,
|
|
ctrl: true,
|
|
want: 0b0011_1101,
|
|
},
|
|
}
|
|
|
|
for i, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
got := EncodeMouseButton(tc.btn, tc.motion, tc.shift, tc.alt, tc.ctrl)
|
|
if got != tc.want {
|
|
t.Errorf("test %d: got %08b; want %08b", i+1, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestMouseSgr(t *testing.T) {
|
|
type test struct {
|
|
name string
|
|
btn byte
|
|
x, y int
|
|
release bool
|
|
}
|
|
|
|
cases := []test{
|
|
{
|
|
name: "mouse left",
|
|
btn: EncodeMouseButton(MouseLeft, false, false, false, false),
|
|
x: 0,
|
|
y: 0,
|
|
},
|
|
{
|
|
name: "wheel down",
|
|
btn: EncodeMouseButton(MouseWheelDown, false, false, false, false),
|
|
x: 1,
|
|
y: 10,
|
|
},
|
|
{
|
|
name: "mouse right with shift, alt, and ctrl",
|
|
btn: EncodeMouseButton(MouseRight, false, true, true, true),
|
|
x: 10,
|
|
y: 1,
|
|
},
|
|
{
|
|
name: "mouse release",
|
|
btn: EncodeMouseButton(MouseNone, false, false, false, false),
|
|
x: 5,
|
|
y: 5,
|
|
release: true,
|
|
},
|
|
{
|
|
name: "mouse button 10 with motion, shift, alt, and ctrl",
|
|
btn: EncodeMouseButton(MouseButton10, true, true, true, true),
|
|
x: 10,
|
|
y: 10,
|
|
},
|
|
{
|
|
name: "mouse wheel up with motion",
|
|
btn: EncodeMouseButton(MouseWheelUp, true, false, false, false),
|
|
x: 15,
|
|
y: 15,
|
|
},
|
|
{
|
|
name: "mouse middle with all modifiers",
|
|
btn: EncodeMouseButton(MouseMiddle, true, true, true, true),
|
|
x: 20,
|
|
y: 20,
|
|
},
|
|
{
|
|
name: "mouse wheel left at max coordinates",
|
|
btn: EncodeMouseButton(MouseWheelLeft, false, false, false, false),
|
|
x: 223,
|
|
y: 223,
|
|
},
|
|
{
|
|
name: "mouse forward release",
|
|
btn: EncodeMouseButton(MouseForward, false, false, false, false),
|
|
x: 100,
|
|
y: 100,
|
|
release: true,
|
|
},
|
|
{
|
|
name: "mouse backward with shift and ctrl",
|
|
btn: EncodeMouseButton(MouseBackward, false, true, false, true),
|
|
x: 50,
|
|
y: 50,
|
|
},
|
|
}
|
|
|
|
for i, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
m := MouseSgr(tc.btn, tc.x, tc.y, tc.release)
|
|
action := 'M'
|
|
if tc.release {
|
|
action = 'm'
|
|
}
|
|
want := fmt.Sprintf("\x1b[<%d;%d;%d%c", tc.btn, tc.x+1, tc.y+1, action)
|
|
if m != want {
|
|
t.Errorf("test %d: got %q; want %q", i+1, m, want)
|
|
}
|
|
})
|
|
}
|
|
}
|