mirror of
https://github.com/db9979/sshtermy.git
synced 2026-12-06 04:34:08 +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>
48 lines
2.0 KiB
Go
48 lines
2.0 KiB
Go
package ansi
|
|
|
|
import "testing"
|
|
|
|
func TestMethod_StringWidth(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
m Method
|
|
in string
|
|
want int
|
|
}{
|
|
{"empty string wcwidth", WcWidth, "", 0},
|
|
{"empty string grapheme width", GraphemeWidth, "", 0},
|
|
{"ascii wcwidth", WcWidth, "hello", 5},
|
|
{"ascii grapheme width", GraphemeWidth, "hello", 5},
|
|
{"ansi wcwidth", WcWidth, "\x1b[31mred\x1b[0m", 3},
|
|
{"ansi grapheme width", GraphemeWidth, "\x1b[31mred\x1b[0m", 3},
|
|
{"wide chars wcwidth", WcWidth, "コンニチハ", 10},
|
|
{"wide chars grapheme width", GraphemeWidth, "コンニチハ", 10},
|
|
{"emoji wcwidth", WcWidth, "😀", 2},
|
|
{"emoji grapheme width", GraphemeWidth, "😀", 2},
|
|
// Wcwidth measures per codepoint, so a ZWJ sequence is as wide as the
|
|
// emoji it joins: a white flag, a zero-width VS16 and ZWJ, and a
|
|
// rainbow. Grapheme width measures the cluster as the one glyph a
|
|
// terminal in Unicode core mode draws.
|
|
{"flag emoji wcwidth", WcWidth, "🏳️🌈", 3},
|
|
{"flag emoji grapheme width", GraphemeWidth, "🏳️🌈", 2},
|
|
// Unicode 15.1 merged Indic conjuncts into single clusters, but a
|
|
// terminal without Unicode core mode still advances once per
|
|
// consonant.
|
|
{"devanagari wcwidth", WcWidth, "नमस्ते", 4},
|
|
{"devanagari grapheme width", GraphemeWidth, "नमस्ते", 3},
|
|
{"zwj family wcwidth", WcWidth, "👨👩👧👦", 8},
|
|
{"zwj family grapheme width", GraphemeWidth, "👨👩👧👦", 2},
|
|
{"skin tone wcwidth", WcWidth, "👍🏽", 4},
|
|
{"skin tone grapheme width", GraphemeWidth, "👍🏽", 2},
|
|
{"combining mark wcwidth", WcWidth, "é", 1},
|
|
{"combining mark grapheme width", GraphemeWidth, "é", 1},
|
|
{"vs16 wcwidth", WcWidth, "⚠️", 1},
|
|
{"vs16 grapheme width", GraphemeWidth, "⚠️", 2},
|
|
}
|
|
for _, tt := range tests {
|
|
if got := tt.m.StringWidth(tt.in); got != tt.want {
|
|
t.Errorf("%s: Method.StringWidth(%q) = %d, want %d", tt.name, tt.in, got, tt.want)
|
|
}
|
|
}
|
|
}
|