diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2014-03-08 08:53:48 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2014-03-08 08:53:48 +0000 |
commit | 9880114aff0b48649f00266125da1dc3c94a70eb (patch) | |
tree | f8fc1b339163f4f44ee015e5267e7d330dace681 /cmd-set-buffer.c | |
parent | 3625bcba24b2cfeaa2c3d1728933dcc9c04ff4bc (diff) | |
download | rtmux-9880114aff0b48649f00266125da1dc3c94a70eb.tar.gz rtmux-9880114aff0b48649f00266125da1dc3c94a70eb.tar.bz2 rtmux-9880114aff0b48649f00266125da1dc3c94a70eb.zip |
Make -a append to top buffer if -b is not specified.
Diffstat (limited to 'cmd-set-buffer.c')
-rw-r--r-- | cmd-set-buffer.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/cmd-set-buffer.c b/cmd-set-buffer.c index 30a137cd..0e754bb6 100644 --- a/cmd-set-buffer.c +++ b/cmd-set-buffer.c @@ -53,6 +53,9 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq) psize = 0; pdata = NULL; + pb = NULL; + buffer = -1; + if (args_has(args, 'b')) { buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); if (cause != NULL) { @@ -65,13 +68,17 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq) cmdq_error(cmdq, "no buffer %d", buffer); return (CMD_RETURN_ERROR); } - if (args_has(args, 'a')) { - psize = pb->size; - pdata = xmalloc(psize); - memcpy(pdata, pb->data, psize); - } - } else - buffer = -1; + } else if (args_has(args, 'a')) { + pb = paste_get_top(&global_buffers); + if (pb != NULL) + buffer = 0; + } + + if (args_has(args, 'a') && pb != NULL) { + psize = pb->size; + pdata = xmalloc(psize); + memcpy(pdata, pb->data, psize); + } newsize = strlen(args->argv[0]); |