[hackers] [st][PATCH] Support OSC 110, 111, and 112 for resetting colors

From: Ayman Bagabas <ayman.bagabas_AT_gmail.com>
Date: Fri, 8 Aug 2025 17:11:59 -0400

This adds support for OSC 110, 111, and 112 escape sequences to reset
the foreground, background, and cursor colors in the terminal. The
changes include handling these sequences in the `strhandle` function of
`st.c`, allowing applications to reset colors to their default values.

The OSC sequences originated from Xterm control sequences and are now
widely used in terminal applications and supported by many terminal
emulators. For applications, this allows them to reset colors to
default values without needing to know the colors beforehand.

Signed-off-by: Ayman Bagabas <ayman.bagabas_AT_gmail.com>
---
 st.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff --git a/st.c b/st.c
index 37f38c546476..e9fea17d3cc2 100644
--- a/st.c
+++ b/st.c
_AT_@ -1967,6 +1967,19 @@ strhandle(void)
 				tfulldirt();
 			}
 			return;
+		case 110:
+		case 111:
+		case 112:
+			if (narg != 1)
+				break;
+			if ((j = par - 110) < 0 || j >= LEN(osc_table))
+				break; /* shouldn't be possible */
+			if (xsetcolorname(osc_table[j].idx, NULL)) {
+				fprintf(stderr, "erresc: %s color not found\n", osc_table[j].str);
+			} else {
+				tfulldirt();
+			}
+			return;
 		}
 		break;
 	case 'k': /* old title set compatibility */
-- 
2.50.1
Received on Fri Aug 08 2025 - 23:11:59 CEST

This archive was generated by hypermail 2.3.0 : Sat Aug 09 2025 - 04:48:33 CEST