Add pane_tags format to format_window_pane based on code from George Nachman.

This commit is contained in:
Nicholas Marriott 2013-02-23 13:02:52 +00:00
parent 1994ae4640
commit 5f904aa350
2 changed files with 29 additions and 2 deletions

View File

@ -32,8 +32,9 @@
* string. * string.
*/ */
int format_replace(struct format_tree *, int format_replace(struct format_tree *, const char *, size_t, char **,
const char *, size_t, char **, size_t *, size_t *); size_t *, size_t *);
void format_window_pane_tabs(struct format_tree *, struct window_pane *);
/* Format key-value replacement entry. */ /* Format key-value replacement entry. */
RB_GENERATE(format_tree, format_entry, entry, format_cmp); RB_GENERATE(format_tree, format_entry, entry, format_cmp);
@ -367,6 +368,28 @@ format_winlink(struct format_tree *ft, struct session *s, struct winlink *wl)
free(layout); free(layout);
} }
/* Add window pane tabs. */
void
format_window_pane_tabs(struct format_tree *ft, struct window_pane *wp)
{
struct evbuffer *buffer;
u_int i;
buffer = evbuffer_new();
for (i = 0; i < wp->base.grid->sx; i++) {
if (!bit_test(wp->base.tabs, i))
continue;
if (EVBUFFER_LENGTH(buffer) > 0)
evbuffer_add(buffer, ",", 1);
evbuffer_add_printf(buffer, "%d", i);
}
format_add(ft, "pane_tabs", "%.*s", (int) EVBUFFER_LENGTH(buffer),
EVBUFFER_DATA(buffer));
evbuffer_free(buffer);
}
/* Set default format keys for a window pane. */ /* Set default format keys for a window pane. */
void void
format_window_pane(struct format_tree *ft, struct window_pane *wp) format_window_pane(struct format_tree *ft, struct window_pane *wp)
@ -444,8 +467,11 @@ format_window_pane(struct format_tree *ft, struct window_pane *wp)
!!(wp->base.mode & MODE_MOUSE_ANY)); !!(wp->base.mode & MODE_MOUSE_ANY));
format_add(ft, "mouse_utf8_flag", "%d", format_add(ft, "mouse_utf8_flag", "%d",
!!(wp->base.mode & MODE_MOUSE_UTF8)); !!(wp->base.mode & MODE_MOUSE_UTF8));
format_window_pane_tabs(ft, wp);
} }
/* Set default format keys for paste buffer. */
void void
format_paste_buffer(struct format_tree *ft, struct paste_buffer *pb) format_paste_buffer(struct format_tree *ft, struct paste_buffer *pb)
{ {

1
tmux.1
View File

@ -3037,6 +3037,7 @@ The following variables are available, where appropriate:
.It Li "pane_pid" Ta "PID of first process in pane" .It Li "pane_pid" Ta "PID of first process in pane"
.It Li "pane_start_command" Ta "Command pane started with" .It Li "pane_start_command" Ta "Command pane started with"
.It Li "pane_start_path" Ta "Path pane started with" .It Li "pane_start_path" Ta "Path pane started with"
.It Li "pane_tabs" Ta "Pane tab positions"
.It Li "pane_title" Ta "Title of pane" .It Li "pane_title" Ta "Title of pane"
.It Li "pane_tty" Ta "Pseudo terminal of pane" .It Li "pane_tty" Ta "Pseudo terminal of pane"
.It Li "pane_width" Ta "Width of pane" .It Li "pane_width" Ta "Width of pane"