diff --git a/paste.c b/paste.c index f5702438..94fca0ed 100644 --- a/paste.c +++ b/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); diff --git a/tmux.h b/tmux.h index 46e35aab..ba8a5019 100644 --- a/tmux.h +++ b/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 **);