mirror of
https://github.com/tmux/tmux.git
synced 2024-12-12 17:38:48 +00:00
Keep buffer creation time and add accessors for it and the order number.
This commit is contained in:
parent
b4f95c43fc
commit
4117a7ed19
21
paste.c
21
paste.c
@ -35,6 +35,7 @@ struct paste_buffer {
|
||||
size_t size;
|
||||
|
||||
char *name;
|
||||
time_t created;
|
||||
int automatic;
|
||||
u_int order;
|
||||
|
||||
@ -79,6 +80,20 @@ paste_buffer_name(struct paste_buffer *pb)
|
||||
return (pb->name);
|
||||
}
|
||||
|
||||
/* Get paste buffer order. */
|
||||
u_int
|
||||
paste_buffer_order(struct paste_buffer *pb)
|
||||
{
|
||||
return (pb->order);
|
||||
}
|
||||
|
||||
/* Get paste buffer created. */
|
||||
time_t
|
||||
paste_buffer_created(struct paste_buffer *pb)
|
||||
{
|
||||
return (pb->created);
|
||||
}
|
||||
|
||||
/* Get paste buffer data. */
|
||||
const char *
|
||||
paste_buffer_data(struct paste_buffer *pb, size_t *size)
|
||||
@ -88,7 +103,7 @@ paste_buffer_data(struct paste_buffer *pb, size_t *size)
|
||||
return (pb->data);
|
||||
}
|
||||
|
||||
/* Walk paste buffers by name. */
|
||||
/* Walk paste buffers by time. */
|
||||
struct paste_buffer *
|
||||
paste_walk(struct paste_buffer *pb)
|
||||
{
|
||||
@ -174,6 +189,8 @@ paste_add(char *data, size_t size)
|
||||
pb->automatic = 1;
|
||||
paste_num_automatic++;
|
||||
|
||||
pb->created = time(NULL);
|
||||
|
||||
pb->order = paste_next_order++;
|
||||
RB_INSERT(paste_name_tree, &paste_by_name, pb);
|
||||
RB_INSERT(paste_time_tree, &paste_by_time, pb);
|
||||
@ -264,6 +281,8 @@ paste_set(char *data, size_t size, const char *name, char **cause)
|
||||
pb->automatic = 0;
|
||||
pb->order = paste_next_order++;
|
||||
|
||||
pb->created = time(NULL);
|
||||
|
||||
if ((old = paste_get_name(name)) != NULL)
|
||||
paste_free(old);
|
||||
|
||||
|
2
tmux.h
2
tmux.h
@ -1587,6 +1587,8 @@ void cfg_show_causes(struct session *);
|
||||
/* paste.c */
|
||||
struct paste_buffer;
|
||||
const char *paste_buffer_name(struct paste_buffer *);
|
||||
u_int paste_buffer_order(struct paste_buffer *);
|
||||
time_t paste_buffer_created(struct paste_buffer *);
|
||||
const char *paste_buffer_data(struct paste_buffer *, size_t *);
|
||||
struct paste_buffer *paste_walk(struct paste_buffer *);
|
||||
struct paste_buffer *paste_get_top(const char **);
|
||||
|
Loading…
Reference in New Issue
Block a user