mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-08 21:44:39 +02:00
Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders copy-buffer useless and makes buffer-limit now a server option. By Tiago Cunha.
This commit is contained in:
@ -30,7 +30,7 @@ int cmd_set_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||
|
||||
const struct cmd_entry cmd_set_buffer_entry = {
|
||||
"set-buffer", "setb",
|
||||
CMD_BUFFER_SESSION_USAGE " data",
|
||||
CMD_BUFFER_USAGE " data",
|
||||
CMD_ARG1, "",
|
||||
cmd_buffer_init,
|
||||
cmd_buffer_parse,
|
||||
@ -43,23 +43,20 @@ int
|
||||
cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
{
|
||||
struct cmd_buffer_data *data = self->data;
|
||||
struct session *s;
|
||||
u_int limit;
|
||||
char *pdata;
|
||||
size_t psize;
|
||||
|
||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
||||
return (-1);
|
||||
limit = options_get_number(&s->options, "buffer-limit");
|
||||
limit = options_get_number(&global_options, "buffer-limit");
|
||||
|
||||
pdata = xstrdup(data->arg);
|
||||
psize = strlen(pdata);
|
||||
|
||||
if (data->buffer == -1) {
|
||||
paste_add(&s->buffers, pdata, psize, limit);
|
||||
paste_add(&global_buffers, pdata, psize, limit);
|
||||
return (0);
|
||||
}
|
||||
if (paste_replace(&s->buffers, data->buffer, pdata, psize) != 0) {
|
||||
if (paste_replace(&global_buffers, data->buffer, pdata, psize) != 0) {
|
||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
||||
xfree(pdata);
|
||||
return (-1);
|
||||
|
Reference in New Issue
Block a user