diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-24 09:29:41 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-24 09:29:41 +0000 |
commit | 28879585bf41298f1a983500bdb89563d97aa451 (patch) | |
tree | 280dd6032a74d0fd2e33e5e9ca1c3ec8890c1ce9 /usr.bin | |
parent | 420e6fb4b9f11a32f753f5dc15ff734f11635e16 (diff) |
Add pane_tabs format to format_window_pane based on code from George
Nachman.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/format.c | 32 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 3 |
2 files changed, 31 insertions, 4 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 748a9ee1eef..8bb894225b1 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.18 2013/03/24 09:23:00 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.19 2013/03/24 09:29:40 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,8 +32,9 @@ * string. */ -int format_replace(struct format_tree *, - const char *, size_t, char **, size_t *, size_t *); +int format_replace(struct format_tree *, const char *, size_t, char **, + size_t *, size_t *); +void format_window_pane_tabs(struct format_tree *, struct window_pane *); /* Format key-value replacement entry. */ 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); } +/* 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. */ void 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)); format_add(ft, "mouse_utf8_flag", "%d", !!(wp->base.mode & MODE_MOUSE_UTF8)); + + format_window_pane_tabs(ft, wp); } +/* Set default format keys for paste buffer. */ void format_paste_buffer(struct format_tree *ft, struct paste_buffer *pb) { diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 8b1545ae39d..0cd7da0bca4 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.332 2013/03/24 09:21:27 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.333 2013/03/24 09:29:40 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -3033,6 +3033,7 @@ The following variables are available, where appropriate: .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_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_tty" Ta "Pseudo terminal of pane" .It Li "pane_width" Ta "Width of pane" |