aboutsummaryrefslogtreecommitdiff
path: root/status.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2018-08-29 13:02:38 +0100
committerThomas Adam <thomas@xteddy.org>2018-08-29 13:02:38 +0100
commitb29028a914ba1c99a93fa51bc9a88b3d7b47dd09 (patch)
tree233c0f9bd8fef12823351b98a7f54b2fe5e623ae /status.c
parent1ea17a72f0d921c6630ce1cf06b470c2c5e9e994 (diff)
parentf57aa143c162679555c4713ca94b7f2c60aa6bf4 (diff)
downloadrtmux-b29028a914ba1c99a93fa51bc9a88b3d7b47dd09.tar.gz
rtmux-b29028a914ba1c99a93fa51bc9a88b3d7b47dd09.tar.bz2
rtmux-b29028a914ba1c99a93fa51bc9a88b3d7b47dd09.zip
Merge branch 'obsd-master'
Diffstat (limited to 'status.c')
-rw-r--r--status.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/status.c b/status.c
index dbece902..211da9fc 100644
--- a/status.c
+++ b/status.c
@@ -766,6 +766,9 @@ status_prompt_clear(struct client *c)
free(c->prompt_buffer);
c->prompt_buffer = NULL;
+ free(c->prompt_saved);
+ c->prompt_saved = NULL;
+
c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_ALLREDRAWFLAGS; /* was frozen and may have changed */
@@ -1217,6 +1220,12 @@ process_key:
}
}
+ free(c->prompt_saved);
+ c->prompt_saved = xcalloc(sizeof *c->prompt_buffer,
+ (c->prompt_index - idx) + 1);
+ memcpy(c->prompt_saved, c->prompt_buffer + idx,
+ (c->prompt_index - idx) * sizeof *c->prompt_buffer);
+
memmove(c->prompt_buffer + idx,
c->prompt_buffer + c->prompt_index,
(size + 1 - c->prompt_index) *
@@ -1290,22 +1299,28 @@ process_key:
c->prompt_index = utf8_strlen(c->prompt_buffer);
goto changed;
case '\031': /* C-y */
- if ((pb = paste_get_top(NULL)) == NULL)
- break;
- bufdata = paste_buffer_data(pb, &bufsize);
- for (n = 0; n < bufsize; n++) {
- ch = (u_char)bufdata[n];
- if (ch < 32 || ch >= 127)
+ if (c->prompt_saved != NULL) {
+ ud = c->prompt_saved;
+ n = utf8_strlen(c->prompt_saved);
+ } else {
+ if ((pb = paste_get_top(NULL)) == NULL)
break;
+ bufdata = paste_buffer_data(pb, &bufsize);
+ for (n = 0; n < bufsize; n++) {
+ ch = (u_char)bufdata[n];
+ if (ch < 32 || ch >= 127)
+ break;
+ }
+ ud = xreallocarray(NULL, n, sizeof *ud);
+ for (idx = 0; idx < n; idx++)
+ utf8_set(&ud[idx], bufdata[idx]);
}
c->prompt_buffer = xreallocarray(c->prompt_buffer, size + n + 1,
sizeof *c->prompt_buffer);
if (c->prompt_index == size) {
- for (idx = 0; idx < n; idx++) {
- ud = &c->prompt_buffer[c->prompt_index + idx];
- utf8_set(ud, bufdata[idx]);
- }
+ memcpy(c->prompt_buffer + c->prompt_index, ud,
+ n * sizeof *c->prompt_buffer);
c->prompt_index += n;
c->prompt_buffer[c->prompt_index].size = 0;
} else {
@@ -1313,12 +1328,13 @@ process_key:
c->prompt_buffer + c->prompt_index,
(size + 1 - c->prompt_index) *
sizeof *c->prompt_buffer);
- for (idx = 0; idx < n; idx++) {
- ud = &c->prompt_buffer[c->prompt_index + idx];
- utf8_set(ud, bufdata[idx]);
- }
+ memcpy(c->prompt_buffer + c->prompt_index, ud,
+ n * sizeof *c->prompt_buffer);
c->prompt_index += n;
}
+
+ if (ud != c->prompt_saved)
+ free(ud);
goto changed;
case '\024': /* C-t */
idx = c->prompt_index;