Move struct paste_buffer out of tmux.h.

This commit is contained in:
nicm
2015-08-29 09:25:00 +00:00
parent b9f0571780
commit b569585000
9 changed files with 108 additions and 88 deletions

34
paste.c
View File

@ -30,6 +30,18 @@
* string!
*/
struct paste_buffer {
char *data;
size_t size;
char *name;
int automatic;
u_int order;
RB_ENTRY(paste_buffer) name_entry;
RB_ENTRY(paste_buffer) time_entry;
};
u_int paste_next_index;
u_int paste_next_order;
u_int paste_num_automatic;
@ -60,6 +72,22 @@ paste_cmp_times(const struct paste_buffer *a, const struct paste_buffer *b)
return (0);
}
/* Get paste buffer name. */
const char *
paste_buffer_name(struct paste_buffer *pb)
{
return (pb->name);
}
/* Get paste buffer data. */
const char *
paste_buffer_data(struct paste_buffer *pb, size_t *size)
{
if (size != NULL)
*size = pb->size;
return (pb->data);
}
/* Walk paste buffers by name. */
struct paste_buffer *
paste_walk(struct paste_buffer *pb)
@ -71,13 +99,15 @@ paste_walk(struct paste_buffer *pb)
/* Get the most recent automatic buffer. */
struct paste_buffer *
paste_get_top(void)
paste_get_top(const char **name)
{
struct paste_buffer *pb;
pb = RB_MIN(paste_time_tree, &paste_by_time);
if (pb == NULL)
return (NULL);
if (name != NULL)
*name = pb->name;
return (pb);
}
@ -87,7 +117,7 @@ paste_free_top(void)
{
struct paste_buffer *pb;
pb = paste_get_top();
pb = paste_get_top(NULL);
if (pb == NULL)
return (-1);
return (paste_free_name(pb->name));