scripts: Prefer 1;30-37m ansi codes over 90-97m

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.
This commit is contained in:
Christopher Haster
2025-04-10 15:30:27 -05:00
parent cd039f6227
commit b715e9a749
8 changed files with 32 additions and 33 deletions
+9 -9
View File
@@ -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:
+1 -1
View File
@@ -87,7 +87,7 @@ COLORS = {
'data': '32',
'corrupt': '31',
'conflict': '30;41',
'unused': '90',
'unused': '1;30',
}
# give more interesting objects a higher priority
+1 -1
View File
@@ -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 '',
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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 '',
+6 -6
View File
@@ -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, '',
+9 -9
View File
@@ -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:
+2 -3
View File
@@ -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
#