mirror of
https://github.com/systemd/systemd
synced 2024-10-06 16:21:34 +00:00
ptyfwd: automatically turn off tinting/window title logic on dumb terminals
If we are not talking to a reasonable terminal let's not try to set the window title or tint the background.
This commit is contained in:
parent
8f1fe0410d
commit
d7c3724258
|
@ -389,6 +389,9 @@ static int pty_forward_ansi_process(PTYForward *f, size_t offset) {
|
|||
if (!f->background_color)
|
||||
return 0;
|
||||
|
||||
if (FLAGS_SET(f->flags, PTY_FORWARD_DUMB_TERMINAL))
|
||||
return 0;
|
||||
|
||||
for (size_t i = offset; i < f->out_buffer_full; i++) {
|
||||
char c = f->out_buffer[i];
|
||||
|
||||
|
@ -484,7 +487,11 @@ static int do_shovel(PTYForward *f) {
|
|||
|
||||
assert(f);
|
||||
|
||||
if (f->out_buffer_size == 0) {
|
||||
if (f->out_buffer_size == 0 && !FLAGS_SET(f->flags, PTY_FORWARD_DUMB_TERMINAL)) {
|
||||
/* If the output hasn't been allocated yet, we are at the beginning of the first
|
||||
* shovelling. Hence, possibly send some initial ANSI sequences. But do so only if we are
|
||||
* talking to an actual TTY. */
|
||||
|
||||
if (f->background_color) {
|
||||
/* Erase the first line when we start */
|
||||
f->out_buffer = background_color_sequence(f);
|
||||
|
@ -792,6 +799,10 @@ int pty_forward_new(
|
|||
|
||||
f->master = master;
|
||||
|
||||
/* Disable color/window title setting unless we talk to a good TTY */
|
||||
if (!isatty_safe(f->output_fd) || get_color_mode() == COLOR_OFF)
|
||||
f->flags |= PTY_FORWARD_DUMB_TERMINAL;
|
||||
|
||||
if (ioctl(f->output_fd, TIOCGWINSZ, &ws) < 0)
|
||||
/* If we can't get the resolution from the output fd, then use our internal, regular width/height,
|
||||
* i.e. something derived from $COLUMNS and $LINES if set. */
|
||||
|
|
|
@ -10,13 +10,17 @@
|
|||
typedef struct PTYForward PTYForward;
|
||||
|
||||
typedef enum PTYForwardFlags {
|
||||
PTY_FORWARD_READ_ONLY = 1,
|
||||
/* Only output to STDOUT, never try to read from STDIN */
|
||||
PTY_FORWARD_READ_ONLY = 1 << 0,
|
||||
|
||||
/* Continue reading after hangup? */
|
||||
PTY_FORWARD_IGNORE_VHANGUP = 2,
|
||||
PTY_FORWARD_IGNORE_VHANGUP = 1 << 1,
|
||||
|
||||
/* Continue reading after hangup but only if we never read anything else? */
|
||||
PTY_FORWARD_IGNORE_INITIAL_VHANGUP = 4,
|
||||
PTY_FORWARD_IGNORE_INITIAL_VHANGUP = 1 << 2,
|
||||
|
||||
/* Don't tint the background, or set window title */
|
||||
PTY_FORWARD_DUMB_TERMINAL = 1 << 3,
|
||||
} PTYForwardFlags;
|
||||
|
||||
typedef int (*PTYForwardHandler)(PTYForward *f, int rcode, void *userdata);
|
||||
|
|
Loading…
Reference in a new issue