Merge branch 'obsd-master'

pull/2195/head
Thomas Adam 2020-04-20 17:43:20 +01:00
commit 32c3fe40eb
9 changed files with 67 additions and 45 deletions

View File

@ -458,7 +458,6 @@ screen_redraw_screen(struct client *c)
}
tty_reset(&c->tty);
tty_sync_end(&c->tty);
}
/* Redraw a single pane. */
@ -476,7 +475,6 @@ screen_redraw_pane(struct client *c, struct window_pane *wp)
screen_redraw_draw_pane(&ctx, wp);
tty_reset(&c->tty);
tty_sync_end(&c->tty);
}
/* Draw a border cell. */

View File

@ -118,8 +118,9 @@ screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx,
ttyctx->orlower = s->rlower;
ttyctx->orupper = s->rupper;
if (sync && !ctx->sync && ttyctx->wp != NULL) {
log_debug("%s: starting sync", __func__);
if (ctx->wp != NULL &&
!ctx->sync &&
(sync || ctx->wp != ctx->wp->window->active)) {
tty_write(tty_cmd_syncstart, ttyctx);
ctx->sync = 1;
}
@ -184,8 +185,6 @@ screen_write_start(struct screen_write_ctx *ctx, struct window_pane *wp,
void
screen_write_stop(struct screen_write_ctx *ctx)
{
struct tty_ctx ttyctx;
screen_write_collect_end(ctx);
screen_write_collect_flush(ctx, 0, __func__);
@ -196,12 +195,6 @@ screen_write_stop(struct screen_write_ctx *ctx)
ctx->wp->skipped += ctx->skipped;
}
if (ctx->sync) {
screen_write_initctx(ctx, &ttyctx, 0);
tty_write(tty_cmd_syncend, &ttyctx);
log_debug("%s: ending sync", __func__);
}
free(ctx->item);
}

View File

@ -1539,7 +1539,7 @@ server_client_reset_state(struct client *c)
struct window_pane *wp = w->active, *loop;
struct screen *s;
struct options *oo = c->session->options;
int mode, cursor;
int mode, cursor, flags;
u_int cx = 0, cy = 0, ox, oy, sx, sy;
if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED))
@ -1604,6 +1604,16 @@ server_client_reset_state(struct client *c)
/* Set the terminal mode and reset attributes. */
tty_update_mode(&c->tty, mode, s);
tty_reset(&c->tty);
/*
* All writing must be done, send a sync end (if it was started). It
* may have been started by redrawing so needs to go out even if the
* block flag is set.
*/
flags = (c->tty.flags & TTY_BLOCK);
c->tty.flags &= ~TTY_BLOCK;
tty_sync_end(&c->tty);
c->tty.flags |= flags;
}
/* Repeat time callback. */

2
tmux.1
View File

@ -5534,7 +5534,7 @@ The server crashed or otherwise exited without telling the client the reason.
.Sh TERMINFO EXTENSIONS
.Nm
understands some unofficial extensions to
.Xr terminfo 5.
.Xr terminfo 5 .
It is not normally necessary to set these manually, instead the
.Ic terminal-features
option should be used.

4
tmux.h
View File

@ -1994,12 +1994,12 @@ void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *);
void tty_cmd_setselection(struct tty *, const struct tty_ctx *);
void tty_cmd_rawstring(struct tty *, const struct tty_ctx *);
void tty_cmd_syncstart(struct tty *, const struct tty_ctx *);
void tty_cmd_syncend(struct tty *, const struct tty_ctx *);
/* tty-term.c */
extern struct tty_terms tty_terms;
u_int tty_term_ncodes(void);
void tty_term_apply(struct tty_term *, const char *, int);
void tty_term_apply_overrides(struct tty_term *);
struct tty_term *tty_term_create(struct tty *, char *, int *, int, char **);
void tty_term_free(struct tty_term *);
int tty_term_has(struct tty_term *, enum tty_code_code);
@ -2020,7 +2020,7 @@ const char *tty_term_describe(struct tty_term *, enum tty_code_code);
/* tty-features.c */
void tty_add_features(int *, const char *, const char *);
const char *tty_get_features(int);
void tty_apply_features(struct tty_term *, int);
int tty_apply_features(struct tty_term *, int);
/* tty-acs.c */
int tty_acs_needed(struct tty *);

View File

@ -232,7 +232,7 @@ tty_get_features(int feat)
return (s);
}
void
int
tty_apply_features(struct tty_term *term, int feat)
{
const struct tty_feature *tf;
@ -240,7 +240,7 @@ tty_apply_features(struct tty_term *term, int feat)
u_int i;
if (feat == 0)
return;
return (0);
log_debug("applying terminal features: %s", tty_get_features(feat));
for (i = 0; i < nitems(tty_features); i++) {
@ -259,5 +259,8 @@ tty_apply_features(struct tty_term *term, int feat)
}
term->flags |= tf->flags;
}
if ((term->features | feat) == term->features)
return (0);
term->features |= feat;
return (1);
}

View File

@ -1150,7 +1150,7 @@ tty_keys_device_status_report(struct tty *tty, const char *buf, size_t len,
"cstyle,"
"margins,"
"sync,"
"title,",
"title",
",");
} else if (strncmp(tmp, "TMUX ", 5) == 0) {
tty_add_features(&c->term_features,

View File

@ -413,6 +413,30 @@ tty_term_apply(struct tty_term *term, const char *capabilities, int quiet)
}
}
void
tty_term_apply_overrides(struct tty_term *term)
{
struct options_entry *o;
struct options_array_item *a;
union options_value *ov;
const char *s;
size_t offset;
char *first;
o = options_get_only(global_options, "terminal-overrides");
a = options_array_first(o);
while (a != NULL) {
ov = options_array_item_value(a);
s = ov->string;
offset = 0;
first = tty_term_override_next(s, &offset);
if (first != NULL && fnmatch(first, term->name, 0) == 0)
tty_term_apply(term, s + offset, 0);
a = options_array_next(a);
}
}
struct tty_term *
tty_term_create(struct tty *tty, char *name, int *feat, int fd, char **cause)
{
@ -504,20 +528,6 @@ tty_term_create(struct tty *tty, char *name, int *feat, int fd, char **cause)
a = options_array_next(a);
}
/* Apply terminal overrides. */
o = options_get_only(global_options, "terminal-overrides");
a = options_array_first(o);
while (a != NULL) {
ov = options_array_item_value(a);
s = ov->string;
offset = 0;
first = tty_term_override_next(s, &offset);
if (first != NULL && fnmatch(first, term->name, 0) == 0)
tty_term_apply(term, s + offset, 0);
a = options_array_next(a);
}
/* Delete curses data. */
#if !defined(NCURSES_VERSION_MAJOR) || NCURSES_VERSION_MAJOR > 5 || \
(NCURSES_VERSION_MAJOR == 5 && NCURSES_VERSION_MINOR > 6)
@ -550,8 +560,9 @@ tty_term_create(struct tty *tty, char *name, int *feat, int fd, char **cause)
if (tty_term_flag(term, TTYC_XT))
tty_add_features(feat, "title", ":,");
/* Apply the features. */
/* Apply the features and overrides. */
tty_apply_features(term, *feat);
tty_term_apply_overrides(term);
/*
* Terminals without xenl (eat newline glitch) wrap at at $COLUMNS - 1

29
tty.c
View File

@ -469,7 +469,8 @@ tty_update_features(struct tty *tty)
{
struct client *c = tty->client;
tty_apply_features(tty->term, c->term_features);
if (tty_apply_features(tty->term, c->term_features))
tty_term_apply_overrides(tty->term);
if (tty_use_margin(tty))
tty_puts(tty, "\033[?69h"); /* DECLRMM */
@ -1427,18 +1428,30 @@ tty_draw_line(struct tty *tty, struct window_pane *wp, struct screen *s,
void
tty_sync_start(struct tty *tty)
{
if ((~tty->flags & TTY_SYNCING) && tty_term_has(tty->term, TTYC_SYNC)) {
if (tty->flags & TTY_BLOCK)
return;
if (tty->flags & TTY_SYNCING)
return;
tty->flags |= TTY_SYNCING;
if (tty_term_has(tty->term, TTYC_SYNC)) {
log_debug("%s sync start", tty->client->name);
tty_putcode1(tty, TTYC_SYNC, 1);
tty->flags |= TTY_SYNCING;
}
}
void
tty_sync_end(struct tty *tty)
{
if ((tty->flags & TTY_SYNCING) && tty_term_has(tty->term, TTYC_SYNC)) {
if (tty->flags & TTY_BLOCK)
return;
if (~tty->flags & TTY_SYNCING)
return;
tty->flags &= ~TTY_SYNCING;
if (tty_term_has(tty->term, TTYC_SYNC)) {
log_debug("%s sync end", tty->client->name);
tty_putcode1(tty, TTYC_SYNC, 2);
tty->flags &= ~TTY_SYNCING;
}
}
@ -1952,12 +1965,6 @@ tty_cmd_syncstart(struct tty *tty, __unused const struct tty_ctx *ctx)
tty_sync_start(tty);
}
void
tty_cmd_syncend(struct tty *tty, __unused const struct tty_ctx *ctx)
{
tty_sync_end(tty);
}
static void
tty_cell(struct tty *tty, const struct grid_cell *gc, struct window_pane *wp)
{