From 96e12c8a274ea3e08648116f3fb052e3de005560 Mon Sep 17 00:00:00 2001 From: Matthew Sotoudeh Date: Mon, 13 Apr 2020 08:40:01 -0700 Subject: Initial code release --- patches/latexrun-force-colors | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 patches/latexrun-force-colors (limited to 'patches/latexrun-force-colors') diff --git a/patches/latexrun-force-colors b/patches/latexrun-force-colors new file mode 100644 index 0000000..829a1fe --- /dev/null +++ b/patches/latexrun-force-colors @@ -0,0 +1,28 @@ +--- latexrun ++++ latexrun +@@ -416,7 +416,24 @@ class _Terminfo: + else: + s = self.__ensure(cap) + sys.stdout.buffer.write(s) +-terminfo = _Terminfo() ++ ++class _BatchColorTerminfo: ++ def has(self, *caps): ++ for cap in caps: ++ if cap not in ['bold', 'setaf', 'sgr0']: ++ return False ++ return True ++ ++ def send(self, *caps): ++ sys.stdout.flush() ++ for cap in caps: ++ if cap == 'bold': ++ sys.stdout.buffer.write(b'\x1b[1m') ++ elif isinstance(cap, tuple) and cap[0] == 'setaf': ++ sys.stdout.buffer.write(b'\x1b[%dm' % (cap[1] + 30)) ++ elif cap == 'sgr0': ++ sys.stdout.buffer.write(b'\x1b[m') ++terminfo = _BatchColorTerminfo() + + class Progress: + _enabled = None -- cgit v1.2.3