terminal-util: define ANSI_OSC as macro for the OSC terminal sequence prefix

This commit is contained in:
Lennart Poettering
2024-10-31 11:38:18 +01:00
parent de0ebee637
commit 0367424786
4 changed files with 12 additions and 7 deletions
+2 -2
View File
@@ -1923,12 +1923,12 @@ int get_default_background_color(double *ret_red, double *ret_green, double *ret
if (tcsetattr(STDIN_FILENO, TCSADRAIN, &new_termios) < 0)
return -errno;
r = loop_write(STDOUT_FILENO, "\x1B]11;?" ANSI_ST, SIZE_MAX);
r = loop_write(STDOUT_FILENO, ANSI_OSC "11;?" ANSI_ST, SIZE_MAX);
if (r < 0)
goto finish;
usec_t end = usec_add(now(CLOCK_MONOTONIC), 333 * USEC_PER_MSEC);
char buf[STRLEN("\x1B]11;rgb:0/0/0" ANSI_ST)]; /* shortest possible reply */
char buf[STRLEN(ANSI_OSC "11;rgb:0/0/0" ANSI_ST)]; /* shortest possible reply */
size_t buf_full = 0;
BackgroundColorContext context = {};
+3
View File
@@ -34,6 +34,9 @@
* use 0x1B 0x5c */
#define ANSI_ST "\e\\"
/* The "operating system command" ("OSC") start sequence */
#define ANSI_OSC "\e]"
bool isatty_safe(int fd);
int terminal_reset_defensive(int fd, bool switch_to_text);