feat: GPU-Nummer im Chip-Symbol statt als Text daneben (#1108); Version 0.1.17-rc2

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GmHhg6sxZ8wsKZAVLQ6Xj5
This commit is contained in:
2026-11-21 20:20:26 +01:00
parent 8670f59e55
commit 0673dc6c00
9 changed files with 59 additions and 11 deletions

View File

@ -262,14 +262,17 @@ pub(super) fn freigabe(enabled: bool) -> String {
)
}
/// GPU-Nummern („0, 1“) als Chip-Symbole mit Nummer.
/// GPU-Nummern („0, 1“) als Chip-Symbole; die Nummer steht **im** Symbol, daneben kein Text (#1108). Alle in
/// derselben Farbe: Die Nummer unterscheidet die Karten, Farbe allein trägt keine Information.
pub(super) fn gpu_symbole(gpus: &str) -> String {
gpus.split(',')
.map(str::trim)
.filter(|n| !n.is_empty())
.map(|n| {
// Zwei Stellen brauchen eine kleinere Schrift, damit die Nummer im Chip bleibt.
let groesse = if n.chars().count() > 1 { "10" } else { "13" };
format!(
"<span class=\"fkann\" title=\"GPU {n}\"><svg class=\"fsym engine k-embed\" viewBox=\"0 0 24 24\" role=\"img\" aria-label=\"GPU {n}\"><path d=\"M12 20v2\"/><path d=\"M12 2v2\"/><path d=\"M17 20v2\"/><path d=\"M17 2v2\"/><path d=\"M2 12h2\"/><path d=\"M2 17h2\"/><path d=\"M2 7h2\"/><path d=\"M20 12h2\"/><path d=\"M20 17h2\"/><path d=\"M20 7h2\"/><path d=\"M7 20v2\"/><path d=\"M7 2v2\"/><rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"2\"/><rect x=\"8\" y=\"8\" width=\"8\" height=\"8\" rx=\"1\"/></svg>{n}</span>",
"<span class=\"fkann\" title=\"GPU {n}\"><svg class=\"fsym gpusym\" viewBox=\"0 0 24 24\" role=\"img\" aria-label=\"GPU {n}\"><path d=\"M12 20v2\"/><path d=\"M12 2v2\"/><path d=\"M17 20v2\"/><path d=\"M17 2v2\"/><path d=\"M2 12h2\"/><path d=\"M2 17h2\"/><path d=\"M2 7h2\"/><path d=\"M20 12h2\"/><path d=\"M20 17h2\"/><path d=\"M20 7h2\"/><path d=\"M7 20v2\"/><path d=\"M7 2v2\"/><rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"2\"/><text x=\"12\" y=\"12.2\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"{groesse}\" font-weight=\"700\">{n}</text></svg></span>",
n = esc(n)
)
})
@ -323,6 +326,21 @@ pub(super) fn engine_faehigkeiten(caps: &Capabilities) -> String {
mod tests {
use super::*;
#[test]
fn gpu_nummer_steht_im_symbol_und_nicht_daneben() {
// #1108: Die Nummer ist Text im SVG, nach dem Symbol folgt kein weiterer Text.
let html = gpu_symbole("0, 1");
assert_eq!(html.matches("<svg").count(), 2, "{html}");
assert!(html.contains(">0</text></svg></span>"), "{html}");
assert!(html.contains(">1</text></svg></span>"), "{html}");
assert!(!html.contains("</svg>0"), "{html}");
assert!(!html.contains("k-embed"), "eine Farbe für alle: {html}");
assert!(html.contains("aria-label=\"GPU 1\""), "{html}");
// Zwei Stellen: kleinere Schrift; leere Angabe: nichts.
assert!(gpu_symbole("12").contains("font-size=\"10\""));
assert_eq!(gpu_symbole(" "), "");
}
fn caps(
chat: bool,
images: bool,