Add a show compiler so QLC+ workspaces can be described and tested.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jimmyandCursor committed 2026-10-21 17:39:13 +13:00
1 parent fee1985e1a
commit 4374ffb430
14 files changed
+3739

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
"""Small XML helpers shared by the workspace writer."""
from __future__ import annotations
from xml.sax.saxutils import escape, quoteattr
def attr(value: object) -> str:
return quoteattr(str(value))
def text(value: object) -> str:
return escape(str(value))
def qlc_color(r: int, g: int, b: int) -> str:
"""QLC+ widget colour as a decimal ARGB word."""
return str((0xFF << 24) | ((int(r) & 255) << 16) | ((int(g) & 255) << 8) | (int(b) & 255))
def colour(value: object, default: str = "Default") -> str:
if value is None:
return default
if isinstance(value, str):
return value
if isinstance(value, int) and not isinstance(value, bool):
return str(value)
if isinstance(value, (list, tuple)) and len(value) == 3:
return qlc_color(int(value[0]), int(value[1]), int(value[2]))
raise TypeError(f"colour must be 'Default', an ARGB decimal, or [r, g, b], not {value!r}")
def appearance(
fg: object = "Default",
bg: object = "Default",
frame: str = "Sunken",
indent: str = " ",
) -> str:
inner = indent + " "
return (
f"{indent}<Appearance>\n"
f"{inner}<FrameStyle>{text(frame)}</FrameStyle>\n"
f"{inner}<ForegroundColor>{text(colour(fg))}</ForegroundColor>\n"
f"{inner}<BackgroundColor>{text(colour(bg))}</BackgroundColor>\n"
f"{inner}<BackgroundImage>None</BackgroundImage>\n"
f"{inner}<Font>Default</Font>\n"
f"{indent}</Appearance>"
)