summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2021-12-10 12:42:38 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2021-12-10 12:42:38 +0000
commit6dcdf69b56cb86669e15c34a15a3a431e1887062 (patch)
treed16bb0bee60e78f8d29760b4e1b2f98c47543e48 /usr.bin
parent3bdee03f66e9f8b6991895b6bcb07d5d9ce0bc29 (diff)
Add a NOBLOCK flag rather than adding amount to wait for when
dealing with potentially-long sequences. GitHub issue 3001.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/tmux.h4
-rw-r--r--usr.bin/tmux/tty.c10
2 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index ec0fb684011..03853e75f95 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.1155 2021/11/15 10:58:13 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1156 2021/12/10 12:42:37 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1311,7 +1311,7 @@ struct tty {
#define TTY_NOCURSOR 0x1
#define TTY_FREEZE 0x2
#define TTY_TIMER 0x4
-/* 0x8 unused */
+#define TTY_NOBLOCK 0x8
#define TTY_STARTED 0x10
#define TTY_OPENED 0x20
/* 0x40 unused */
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index f67e9c5bf83..d43097d52d4 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.413 2021/12/06 10:08:42 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.414 2021/12/10 12:42:37 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -206,6 +206,11 @@ tty_block_maybe(struct tty *tty)
size_t size = EVBUFFER_LENGTH(tty->out);
struct timeval tv = { .tv_usec = TTY_BLOCK_INTERVAL };
+ if (size == 0)
+ tty->flags &= ~TTY_NOBLOCK;
+ else if (tty->flags & TTY_NOBLOCK)
+ return (0);
+
if (size < TTY_BLOCK_START(tty))
return (0);
@@ -2088,8 +2093,8 @@ tty_set_selection(struct tty *tty, const char *buf, size_t len)
encoded = xmalloc(size);
b64_ntop(buf, len, encoded, size);
+ tty->flags |= TTY_NOBLOCK;
tty_putcode_ptr2(tty, TTYC_MS, "", encoded);
- tty->client->redraw = EVBUFFER_LENGTH(tty->out);
free(encoded);
}
@@ -2097,6 +2102,7 @@ tty_set_selection(struct tty *tty, const char *buf, size_t len)
void
tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx)
{
+ tty->flags |= TTY_NOBLOCK;
tty_add(tty, ctx->ptr, ctx->num);
tty_invalidate(tty);
}