From b715e9a7493d39ea93aa6527e08b322849f998f4 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Thu, 10 Apr 2025 15:30:27 -0500 Subject: [PATCH] scripts: Prefer 1;30-37m ansi codes over 90-97m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reading Wikipedia: > Later terminals added the ability to directly specify the "bright" > colors with 90–97 and 100–107. So if we want to stick to one pattern, we should probably go with brightness as a separate modifier. This shouldn't noticeably change any script, unless your terminal interprets 90-97m colors differently from 1;30-37m, in which case things should be more consistent now. --- scripts/bench.py | 18 +++++++++--------- scripts/dbgbmap.py | 2 +- scripts/dbgbtree.py | 2 +- scripts/dbglfs.py | 6 +++--- scripts/dbgmtree.py | 2 +- scripts/dbgrbyd.py | 12 ++++++------ scripts/test.py | 18 +++++++++--------- scripts/tracebd.py | 5 ++--- 8 files changed, 32 insertions(+), 33 deletions(-) diff --git a/scripts/bench.py b/scripts/bench.py index 5b5c9d5e..2d3cd113 100755 --- a/scripts/bench.py +++ b/scripts/bench.py @@ -156,7 +156,7 @@ class BenchCase: for k in config.keys(): print('%swarning:%s in %s, found unused key %r' % ( - '\x1b[01;33m' if args['color'] else '', + '\x1b[1;33m' if args['color'] else '', '\x1b[m' if args['color'] else '', self.name, k), @@ -264,7 +264,7 @@ class BenchSuite: for k in config.keys(): print('%swarning:%s in %s, found unused key %r' % ( - '\x1b[01;33m' if args['color'] else '', + '\x1b[1;33m' if args['color'] else '', '\x1b[m' if args['color'] else '', self.name, k), @@ -305,7 +305,7 @@ def compile(bench_paths, **args): if len(pending_) == len(pending): print('%serror:%s cycle detected in suite ordering: {%s}' % ( - '\x1b[01;31m' if args['color'] else '', + '\x1b[1;31m' if args['color'] else '', '\x1b[m' if args['color'] else '', ', '.join(suite.name for suite in pending.values())), file=sys.stderr) @@ -319,7 +319,7 @@ def compile(bench_paths, **args): for suite in suites: if suite.name in seen: print('%swarning:%s conflicting suite %r, %s and %s' % ( - '\x1b[01;33m' if args['color'] else '', + '\x1b[1;33m' if args['color'] else '', '\x1b[m' if args['color'] else '', suite.name, suite.path, @@ -333,7 +333,7 @@ def compile(bench_paths, **args): isinstance(seen[case.name], BenchSuite) and seen[case.name].cases == [case]): print('%swarning:%s conflicting case %r, %s and %s' % ( - '\x1b[01;33m' if args['color'] else '', + '\x1b[1;33m' if args['color'] else '', '\x1b[m' if args['color'] else '', case.name, case.path, @@ -345,7 +345,7 @@ def compile(bench_paths, **args): if not args.get('source'): if len(suites) > 1: print('%serror:%s compiling more than one bench suite? (%r)' % ( - '\x1b[01;31m' if args['color'] else '', + '\x1b[1;31m' if args['color'] else '', '\x1b[m' if args['color'] else '', bench_paths), file=sys.stderr) @@ -893,7 +893,7 @@ def find_ids(runner, bench_ids=[], **args): # no suite/case found? error if not bench_ids__: print('%serror:%s no benches match id %r?' % ( - '\x1b[01;31m' if args['color'] else '', + '\x1b[1;31m' if args['color'] else '', '\x1b[m' if args['color'] else '', id), file=sys.stderr) @@ -1409,7 +1409,7 @@ def run(runner, bench_ids=[], **args): print('%s%s:%d:%sfailure:%s %s%s failed' % ( '\x1b[01m' if args['color'] else '', path, lineno, - '\x1b[01;31m' if args['color'] else '', + '\x1b[1;31m' if args['color'] else '', '\x1b[m' if args['color'] else '', failure.id, ' (%s)' % ', '.join('%s=%s' % (k,v) @@ -1428,7 +1428,7 @@ def run(runner, bench_ids=[], **args): print('%s%s:%d:%sassert:%s %s' % ( '\x1b[01m' if args['color'] else '', path, lineno, - '\x1b[01;31m' if args['color'] else '', + '\x1b[1;31m' if args['color'] else '', '\x1b[m' if args['color'] else '', message)) with open(path) as f: diff --git a/scripts/dbgbmap.py b/scripts/dbgbmap.py index 13a2e437..767685fd 100755 --- a/scripts/dbgbmap.py +++ b/scripts/dbgbmap.py @@ -87,7 +87,7 @@ COLORS = { 'data': '32', 'corrupt': '31', 'conflict': '30;41', - 'unused': '90', + 'unused': '1;30', } # give more interesting objects a higher priority diff --git a/scripts/dbgbtree.py b/scripts/dbgbtree.py index 931076e3..22d2bd3d 100755 --- a/scripts/dbgbtree.py +++ b/scripts/dbgbtree.py @@ -1504,7 +1504,7 @@ class TreeArt: trunk.append('%s%s%s%s' % ( '\x1b[33m' if color and c == 'y' else '\x1b[31m' if color and c == 'r' - else '\x1b[90m' if color and c == 'b' + else '\x1b[1;30m' if color and c == 'b' else '', t, ('>' if was else ' ') if d == self.depth-1 else '', diff --git a/scripts/dbglfs.py b/scripts/dbglfs.py index 33fb29a6..0c5308a2 100755 --- a/scripts/dbglfs.py +++ b/scripts/dbglfs.py @@ -3800,7 +3800,7 @@ class TreeArt: trunk.append('%s%s%s%s' % ( '\x1b[33m' if color and c == 'y' else '\x1b[31m' if color and c == 'r' - else '\x1b[90m' if color and c == 'b' + else '\x1b[1;30m' if color and c == 'b' else '', t, ('>' if was else ' ') if d == self.depth-1 else '', @@ -4066,7 +4066,7 @@ def dbg_gstate(lfs, *, if args.get('gdelta'): for mid, gdelta in gstate.gdeltas: print('%s%12s %*s %-*s %s%s' % ( - '\x1b[90m' if color else '', + '\x1b[1;30m' if color else '', '{%s}:' % ','.join('%04x' % block for block in gdelta.blocks), 2*w_width+1, mid.repr(), @@ -4185,7 +4185,7 @@ def dbg_files(lfs, paths, *, print('%s%12s %*s %-*s %s%s%s' % ( '\x1b[31m' if color and not file.grmed and notes - else '\x1b[90m' + else '\x1b[1;30m' if color and (file.grmed or file.internal) else '', '{%s}:' % ','.join('%04x' % block diff --git a/scripts/dbgmtree.py b/scripts/dbgmtree.py index 09cebb89..41182441 100755 --- a/scripts/dbgmtree.py +++ b/scripts/dbgmtree.py @@ -2399,7 +2399,7 @@ class TreeArt: trunk.append('%s%s%s%s' % ( '\x1b[33m' if color and c == 'y' else '\x1b[31m' if color and c == 'r' - else '\x1b[90m' if color and c == 'b' + else '\x1b[1;30m' if color and c == 'b' else '', t, ('>' if was else ' ') if d == self.depth-1 else '', diff --git a/scripts/dbgrbyd.py b/scripts/dbgrbyd.py index 6b10dc40..b5deafb4 100755 --- a/scripts/dbgrbyd.py +++ b/scripts/dbgrbyd.py @@ -970,7 +970,7 @@ class JumpArt: c_start = ( '\x1b[33m' if color and c == 'y' else '\x1b[31m' if color and c == 'r' - else '\x1b[90m' if color + else '\x1b[1;30m' if color else '') c_stop = '\x1b[m' if color else '' @@ -1451,7 +1451,7 @@ class TreeArt: trunk.append('%s%s%s%s' % ( '\x1b[33m' if color and c == 'y' else '\x1b[31m' if color and c == 'r' - else '\x1b[90m' if color and c == 'b' + else '\x1b[1;30m' if color and c == 'b' else '', t, ('>' if was else ' ') if d == self.depth-1 else '', @@ -1575,13 +1575,13 @@ def dbg_log(rbyd, *, # show human-readable tag representation print('%s%08x:%s %*s%s%*s %-*s%s%s%s' % ( - '\x1b[90m' if color and j >= rbyd.eoff else '', + '\x1b[1;30m' if color and j >= rbyd.eoff else '', j, '\x1b[m' if color and j >= rbyd.eoff else '', l_width, lifetimeart.repr(j, color) if args.get('lifetimes') else '', - '\x1b[90m' if color and j >= rbyd.eoff else '', + '\x1b[1;30m' if color and j >= rbyd.eoff else '', 2*w_width+1, '' if (tag & 0xe000) != 0x0000 else '%d-%d' % (rid-(w-1), rid) if w > 1 else rid, @@ -1602,7 +1602,7 @@ def dbg_log(rbyd, *, if args.get('raw'): for o, line in enumerate(xxd(data[j:j+d])): print('%s%8s: %*s%*s %s%s' % ( - '\x1b[90m' if color and j >= rbyd.eoff else '', + '\x1b[1;30m' if color and j >= rbyd.eoff else '', '%04x' % (j + o*16), l_width, '', 2*w_width+1, '', @@ -1612,7 +1612,7 @@ def dbg_log(rbyd, *, if not tag & TAG_ALT: for o, line in enumerate(xxd(data[j+d:j+d+size])): print('%s%8s: %*s%*s %s%s' % ( - '\x1b[90m' if color and j >= rbyd.eoff else '', + '\x1b[1;30m' if color and j >= rbyd.eoff else '', '%04x' % (j+d + o*16), l_width, '', 2*w_width+1, '', diff --git a/scripts/test.py b/scripts/test.py index f874f1a9..bd471aaa 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -162,7 +162,7 @@ class TestCase: for k in config.keys(): print('%swarning:%s in %s, found unused key %r' % ( - '\x1b[01;33m' if args['color'] else '', + '\x1b[1;33m' if args['color'] else '', '\x1b[m' if args['color'] else '', self.name, k), @@ -276,7 +276,7 @@ class TestSuite: for k in config.keys(): print('%swarning:%s in %s, found unused key %r' % ( - '\x1b[01;33m' if args['color'] else '', + '\x1b[1;33m' if args['color'] else '', '\x1b[m' if args['color'] else '', self.name, k), @@ -317,7 +317,7 @@ def compile(test_paths, **args): if len(pending_) == len(pending): print('%serror:%s cycle detected in suite ordering: {%s}' % ( - '\x1b[01;31m' if args['color'] else '', + '\x1b[1;31m' if args['color'] else '', '\x1b[m' if args['color'] else '', ', '.join(suite.name for suite in pending.values())), file=sys.stderr) @@ -331,7 +331,7 @@ def compile(test_paths, **args): for suite in suites: if suite.name in seen: print('%swarning:%s conflicting suite %r, %s and %s' % ( - '\x1b[01;33m' if args['color'] else '', + '\x1b[1;33m' if args['color'] else '', '\x1b[m' if args['color'] else '', suite.name, suite.path, @@ -345,7 +345,7 @@ def compile(test_paths, **args): isinstance(seen[case.name], TestSuite) and seen[case.name].cases == [case]): print('%swarning:%s conflicting case %r, %s and %s' % ( - '\x1b[01;33m' if args['color'] else '', + '\x1b[1;33m' if args['color'] else '', '\x1b[m' if args['color'] else '', case.name, case.path, @@ -357,7 +357,7 @@ def compile(test_paths, **args): if not args.get('source'): if len(suites) > 1: print('%serror:%s compiling more than one test suite? (%r)' % ( - '\x1b[01;31m' if args['color'] else '', + '\x1b[1;31m' if args['color'] else '', '\x1b[m' if args['color'] else '', test_paths), file=sys.stderr) @@ -913,7 +913,7 @@ def find_ids(runner, test_ids=[], **args): # no suite/case found? error if not test_ids__: print('%serror:%s no tests match id %r?' % ( - '\x1b[01;31m' if args['color'] else '', + '\x1b[1;31m' if args['color'] else '', '\x1b[m' if args['color'] else '', id), file=sys.stderr) @@ -1381,7 +1381,7 @@ def run(runner, test_ids=[], **args): print('%s%s:%d:%sfailure:%s %s%s failed' % ( '\x1b[01m' if args['color'] else '', path, lineno, - '\x1b[01;31m' if args['color'] else '', + '\x1b[1;31m' if args['color'] else '', '\x1b[m' if args['color'] else '', failure.id, ' (%s)' % ', '.join('%s=%s' % (k,v) @@ -1400,7 +1400,7 @@ def run(runner, test_ids=[], **args): print('%s%s:%d:%sassert:%s %s' % ( '\x1b[01m' if args['color'] else '', path, lineno, - '\x1b[01;31m' if args['color'] else '', + '\x1b[1;31m' if args['color'] else '', '\x1b[m' if args['color'] else '', message)) with open(path) as f: diff --git a/scripts/tracebd.py b/scripts/tracebd.py index 38d3f431..ebc17e5b 100755 --- a/scripts/tracebd.py +++ b/scripts/tracebd.py @@ -40,13 +40,12 @@ COLORS = { 'read': '32', 'prog': '35', 'erase': '34', - 'noop': '90', + 'noop': '1;30', } # assign chars/colors to varying levels of wear WEAR_CHARS = '0123456789' -# TODO adopt 9x for all of these? -WEAR_COLORS = ['90', '90', '90', '', '', '', '', '31', '31', '91'] +WEAR_COLORS = ['1;30', '1;30', '1;30', '', '', '', '', '31', '31', '1;31'] # give more interesting operations a higher priority #