mirror of
https://github.com/db9979/sshtermy.git
synced 2026-12-05 12:24:08 +01:00
Texte in allen Themes lesbar: Kontrastschutz für Serverausgabe, Markierung in Theme-Farben (#171)
Programme, die das Theme nicht kennen (Claude Code, bat, delta im dunklen Modus), schrieben auf hellen Themes weiß auf weiß; Markierungen kehrten nur um und blieben dann ebenfalls unlesbar. - termemu/look.go: jede Zelle in echte Farben auflösen (Standard, ANSI- Palette hell/dunkel, 256er, Umkehren, Abgedunkelt) und Schrift auf mindestens 4,5:1 anheben (Hochkontrast 7:1). Rahmen/Blöcke/Braille bleiben. - Markierung im Terminal: Akzentfarbe statt Umkehren. - PROD-Marke, inaktive Tab- und Bereichsnamen: Kontrast gesichert. - Nacht: Gedämpft etwas heller, Lagerfeuer: Gefahr etwas heller. - Textfelder immer in Theme-Farben (themedInput, aiInput.restyle), auch nach einem Theme-Wechsel; Platzhalter nicht mehr zusätzlich abgedunkelt. - Tests: jede Zelle jedes Golden-Bildschirms in allen 26 Themes, dazu Serverausgabe mit fremden Farben, Markierung und Suchtreffern. - README DE/EN, Webseite. Claude-Session: https://claude.ai/code/session_018i4GUiY8TqDYwJ9pNmhHF1 Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
db5a41e821
commit
f7267504ec
35 files changed
+718
-50
No files matched your search
@@ -234,6 +234,7 @@ nicht als Beweis. Die Liste: Palette *Logwache: Meldungen* oder `w` im Log-Blick
|
||||
dunkler, und Kopfzeile und Logo tragen einen sanften Farbverlauf; wahlweise mit runden Ecken oder ganz flach wie früher (ohne Schatten und Verläufe)
|
||||
- **Farbiger Rahmen je Tab**: jedes Terminal, allein oder als Bereich der geteilten Ansicht, bekommt einen Rahmen in der Farbe seiner Verbindung, und sein Name in der Tab-Leiste und im Bereichstitel steht in derselben Farbe. Farbe je Verbindung im Formular wählbar („Farbe“); automatisch heißt prod rot, test grün, labor blau, sonst jeder offene Tab eine eigene Farbe, nie Rot, Rot bedeutet also immer produktiv. Palette › Einstellungen › „Farbiger Rahmen um jeden Tab“ schaltet es ab
|
||||
- **Aktives Fenster auf einen Blick**: Der aktive Tab in der Leiste oben und der Titel des aktiven Bereichs sind in der Tab-Farbe gefüllt, fett und mit ▶ markiert, sein Rahmen ist dick; alle anderen bleiben gedämpft auf eigener Fläche. Lesbar in allen 26 Farbschemata und auch ohne Farbe (▶, Fettdruck, dicker Rahmen)
|
||||
- **Lesbar in jedem Farbschema**: Ausgabe von Programmen auf dem Server, die das Theme nicht kennen (z. B. Claude Code, bat oder delta im dunklen Modus auf einem hellen Theme), wird auf mindestens 4,5:1 Kontrast angehoben (Hochkontrast 7:1), ANSI-Farben kommen aus einer Palette passend zu hell oder dunkel, Abgedunkeltes rechnet sshTermy selbst aus. Markierungen erscheinen in der Akzentfarbe des Themes statt nur umgekehrt. Rahmen-, Block- und Braille-Zeichen (Bilder, Diagramme) behalten ihre Farben. Ein Test prüft jede Zelle jedes Bildschirms in allen 26 Themes
|
||||
- **Barrierearm** (Einstellungen › Aussehen): keine Animationen, Formen statt nur Farben (× für „nicht erreichbar“);
|
||||
dazu die **Farbenblind-Themes** (Blau/Gelb/Orange statt Grün/Rot, Okabe-Ito-Farben)
|
||||
- **Lebendige Oberfläche** (Palette „Bewegung“: voll, dezent, aus): Spinner im Tab beim Verbinden, Tabs leuchten bei
|
||||
|
||||
@@ -228,6 +228,7 @@ lets them in. The AI status report treats syslog lines as hints, not as proof. T
|
||||
little, and the header and logo carry a soft color gradient; optionally with round corners, or flat as before (no shadows, no gradients)
|
||||
- **Colored frame per tab**: every terminal, alone or as a pane of the split view, gets a frame in its connection's color, and its name in the tab bar and pane title shows in the same color. Pick the color per connection in the form (“Color”); automatic means prod red, test green, lab blue, otherwise each open tab its own color, never red, so red always means production. Palette › Settings › “Colored frame around each tab” turns it off
|
||||
- **Active window at a glance**: the active tab in the top bar and the title of the active pane are filled in the tab color, bold and marked with ▶, its frame is thick; all others stay muted on their own surface. Readable in all 26 themes and without color (▶, bold, thick frame)
|
||||
- **Readable in every theme**: output from server programs that don't know the theme (e.g. Claude Code, bat or delta in dark mode on a light theme) is lifted to at least 4.5:1 contrast (7:1 in high contrast), ANSI colors use a palette matching light or dark, dimmed text is computed by sshTermy itself. Selections are drawn in the theme's accent color instead of just inverted. Box, block and Braille characters (pictures, graphs) keep their colors. A test checks every cell of every screen in all 26 themes
|
||||
- **Accessible mode** (Settings › Appearance): no animations, shapes instead of color only (× for “unreachable”);
|
||||
together with the **color-blind themes** (blue/yellow/orange instead of green/red, Okabe-Ito colors)
|
||||
- **Lively interface** (palette “Motion”: full, subtle, off): a spinner in the tab while connecting, tabs flash green
|
||||
|
||||
@@ -13,6 +13,9 @@ import (
|
||||
type HL struct {
|
||||
Set *highlight.Set
|
||||
Colors [8]color.Color
|
||||
// Look: Theme-Farben und Kontrastschutz (look.go); nil = Farben so
|
||||
// weiterreichen, wie das Programm sie schreibt.
|
||||
Look *Look
|
||||
}
|
||||
|
||||
// columnsOf: wie columns, für eine schon geholte Zeile.
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
package termemu
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"math"
|
||||
|
||||
uv "github.com/charmbracelet/ultraviolet"
|
||||
"github.com/charmbracelet/x/ansi"
|
||||
)
|
||||
|
||||
// Lesbarkeit der Serverausgabe
|
||||
//
|
||||
// Programme auf dem Server wissen nicht, welches Farbschema sshTermy zeigt.
|
||||
// Claude Code, bat, delta & Co. schreiben im dunklen Modus z. B. fest
|
||||
// #f8f8f2 als Schrift – auf einem hellen Theme ist das weiß auf weiß. Das
|
||||
// äußere Terminal kennt außerdem nur seine eigene ANSI-Palette, die zu
|
||||
// sshTermys Hintergrund nicht passen muss.
|
||||
//
|
||||
// Look löst darum jede Zelle in echte Farben auf (Standardfarbe → Theme,
|
||||
// ANSI 0–15 → Palette passend zu hell/dunkel, 256er-Farben → xterm-Werte,
|
||||
// Umkehren und Abgedunkelt ausgerechnet) und hebt die Schrift so weit an,
|
||||
// dass sie mindestens MinContrast zum Hintergrund hat (wie VS Code
|
||||
// „minimumContrastRatio“). Rahmen-, Block- und Braille-Zeichen bleiben
|
||||
// unverändert, sonst würden Bilder aus Halbblöcken und Diagramme verfälscht.
|
||||
|
||||
// Look: Farben des Themes für die Terminalfläche.
|
||||
type Look struct {
|
||||
Fg, Bg color.Color // Standardschrift und -grund
|
||||
ANSI [16]color.Color // Palette für ANSI 0–15 (nil = xterm-Wert)
|
||||
SelFg, SelBg color.Color // Markierung (nil = Fg/Bg vertauscht)
|
||||
MinContrast float64 // 0 = Schrift nie anheben
|
||||
MinFaint float64 // für Abgedunkeltes (0 = MinContrast)
|
||||
}
|
||||
|
||||
// rgb: Farbe als 8-Bit-Anteile.
|
||||
type rgb struct{ r, g, b uint8 }
|
||||
|
||||
func toRGB(c color.Color) rgb {
|
||||
r, g, b, _ := c.RGBA()
|
||||
return rgb{uint8(r >> 8), uint8(g >> 8), uint8(b >> 8)}
|
||||
}
|
||||
|
||||
func (c rgb) color() color.Color { return color.RGBA{c.r, c.g, c.b, 0xff} }
|
||||
|
||||
func chan01(v uint8) float64 {
|
||||
x := float64(v) / 255
|
||||
if x <= 0.03928 {
|
||||
return x / 12.92
|
||||
}
|
||||
return math.Pow((x+0.055)/1.055, 2.4)
|
||||
}
|
||||
|
||||
// lum: relative Helligkeit nach WCAG 2.
|
||||
func (c rgb) lum() float64 {
|
||||
return 0.2126*chan01(c.r) + 0.7152*chan01(c.g) + 0.0722*chan01(c.b)
|
||||
}
|
||||
|
||||
// Contrast: Kontrastverhältnis nach WCAG 2 (1 bis 21).
|
||||
func Contrast(a, b color.Color) float64 { return contrastRGB(toRGB(a), toRGB(b)) }
|
||||
|
||||
func contrastRGB(a, b rgb) float64 {
|
||||
la, lb := a.lum()+0.05, b.lum()+0.05
|
||||
return math.Max(la, lb) / math.Min(la, lb)
|
||||
}
|
||||
|
||||
func mixRGB(a, b rgb, t float64) rgb {
|
||||
m := func(x, y uint8) uint8 { return uint8(math.Round(float64(x) + (float64(y)-float64(x))*t)) }
|
||||
return rgb{m(a.r, b.r), m(a.g, b.g), m(a.b, b.b)}
|
||||
}
|
||||
|
||||
// Readable: fg so wenig wie nötig Richtung Weiß oder Schwarz schieben, bis
|
||||
// es need:1 zu bg erreicht. Der Farbton bleibt erkennbar.
|
||||
func Readable(fg, bg color.Color, need float64) color.Color {
|
||||
return readable(toRGB(fg), toRGB(bg), need).color()
|
||||
}
|
||||
|
||||
func readable(fg, bg rgb, need float64) rgb {
|
||||
if need <= 1 || contrastRGB(fg, bg) >= need {
|
||||
return fg
|
||||
}
|
||||
white, black := rgb{255, 255, 255}, rgb{0, 0, 0}
|
||||
first, second := black, white
|
||||
if bg.lum() < 0.18 { // dunkler Grund: heller machen
|
||||
first, second = white, black
|
||||
}
|
||||
best := fg
|
||||
for _, end := range []rgb{first, second} {
|
||||
if contrastRGB(end, bg) < need {
|
||||
if contrastRGB(end, bg) > contrastRGB(best, bg) {
|
||||
best = end // Ziel nicht erreichbar: wenigstens das Beste
|
||||
}
|
||||
continue
|
||||
}
|
||||
lo, hi := 0.0, 1.0
|
||||
for i := 0; i < 12; i++ {
|
||||
mid := (lo + hi) / 2
|
||||
if contrastRGB(mixRGB(fg, end, mid), bg) >= need {
|
||||
hi = mid
|
||||
} else {
|
||||
lo = mid
|
||||
}
|
||||
}
|
||||
return mixRGB(fg, end, hi)
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
// Paletten für ANSI 0–15 (Werte wie im Terminal von VS Code, Dark+/Light+).
|
||||
var (
|
||||
ansiDark = [16]rgb{
|
||||
{0x00, 0x00, 0x00}, {0xcd, 0x31, 0x31}, {0x0d, 0xbc, 0x79}, {0xe5, 0xe5, 0x10},
|
||||
{0x24, 0x72, 0xc8}, {0xbc, 0x3f, 0xbc}, {0x11, 0xa8, 0xcd}, {0xe5, 0xe5, 0xe5},
|
||||
{0x66, 0x66, 0x66}, {0xf1, 0x4c, 0x4c}, {0x23, 0xd1, 0x8b}, {0xf5, 0xf5, 0x43},
|
||||
{0x3b, 0x8e, 0xea}, {0xd6, 0x70, 0xd6}, {0x29, 0xb8, 0xdb}, {0xff, 0xff, 0xff},
|
||||
}
|
||||
ansiLight = [16]rgb{
|
||||
{0x00, 0x00, 0x00}, {0xcd, 0x31, 0x31}, {0x00, 0xbc, 0x00}, {0x94, 0x98, 0x00},
|
||||
{0x04, 0x51, 0xa5}, {0xbc, 0x05, 0xbc}, {0x05, 0x98, 0xbc}, {0x55, 0x55, 0x55},
|
||||
{0x66, 0x66, 0x66}, {0xcd, 0x31, 0x31}, {0x14, 0xce, 0x14}, {0xb5, 0xba, 0x00},
|
||||
{0x04, 0x51, 0xa5}, {0xbc, 0x05, 0xbc}, {0x05, 0x98, 0xbc}, {0xa5, 0xa5, 0xa5},
|
||||
}
|
||||
)
|
||||
|
||||
// StandardANSI: Palette für ANSI 0–15 passend zu hellem oder dunklem Grund.
|
||||
func StandardANSI(dark bool) [16]color.Color {
|
||||
src := ansiLight
|
||||
if dark {
|
||||
src = ansiDark
|
||||
}
|
||||
var out [16]color.Color
|
||||
for i, c := range src {
|
||||
out[i] = c.color()
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// resolve: Zellfarbe als RGB (nil = Standardfarbe def).
|
||||
func (l *Look) resolve(c color.Color, def rgb) rgb {
|
||||
switch v := c.(type) {
|
||||
case nil:
|
||||
return def
|
||||
case ansi.BasicColor:
|
||||
if v < 16 && l.ANSI[v] != nil {
|
||||
return toRGB(l.ANSI[v])
|
||||
}
|
||||
case ansi.IndexedColor:
|
||||
if v < 16 && l.ANSI[v] != nil {
|
||||
return toRGB(l.ANSI[v])
|
||||
}
|
||||
}
|
||||
return toRGB(c)
|
||||
}
|
||||
|
||||
// DecorGlyph: Zeichen, deren Farbe ein Bild ergibt (Rahmen, Blöcke,
|
||||
// Braille-Diagramme, Powerline-Pfeile) – hier nichts anheben.
|
||||
func DecorGlyph(s string) bool {
|
||||
for _, r := range s {
|
||||
switch {
|
||||
case r >= 0x2500 && r <= 0x259f, // Rahmen + Blöcke
|
||||
r >= 0x2800 && r <= 0x28ff, // Braille
|
||||
r >= 0xe0b0 && r <= 0xe0d7, // Powerline
|
||||
r >= 0x1fb00 && r <= 0x1fbff: // Legacy Computing (Sextanten …)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// lookKey: Zellstil vor dem Umrechnen. Gleiche Stile kommen auf einem
|
||||
// Bildschirm ständig vor; der Merker spart Rechnen und Speicher je Zelle.
|
||||
type lookKey struct {
|
||||
fg, bg color.Color
|
||||
attrs uint8
|
||||
sel, glyphs bool // markiert; Schrift zählt (kein Leerzeichen/Blockzeichen)
|
||||
}
|
||||
|
||||
type lookVal struct {
|
||||
fg, bg color.Color
|
||||
attrs uint8
|
||||
}
|
||||
|
||||
// lookMemo: Merker für einen Bildaufbau. Meist hat die Nachbarzelle den
|
||||
// gleichen Stil; der letzte Treffer liegt darum vorn.
|
||||
type lookMemo struct {
|
||||
m map[lookKey]lookVal
|
||||
lastK lookKey
|
||||
lastV lookVal
|
||||
has bool
|
||||
}
|
||||
|
||||
func newLookMemo() *lookMemo { return &lookMemo{m: make(map[lookKey]lookVal, 32)} }
|
||||
|
||||
// apply schreibt die echten Farben in die Zelle. sel: Zelle ist markiert.
|
||||
func (l *Look) apply(c *uv.Cell, sel bool, memo *lookMemo) {
|
||||
glyphs := !(c.Content == "" || c.Content == " " || DecorGlyph(c.Content))
|
||||
k := lookKey{c.Style.Fg, c.Style.Bg, c.Style.Attrs, sel, glyphs}
|
||||
var v lookVal
|
||||
if memo.has && memo.lastK == k {
|
||||
v = memo.lastV
|
||||
} else {
|
||||
var ok bool
|
||||
if v, ok = memo.m[k]; !ok {
|
||||
v = l.compute(k)
|
||||
memo.m[k] = v
|
||||
}
|
||||
memo.lastK, memo.lastV, memo.has = k, v, true
|
||||
}
|
||||
c.Style.Fg, c.Style.Bg, c.Style.Attrs = v.fg, v.bg, v.attrs
|
||||
}
|
||||
|
||||
func (l *Look) compute(k lookKey) lookVal {
|
||||
defFg, defBg := toRGB(l.Fg), toRGB(l.Bg)
|
||||
fg := l.resolve(k.fg, defFg)
|
||||
bg := l.resolve(k.bg, defBg)
|
||||
a := k.attrs
|
||||
if a&uv.AttrReverse != 0 {
|
||||
fg, bg = bg, fg
|
||||
a &^= uv.AttrReverse
|
||||
}
|
||||
if k.sel {
|
||||
if l.SelBg != nil && l.SelFg != nil {
|
||||
fg, bg = toRGB(l.SelFg), toRGB(l.SelBg)
|
||||
} else {
|
||||
fg, bg = bg, fg
|
||||
}
|
||||
}
|
||||
need := l.MinContrast
|
||||
if a&uv.AttrFaint != 0 {
|
||||
// Abgedunkelt selbst ausrechnen: Terminals machen das sehr
|
||||
// unterschiedlich, manche gar nicht oder bis zur Unlesbarkeit.
|
||||
fg = mixRGB(fg, bg, 0.4)
|
||||
a &^= uv.AttrFaint
|
||||
if l.MinFaint > 0 {
|
||||
need = math.Min(need, l.MinFaint)
|
||||
}
|
||||
}
|
||||
// verborgen (Passwort-Echo) bleibt verborgen
|
||||
if k.glyphs && a&uv.AttrConceal == 0 {
|
||||
fg = readable(fg, bg, need)
|
||||
}
|
||||
return lookVal{fg.color(), bg.color(), a}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package termemu
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"testing"
|
||||
|
||||
uv "github.com/charmbracelet/ultraviolet"
|
||||
"github.com/charmbracelet/x/ansi"
|
||||
)
|
||||
|
||||
var lightLook = &Look{
|
||||
Fg: color.RGBA{0x1f, 0x23, 0x35, 0xff}, Bg: color.RGBA{0xf5, 0xf5, 0xf7, 0xff},
|
||||
ANSI: StandardANSI(false), SelFg: color.RGBA{0xf5, 0xf5, 0xf7, 0xff}, SelBg: color.RGBA{0x2e, 0x59, 0xc9, 0xff},
|
||||
MinContrast: 4.5, MinFaint: 3.5,
|
||||
}
|
||||
|
||||
func applied(c uv.Cell, sel bool) uv.Cell {
|
||||
lightLook.apply(&c, sel, newLookMemo())
|
||||
return c
|
||||
}
|
||||
|
||||
// Claude Code im dunklen Modus auf hellem Theme: #f8f8f2 wird lesbar.
|
||||
func TestLookLiftsLightTextOnLightTheme(t *testing.T) {
|
||||
c := applied(uv.Cell{Content: "x", Width: 1, Style: uv.Style{Fg: color.RGBA{0xf8, 0xf8, 0xf2, 0xff}}}, false)
|
||||
if r := Contrast(c.Style.Fg, c.Style.Bg); r < 4.5 {
|
||||
t.Fatalf("Kontrast %.2f", r)
|
||||
}
|
||||
if toRGB(c.Style.Bg) != toRGB(lightLook.Bg) {
|
||||
t.Fatalf("Grund %v", c.Style.Bg)
|
||||
}
|
||||
}
|
||||
|
||||
// Gut lesbare Farben bleiben genau so.
|
||||
func TestLookKeepsGoodColors(t *testing.T) {
|
||||
red := color.RGBA{0xc4, 0x12, 0x2f, 0xff}
|
||||
c := applied(uv.Cell{Content: "x", Width: 1, Style: uv.Style{Fg: red}}, false)
|
||||
if toRGB(c.Style.Fg) != toRGB(red) {
|
||||
t.Fatalf("geändert: %v", c.Style.Fg)
|
||||
}
|
||||
}
|
||||
|
||||
// Umkehren, ANSI-Palette, Verborgen, Blockzeichen.
|
||||
func TestLookAttributes(t *testing.T) {
|
||||
c := applied(uv.Cell{Content: "x", Width: 1, Style: uv.Style{Attrs: uv.AttrReverse}}, false)
|
||||
if c.Style.Attrs&uv.AttrReverse != 0 || toRGB(c.Style.Bg) != toRGB(lightLook.Fg) {
|
||||
t.Fatalf("Umkehren nicht ausgerechnet: %+v", c.Style)
|
||||
}
|
||||
c = applied(uv.Cell{Content: "x", Width: 1, Style: uv.Style{Fg: ansi.BasicColor(7)}}, false)
|
||||
if r := Contrast(c.Style.Fg, c.Style.Bg); r < 4.5 {
|
||||
t.Fatalf("ANSI weiß: %.2f", r)
|
||||
}
|
||||
white := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
||||
c = applied(uv.Cell{Content: "█", Width: 1, Style: uv.Style{Fg: white}}, false)
|
||||
if toRGB(c.Style.Fg) != toRGB(white) {
|
||||
t.Fatal("Blockzeichen (Bilder) dürfen nicht umgefärbt werden")
|
||||
}
|
||||
c = applied(uv.Cell{Content: "x", Width: 1, Style: uv.Style{Fg: white, Attrs: uv.AttrConceal}}, false)
|
||||
if toRGB(c.Style.Fg) != toRGB(white) {
|
||||
t.Fatal("Verborgenes bleibt verborgen")
|
||||
}
|
||||
c = applied(uv.Cell{Content: "x", Width: 1, Style: uv.Style{Attrs: uv.AttrFaint}}, false)
|
||||
if c.Style.Attrs&uv.AttrFaint != 0 || Contrast(c.Style.Fg, c.Style.Bg) < 3.5 {
|
||||
t.Fatalf("Abgedunkelt: %+v", c.Style)
|
||||
}
|
||||
}
|
||||
|
||||
// Markierung: Theme-Farben, auch über umgekehrtem Text.
|
||||
func TestLookSelection(t *testing.T) {
|
||||
for _, st := range []uv.Style{{}, {Attrs: uv.AttrReverse}, {Fg: color.RGBA{0xf8, 0xf8, 0xf2, 0xff}}} {
|
||||
c := applied(uv.Cell{Content: "x", Width: 1, Style: st}, true)
|
||||
if toRGB(c.Style.Bg) != toRGB(lightLook.SelBg) || Contrast(c.Style.Fg, c.Style.Bg) < 4.5 {
|
||||
t.Fatalf("%+v → %+v", st, c.Style)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,22 +146,33 @@ func (t *Term) render(offset int, sel *Sel, hook func(line, x int, c *uv.Cell),
|
||||
first := sb - offset
|
||||
rows := make([]string, h)
|
||||
line := make(uv.Line, w)
|
||||
if hl != nil && t.AltScreen() {
|
||||
hl = nil // vim, htop, less: die Programme färben selbst
|
||||
var look *Look
|
||||
if hl != nil {
|
||||
look = hl.Look
|
||||
}
|
||||
var memo *lookMemo
|
||||
if look != nil {
|
||||
memo = newLookMemo()
|
||||
}
|
||||
useSet := hl != nil && hl.Set != nil && !t.AltScreen() // vim, htop, less: die Programme färben selbst
|
||||
for y := 0; y < h; y++ {
|
||||
abs := first + y
|
||||
t.lineCells(sb, abs, line)
|
||||
var colors []color.Color
|
||||
if hl != nil {
|
||||
if useSet {
|
||||
colors = hl.columnsOf(line)
|
||||
}
|
||||
for x := 0; x < w; x++ {
|
||||
selected := false
|
||||
if sel != nil && !line[x].IsZero() && sel.Contains(Pos{abs, x}) {
|
||||
if line[x].Content == "" {
|
||||
line[x].Content, line[x].Width = " ", 1
|
||||
}
|
||||
line[x].Style.Attrs ^= uv.AttrReverse
|
||||
if look != nil {
|
||||
selected = true
|
||||
} else {
|
||||
line[x].Style.Attrs ^= uv.AttrReverse
|
||||
}
|
||||
}
|
||||
if colors != nil && colors[x] != nil && line[x].Style.Fg == nil && line[x].Style.Bg == nil && !line[x].IsZero() {
|
||||
line[x].Style.Fg = colors[x]
|
||||
@@ -169,6 +180,9 @@ func (t *Term) render(offset int, sel *Sel, hook func(line, x int, c *uv.Cell),
|
||||
if hook != nil && !line[x].IsZero() {
|
||||
hook(abs, x, &line[x])
|
||||
}
|
||||
if look != nil && !line[x].IsZero() {
|
||||
look.apply(&line[x], selected, memo)
|
||||
}
|
||||
}
|
||||
r := line.Render()
|
||||
if rw := ansi.StringWidth(r); rw < w {
|
||||
|
||||
@@ -340,7 +340,7 @@ func (t *Term) ViewHL(ghost string, ghostStyle func(string) string, hl *HL) stri
|
||||
w, h := t.Size()
|
||||
var raw string
|
||||
padded := false // render liefert jede Zeile schon genau w breit
|
||||
if hl != nil && !t.AltScreen() {
|
||||
if hl != nil && (hl.Look != nil || !t.AltScreen()) {
|
||||
raw, padded = t.render(0, nil, nil, hl), true
|
||||
} else {
|
||||
raw = strings.ReplaceAll(t.emu.Render(), "\r\n", "\n")
|
||||
|
||||
+35
-14
@@ -20,6 +20,38 @@ const aiInputMaxRows = 8
|
||||
type aiInput struct {
|
||||
textarea.Model
|
||||
singleLine bool // z. B. Befehl bearbeiten: umbrechen ja, Zeilenumbruch nein
|
||||
gen int // Theme-Stand der Farben (themeGen)
|
||||
}
|
||||
|
||||
// aiInputStyles: Farben des Feldes passend zum Theme.
|
||||
func aiInputStyles(t Theme) textarea.Styles {
|
||||
sty := textarea.DefaultStyles(t.Dark)
|
||||
sty.Focused.Text = lipgloss.NewStyle().Foreground(t.Text)
|
||||
sty.Blurred.Text = lipgloss.NewStyle().Foreground(t.Muted)
|
||||
sty.Focused.Placeholder = lipgloss.NewStyle().Foreground(t.Muted)
|
||||
sty.Blurred.Placeholder = sty.Focused.Placeholder
|
||||
sty.Cursor.Color = t.Accent
|
||||
plain := lipgloss.NewStyle()
|
||||
sty.Focused.CursorLine = plain
|
||||
sty.Focused.EndOfBuffer = plain
|
||||
sty.Blurred.CursorLine = plain
|
||||
sty.Blurred.EndOfBuffer = plain
|
||||
return sty
|
||||
}
|
||||
|
||||
// restyle: Theme wurde gewechselt, während das Feld schon bestand (Ziel-,
|
||||
// Frage-, Vorgangsfeld leben so lange wie der Tab). Sonst bliebe z. B. die
|
||||
// helle Schrift von „Nacht“ auf einem hellen Theme stehen.
|
||||
func (in *aiInput) restyle() {
|
||||
if in.gen != themeGen {
|
||||
in.Model.SetStyles(aiInputStyles(activeTheme))
|
||||
in.gen = themeGen
|
||||
}
|
||||
}
|
||||
|
||||
func (in aiInput) View() string {
|
||||
in.restyle()
|
||||
return in.Model.View()
|
||||
}
|
||||
|
||||
func newAIInput(placeholder string) aiInput {
|
||||
@@ -36,21 +68,9 @@ func newAIInput(placeholder string) aiInput {
|
||||
// Kein Alt+⏎: das schaltet Windows Terminal auf Vollbild.
|
||||
ta.KeyMap.InsertNewline = key.NewBinding(key.WithKeys(activeKeys.keys[actNewline]...))
|
||||
|
||||
t := activeTheme
|
||||
sty := textarea.DefaultStyles(t.Dark)
|
||||
sty.Focused.Text = lipgloss.NewStyle().Foreground(t.Text)
|
||||
sty.Blurred.Text = lipgloss.NewStyle().Foreground(t.Muted)
|
||||
sty.Focused.Placeholder = lipgloss.NewStyle().Foreground(t.Muted)
|
||||
sty.Blurred.Placeholder = sty.Focused.Placeholder
|
||||
sty.Cursor.Color = t.Accent
|
||||
plain := lipgloss.NewStyle()
|
||||
sty.Focused.CursorLine = plain
|
||||
sty.Focused.EndOfBuffer = plain
|
||||
sty.Blurred.CursorLine = plain
|
||||
sty.Blurred.EndOfBuffer = plain
|
||||
ta.SetStyles(sty)
|
||||
ta.SetStyles(aiInputStyles(activeTheme))
|
||||
ta.SetWidth(40)
|
||||
return aiInput{Model: ta}
|
||||
return aiInput{Model: ta, gen: themeGen}
|
||||
}
|
||||
|
||||
// newCommandInput: bricht um, erlaubt aber keine Zeilenumbrüche (ein Befehl).
|
||||
@@ -62,6 +82,7 @@ func newCommandInput() aiInput {
|
||||
}
|
||||
|
||||
func (in aiInput) Update(msg tea.Msg) (aiInput, tea.Cmd) {
|
||||
in.restyle()
|
||||
var cmd tea.Cmd
|
||||
in.Model, cmd = in.Model.Update(msg)
|
||||
if in.singleLine {
|
||||
|
||||
+6
-1
@@ -39,6 +39,7 @@ import (
|
||||
"github.com/db9979/sshtermy/internal/sessionlog"
|
||||
"github.com/db9979/sshtermy/internal/sshx"
|
||||
"github.com/db9979/sshtermy/internal/store"
|
||||
"github.com/db9979/sshtermy/internal/termemu"
|
||||
"github.com/db9979/sshtermy/internal/update"
|
||||
"github.com/db9979/sshtermy/internal/vault"
|
||||
"github.com/db9979/sshtermy/internal/version"
|
||||
@@ -189,7 +190,11 @@ type App struct {
|
||||
restart bool // nach dem Beenden neu starten (siehe Restart)
|
||||
lastKey time.Time
|
||||
|
||||
hl hlState // Farbregeln (highlight.go)
|
||||
hl hlState // Farbregeln (highlight.go)
|
||||
look struct { // Terminalfarben je Theme-Stand (termLook)
|
||||
l *termemu.Look
|
||||
gen int
|
||||
}
|
||||
edits []*remoteEdit // Server-Dateien im eigenen Editor (editor.go)
|
||||
openTmp []string // heruntergeladen zum Öffnen mit dem Standardprogramm (fileview.go)
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ func (a *App) viewBcVars() string {
|
||||
if v.Default != "" {
|
||||
hint = s.Muted.Render(i18n.T(" leer = ") + v.Default)
|
||||
}
|
||||
o.WriteString(lbl + b.varIn[i].View() + hint + "\n")
|
||||
o.WriteString(lbl + themedInput(b.varIn[i]) + hint + "\n")
|
||||
}
|
||||
if runbook.HasBuiltins(b.stepList()) {
|
||||
o.WriteString("\n" + s.Muted.Render(i18n.T("{{host}}, {{alias}}, {{user}} und {{port}} setzt sshTermy pro Host ein.")) + "\n")
|
||||
|
||||
@@ -650,7 +650,7 @@ func (a *App) viewFiles(s *session, w, h int) string {
|
||||
switch {
|
||||
case f.mkdir != nil:
|
||||
f.mkdir.SetWidth(w - 20)
|
||||
status = st.Accent.Render(i18n.T(" Neuer Ordner: ")) + f.mkdir.View()
|
||||
status = st.Accent.Render(i18n.T(" Neuer Ordner: ")) + themedInput(*f.mkdir)
|
||||
case f.xfer != nil:
|
||||
status = a.xferStatus(f.xfer, w) // xferview.go, zwei Zeilen
|
||||
case f.drag != nil && f.drag.moved:
|
||||
|
||||
@@ -742,7 +742,7 @@ func (a *App) viewFileView(s *session, w, h int) string {
|
||||
switch {
|
||||
case v.search != nil:
|
||||
v.search.SetWidth(w - 12)
|
||||
status = st.Accent.Render(i18n.T(" Suchen: ")) + v.search.View()
|
||||
status = st.Accent.Render(i18n.T(" Suchen: ")) + themedInput(*v.search)
|
||||
case v.query != "":
|
||||
status = st.Muted.Render(fmt.Sprintf(i18n.T(" Suche „%s“ · n weiter, N zurück, Esc hebt auf"), v.query))
|
||||
if v.hit < 0 {
|
||||
|
||||
+1
-1
@@ -326,7 +326,7 @@ func (f *form) view(s Styles, width int, z *zones) string {
|
||||
}
|
||||
default:
|
||||
fl.in.SetWidth(inW - 1)
|
||||
val = " " + fl.in.View()
|
||||
val = " " + themedInput(fl.in)
|
||||
}
|
||||
marker := " "
|
||||
if tint != nil {
|
||||
|
||||
@@ -52,12 +52,13 @@ func (a *App) hlSet() *highlight.Set {
|
||||
|
||||
// termHL: Farbregeln mit den Farben des Themes für das Zeichnen.
|
||||
func (a *App) termHL() *termemu.HL {
|
||||
t := a.s.T
|
||||
h := &termemu.HL{Look: a.termLook()}
|
||||
set := a.hlSet()
|
||||
if set == nil {
|
||||
return nil
|
||||
return h
|
||||
}
|
||||
t := a.s.T
|
||||
h := &termemu.HL{Set: set}
|
||||
h.Set = set
|
||||
h.Colors[highlight.Red] = t.Danger
|
||||
h.Colors[highlight.Yellow] = t.Warn
|
||||
h.Colors[highlight.Green] = t.OK
|
||||
@@ -67,6 +68,35 @@ func (a *App) termHL() *termemu.HL {
|
||||
return h
|
||||
}
|
||||
|
||||
// termLook: Farben und Kontrastschutz für die Serverausgabe (gemerkt je
|
||||
// Theme-Stand, siehe termemu/look.go).
|
||||
func (a *App) termLook() *termemu.Look {
|
||||
if a.look.l != nil && a.look.gen == a.styleGen {
|
||||
return a.look.l
|
||||
}
|
||||
a.look.l, a.look.gen = lookOf(a.s.T), a.styleGen
|
||||
return a.look.l
|
||||
}
|
||||
|
||||
// minTermContrast: Mindestkontrast für Text vom Server (WCAG AA wie in
|
||||
// VS Code), bei den Hochkontrast-Themes AAA.
|
||||
func minTermContrast(t Theme) float64 {
|
||||
if strings.HasPrefix(t.Name, "kontrast") {
|
||||
return 7
|
||||
}
|
||||
return 4.5
|
||||
}
|
||||
|
||||
func lookOf(t Theme) *termemu.Look {
|
||||
return &termemu.Look{
|
||||
Fg: t.Text, Bg: t.Bg,
|
||||
ANSI: termemu.StandardANSI(t.Dark),
|
||||
SelFg: t.Bg, SelBg: t.Accent,
|
||||
MinContrast: minTermContrast(t),
|
||||
MinFaint: minMutedFor(t),
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) highlightOn() bool { return !a.st.Settings().Highlight.Off }
|
||||
|
||||
func (a *App) toggleHighlight() tea.Cmd {
|
||||
|
||||
@@ -39,9 +39,9 @@ func TestHighlightAlertInHiddenTab(t *testing.T) {
|
||||
if bg.alerts.Load() != nil {
|
||||
t.Fatal("Scanner muss weg")
|
||||
}
|
||||
// Farbregeln aus: nichts zum Zeichnen
|
||||
// Farbregeln aus: keine Regeln mehr, Theme-Farben bleiben
|
||||
_ = a.st.UpdateSettings(func(s *domain.Settings) { s.Highlight.Off = true })
|
||||
if a.termHL() != nil {
|
||||
if h := a.termHL(); h.Set != nil || h.Look == nil {
|
||||
t.Fatal("aus heißt aus")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ func (a *App) viewImport() string {
|
||||
b.WriteString("\n")
|
||||
if m.asking {
|
||||
m.path.SetWidth(w - 12)
|
||||
b.WriteString(" " + s.Accent.Render(i18n.T("Datei: ")) + m.path.View() + "\n\n")
|
||||
b.WriteString(" " + s.Accent.Render(i18n.T("Datei: ")) + themedInput(m.path) + "\n\n")
|
||||
}
|
||||
if m.err != "" {
|
||||
b.WriteString(" " + s.Danger.Render(m.err) + "\n\n")
|
||||
|
||||
+1
-1
@@ -170,7 +170,7 @@ func (a *App) viewLock() string {
|
||||
}
|
||||
}
|
||||
b.WriteString(s.Muted.Render(plural(running, i18n.T("Sitzung läuft"), i18n.T("Sitzungen laufen"))+i18n.T(" im Hintergrund weiter.")) + "\n\n")
|
||||
b.WriteString(s.Label.Render(i18n.T("Master-Passwort")) + l.in.View() + "\n")
|
||||
b.WriteString(s.Label.Render(i18n.T("Master-Passwort")) + themedInput(l.in) + "\n")
|
||||
if l.busy {
|
||||
b.WriteString("\n" + s.AI.Render(i18n.T("⠿ Passwort wird geprüft …")))
|
||||
}
|
||||
|
||||
+1
-1
@@ -459,7 +459,7 @@ func (a *App) viewLogs() string {
|
||||
view = i18n.T("Tab nach Zeit")
|
||||
}
|
||||
if m.searching || m.search.Value() != "" {
|
||||
lb.WriteString(" " + s.Accent.Render("/") + " " + m.search.View() + "\n")
|
||||
lb.WriteString(" " + s.Accent.Render("/") + " " + themedInput(m.search) + "\n")
|
||||
} else {
|
||||
count := fmt.Sprintf(" %d", nLogs)
|
||||
if m.byHost {
|
||||
|
||||
@@ -28,6 +28,10 @@ func (a *App) setStyles(t Theme) {
|
||||
}
|
||||
|
||||
// applyLook übernimmt Theme und Tasten aus den Einstellungen.
|
||||
// themeGen zählt Theme-Wechsel; Eingabefelder, die länger leben, holen
|
||||
// damit ihre Farben nach (aiInput.restyle).
|
||||
var themeGen int
|
||||
|
||||
func (a *App) applyLook() {
|
||||
a.applyLang()
|
||||
set := a.st.Settings()
|
||||
@@ -48,11 +52,15 @@ func (a *App) applyLook() {
|
||||
}
|
||||
iconSet = set.IconsNow()
|
||||
activeTheme = t
|
||||
themeGen++
|
||||
a.setStyles(t)
|
||||
a.keys = newKeymap(set.KeysNow())
|
||||
activeKeys = a.keys
|
||||
// Felder, die schon existieren, bekommen die neuen Farben.
|
||||
a.mgr.search.SetStyles(inputStyles(t))
|
||||
for _, s := range a.sessions {
|
||||
s.search.in.SetStyles(inputStyles(t))
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) setTheme(name string) tea.Cmd {
|
||||
|
||||
@@ -420,7 +420,7 @@ func (a *App) viewManager() string {
|
||||
lb.WriteString(" " + s.Warn.Render("↕ "+i18n.T("„")+trunc(name, 16)+i18n.T("“")+" "+trunc(desc, leftW-24)) + "\n")
|
||||
case m.searching || m.search.Value() != "":
|
||||
m.search.SetWidth(leftW - 6)
|
||||
lb.WriteString(" " + s.Accent.Render("/") + " " + m.search.View() + "\n")
|
||||
lb.WriteString(" " + s.Accent.Render("/") + " " + themedInput(m.search) + "\n")
|
||||
default:
|
||||
title := s.PanelTitle.Foreground(s.T.Accent).Render(i18n.T(" Verbindungen")) + s.Muted.Render(fmt.Sprintf(" %d", total))
|
||||
// Hinweise nur, solange sie in die Zeile passen
|
||||
|
||||
@@ -347,9 +347,9 @@ func (m *modal) view(s Styles, w, h int) string {
|
||||
body := ansi.Wrap(s.Text.Render(m.body), d.width, "")
|
||||
switch m.kind {
|
||||
case mInput:
|
||||
body += "\n\n" + m.in.View()
|
||||
body += "\n\n" + themedInput(m.in)
|
||||
case mSecret:
|
||||
body += "\n\n" + m.in.View() + "\n\n" + s.Muted.Render(i18n.T("Wird nicht gespeichert."))
|
||||
body += "\n\n" + themedInput(m.in) + "\n\n" + s.Muted.Render(i18n.T("Wird nicht gespeichert."))
|
||||
}
|
||||
d.body = body
|
||||
if m.kind != mAbout && m.kind != mHostKey && m.kind != mInput && m.kind != mSecret {
|
||||
|
||||
@@ -163,7 +163,7 @@ func (a *App) viewPicker() string {
|
||||
|
||||
var b strings.Builder
|
||||
p.in.SetWidth(w - 8)
|
||||
b.WriteString(s.Accent.Render("/ ") + p.in.View() + "\n\n")
|
||||
b.WriteString(s.Accent.Render("/ ") + themedInput(p.in) + "\n\n")
|
||||
var list strings.Builder
|
||||
for i := p.top; i < len(vis) && i < p.top+rows; i++ {
|
||||
it := vis[i]
|
||||
|
||||
@@ -388,7 +388,7 @@ func (a *App) viewPlayer() string {
|
||||
b.WriteString(st.PanelTitle.Render(trunc("▶ "+title, w)) + "\n")
|
||||
tw, th := p.term.Size()
|
||||
rows := h - 4
|
||||
lines := strings.Split(p.term.Render(0, nil), "\n")
|
||||
lines := strings.Split(p.term.RenderHL(0, nil, &termemu.HL{Look: a.termLook()}), "\n")
|
||||
for i := 0; i < rows; i++ {
|
||||
if i < len(lines) && i < th {
|
||||
b.WriteString(ansi.Truncate(lines[i], w, "") + "\x1b[0m")
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"charm.land/lipgloss/v2"
|
||||
uv "github.com/charmbracelet/ultraviolet"
|
||||
"github.com/charmbracelet/x/vt"
|
||||
|
||||
"github.com/db9979/sshtermy/internal/domain"
|
||||
"github.com/db9979/sshtermy/internal/i18n"
|
||||
"github.com/db9979/sshtermy/internal/termemu"
|
||||
)
|
||||
|
||||
// Lesbarkeit in allen Farbschemata
|
||||
//
|
||||
// Dominik (2026-11-16): In einem hellen Theme war die Ausgabe von Claude
|
||||
// Code weiß auf weiß, Markierungen teils unlesbar. Die Tests hier zeichnen
|
||||
// echte Bilder in jedem Theme, lesen sie mit einem Terminal-Emulator Zelle
|
||||
// für Zelle zurück und prüfen den Kontrast jeder Schrift zu ihrem Grund.
|
||||
|
||||
// colorZoo: Ausgabe, wie Programme sie schreiben, die das Theme nicht
|
||||
// kennen: feste Truecolor-Schrift (Monokai aus Claude Code, reines Weiß und
|
||||
// Schwarz), ANSI 0–15 als Schrift und als Grund, 256er-Farben, Umkehren,
|
||||
// Abgedunkelt, Fett.
|
||||
func colorZoo() string {
|
||||
var b strings.Builder
|
||||
b.WriteString("\x1b[1mWrite\x1b[0m(/opt/lib/agentkonto.py)\n")
|
||||
for _, hex := range []string{"f8f8f2", "ffffff", "e6db74", "f92672", "75715e", "a6e22e", "000000", "1a1b26", "f5f5f7", "808080"} {
|
||||
var r, g, bl int
|
||||
_, _ = fmt.Sscanf(hex, "%02x%02x%02x", &r, &g, &bl)
|
||||
fmt.Fprintf(&b, "\x1b[38;2;%d;%d;%dm%s \x1b[0m", r, g, bl, hex)
|
||||
}
|
||||
b.WriteString("\n")
|
||||
for i := 0; i < 16; i++ {
|
||||
fmt.Fprintf(&b, "\x1b[%dmF%02d\x1b[0m ", map[bool]int{true: 30 + i, false: 90 + i - 8}[i < 8], i)
|
||||
}
|
||||
b.WriteString("\n")
|
||||
for i := 0; i < 16; i++ {
|
||||
fmt.Fprintf(&b, "\x1b[%dmB%02d\x1b[0m ", map[bool]int{true: 40 + i, false: 100 + i - 8}[i < 8], i)
|
||||
}
|
||||
b.WriteString("\n")
|
||||
for i := 0; i < 256; i += 9 {
|
||||
fmt.Fprintf(&b, "\x1b[38;5;%dm%03d\x1b[0m", i, i)
|
||||
}
|
||||
b.WriteString("\n")
|
||||
for i := 0; i < 256; i += 11 {
|
||||
fmt.Fprintf(&b, "\x1b[48;5;%dm%03d\x1b[0m", i, i)
|
||||
}
|
||||
b.WriteString("\n\x1b[7mumgekehrt\x1b[0m \x1b[2mabgedunkelt … +164 lines\x1b[0m \x1b[1;37mfett weiß\x1b[0m ")
|
||||
b.WriteString("\x1b[7;38;2;248;248;242mumgekehrt hell\x1b[0m \x1b[48;2;255;255;255mauf Weiß\x1b[0m \x1b[48;2;0;0;0mauf Schwarz\x1b[0m\n")
|
||||
b.WriteString("\x1b[38;2;248;248;242;48;2;61;1;1m- alte Zeile\x1b[0m \x1b[48;2;2;40;0m+ neue Zeile\x1b[0m\n")
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// cell: Schrift und Grund einer Zelle, wie das äußere Terminal sie zeigt.
|
||||
type cellInk struct {
|
||||
x, y int
|
||||
text string
|
||||
fg, bg color.Color
|
||||
}
|
||||
|
||||
// inkCells liest ein gezeichnetes Bild Zelle für Zelle zurück. Leere Zellen
|
||||
// und Zeichen, deren Farbe ein Bild ergibt (Rahmen, Blöcke), fehlen.
|
||||
func inkCells(view string, w, h int, t Theme) []cellInk {
|
||||
e := vt.NewEmulator(w, h)
|
||||
_, _ = e.Write([]byte(strings.ReplaceAll(view, "\n", "\r\n")))
|
||||
var out []cellInk
|
||||
for y := 0; y < h; y++ {
|
||||
for x := 0; x < w; x++ {
|
||||
c := e.CellAt(x, y)
|
||||
if c == nil || strings.TrimSpace(c.Content) == "" || termemu.DecorGlyph(c.Content) {
|
||||
continue
|
||||
}
|
||||
fg, bg := c.Style.Fg, c.Style.Bg
|
||||
if fg == nil {
|
||||
fg = t.Text
|
||||
}
|
||||
if bg == nil {
|
||||
bg = t.Bg
|
||||
}
|
||||
if c.Style.Attrs&uv.AttrReverse != 0 {
|
||||
fg, bg = bg, fg
|
||||
}
|
||||
if c.Style.Attrs&uv.AttrFaint != 0 {
|
||||
fg = mixColor(fg, bg, 0.4) // so dunkeln die meisten Terminals ab
|
||||
}
|
||||
out = append(out, cellInk{x, y, c.Content, fg, bg})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// lowContrast: Zellen unter need, je Farbpaar einmal mit Textprobe.
|
||||
func lowContrast(cells []cellInk, need float64, in func(x, y int) bool) []string {
|
||||
seen := map[string]bool{}
|
||||
var bad []string
|
||||
for i, c := range cells {
|
||||
if in != nil && !in(c.x, c.y) {
|
||||
continue
|
||||
}
|
||||
r := contrast(c.fg, c.bg)
|
||||
// Auf mittleren Gründen (z. B. 256er-Farbe als Hintergrund) ist 7:1
|
||||
// nicht erreichbar; dann zählt, ob das Bestmögliche gewählt ist.
|
||||
best := max(contrast(color.Black, c.bg), contrast(color.White, c.bg))
|
||||
if r >= min(need, best-0.05) {
|
||||
continue
|
||||
}
|
||||
key := hexOf(c.fg) + "/" + hexOf(c.bg)
|
||||
if seen[key] {
|
||||
continue
|
||||
}
|
||||
seen[key] = true
|
||||
sample := ""
|
||||
for _, d := range cells[i:] {
|
||||
if d.y != c.y || len([]rune(sample)) >= 24 {
|
||||
break
|
||||
}
|
||||
sample += d.text
|
||||
}
|
||||
bad = append(bad, fmt.Sprintf("Zeile %d: %q %s auf %s = %.2f:1", c.y, sample, hexOf(c.fg), hexOf(c.bg), r))
|
||||
}
|
||||
return bad
|
||||
}
|
||||
|
||||
// Serverausgabe: jede Schrift erreicht in jedem Theme den Mindestkontrast,
|
||||
// auch markiert und unter Suchtreffern.
|
||||
func TestTerminalOutputReadableInAllThemes(t *testing.T) {
|
||||
zoo := strings.ReplaceAll(colorZoo(), "\n", "\r\n")
|
||||
for _, th := range Themes {
|
||||
term := termemu.New(120, 14, discard{})
|
||||
_, _ = term.Write([]byte(zoo))
|
||||
need := minTermContrast(th)
|
||||
hl := &termemu.HL{Look: lookOf(th)}
|
||||
sel := &termemu.Sel{A: termemu.Pos{Line: 1, Col: 0}, B: termemu.Pos{Line: 4, Col: 30}}
|
||||
marks := []termemu.Mark{{Line: 2, Col: 0, Len: 20}, {Line: 6, Col: 0, Len: 12, Current: true}}
|
||||
ms := termemu.MarkStyle{Hit: uv.Style{Fg: th.Bg, Bg: th.Warn}, Current: uv.Style{Fg: th.Bg, Bg: th.Danger}}
|
||||
for name, view := range map[string]string{
|
||||
"normal": term.RenderHL(0, nil, hl),
|
||||
"markiert": term.RenderHL(0, sel, hl),
|
||||
"Treffer": term.RenderMarked(0, nil, marks, ms, hl),
|
||||
"Leerlauf": term.ViewHL("", func(s string) string { return s }, hl),
|
||||
} {
|
||||
cells := inkCells(view, 120, 14, th)
|
||||
if len(cells) < 400 {
|
||||
t.Fatalf("%s/%s: nur %d Zellen gelesen", th.Name, name, len(cells))
|
||||
}
|
||||
// Abgedunkeltes darf leiser sein (3,5:1), alles andere need.
|
||||
var bad []string
|
||||
for _, b := range lowContrast(cells, need, nil) {
|
||||
if !strings.Contains(b, "abgedunkelt") && !strings.Contains(b, "+164") {
|
||||
bad = append(bad, b)
|
||||
}
|
||||
}
|
||||
bad = append(bad, lowContrast(cells, minMutedFor(th), nil)...)
|
||||
if len(bad) > 0 {
|
||||
t.Errorf("%s/%s: schlecht lesbar:\n %s", th.Name, name, strings.Join(bad, "\n "))
|
||||
}
|
||||
}
|
||||
term.Close()
|
||||
}
|
||||
}
|
||||
|
||||
// Markierung im Terminal: Theme-Farben statt Umkehren. Umkehren machte aus
|
||||
// heller Programmschrift auf hellem Theme eine helle Fläche mit heller Schrift.
|
||||
func TestTerminalSelectionUsesThemeColors(t *testing.T) {
|
||||
th := Hell
|
||||
term := termemu.New(40, 3, discard{})
|
||||
defer term.Close()
|
||||
_, _ = term.Write([]byte("\x1b[38;2;248;248;242mweiss\x1b[0m normal"))
|
||||
view := term.RenderHL(0, &termemu.Sel{A: termemu.Pos{Line: 0, Col: 0}, B: termemu.Pos{Line: 0, Col: 11}}, &termemu.HL{Look: lookOf(th)})
|
||||
for _, c := range inkCells(view, 40, 3, th) {
|
||||
if c.x > 11 {
|
||||
continue
|
||||
}
|
||||
if hexOf(c.bg) != hexOf(th.Accent) {
|
||||
t.Fatalf("Zelle %d %q: Grund %s, erwartet Akzent %s", c.x, c.text, hexOf(c.bg), hexOf(th.Accent))
|
||||
}
|
||||
if r := contrast(c.fg, c.bg); r < minText {
|
||||
t.Fatalf("Zelle %d %q: Kontrast %.2f", c.x, c.text, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// readableCases: zusätzlich zu den Golden-Bildern Terminal mit fremden
|
||||
// Farben, Markierung und Suche.
|
||||
var readableCases = []goldenCase{
|
||||
{name: "terminal-farben", w: 120, h: 30, setup: func(g *gold) {
|
||||
s := g.session("web-01", colorZoo())
|
||||
s.sel = &termemu.Sel{A: termemu.Pos{Line: 1, Col: 0}, B: termemu.Pos{Line: 3, Col: 40}}
|
||||
}},
|
||||
{name: "terminal-farben-suche", w: 120, h: 30, setup: func(g *gold) {
|
||||
g.session("web-01", colorZoo())
|
||||
g.keys("ctrl+f").typ("lines")
|
||||
}},
|
||||
}
|
||||
|
||||
// Jeder Bildschirm in jedem Theme: Schrift mindestens 3,5:1 (die Regel für
|
||||
// Gedämpftes), Hochkontrast-Themes 4,5:1. Unter einem offenen Fenster wird
|
||||
// nur das Fenster geprüft; der Rest ist absichtlich abgedunkelt.
|
||||
func TestScreensReadableInAllThemes(t *testing.T) {
|
||||
cases := append(append([]goldenCase{}, goldenCases...), readableCases...)
|
||||
for _, c := range cases {
|
||||
if c.empty {
|
||||
continue
|
||||
}
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
g := newGold(t, i18n.DE, c.w, c.h, true)
|
||||
c.setup(g)
|
||||
for i, th := range Themes {
|
||||
if g.a.scr == scrThemes {
|
||||
// Farbschema-Auswahl: dort zeigt die Vorschau das Theme
|
||||
g.a.themePick.sel = i
|
||||
g.a.previewTheme()
|
||||
} else {
|
||||
_ = g.a.st.UpdateSettings(func(s *domain.Settings) { s.Theme = th.Name })
|
||||
g.a.applyLook()
|
||||
}
|
||||
th = g.a.s.T // Sperrbildschirm: immer das Standard-Theme
|
||||
g.a.fx.ghost = ""
|
||||
view := g.a.View().Content
|
||||
in := func(x, y int) bool { return true }
|
||||
if gh := g.a.fx.ghost; gh != "" {
|
||||
mx, my, mw, mh := g.a.fx.x, g.a.fx.y, lipgloss.Width(gh), lipgloss.Height(gh)
|
||||
in = func(x, y int) bool { return x >= mx && x < mx+mw && y >= my && y < my+mh }
|
||||
}
|
||||
need := minMutedFor(th)
|
||||
if bad := lowContrast(inkCells(view, c.w, c.h, th), need, in); len(bad) > 0 {
|
||||
t.Errorf("%s: schlecht lesbar:\n %s", th.Name, strings.Join(bad, "\n "))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -289,7 +289,7 @@ func (a *App) searchBar(s *session) string {
|
||||
right = a.s.Warn.Render(i18n.T("nur Fehlerzeilen "))
|
||||
}
|
||||
sr.in.SetWidth(max(10, a.w-ansi.StringWidth(label)-ansi.StringWidth(count)-ansi.StringWidth(right)-2))
|
||||
out := st.Accent.Render(label) + sr.in.View() + count
|
||||
out := st.Accent.Render(label) + themedInput(sr.in) + count
|
||||
gap := a.w - ansi.StringWidth(out) - ansi.StringWidth(right)
|
||||
if gap > 0 {
|
||||
out += strings.Repeat(" ", gap) + right
|
||||
|
||||
@@ -872,7 +872,7 @@ func (a *App) paneTitle(s *session, w int, focused, grip bool) string {
|
||||
// steht auch der Name in dieser Farbe. Produktiv: rote Marke.
|
||||
col := a.tabColor(s)
|
||||
if col != nil && a.framed() && !focused {
|
||||
bar = bar.Foreground(mixColor(st.T.Surface, col, 0.85)) // gedämpft
|
||||
bar = bar.Foreground(readableOn(mixColor(st.T.Surface, col, 0.85), st.T.Surface, minMutedFor(st.T))) // gedämpft, aber lesbar
|
||||
}
|
||||
dot := map[sessState]string{stConnecting: "◌", stConnected: "●", stClosed: "○", stReconnect: "◌"}[s.state]
|
||||
left := " " + dot + " " + strconv.Itoa(a.winNo(s)) + " · " + s.conn.Alias + " " + s.conn.Username + "@" + s.conn.Host
|
||||
|
||||
@@ -54,7 +54,8 @@ func (a *App) prodChip(short bool) string {
|
||||
if short {
|
||||
txt = i18n.T("▲ PROD")
|
||||
}
|
||||
return lipgloss.NewStyle().Foreground(st.T.Danger).Background(mixColor(st.T.Surface, st.T.Danger, 0.22)).
|
||||
bg := mixColor(st.T.Surface, st.T.Danger, 0.22)
|
||||
return lipgloss.NewStyle().Foreground(readableOn(st.T.Danger, bg, minText)).Background(bg).
|
||||
Bold(true).Padding(0, 1).Render(txt)
|
||||
}
|
||||
|
||||
|
||||
@@ -938,7 +938,7 @@ func (a *App) tabStrip(room int) string {
|
||||
if col := a.tabColor(x); col != nil {
|
||||
stripe = glyph("▌", col, ts.GetBackground())
|
||||
if a.framed() { // Name gedämpft in der Rahmenfarbe (tabframe.go)
|
||||
text = " " + lipgloss.NewStyle().Foreground(mixColor(ts.GetBackground(), col, 0.85)).Background(ts.GetBackground()).Render(strings.TrimPrefix(text, " "))
|
||||
text = " " + lipgloss.NewStyle().Foreground(readableOn(mixColor(ts.GetBackground(), col, 0.85), ts.GetBackground(), minMutedFor(st.T))).Background(ts.GetBackground()).Render(strings.TrimPrefix(text, " "))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+31
-1
@@ -1,9 +1,12 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"charm.land/bubbles/v2/textinput"
|
||||
"charm.land/lipgloss/v2"
|
||||
|
||||
"github.com/db9979/sshtermy/internal/termemu"
|
||||
"github.com/db9979/sshtermy/internal/ui/theme"
|
||||
)
|
||||
|
||||
@@ -35,6 +38,24 @@ var (
|
||||
rgbOf = theme.RGB
|
||||
)
|
||||
|
||||
// readableOn: Schrift so wenig wie nötig aufhellen/abdunkeln, bis sie auf
|
||||
// dem Grund lesbar ist (gleiche Rechnung wie für die Serverausgabe).
|
||||
var readableOn = termemu.Readable
|
||||
|
||||
// Mindestkontraste (WCAG 2): Text 4,5:1, Gedämpftes und Nebensachen 3,5:1.
|
||||
const (
|
||||
minText = 4.5
|
||||
minMuted = 3.5
|
||||
)
|
||||
|
||||
// minMutedFor: Hochkontrast-Themes halten auch Nebensachen bei 4,5:1.
|
||||
func minMutedFor(t Theme) float64 {
|
||||
if strings.HasPrefix(t.Name, "kontrast") {
|
||||
return minText
|
||||
}
|
||||
return minMuted
|
||||
}
|
||||
|
||||
// frameBorder: eckige Rahmen für den Terminal-Look (┌─┐ statt ╭─╮).
|
||||
var frameBorder = lipgloss.NormalBorder()
|
||||
|
||||
@@ -92,13 +113,22 @@ func NewStyles(t Theme) Styles {
|
||||
return s
|
||||
}
|
||||
|
||||
// themedInput zeichnet ein Textfeld immer in den Farben des aktiven Themes.
|
||||
// bubbles setzt sonst Farben für dunkle Terminals (Eingabe „weiß“), und
|
||||
// Felder, die vor einem Theme-Wechsel entstanden, behielten die alten.
|
||||
func themedInput(in textinput.Model) string {
|
||||
in.SetStyles(inputStyles(activeTheme))
|
||||
return in.View()
|
||||
}
|
||||
|
||||
// inputStyles: Textfelder passend zum Theme (sonst wäre Text auf Hell
|
||||
// unsichtbar, weil bubbles Standardfarben für dunkle Terminals setzt).
|
||||
func inputStyles(t Theme) textinput.Styles {
|
||||
s := textinput.DefaultStyles(t.Dark)
|
||||
s.Focused.Text = lipgloss.NewStyle().Foreground(t.Text)
|
||||
s.Blurred.Text = lipgloss.NewStyle().Foreground(t.Text)
|
||||
s.Focused.Placeholder = lipgloss.NewStyle().Foreground(t.Muted).Faint(true).Italic(true)
|
||||
// nicht zusätzlich abgedunkelt: Gedämpft hat schon nur 3,5:1
|
||||
s.Focused.Placeholder = lipgloss.NewStyle().Foreground(t.Muted).Italic(true)
|
||||
s.Blurred.Placeholder = s.Focused.Placeholder
|
||||
s.Focused.Prompt = lipgloss.NewStyle().Foreground(t.Accent)
|
||||
s.Blurred.Prompt = s.Focused.Prompt
|
||||
|
||||
@@ -76,7 +76,7 @@ var Lagerfeuer = Theme{
|
||||
AI: lipgloss.Color("#d3869b"),
|
||||
OK: lipgloss.Color("#b8bb26"),
|
||||
Warn: lipgloss.Color("#fabd2f"),
|
||||
Danger: lipgloss.Color("#fb4934"),
|
||||
Danger: lipgloss.Color("#fb5743"),
|
||||
Orange: lipgloss.Color("#fe8019"),
|
||||
Cyan: lipgloss.Color("#8ec07c"),
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ var Nacht = Theme{
|
||||
Surface2: lipgloss.Color("#292e42"),
|
||||
Border: lipgloss.Color("#3b4261"),
|
||||
Text: lipgloss.Color("#c0caf5"),
|
||||
Muted: lipgloss.Color("#737aa2"),
|
||||
Muted: lipgloss.Color("#7c83a8"),
|
||||
Accent: lipgloss.Color("#7aa2f7"),
|
||||
AI: lipgloss.Color("#bb9af7"),
|
||||
OK: lipgloss.Color("#9ece6a"),
|
||||
|
||||
@@ -153,8 +153,8 @@ func (a *App) viewUnlock() string {
|
||||
if u.setup {
|
||||
b.WriteString(s.Text.Render(i18n.T("Willkommen! Lege ein Master-Passwort für deinen verschlüsselten Store an.")) + "\n")
|
||||
b.WriteString(s.Muted.Render(i18n.T("Es wird nie gespeichert. Argon2id + AES-256-GCM schützen Passwörter, Keys und API-Keys.")) + "\n\n")
|
||||
b.WriteString(s.Label.Render(i18n.T("Master-Passwort")) + u.pw.View() + "\n")
|
||||
b.WriteString(s.Label.Render(i18n.T("Wiederholen")) + u.pw2.View() + "\n")
|
||||
b.WriteString(s.Label.Render(i18n.T("Master-Passwort")) + themedInput(u.pw) + "\n")
|
||||
b.WriteString(s.Label.Render(i18n.T("Wiederholen")) + themedInput(u.pw2) + "\n")
|
||||
mark := "○"
|
||||
if u.dpapi {
|
||||
mark = s.OK.Render("●")
|
||||
@@ -170,7 +170,7 @@ func (a *App) viewUnlock() string {
|
||||
b.WriteString(focus + mark + " " + s.Text.Render(lbl) + "\n")
|
||||
} else {
|
||||
b.WriteString(s.Text.Render(i18n.T("Store gesperrt.")) + "\n\n")
|
||||
b.WriteString(s.Label.Render(i18n.T("Master-Passwort")) + u.pw.View() + "\n")
|
||||
b.WriteString(s.Label.Render(i18n.T("Master-Passwort")) + themedInput(u.pw) + "\n")
|
||||
}
|
||||
if u.busy {
|
||||
b.WriteString("\n" + s.AI.Render(i18n.T("⠿ Schlüssel wird abgeleitet (Argon2id) …")))
|
||||
|
||||
@@ -115,7 +115,7 @@ func (a *App) vgViewSetup(add func(string), w int) {
|
||||
st := a.s
|
||||
lbl := st.Muted.Render(i18n.T("Worum geht's? (optional, hilft der KI) "))
|
||||
g.goalIn.SetWidth(max(20, w-lipgloss.Width(lbl)-4))
|
||||
add(lbl + g.goalIn.View())
|
||||
add(lbl + themedInput(g.goalIn))
|
||||
add("")
|
||||
add(st.Muted.Render(fmt.Sprintf(" %-24s %-34s %s", i18n.T("Fenster"), i18n.T("System"), i18n.T("KI sieht"))))
|
||||
for i, r := range g.rows {
|
||||
|
||||
+1
-1
@@ -175,7 +175,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
|
||||
<div class="card"><h3>Profi-SSH</h3><p>Agent-Weiterleitung, X11-Weiterleitung, FIDO2-Sicherheitsschlüssel, Kerberos/GSSAPI, SSH-Zertifikate, feste tmux/screen-Sitzungen. Quantensicherer Schlüsseltausch (ML-KEM), wo der Server ihn kann, und ein deutlicher Hinweis, wenn ein altes Gerät nur SHA-1/CBC spricht.</p></div>
|
||||
<div class="card"><h3>Dateien im Terminal</h3><p><code>tsz</code>/<code>trz</code> (trzsz) auch durch <code>sudo su</code> und mehrere Sprünge, Zwischenablage vom Server per OSC 52.</p></div>
|
||||
<div class="card"><h3>Team-Freigabe</h3><p>Verschlüsselte <code>.sshteam</code>-Pakete und Team-Ordner, die die Verbindungen aller aktuell halten, ohne Passwörter.</p></div>
|
||||
<div class="card"><h3>Aussehen & Tasten</h3><p>26 Themes mit Live-Vorschau, von Polarnacht, Abendrot und Tusche bis Papier und Minze, dazu Hochkontrast und Farbenblind, eigene Farben, vier Symbol-Stile, jede Taste frei belegbar.</p></div>
|
||||
<div class="card"><h3>Aussehen & Tasten</h3><p>26 Themes mit Live-Vorschau, von Polarnacht, Abendrot und Tusche bis Papier und Minze, dazu Hochkontrast und Farbenblind, eigene Farben, vier Symbol-Stile, jede Taste frei belegbar. Serverausgabe bleibt in jedem Theme lesbar: Farben von Programmen, die das Theme nicht kennen, werden auf guten Kontrast angehoben.</p></div>
|
||||
<div class="card"><h3>Aufgeräumter Bildschirm</h3><p>Eine Kopfzeile mit Tabs links und dem Zustand der Sitzung rechts, rote Marke ▲ PRODUKTIV statt roter Fläche, unten eine F-Tasten-Leiste (<code>1Hilfe 2Ziel 3KI …</code>). Der Manager zeigt rechts nur, was zur Auswahl gehört, ein Ordner seinen Inhalt mit Status. Die Hilfe (<kbd>F1</kbd>) hat Reiter, tippen filtert.</p></div>
|
||||
<div class="card"><h3>Lebendige Oberfläche</h3><p>Verbindungsaufbau als Karte mit Schritten und Lichtlauf (was du dabei tippst, wartet auf den Prompt), Tabs leuchten bei Erfolg und Fehler auf, Karte beim Überfahren eines Tabs, atmende Online-Punkte (geprüft wird nur, was sichtbar ist) und Lastbalken, KI-Antwort tippt sich, Palette mit leuchtenden Treffern, Latenzkurve in der Kopfzeile, gleitender Rahmen in der geteilten Ansicht, Dialoge mit Schatten und wahlweise runden Ecken. Voll, dezent oder aus.</p></div>
|
||||
<div class="card"><h3>Barrierearm & Support</h3><p>Barrierearmer Modus ohne Animationen, mit Formen statt nur Farben. Debug-Protokoll für Fehlerberichte (<code>--debug</code>), bereinigt von Hosts, IPs und Passwörtern. Adaptive Bildrate bei Ausgabeflut, dazu eine Leistungsanzeige in der Palette, die die Zeichenzeit in Worten bewertet.</p></div>
|
||||
|
||||
+1
-1
@@ -175,7 +175,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
|
||||
<div class="card"><h3>Pro SSH</h3><p>Agent forwarding, X11 forwarding, FIDO2 security keys, Kerberos/GSSAPI, SSH certificates, persistent tmux/screen sessions. Quantum-safe key exchange (ML-KEM) where the server supports it, and a clear notice when an old device only speaks SHA-1/CBC.</p></div>
|
||||
<div class="card"><h3>Files in the terminal</h3><p><code>tsz</code>/<code>trz</code> (trzsz) through <code>sudo su</code> and several hops, clipboard from the server via OSC 52.</p></div>
|
||||
<div class="card"><h3>Team sharing</h3><p>Encrypted <code>.sshteam</code> packages and team folders that keep everyone's connections up to date, without passwords.</p></div>
|
||||
<div class="card"><h3>Look & keys</h3><p>26 themes with live preview, from Polar night, Synthwave and Ink to Paper and Mint, plus high contrast and color blindness, your own colors, four icon styles, every shortcut can be changed.</p></div>
|
||||
<div class="card"><h3>Look & keys</h3><p>26 themes with live preview, from Polar night, Synthwave and Ink to Paper and Mint, plus high contrast and color blindness, your own colors, four icon styles, every shortcut can be changed. Server output stays readable in every theme: colors from programs that don't know the theme are lifted to good contrast.</p></div>
|
||||
<div class="card"><h3>Tidy screen</h3><p>One header line with tabs on the left and the session state on the right, a red ▲ PRODUCTION badge instead of a red bar, a function key bar at the bottom (<code>1Help 2Goal 3AI …</code>). The manager shows only what belongs to the selection, a folder its contents with status. Help (<kbd>F1</kbd>) has tabs, typing filters.</p></div>
|
||||
<div class="card"><h3>Lively interface</h3><p>Connecting as a card with steps and a light sweep (text typed meanwhile waits for the prompt), tabs flash on success and errors, a card when hovering a tab, breathing online dots (only visible connections are checked) and load bars, the AI answer types out, palette matches light up, latency curve in the header, a frame gliding between split panes, dialogs with shadows and optional round corners. Full, subtle or off.</p></div>
|
||||
<div class="card"><h3>Accessible & supportable</h3><p>Accessible mode without animations and with shapes instead of color only. Debug log for bug reports (<code>--debug</code>), saved cleaned of hosts, IPs and passwords. Adaptive frame rate when output floods, plus a performance display in the palette that rates draw time in plain words.</p></div>
|
||||
|
||||
Reference in new issue
Block a user