summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/basic/terminal-util.c4
-rw-r--r--src/basic/terminal-util.h3
-rw-r--r--src/shared/pretty-print.c8
-rw-r--r--src/shared/ptyfwd.c4
4 files changed, 12 insertions, 7 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);
diff --git a/src/shared/pretty-print.c b/src/shared/pretty-print.c
index 1e9819ab09..4e38e60775 100644
--- a/src/shared/pretty-print.c
+++ b/src/shared/pretty-print.c
@@ -88,7 +88,9 @@ int terminal_urlify(const char *url, const char *text, char **ret) {
text = url;
if (urlify_enabled())
- n = strjoin("\x1B]8;;", url, ANSI_ST, text, "\x1B]8;;" ANSI_ST);
+ n = strjoin(ANSI_OSC "8;;", url, ANSI_ST,
+ text,
+ ANSI_OSC "8;;" ANSI_ST);
else
n = strdup(text);
if (!n)
@@ -475,7 +477,7 @@ void draw_progress_bar_unbuffered(const char *prefix, double percentage) {
* https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC
* https://github.com/microsoft/terminal/pull/8055
*/
- fprintf(stderr, "\x1B]9;4;1;%u" ANSI_ST, (unsigned) ceil(percentage));
+ fprintf(stderr, ANSI_OSC "9;4;1;%u" ANSI_ST, (unsigned) ceil(percentage));
size_t cols = columns();
size_t prefix_width = utf8_console_width(prefix) + 1 /* space */;
@@ -534,7 +536,7 @@ void clear_progress_bar_unbuffered(const char *prefix) {
stderr);
else
/* Undo Windows Terminal progress indication again. */
- fputs("\x1B]9;4;0;;" ANSI_ST
+ fputs(ANSI_OSC "9;4;0;;" ANSI_ST
ANSI_ERASE_TO_END_OF_LINE, stderr);
fputc('\r', stderr);
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c
index 34b24837ef..c1e3b7180b 100644
--- a/src/shared/ptyfwd.c
+++ b/src/shared/ptyfwd.c
@@ -397,7 +397,7 @@ static int insert_window_title_fix(PTYForward *f, size_t offset) {
if (!t)
return 0;
- _cleanup_free_ char *joined = strjoin("\x1b]0;", f->title_prefix, t, ANSI_ST);
+ _cleanup_free_ char *joined = strjoin(ANSI_OSC "0;", f->title_prefix, t, ANSI_ST);
if (!joined)
return -ENOMEM;
@@ -572,7 +572,7 @@ static int do_shovel(PTYForward *f) {
if (f->title) {
if (!strextend(&f->out_buffer,
ANSI_WINDOW_TITLE_PUSH
- "\x1b]2;", f->title, ANSI_ST))
+ ANSI_OSC "2;", f->title, ANSI_ST))
return log_oom();
}