mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
Add an argument to copy commands to set the prefix for the buffer name,
allows buffers for different sessions to be named separately.
This commit is contained in:
9
paste.c
9
paste.c
@ -158,11 +158,14 @@ paste_free(struct paste_buffer *pb)
|
||||
* that the caller is responsible for allocating data.
|
||||
*/
|
||||
void
|
||||
paste_add(char *data, size_t size)
|
||||
paste_add(const char *prefix, char *data, size_t size)
|
||||
{
|
||||
struct paste_buffer *pb, *pb1;
|
||||
u_int limit;
|
||||
|
||||
if (prefix == NULL)
|
||||
prefix = "buffer";
|
||||
|
||||
if (size == 0) {
|
||||
free(data);
|
||||
return;
|
||||
@ -181,7 +184,7 @@ paste_add(char *data, size_t size)
|
||||
pb->name = NULL;
|
||||
do {
|
||||
free(pb->name);
|
||||
xasprintf(&pb->name, "buffer%04u", paste_next_index);
|
||||
xasprintf(&pb->name, "%s%u", prefix, paste_next_index);
|
||||
paste_next_index++;
|
||||
} while (paste_get_name(pb->name) != NULL);
|
||||
|
||||
@ -263,7 +266,7 @@ paste_set(char *data, size_t size, const char *name, char **cause)
|
||||
return (0);
|
||||
}
|
||||
if (name == NULL) {
|
||||
paste_add(data, size);
|
||||
paste_add(NULL, data, size);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user