Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2023-04-27 19:16:08 +01:00
commit 9d8131c190
12 changed files with 170 additions and 110 deletions

6
file.c
View File

@ -174,9 +174,9 @@ file_fire_read(struct client_file *cf)
int int
file_can_print(struct client *c) file_can_print(struct client *c)
{ {
if (c == NULL) if (c == NULL ||
return (0); (c->flags & CLIENT_ATTACHED) ||
if (c->session != NULL && (~c->flags & CLIENT_CONTROL)) (c->flags & CLIENT_CONTROL))
return (0); return (0);
return (1); return (1);
} }

View File

@ -1885,6 +1885,18 @@ format_cb_pane_input_off(struct format_tree *ft)
return (NULL); return (NULL);
} }
/* Callback for pane_unseen_changes. */
static void *
format_cb_pane_unseen_changes(struct format_tree *ft)
{
if (ft->wp != NULL) {
if (ft->wp->flags & PANE_UNSEENCHANGES)
return (xstrdup("1"));
return (xstrdup("0"));
}
return (NULL);
}
/* Callback for pane_last. */ /* Callback for pane_last. */
static void * static void *
format_cb_pane_last(struct format_tree *ft) format_cb_pane_last(struct format_tree *ft)
@ -2953,6 +2965,9 @@ static const struct format_table_entry format_table[] = {
{ "pane_tty", FORMAT_TABLE_STRING, { "pane_tty", FORMAT_TABLE_STRING,
format_cb_pane_tty format_cb_pane_tty
}, },
{ "pane_unseen_changes", FORMAT_TABLE_STRING,
format_cb_pane_unseen_changes
},
{ "pane_width", FORMAT_TABLE_STRING, { "pane_width", FORMAT_TABLE_STRING,
format_cb_pane_width format_cb_pane_width
}, },

View File

@ -971,6 +971,10 @@ input_parse_buffer(struct window_pane *wp, u_char *buf, size_t len)
window_update_activity(wp->window); window_update_activity(wp->window);
wp->flags |= PANE_CHANGED; wp->flags |= PANE_CHANGED;
/* Flag new input while in a mode. */
if (!TAILQ_EMPTY(&wp->modes))
wp->flags |= PANE_UNSEENCHANGES;
/* NULL wp if there is a mode set as don't want to update the tty. */ /* NULL wp if there is a mode set as don't want to update the tty. */
if (TAILQ_EMPTY(&wp->modes)) if (TAILQ_EMPTY(&wp->modes))
screen_write_start_pane(sctx, wp, &wp->base); screen_write_start_pane(sctx, wp, &wp->base);

View File

@ -132,6 +132,12 @@ screen_write_set_client_cb(struct tty_ctx *ttyctx, struct client *c)
{ {
struct window_pane *wp = ttyctx->arg; struct window_pane *wp = ttyctx->arg;
if (ttyctx->allow_invisible_panes) {
if (session_has(c->session, wp->window))
return (1);
return (0);
}
if (c->session->curw->window != wp->window) if (c->session->curw->window != wp->window)
return (0); return (0);
if (wp->layout_cell == NULL) if (wp->layout_cell == NULL)

View File

@ -1471,8 +1471,6 @@ process_key:
return (0); return (0);
append_key: append_key:
if (key <= 0x1f || (key >= KEYC_BASE && key < KEYC_BASE_END))
return (0);
if (key <= 0x7f) if (key <= 0x7f)
utf8_set(&tmp, key); utf8_set(&tmp, key);
else if (KEYC_IS_UNICODE(key)) else if (KEYC_IS_UNICODE(key))

6
tmux.1
View File

@ -1281,7 +1281,10 @@ behave like
.Ic attach-session .Ic attach-session
if if
.Ar session-name .Ar session-name
already exists; in this case, already exists;
if
.Fl A
is given,
.Fl D .Fl D
behaves like behaves like
.Fl d .Fl d
@ -5260,6 +5263,7 @@ The following variables are available, where appropriate:
.It Li "pane_title" Ta "#T" Ta "Title of pane (can be set by application)" .It Li "pane_title" Ta "#T" Ta "Title of pane (can be set by application)"
.It Li "pane_top" Ta "" Ta "Top of pane" .It Li "pane_top" Ta "" Ta "Top of pane"
.It Li "pane_tty" Ta "" Ta "Pseudo terminal of pane" .It Li "pane_tty" Ta "" Ta "Pseudo terminal of pane"
.It Li "pane_unseen_changes" Ta "" Ta "1 if there were changes in pane while in mode"
.It Li "pane_width" Ta "" Ta "Width of pane" .It Li "pane_width" Ta "" Ta "Width of pane"
.It Li "pid" Ta "" Ta "Server PID" .It Li "pid" Ta "" Ta "Server PID"
.It Li "rectangle_toggle" Ta "" Ta "1 if rectangle selection is activated" .It Li "rectangle_toggle" Ta "" Ta "1 if rectangle selection is activated"

2
tmux.c
View File

@ -391,7 +391,7 @@ main(int argc, char **argv)
cfg_quiet = 0; cfg_quiet = 0;
break; break;
case 'V': case 'V':
printf("%s %s\n", getprogname(), getversion()); printf("tmux %s\n", getversion());
exit(0); exit(0);
case 'l': case 'l':
flags |= CLIENT_LOGIN; flags |= CLIENT_LOGIN;

31
tmux.h
View File

@ -161,7 +161,9 @@ struct winlink;
#define KEYC_IS_UNICODE(key) \ #define KEYC_IS_UNICODE(key) \
(((key) & KEYC_MASK_KEY) > 0x7f && \ (((key) & KEYC_MASK_KEY) > 0x7f && \
(((key) & KEYC_MASK_KEY) < KEYC_BASE || \ (((key) & KEYC_MASK_KEY) < KEYC_BASE || \
((key) & KEYC_MASK_KEY) >= KEYC_BASE_END)) ((key) & KEYC_MASK_KEY) >= KEYC_BASE_END) && \
(((key) & KEYC_MASK_KEY) < KEYC_USER || \
((key) & KEYC_MASK_KEY) >= KEYC_USER + KEYC_NUSER))
/* Multiple click timeout. */ /* Multiple click timeout. */
#define KEYC_CLICK_TIMEOUT 300 #define KEYC_CLICK_TIMEOUT 300
@ -1049,6 +1051,7 @@ struct window_pane {
#define PANE_STATUSDRAWN 0x400 #define PANE_STATUSDRAWN 0x400
#define PANE_EMPTY 0x800 #define PANE_EMPTY 0x800
#define PANE_STYLECHANGED 0x1000 #define PANE_STYLECHANGED 0x1000
#define PANE_UNSEENCHANGES 0x2000
int argc; int argc;
char **argv; char **argv;
@ -2297,12 +2300,12 @@ void tty_margin_off(struct tty *);
void tty_cursor(struct tty *, u_int, u_int); void tty_cursor(struct tty *, u_int, u_int);
void tty_clipboard_query(struct tty *); void tty_clipboard_query(struct tty *);
void tty_putcode(struct tty *, enum tty_code_code); void tty_putcode(struct tty *, enum tty_code_code);
void tty_putcode1(struct tty *, enum tty_code_code, int); void tty_putcode_i(struct tty *, enum tty_code_code, int);
void tty_putcode2(struct tty *, enum tty_code_code, int, int); void tty_putcode_ii(struct tty *, enum tty_code_code, int, int);
void tty_putcode3(struct tty *, enum tty_code_code, int, int, int); void tty_putcode_iii(struct tty *, enum tty_code_code, int, int, int);
void tty_putcode_ptr1(struct tty *, enum tty_code_code, const void *); void tty_putcode_s(struct tty *, enum tty_code_code, const char *);
void tty_putcode_ptr2(struct tty *, enum tty_code_code, const void *, void tty_putcode_ss(struct tty *, enum tty_code_code, const char *,
const void *); const char *);
void tty_puts(struct tty *, const char *); void tty_puts(struct tty *, const char *);
void tty_putc(struct tty *, u_char); void tty_putc(struct tty *, u_char);
void tty_putn(struct tty *, const void *, size_t, u_int); void tty_putn(struct tty *, const void *, size_t, u_int);
@ -2366,15 +2369,15 @@ int tty_term_read_list(const char *, int, char ***, u_int *,
void tty_term_free_list(char **, u_int); void tty_term_free_list(char **, u_int);
int tty_term_has(struct tty_term *, enum tty_code_code); int tty_term_has(struct tty_term *, enum tty_code_code);
const char *tty_term_string(struct tty_term *, enum tty_code_code); const char *tty_term_string(struct tty_term *, enum tty_code_code);
const char *tty_term_string1(struct tty_term *, enum tty_code_code, int); const char *tty_term_string_i(struct tty_term *, enum tty_code_code, int);
const char *tty_term_string2(struct tty_term *, enum tty_code_code, int, const char *tty_term_string_ii(struct tty_term *, enum tty_code_code, int,
int); int);
const char *tty_term_string3(struct tty_term *, enum tty_code_code, int, const char *tty_term_string_iii(struct tty_term *, enum tty_code_code, int,
int, int); int, int);
const char *tty_term_ptr1(struct tty_term *, enum tty_code_code, const char *tty_term_string_s(struct tty_term *, enum tty_code_code,
const void *); const char *);
const char *tty_term_ptr2(struct tty_term *, enum tty_code_code, const char *tty_term_string_ss(struct tty_term *, enum tty_code_code,
const void *, const void *); const char *, const char *);
int tty_term_number(struct tty_term *, enum tty_code_code); int tty_term_number(struct tty_term *, enum tty_code_code);
int tty_term_flag(struct tty_term *, enum tty_code_code); int tty_term_flag(struct tty_term *, enum tty_code_code);
const char *tty_term_describe(struct tty_term *, enum tty_code_code); const char *tty_term_describe(struct tty_term *, enum tty_code_code);

View File

@ -1008,7 +1008,8 @@ tty_keys_extended_key(struct tty *tty, const char *buf, size_t len,
/* /*
* Handle mouse key input. Returns 0 for success, -1 for failure, 1 for partial * Handle mouse key input. Returns 0 for success, -1 for failure, 1 for partial
* (probably a mouse sequence but need more data). * (probably a mouse sequence but need more data), -2 if an invalid mouse
* sequence.
*/ */
static int static int
tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size, tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size,
@ -1069,7 +1070,7 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size,
if (b < MOUSE_PARAM_BTN_OFF || if (b < MOUSE_PARAM_BTN_OFF ||
x < MOUSE_PARAM_POS_OFF || x < MOUSE_PARAM_POS_OFF ||
y < MOUSE_PARAM_POS_OFF) y < MOUSE_PARAM_POS_OFF)
return (-1); return (-2);
b -= MOUSE_PARAM_BTN_OFF; b -= MOUSE_PARAM_BTN_OFF;
x -= MOUSE_PARAM_POS_OFF; x -= MOUSE_PARAM_POS_OFF;
y -= MOUSE_PARAM_POS_OFF; y -= MOUSE_PARAM_POS_OFF;
@ -1111,7 +1112,7 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size,
/* Check and return the mouse input. */ /* Check and return the mouse input. */
if (x < 1 || y < 1) if (x < 1 || y < 1)
return (-1); return (-2);
x--; x--;
y--; y--;
b = sgr_b; b = sgr_b;

View File

@ -766,35 +766,60 @@ tty_term_string(struct tty_term *term, enum tty_code_code code)
} }
const char * const char *
tty_term_string1(struct tty_term *term, enum tty_code_code code, int a) tty_term_string_i(struct tty_term *term, enum tty_code_code code, int a)
{ {
return (tparm((char *) tty_term_string(term, code), a, 0, 0, 0, 0, 0, 0, 0, 0)); const char *x = tty_term_string(term, code), *s;
s = tparm((char *)x, a);
if (s == NULL)
fatalx("could not expand %s", tty_term_codes[code].name);
return (s);
} }
const char * const char *
tty_term_string2(struct tty_term *term, enum tty_code_code code, int a, int b) tty_term_string_ii(struct tty_term *term, enum tty_code_code code, int a, int b)
{ {
return (tparm((char *) tty_term_string(term, code), a, b, 0, 0, 0, 0, 0, 0, 0)); const char *x = tty_term_string(term, code), *s;
s = tparm((char *)x, a, b);
if (s == NULL)
fatalx("could not expand %s", tty_term_codes[code].name);
return (s);
} }
const char * const char *
tty_term_string3(struct tty_term *term, enum tty_code_code code, int a, int b, tty_term_string_iii(struct tty_term *term, enum tty_code_code code, int a, int b,
int c) int c)
{ {
return (tparm((char *) tty_term_string(term, code), a, b, c, 0, 0, 0, 0, 0, 0)); const char *x = tty_term_string(term, code), *s;
s = tparm((char *)x, a, b, c);
if (s == NULL)
fatalx("could not expand %s", tty_term_codes[code].name);
return (s);
} }
const char * const char *
tty_term_ptr1(struct tty_term *term, enum tty_code_code code, const void *a) tty_term_string_s(struct tty_term *term, enum tty_code_code code, const char *a)
{ {
return (tparm((char *) tty_term_string(term, code), (long)a, 0, 0, 0, 0, 0, 0, 0, 0)); const char *x = tty_term_string(term, code), *s;
s = tparm((char *)x, (long)a);
if (s == NULL)
fatalx("could not expand %s", tty_term_codes[code].name);
return (s);
} }
const char * const char *
tty_term_ptr2(struct tty_term *term, enum tty_code_code code, const void *a, tty_term_string_ss(struct tty_term *term, enum tty_code_code code, const char *a,
const void *b) const char *b)
{ {
return (tparm((char *) tty_term_string(term, code), (long)a, (long)b, 0, 0, 0, 0, 0, 0, 0)); const char *x = tty_term_string(term, code), *s;
s = tparm((char *)x, (long)a, (long)b);
if (s == NULL)
fatalx("could not expand %s", tty_term_codes[code].name);
return (s);
} }
int int

153
tty.c
View File

@ -34,8 +34,6 @@
static int tty_log_fd = -1; static int tty_log_fd = -1;
static int tty_client_ready(struct client *);
static void tty_set_italics(struct tty *); static void tty_set_italics(struct tty *);
static int tty_try_colour(struct tty *, int, const char *); static int tty_try_colour(struct tty *, int, const char *);
static void tty_force_cursor_colour(struct tty *, int); static void tty_force_cursor_colour(struct tty *, int);
@ -407,7 +405,7 @@ tty_stop_tty(struct tty *tty)
if (tcsetattr(c->fd, TCSANOW, &tty->tio) == -1) if (tcsetattr(c->fd, TCSANOW, &tty->tio) == -1)
return; return;
tty_raw(tty, tty_term_string2(tty->term, TTYC_CSR, 0, ws.ws_row - 1)); tty_raw(tty, tty_term_string_ii(tty->term, TTYC_CSR, 0, ws.ws_row - 1));
if (tty_acs_needed(tty)) if (tty_acs_needed(tty))
tty_raw(tty, tty_term_string(tty->term, TTYC_RMACS)); tty_raw(tty, tty_term_string(tty->term, TTYC_RMACS));
tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0)); tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0));
@ -417,7 +415,7 @@ tty_stop_tty(struct tty *tty)
if (tty_term_has(tty->term, TTYC_SE)) if (tty_term_has(tty->term, TTYC_SE))
tty_raw(tty, tty_term_string(tty->term, TTYC_SE)); tty_raw(tty, tty_term_string(tty->term, TTYC_SE));
else if (tty_term_has(tty->term, TTYC_SS)) else if (tty_term_has(tty->term, TTYC_SS))
tty_raw(tty, tty_term_string1(tty->term, TTYC_SS, 0)); tty_raw(tty, tty_term_string_i(tty->term, TTYC_SS, 0));
} }
if (tty->ccolour != -1) if (tty->ccolour != -1)
tty_raw(tty, tty_term_string(tty->term, TTYC_CR)); tty_raw(tty, tty_term_string(tty->term, TTYC_CR));
@ -484,6 +482,8 @@ tty_update_features(struct tty *tty)
tty_puts(tty, tty_term_string(tty->term, TTYC_ENFCS)); tty_puts(tty, tty_term_string(tty->term, TTYC_ENFCS));
if (tty->term->flags & TERM_VT100LIKE) if (tty->term->flags & TERM_VT100LIKE)
tty_puts(tty, "\033[?7727h"); tty_puts(tty, "\033[?7727h");
tty_invalidate(tty);
} }
void void
@ -514,42 +514,42 @@ tty_putcode(struct tty *tty, enum tty_code_code code)
} }
void void
tty_putcode1(struct tty *tty, enum tty_code_code code, int a) tty_putcode_i(struct tty *tty, enum tty_code_code code, int a)
{ {
if (a < 0) if (a < 0)
return; return;
tty_puts(tty, tty_term_string1(tty->term, code, a)); tty_puts(tty, tty_term_string_i(tty->term, code, a));
} }
void void
tty_putcode2(struct tty *tty, enum tty_code_code code, int a, int b) tty_putcode_ii(struct tty *tty, enum tty_code_code code, int a, int b)
{ {
if (a < 0 || b < 0) if (a < 0 || b < 0)
return; return;
tty_puts(tty, tty_term_string2(tty->term, code, a, b)); tty_puts(tty, tty_term_string_ii(tty->term, code, a, b));
} }
void void
tty_putcode3(struct tty *tty, enum tty_code_code code, int a, int b, int c) tty_putcode_iii(struct tty *tty, enum tty_code_code code, int a, int b, int c)
{ {
if (a < 0 || b < 0 || c < 0) if (a < 0 || b < 0 || c < 0)
return; return;
tty_puts(tty, tty_term_string3(tty->term, code, a, b, c)); tty_puts(tty, tty_term_string_iii(tty->term, code, a, b, c));
} }
void void
tty_putcode_ptr1(struct tty *tty, enum tty_code_code code, const void *a) tty_putcode_s(struct tty *tty, enum tty_code_code code, const char *a)
{ {
if (a != NULL) if (a != NULL)
tty_puts(tty, tty_term_ptr1(tty->term, code, a)); tty_puts(tty, tty_term_string_s(tty->term, code, a));
} }
void void
tty_putcode_ptr2(struct tty *tty, enum tty_code_code code, const void *a, tty_putcode_ss(struct tty *tty, enum tty_code_code code, const char *a,
const void *b) const char *b)
{ {
if (a != NULL && b != NULL) if (a != NULL && b != NULL)
tty_puts(tty, tty_term_ptr2(tty->term, code, a, b)); tty_puts(tty, tty_term_string_ss(tty->term, code, a, b));
} }
static void static void
@ -611,7 +611,7 @@ tty_putc(struct tty *tty, u_char ch)
* it works on sensible terminals as well. * it works on sensible terminals as well.
*/ */
if (tty->term->flags & TERM_NOAM) if (tty->term->flags & TERM_NOAM)
tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx); tty_putcode_ii(tty, TTYC_CUP, tty->cy, tty->cx);
} else } else
tty->cx++; tty->cx++;
} }
@ -690,7 +690,7 @@ tty_force_cursor_colour(struct tty *tty, int c)
else { else {
colour_split_rgb(c, &r, &g, &b); colour_split_rgb(c, &r, &g, &b);
xsnprintf(s, sizeof s, "rgb:%02hhx/%02hhx/%02hhx", r, g, b); xsnprintf(s, sizeof s, "rgb:%02hhx/%02hhx/%02hhx", r, g, b);
tty_putcode_ptr1(tty, TTYC_CS, s); tty_putcode_s(tty, TTYC_CS, s);
} }
tty->ccolour = c; tty->ccolour = c;
} }
@ -751,7 +751,7 @@ tty_update_cursor(struct tty *tty, int mode, struct screen *s)
if (tty_term_has(tty->term, TTYC_SE)) if (tty_term_has(tty->term, TTYC_SE))
tty_putcode(tty, TTYC_SE); tty_putcode(tty, TTYC_SE);
else else
tty_putcode1(tty, TTYC_SS, 0); tty_putcode_i(tty, TTYC_SS, 0);
} }
if (cmode & (MODE_CURSOR_BLINKING|MODE_CURSOR_VERY_VISIBLE)) if (cmode & (MODE_CURSOR_BLINKING|MODE_CURSOR_VERY_VISIBLE))
tty_putcode(tty, TTYC_CVVIS); tty_putcode(tty, TTYC_CVVIS);
@ -759,27 +759,27 @@ tty_update_cursor(struct tty *tty, int mode, struct screen *s)
case SCREEN_CURSOR_BLOCK: case SCREEN_CURSOR_BLOCK:
if (tty_term_has(tty->term, TTYC_SS)) { if (tty_term_has(tty->term, TTYC_SS)) {
if (cmode & MODE_CURSOR_BLINKING) if (cmode & MODE_CURSOR_BLINKING)
tty_putcode1(tty, TTYC_SS, 1); tty_putcode_i(tty, TTYC_SS, 1);
else else
tty_putcode1(tty, TTYC_SS, 2); tty_putcode_i(tty, TTYC_SS, 2);
} else if (cmode & MODE_CURSOR_BLINKING) } else if (cmode & MODE_CURSOR_BLINKING)
tty_putcode(tty, TTYC_CVVIS); tty_putcode(tty, TTYC_CVVIS);
break; break;
case SCREEN_CURSOR_UNDERLINE: case SCREEN_CURSOR_UNDERLINE:
if (tty_term_has(tty->term, TTYC_SS)) { if (tty_term_has(tty->term, TTYC_SS)) {
if (cmode & MODE_CURSOR_BLINKING) if (cmode & MODE_CURSOR_BLINKING)
tty_putcode1(tty, TTYC_SS, 3); tty_putcode_i(tty, TTYC_SS, 3);
else else
tty_putcode1(tty, TTYC_SS, 4); tty_putcode_i(tty, TTYC_SS, 4);
} else if (cmode & MODE_CURSOR_BLINKING) } else if (cmode & MODE_CURSOR_BLINKING)
tty_putcode(tty, TTYC_CVVIS); tty_putcode(tty, TTYC_CVVIS);
break; break;
case SCREEN_CURSOR_BAR: case SCREEN_CURSOR_BAR:
if (tty_term_has(tty->term, TTYC_SS)) { if (tty_term_has(tty->term, TTYC_SS)) {
if (cmode & MODE_CURSOR_BLINKING) if (cmode & MODE_CURSOR_BLINKING)
tty_putcode1(tty, TTYC_SS, 5); tty_putcode_i(tty, TTYC_SS, 5);
else else
tty_putcode1(tty, TTYC_SS, 6); tty_putcode_i(tty, TTYC_SS, 6);
} else if (cmode & MODE_CURSOR_BLINKING) } else if (cmode & MODE_CURSOR_BLINKING)
tty_putcode(tty, TTYC_CVVIS); tty_putcode(tty, TTYC_CVVIS);
break; break;
@ -835,7 +835,7 @@ tty_emulate_repeat(struct tty *tty, enum tty_code_code code,
enum tty_code_code code1, u_int n) enum tty_code_code code1, u_int n)
{ {
if (tty_term_has(tty->term, code)) if (tty_term_has(tty->term, code))
tty_putcode1(tty, code, n); tty_putcode_i(tty, code, n);
else { else {
while (n-- > 0) while (n-- > 0)
tty_putcode(tty, code1); tty_putcode(tty, code1);
@ -1124,7 +1124,7 @@ tty_clear_line(struct tty *tty, const struct grid_cell *defaults, u_int py,
/* Section of line. Use ECH if possible. */ /* Section of line. Use ECH if possible. */
if (tty_term_has(tty->term, TTYC_ECH)) { if (tty_term_has(tty->term, TTYC_ECH)) {
tty_cursor(tty, px, py); tty_cursor(tty, px, py);
tty_putcode1(tty, TTYC_ECH, nx); tty_putcode_i(tty, TTYC_ECH, nx);
return; return;
} }
} }
@ -1265,7 +1265,7 @@ tty_clear_area(struct tty *tty, const struct grid_cell *defaults, u_int py,
tty_term_has(tty->term, TTYC_INDN)) { tty_term_has(tty->term, TTYC_INDN)) {
tty_region(tty, py, py + ny - 1); tty_region(tty, py, py + ny - 1);
tty_margin_off(tty); tty_margin_off(tty);
tty_putcode1(tty, TTYC_INDN, ny); tty_putcode_i(tty, TTYC_INDN, ny);
return; return;
} }
@ -1280,7 +1280,7 @@ tty_clear_area(struct tty *tty, const struct grid_cell *defaults, u_int py,
tty_term_has(tty->term, TTYC_INDN)) { tty_term_has(tty->term, TTYC_INDN)) {
tty_region(tty, py, py + ny - 1); tty_region(tty, py, py + ny - 1);
tty_margin(tty, px, px + nx - 1); tty_margin(tty, px, px + nx - 1);
tty_putcode1(tty, TTYC_INDN, ny); tty_putcode_i(tty, TTYC_INDN, ny);
return; return;
} }
} }
@ -1587,7 +1587,7 @@ tty_sync_start(struct tty *tty)
if (tty_term_has(tty->term, TTYC_SYNC)) { if (tty_term_has(tty->term, TTYC_SYNC)) {
log_debug("%s sync start", tty->client->name); log_debug("%s sync start", tty->client->name);
tty_putcode1(tty, TTYC_SYNC, 1); tty_putcode_i(tty, TTYC_SYNC, 1);
} }
} }
@ -1602,16 +1602,26 @@ tty_sync_end(struct tty *tty)
if (tty_term_has(tty->term, TTYC_SYNC)) { if (tty_term_has(tty->term, TTYC_SYNC)) {
log_debug("%s sync end", tty->client->name); log_debug("%s sync end", tty->client->name);
tty_putcode1(tty, TTYC_SYNC, 2); tty_putcode_i(tty, TTYC_SYNC, 2);
} }
} }
static int static int
tty_client_ready(struct client *c) tty_client_ready(const struct tty_ctx *ctx, struct client *c)
{ {
if (c->session == NULL || c->tty.term == NULL) if (c->session == NULL || c->tty.term == NULL)
return (0); return (0);
if (c->flags & (CLIENT_REDRAWWINDOW|CLIENT_SUSPENDED)) if (c->flags & CLIENT_SUSPENDED)
return (0);
/*
* If invisible panes are allowed (used for passthrough), don't care if
* redrawing or frozen.
*/
if (ctx->allow_invisible_panes)
return (1);
if (c->flags & CLIENT_REDRAWWINDOW)
return (0); return (0);
if (c->tty.flags & TTY_FREEZE) if (c->tty.flags & TTY_FREEZE)
return (0); return (0);
@ -1628,21 +1638,14 @@ tty_write(void (*cmdfn)(struct tty *, const struct tty_ctx *),
if (ctx->set_client_cb == NULL) if (ctx->set_client_cb == NULL)
return; return;
TAILQ_FOREACH(c, &clients, entry) { TAILQ_FOREACH(c, &clients, entry) {
if (ctx->allow_invisible_panes) { if (tty_client_ready(ctx, c)) {
if (c->session == NULL ||
c->tty.term == NULL ||
c->flags & CLIENT_SUSPENDED)
continue;
} else {
if (!tty_client_ready(c))
continue;
state = ctx->set_client_cb(ctx, c); state = ctx->set_client_cb(ctx, c);
if (state == -1) if (state == -1)
break; break;
if (state == 0) if (state == 0)
continue; continue;
cmdfn(&c->tty, ctx);
} }
cmdfn(&c->tty, ctx);
} }
} }
@ -1817,7 +1820,7 @@ tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx)
if (tty_term_has(tty->term, TTYC_RI)) if (tty_term_has(tty->term, TTYC_RI))
tty_putcode(tty, TTYC_RI); tty_putcode(tty, TTYC_RI);
else else
tty_putcode1(tty, TTYC_RIN, 1); tty_putcode_i(tty, TTYC_RIN, 1);
} }
void void
@ -1898,7 +1901,7 @@ tty_cmd_scrollup(struct tty *tty, const struct tty_ctx *ctx)
tty_cursor(tty, 0, 0); tty_cursor(tty, 0, 0);
else else
tty_cursor(tty, 0, tty->cy); tty_cursor(tty, 0, tty->cy);
tty_putcode1(tty, TTYC_INDN, ctx->num); tty_putcode_i(tty, TTYC_INDN, ctx->num);
} }
} }
@ -1929,7 +1932,7 @@ tty_cmd_scrolldown(struct tty *tty, const struct tty_ctx *ctx)
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper);
if (tty_term_has(tty->term, TTYC_RIN)) if (tty_term_has(tty->term, TTYC_RIN))
tty_putcode1(tty, TTYC_RIN, ctx->num); tty_putcode_i(tty, TTYC_RIN, ctx->num);
else { else {
for (i = 0; i < ctx->num; i++) for (i = 0; i < ctx->num; i++)
tty_putcode(tty, TTYC_RI); tty_putcode(tty, TTYC_RI);
@ -2134,7 +2137,7 @@ tty_set_selection(struct tty *tty, const char *flags, const char *buf,
b64_ntop(buf, len, encoded, size); b64_ntop(buf, len, encoded, size);
tty->flags |= TTY_NOBLOCK; tty->flags |= TTY_NOBLOCK;
tty_putcode_ptr2(tty, TTYC_MS, flags, encoded); tty_putcode_ss(tty, TTYC_MS, flags, encoded);
free(encoded); free(encoded);
} }
@ -2207,7 +2210,7 @@ tty_reset(struct tty *tty)
if (!grid_cells_equal(gc, &grid_default_cell)) { if (!grid_cells_equal(gc, &grid_default_cell)) {
if (gc->link != 0) if (gc->link != 0)
tty_putcode_ptr2(tty, TTYC_HLS, "", ""); tty_putcode_ss(tty, TTYC_HLS, "", "");
if ((gc->attr & GRID_ATTR_CHARSET) && tty_acs_needed(tty)) if ((gc->attr & GRID_ATTR_CHARSET) && tty_acs_needed(tty))
tty_putcode(tty, TTYC_RMACS); tty_putcode(tty, TTYC_RMACS);
tty_putcode(tty, TTYC_SGR0); tty_putcode(tty, TTYC_SGR0);
@ -2282,7 +2285,7 @@ tty_region(struct tty *tty, u_int rupper, u_int rlower)
tty_cursor(tty, 0, tty->cy); tty_cursor(tty, 0, tty->cy);
} }
tty_putcode2(tty, TTYC_CSR, tty->rupper, tty->rlower); tty_putcode_ii(tty, TTYC_CSR, tty->rupper, tty->rlower);
tty->cx = tty->cy = UINT_MAX; tty->cx = tty->cy = UINT_MAX;
} }
@ -2310,7 +2313,7 @@ tty_margin(struct tty *tty, u_int rleft, u_int rright)
if (tty->rleft == rleft && tty->rright == rright) if (tty->rleft == rleft && tty->rright == rright)
return; return;
tty_putcode2(tty, TTYC_CSR, tty->rupper, tty->rlower); tty_putcode_ii(tty, TTYC_CSR, tty->rupper, tty->rlower);
tty->rleft = rleft; tty->rleft = rleft;
tty->rright = rright; tty->rright = rright;
@ -2318,7 +2321,7 @@ tty_margin(struct tty *tty, u_int rleft, u_int rright)
if (rleft == 0 && rright == tty->sx - 1) if (rleft == 0 && rright == tty->sx - 1)
tty_putcode(tty, TTYC_CLMG); tty_putcode(tty, TTYC_CLMG);
else else
tty_putcode2(tty, TTYC_CMG, rleft, rright); tty_putcode_ii(tty, TTYC_CMG, rleft, rright);
tty->cx = tty->cy = UINT_MAX; tty->cx = tty->cy = UINT_MAX;
} }
@ -2428,7 +2431,7 @@ tty_cursor(struct tty *tty, u_int cx, u_int cy)
* the cursor with CUB/CUF. * the cursor with CUB/CUF.
*/ */
if ((u_int) abs(change) > cx && tty_term_has(term, TTYC_HPA)) { if ((u_int) abs(change) > cx && tty_term_has(term, TTYC_HPA)) {
tty_putcode1(tty, TTYC_HPA, cx); tty_putcode_i(tty, TTYC_HPA, cx);
goto out; goto out;
} else if (change > 0 && } else if (change > 0 &&
tty_term_has(term, TTYC_CUB) && tty_term_has(term, TTYC_CUB) &&
@ -2438,12 +2441,12 @@ tty_cursor(struct tty *tty, u_int cx, u_int cy)
tty_putcode(tty, TTYC_CUB1); tty_putcode(tty, TTYC_CUB1);
goto out; goto out;
} }
tty_putcode1(tty, TTYC_CUB, change); tty_putcode_i(tty, TTYC_CUB, change);
goto out; goto out;
} else if (change < 0 && } else if (change < 0 &&
tty_term_has(term, TTYC_CUF) && tty_term_has(term, TTYC_CUF) &&
!tty_use_margin(tty)) { !tty_use_margin(tty)) {
tty_putcode1(tty, TTYC_CUF, -change); tty_putcode_i(tty, TTYC_CUF, -change);
goto out; goto out;
} }
} else if (cx == thisx) { } else if (cx == thisx) {
@ -2476,21 +2479,21 @@ tty_cursor(struct tty *tty, u_int cx, u_int cy)
(change < 0 && cy - change > tty->rlower) || (change < 0 && cy - change > tty->rlower) ||
(change > 0 && cy - change < tty->rupper)) { (change > 0 && cy - change < tty->rupper)) {
if (tty_term_has(term, TTYC_VPA)) { if (tty_term_has(term, TTYC_VPA)) {
tty_putcode1(tty, TTYC_VPA, cy); tty_putcode_i(tty, TTYC_VPA, cy);
goto out; goto out;
} }
} else if (change > 0 && tty_term_has(term, TTYC_CUU)) { } else if (change > 0 && tty_term_has(term, TTYC_CUU)) {
tty_putcode1(tty, TTYC_CUU, change); tty_putcode_i(tty, TTYC_CUU, change);
goto out; goto out;
} else if (change < 0 && tty_term_has(term, TTYC_CUD)) { } else if (change < 0 && tty_term_has(term, TTYC_CUD)) {
tty_putcode1(tty, TTYC_CUD, -change); tty_putcode_i(tty, TTYC_CUD, -change);
goto out; goto out;
} }
} }
absolute: absolute:
/* Absolute movement. */ /* Absolute movement. */
tty_putcode2(tty, TTYC_CUP, cy, cx); tty_putcode_ii(tty, TTYC_CUP, cy, cx);
out: out:
tty->cx = cx; tty->cx = cx;
@ -2511,9 +2514,9 @@ tty_hyperlink(struct tty *tty, const struct grid_cell *gc,
return; return;
if (gc->link == 0 || !hyperlinks_get(hl, gc->link, &uri, NULL, &id)) if (gc->link == 0 || !hyperlinks_get(hl, gc->link, &uri, NULL, &id))
tty_putcode_ptr2(tty, TTYC_HLS, "", ""); tty_putcode_ss(tty, TTYC_HLS, "", "");
else else
tty_putcode_ptr2(tty, TTYC_HLS, id, uri); tty_putcode_ss(tty, TTYC_HLS, id, uri);
} }
void void
@ -2590,13 +2593,13 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc,
!tty_term_has(tty->term, TTYC_SMULX)) !tty_term_has(tty->term, TTYC_SMULX))
tty_putcode(tty, TTYC_SMUL); tty_putcode(tty, TTYC_SMUL);
else if (changed & GRID_ATTR_UNDERSCORE_2) else if (changed & GRID_ATTR_UNDERSCORE_2)
tty_putcode1(tty, TTYC_SMULX, 2); tty_putcode_i(tty, TTYC_SMULX, 2);
else if (changed & GRID_ATTR_UNDERSCORE_3) else if (changed & GRID_ATTR_UNDERSCORE_3)
tty_putcode1(tty, TTYC_SMULX, 3); tty_putcode_i(tty, TTYC_SMULX, 3);
else if (changed & GRID_ATTR_UNDERSCORE_4) else if (changed & GRID_ATTR_UNDERSCORE_4)
tty_putcode1(tty, TTYC_SMULX, 4); tty_putcode_i(tty, TTYC_SMULX, 4);
else if (changed & GRID_ATTR_UNDERSCORE_5) else if (changed & GRID_ATTR_UNDERSCORE_5)
tty_putcode1(tty, TTYC_SMULX, 5); tty_putcode_i(tty, TTYC_SMULX, 5);
} }
if (changed & GRID_ATTR_BLINK) if (changed & GRID_ATTR_BLINK)
tty_putcode(tty, TTYC_BLINK); tty_putcode(tty, TTYC_BLINK);
@ -2653,14 +2656,14 @@ tty_colours(struct tty *tty, const struct grid_cell *gc)
if (have_ax) if (have_ax)
tty_puts(tty, "\033[39m"); tty_puts(tty, "\033[39m");
else if (tc->fg != 7) else if (tc->fg != 7)
tty_putcode1(tty, TTYC_SETAF, 7); tty_putcode_i(tty, TTYC_SETAF, 7);
tc->fg = gc->fg; tc->fg = gc->fg;
} }
if (COLOUR_DEFAULT(gc->bg) && !COLOUR_DEFAULT(tc->bg)) { if (COLOUR_DEFAULT(gc->bg) && !COLOUR_DEFAULT(tc->bg)) {
if (have_ax) if (have_ax)
tty_puts(tty, "\033[49m"); tty_puts(tty, "\033[49m");
else if (tc->bg != 0) else if (tc->bg != 0)
tty_putcode1(tty, TTYC_SETAB, 0); tty_putcode_i(tty, TTYC_SETAB, 0);
tc->bg = gc->bg; tc->bg = gc->bg;
} }
} }
@ -2830,12 +2833,12 @@ tty_colours_fg(struct tty *tty, const struct grid_cell *gc)
xsnprintf(s, sizeof s, "\033[%dm", gc->fg); xsnprintf(s, sizeof s, "\033[%dm", gc->fg);
tty_puts(tty, s); tty_puts(tty, s);
} else } else
tty_putcode1(tty, TTYC_SETAF, gc->fg - 90 + 8); tty_putcode_i(tty, TTYC_SETAF, gc->fg - 90 + 8);
goto save; goto save;
} }
/* Otherwise set the foreground colour. */ /* Otherwise set the foreground colour. */
tty_putcode1(tty, TTYC_SETAF, gc->fg); tty_putcode_i(tty, TTYC_SETAF, gc->fg);
save: save:
/* Save the new values in the terminal current cell. */ /* Save the new values in the terminal current cell. */
@ -2862,12 +2865,12 @@ tty_colours_bg(struct tty *tty, const struct grid_cell *gc)
xsnprintf(s, sizeof s, "\033[%dm", gc->bg + 10); xsnprintf(s, sizeof s, "\033[%dm", gc->bg + 10);
tty_puts(tty, s); tty_puts(tty, s);
} else } else
tty_putcode1(tty, TTYC_SETAB, gc->bg - 90 + 8); tty_putcode_i(tty, TTYC_SETAB, gc->bg - 90 + 8);
goto save; goto save;
} }
/* Otherwise set the background colour. */ /* Otherwise set the background colour. */
tty_putcode1(tty, TTYC_SETAB, gc->bg); tty_putcode_i(tty, TTYC_SETAB, gc->bg);
save: save:
/* Save the new values in the terminal current cell. */ /* Save the new values in the terminal current cell. */
@ -2903,10 +2906,10 @@ tty_colours_us(struct tty *tty, const struct grid_cell *gc)
* non-RGB version may be wrong. * non-RGB version may be wrong.
*/ */
if (tty_term_has(tty->term, TTYC_SETULC)) if (tty_term_has(tty->term, TTYC_SETULC))
tty_putcode1(tty, TTYC_SETULC, c); tty_putcode_i(tty, TTYC_SETULC, c);
else if (tty_term_has(tty->term, TTYC_SETAL) && else if (tty_term_has(tty->term, TTYC_SETAL) &&
tty_term_has(tty->term, TTYC_RGB)) tty_term_has(tty->term, TTYC_RGB))
tty_putcode1(tty, TTYC_SETAL, c); tty_putcode_i(tty, TTYC_SETAL, c);
save: save:
/* Save the new values in the terminal current cell. */ /* Save the new values in the terminal current cell. */
@ -2920,18 +2923,18 @@ tty_try_colour(struct tty *tty, int colour, const char *type)
if (colour & COLOUR_FLAG_256) { if (colour & COLOUR_FLAG_256) {
if (*type == '3' && tty_term_has(tty->term, TTYC_SETAF)) if (*type == '3' && tty_term_has(tty->term, TTYC_SETAF))
tty_putcode1(tty, TTYC_SETAF, colour & 0xff); tty_putcode_i(tty, TTYC_SETAF, colour & 0xff);
else if (tty_term_has(tty->term, TTYC_SETAB)) else if (tty_term_has(tty->term, TTYC_SETAB))
tty_putcode1(tty, TTYC_SETAB, colour & 0xff); tty_putcode_i(tty, TTYC_SETAB, colour & 0xff);
return (0); return (0);
} }
if (colour & COLOUR_FLAG_RGB) { if (colour & COLOUR_FLAG_RGB) {
colour_split_rgb(colour & 0xffffff, &r, &g, &b); colour_split_rgb(colour & 0xffffff, &r, &g, &b);
if (*type == '3' && tty_term_has(tty->term, TTYC_SETRGBF)) if (*type == '3' && tty_term_has(tty->term, TTYC_SETRGBF))
tty_putcode3(tty, TTYC_SETRGBF, r, g, b); tty_putcode_iii(tty, TTYC_SETRGBF, r, g, b);
else if (tty_term_has(tty->term, TTYC_SETRGBB)) else if (tty_term_has(tty->term, TTYC_SETRGBB))
tty_putcode3(tty, TTYC_SETRGBB, r, g, b); tty_putcode_iii(tty, TTYC_SETRGBB, r, g, b);
return (0); return (0);
} }
@ -3015,7 +3018,7 @@ tty_clipboard_query(struct tty *tty)
if ((~tty->flags & TTY_STARTED) || (tty->flags & TTY_OSC52QUERY)) if ((~tty->flags & TTY_STARTED) || (tty->flags & TTY_OSC52QUERY))
return; return;
tty_putcode_ptr2(tty, TTYC_MS, "", "?"); tty_putcode_ss(tty, TTYC_MS, "", "?");
tty->flags |= TTY_OSC52QUERY; tty->flags |= TTY_OSC52QUERY;
evtimer_set(&tty->clipboard_timer, tty_clipboard_query_callback, tty); evtimer_set(&tty->clipboard_timer, tty_clipboard_query_callback, tty);

View File

@ -1130,6 +1130,7 @@ window_pane_reset_mode(struct window_pane *wp)
next = TAILQ_FIRST(&wp->modes); next = TAILQ_FIRST(&wp->modes);
if (next == NULL) { if (next == NULL) {
wp->flags &= ~PANE_UNSEENCHANGES;
log_debug("%s: no next mode", __func__); log_debug("%s: no next mode", __func__);
wp->screen = &wp->base; wp->screen = &wp->base;
} else { } else {