From a1144fd49a84cc31460f20ddc181b348f9a09de2 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 6 Oct 2025 10:48:35 -0400 Subject: [PATCH] Auto-intense color Terminals seem to expect 'bold or intensity' to imply intense color. There are certain terminals that steadfastly refuse to do bold and intense. So implement the logic on behalf of the remote terminal. Commonly, UEFI setup menus request bold white text on white background. This fixes such menus to be readable by explicitly requesting intense white foreground rather than normal background. For example, the kitty terminal has no 'intense on bold feature. --- confluent_client/bin/confetty | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/confetty b/confluent_client/bin/confetty index e14a55ed..9463cddb 100755 --- a/confluent_client/bin/confetty +++ b/confluent_client/bin/confetty @@ -45,6 +45,7 @@ import math import getpass import optparse import os +import re import select import shlex import signal @@ -969,6 +970,9 @@ def main(): sys.stdout.write('Lost connection to server') quitconfetty(fullexit=True) +sgr_re = re.compile(r'(\x1b\[[0-9;]*m)') +sgr_parameters_re = re.compile(r'\x1b\[([0-9;]*)m') + def consume_termdata(fh, bufferonly=False): global clearpowermessage try: @@ -979,7 +983,27 @@ def consume_termdata(fh, bufferonly=False): updatestatus(data) return '' if data is not None: - data = client.stringify(data) + indata = client.stringify(data) + data = '' + for segment in sgr_re.split(indata): + if sgr_re.match(segment): # it is an sgr, analyze, maybe replace + params = [] + bold = False + for parameters in sgr_parameters_re.findall(segment): + for param in parameters.split(';'): + if param == '1': + bold = True + params.append(param) + for idx, param in enumerate(params): + try: + ival = int(param) + except ValueError: + continue + if bold and (30 <= ival <= 37): + ival += 60 + params[idx] = str(ival) + segment = '\x1b[' + ';'.join(str(p) for p in params) + 'm' + data += segment if clearpowermessage: sys.stdout.write("\x1b[2J\x1b[;H") clearpowermessage = False