Color syntax spans with newed palette
This commit is contained in:
@@ -91,6 +91,16 @@ def classify_sgr(params: str) -> str:
|
||||
return "cursor"
|
||||
if "48;2;55;65;92" in joined:
|
||||
return "selection"
|
||||
if "38;2;235;119;84" in joined:
|
||||
return "syntax-keyword"
|
||||
if "38;2;121;155;224" in joined:
|
||||
return "syntax-builtin"
|
||||
if "38;2;116;196;171" in joined:
|
||||
return "syntax-string"
|
||||
if "38;2;103;93;122" in joined:
|
||||
return "syntax-comment"
|
||||
if "38;2;231;168;78" in joined:
|
||||
return "syntax-number"
|
||||
if "48;2;20;18;26" in joined:
|
||||
return "current-line"
|
||||
if "48;2;235;119;84" in joined:
|
||||
@@ -193,6 +203,10 @@ class TerminalGrid:
|
||||
lines.append("attr:cursor ☻")
|
||||
if "selection" in self.seen_attrs and not any("░" in line for line in lines):
|
||||
lines.append("attr:selection ░")
|
||||
for attr in sorted(self.seen_attrs):
|
||||
marker = f"attr:{attr}"
|
||||
if not any(marker in line for line in lines):
|
||||
lines.append(marker)
|
||||
return lines
|
||||
|
||||
def colored_rows(self) -> list[list[Cell]]:
|
||||
@@ -424,6 +438,13 @@ def setup_short(tmp: Path) -> tuple[Path, str | None]:
|
||||
return target, "abcdef\n"
|
||||
|
||||
|
||||
def setup_zig_syntax(tmp: Path) -> tuple[Path, str | None]:
|
||||
target = tmp / "syntax.zig"
|
||||
text = "fn main() void { return \"std\"; // hi }\n"
|
||||
target.write_text(text, encoding="utf-8")
|
||||
return target, text
|
||||
|
||||
|
||||
def setup_brackets(tmp: Path) -> tuple[Path, str | None]:
|
||||
target = tmp / "brackets.txt"
|
||||
target.write_text("(ab)\n", encoding="utf-8")
|
||||
@@ -508,6 +529,7 @@ IOS_DEFAULT_KEYS = set(b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ")
|
||||
SCENARIOS = [
|
||||
Scenario("raw-key-chrome-crlf", 48, 16, "empty", "ios-default-qwertz-space-path", "normal-symbol-save", "truecolor", "file", setup_empty, MOBILE_SYMBOL_SAVE_QUIT, "/", ("1│", "☻", "mode:normal"), max_key_events=7),
|
||||
Scenario("coding-symbol-rail", 56, 12, "empty", "ios-default-qwertz-space-path", "normal-symbols", "truecolor", "file", setup_empty, (b" ", b"p", b"f", b" ", b"p", b"x", b" ", b"p", b"a", b" ", b"p", b"h", b" ", b"p", b"d", b" ", b"p", b"r", b" ", b"w", b" ", b"q"), "//*&#$@", ("symbols:", "mode:normal", "☻"), max_key_events=24),
|
||||
Scenario("syntax-highlight-colors", 64, 10, "zig-syntax", "attached-keyboard", "syntax", "truecolor", "file", setup_zig_syntax, (b" ", b"q"), "fn main() void { return \"std\"; // hi }\n", ("mode:normal",), required_attrs=("cursor", "status", "current-line", "syntax-keyword", "syntax-builtin", "syntax-string", "syntax-comment"), max_key_events=2),
|
||||
Scenario("ios-normal-replace-shift-path", 44, 12, "existing", "ios-default-qwertz-space-path", "normal-replace", "truecolor", "file", setup_existing, MOBILE_REPLACE_SAVE_QUIT, "xlpha\nbeta", ("1│", "☻", "mode:normal")),
|
||||
Scenario("attached-existing-medium", 72, 18, "existing", "attached-keyboard", "insert-normal", "truecolor", "file", setup_existing, ATTACHED_SAVE_QUIT, "alpha!\nbeta", ("1│", "2│", "☻"), max_key_events=8),
|
||||
Scenario("new-file-mono-narrow", 40, 12, "new", "ios-default-qwertz-space-path", "normal-symbol-save", "mono", "file", setup_new, MOBILE_SYMBOL_SAVE_QUIT, "/", ("1│", "☻", "mode:normal")),
|
||||
@@ -621,6 +643,11 @@ def run_one(mim: Path, root_out: Path, scenario: Scenario) -> tuple[str, Path]:
|
||||
("48;2;55;65;92", "selection"),
|
||||
("48;2;20;18;26", "current-line"),
|
||||
("48;2;235;119;84", "status"),
|
||||
("38;2;235;119;84", "syntax-keyword"),
|
||||
("38;2;121;155;224", "syntax-builtin"),
|
||||
("38;2;116;196;171", "syntax-string"),
|
||||
("38;2;103;93;122", "syntax-comment"),
|
||||
("38;2;231;168;78", "syntax-number"),
|
||||
):
|
||||
if sgr in raw_text:
|
||||
raw_attrs.add(attr)
|
||||
|
||||
Reference in New Issue
Block a user