diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-10-31 10:37:02 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-10-31 11:38:18 +0100 |
commit | 0367424786e1ceac953e6336d5592c376d47d73a (patch) | |
tree | 8d95d2a2368da087e1e097f339ad657d81ff600f /src/basic | |
parent | ptyfwd: document why we only honour two of the three kinds of ST (diff) | |
download | systemd-0367424786e1ceac953e6336d5592c376d47d73a.tar.xz systemd-0367424786e1ceac953e6336d5592c376d47d73a.zip |
terminal-util: define ANSI_OSC as macro for the OSC terminal sequence prefix
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/terminal-util.c | 4 | ||||
-rw-r--r-- | src/basic/terminal-util.h | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 4172db12a5..81c02d85a3 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -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 = {}; diff --git a/src/basic/terminal-util.h b/src/basic/terminal-util.h index 3d02e92d0b..08d8cbac25 100644 --- a/src/basic/terminal-util.h +++ b/src/basic/terminal-util.h @@ -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); |