MCPcopy Create free account
hub / github.com/FastLED/FastLED / colorize

Function colorize

ci/run-clang-format.py:233–256  ·  view source on GitHub ↗
(diff_lines: list[str])

Source from the content-addressed store, hash-verified

231
232
233def colorize(diff_lines: list[str]) -> Generator[str, None, None]:
234 def bold(s: str) -> str:
235 return "\x1b[1m" + s + "\x1b[0m"
236
237 def cyan(s: str) -> str:
238 return "\x1b[36m" + s + "\x1b[0m"
239
240 def green(s: str) -> str:
241 return "\x1b[32m" + s + "\x1b[0m"
242
243 def red(s: str) -> str:
244 return "\x1b[31m" + s + "\x1b[0m"
245
246 for line in diff_lines:
247 if line[:4] in ["--- ", "+++ "]:
248 yield bold(line)
249 elif line.startswith("@@ "):
250 yield cyan(line)
251 elif line.startswith("+"):
252 yield green(line)
253 elif line.startswith("-"):
254 yield red(line)
255 else:
256 yield line
257
258
259def print_diff(diff_lines: list[str], use_color: bool) -> None:

Callers 1

print_diffFunction · 0.85

Calls 4

boldFunction · 0.85
cyanFunction · 0.85
greenFunction · 0.85
redFunction · 0.85

Tested by

no test coverage detected