mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 01:48:47 +00:00
buffer-limit option.
This commit is contained in:
parent
ef1c1d5753
commit
3128de3f19
3
CHANGES
3
CHANGES
@ -1,5 +1,6 @@
|
|||||||
20 June 2008
|
20 June 2008
|
||||||
|
|
||||||
|
* buffer-limit option to set maximum size of buffer stack. Default is 9.
|
||||||
* Initial buffer improvements. Each session has a stack of buffers and each
|
* Initial buffer improvements. Each session has a stack of buffers and each
|
||||||
buffer command takes a -b option to manipulate items on the stack. If -b
|
buffer command takes a -b option to manipulate items on the stack. If -b
|
||||||
is omitted, the top entry is used. The following commands are currently
|
is omitted, the top entry is used. The following commands are currently
|
||||||
@ -528,4 +529,4 @@
|
|||||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||||
customisation.
|
customisation.
|
||||||
|
|
||||||
$Id: CHANGES,v 1.131 2008-06-20 17:31:48 nicm Exp $
|
$Id: CHANGES,v 1.132 2008-06-20 18:45:35 nicm Exp $
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-buffer.c,v 1.1 2008-06-20 08:36:20 nicm Exp $ */
|
/* $Id: cmd-set-buffer.c,v 1.2 2008-06-20 18:45:35 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -47,12 +47,14 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
{
|
{
|
||||||
struct cmd_buffer_data *data = self->data;
|
struct cmd_buffer_data *data = self->data;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
u_int limit;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
if ((s = cmd_find_session(ctx, data->target)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
limit = options_get_number(&s->options, "buffer-limit");
|
||||||
if (data->buffer == -1)
|
if (data->buffer == -1)
|
||||||
paste_add(&s->buffers, data->arg);
|
paste_add(&s->buffers, data->arg, limit);
|
||||||
else {
|
else {
|
||||||
if (paste_replace(&s->buffers, data->buffer, data->arg) != 0)
|
if (paste_replace(&s->buffers, data->buffer, data->arg) != 0)
|
||||||
ctx->error(ctx, "no buffer %d", data->buffer);
|
ctx->error(ctx, "no buffer %d", data->buffer);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-option.c,v 1.33 2008-06-19 23:20:45 nicm Exp $ */
|
/* $Id: cmd-set-option.c,v 1.34 2008-06-20 18:45:35 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -250,6 +250,24 @@ cmd_set_option_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
options_set_number(oo, "display-time", number);
|
options_set_number(oo, "display-time", number);
|
||||||
|
} else if (strcmp(data->option, "buffer-limit") == 0) {
|
||||||
|
if (data->value == NULL || number == -1) {
|
||||||
|
ctx->error(ctx, "invalid value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (errstr != NULL) {
|
||||||
|
ctx->error(ctx, "buffer-limit %s", errstr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (number == 0) {
|
||||||
|
ctx->error(ctx, "zero buffer-limit");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (number > INT_MAX) {
|
||||||
|
ctx->error(ctx, "buffer-limit too big: %u", number);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
options_set_number(oo, "buffer-limit", number);
|
||||||
} else if (strcmp(data->option, "status-left") == 0) {
|
} else if (strcmp(data->option, "status-left") == 0) {
|
||||||
if (data->value == NULL) {
|
if (data->value == NULL) {
|
||||||
ctx->error(ctx, "invalid value");
|
ctx->error(ctx, "invalid value");
|
||||||
|
7
paste.c
7
paste.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: paste.c,v 1.2 2008-06-20 17:31:48 nicm Exp $ */
|
/* $Id: paste.c,v 1.3 2008-06-20 18:45:35 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -97,10 +97,13 @@ paste_free_index(struct paste_stack *ps, u_int idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
paste_add(struct paste_stack *ps, const char *data)
|
paste_add(struct paste_stack *ps, const char *data, u_int limit)
|
||||||
{
|
{
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
|
|
||||||
|
while (ARRAY_LENGTH(ps) >= limit)
|
||||||
|
ARRAY_TRUNC(ps, 1);
|
||||||
|
|
||||||
pb = xmalloc(sizeof *pb);
|
pb = xmalloc(sizeof *pb);
|
||||||
ARRAY_INSERT(ps, 0, pb);
|
ARRAY_INSERT(ps, 0, pb);
|
||||||
|
|
||||||
|
3
tmux.c
3
tmux.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.c,v 1.65 2008-06-20 17:31:48 nicm Exp $ */
|
/* $Id: tmux.c,v 1.66 2008-06-20 18:45:35 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -220,6 +220,7 @@ main(int argc, char **argv)
|
|||||||
&global_options, "status-right", "%%H:%%M %%d-%%b-%%y");
|
&global_options, "status-right", "%%H:%%M %%d-%%b-%%y");
|
||||||
options_set_number(&global_options, "status-interval", 15);
|
options_set_number(&global_options, "status-interval", 15);
|
||||||
options_set_number(&global_options, "set-titles", 1);
|
options_set_number(&global_options, "set-titles", 1);
|
||||||
|
options_set_number(&global_options, "buffer-limit", 9);
|
||||||
|
|
||||||
if (cfg_file == NULL) {
|
if (cfg_file == NULL) {
|
||||||
home = getenv("HOME");
|
home = getenv("HOME");
|
||||||
|
4
tmux.h
4
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.158 2008-06-20 17:31:48 nicm Exp $ */
|
/* $Id: tmux.h,v 1.159 2008-06-20 18:45:35 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -875,7 +875,7 @@ struct paste_buffer *paste_get_top(struct paste_stack *);
|
|||||||
struct paste_buffer *paste_get_index(struct paste_stack *, u_int);
|
struct paste_buffer *paste_get_index(struct paste_stack *, u_int);
|
||||||
int paste_free_top(struct paste_stack *);
|
int paste_free_top(struct paste_stack *);
|
||||||
int paste_free_index(struct paste_stack *, u_int);
|
int paste_free_index(struct paste_stack *, u_int);
|
||||||
void paste_add(struct paste_stack *, const char *);
|
void paste_add(struct paste_stack *, const char *, u_int);
|
||||||
int paste_replace(struct paste_stack *, u_int, const char *);
|
int paste_replace(struct paste_stack *, u_int, const char *);
|
||||||
|
|
||||||
/* arg.c */
|
/* arg.c */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: window-copy.c,v 1.20 2008-06-20 17:31:48 nicm Exp $ */
|
/* $Id: window-copy.c,v 1.21 2008-06-20 18:45:35 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -362,7 +362,7 @@ window_copy_copy_selection(struct window *w, struct client *c)
|
|||||||
struct screen *s = &data->screen;
|
struct screen *s = &data->screen;
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t len, off;
|
size_t len, off;
|
||||||
u_int i, xx, yy, sx, sy, ex, ey;
|
u_int i, xx, yy, sx, sy, ex, ey, limit;
|
||||||
|
|
||||||
if (!s->sel.flag)
|
if (!s->sel.flag)
|
||||||
return;
|
return;
|
||||||
@ -415,7 +415,8 @@ window_copy_copy_selection(struct window *w, struct client *c)
|
|||||||
buf[off - 1] = '\0';
|
buf[off - 1] = '\0';
|
||||||
|
|
||||||
/* Add the buffer to the stack. */
|
/* Add the buffer to the stack. */
|
||||||
paste_add(&c->session->buffers, buf);
|
limit = options_get_number(&c->session->options, "buffer-limit");
|
||||||
|
paste_add(&c->session->buffers, buf, limit);
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user