Add formats for when window is larger than client, and show offset in

status-right by default when larger.
pull/1495/head
Nicholas Marriott 2018-09-26 18:41:18 +01:00
parent b74b047730
commit ebaf54251a
4 changed files with 23 additions and 4 deletions

View File

@ -106,9 +106,10 @@ struct format_entry {
/* Format entry tree. */
struct format_tree {
struct window *w;
struct winlink *wl;
struct client *c;
struct session *s;
struct winlink *wl;
struct window *w;
struct window_pane *wp;
struct client *client;
@ -1395,6 +1396,7 @@ format_defaults_client(struct format_tree *ft, struct client *c)
if (ft->s == NULL)
ft->s = c->session;
ft->c = c;
format_add(ft, "client_name", "%s", c->name);
format_add(ft, "client_pid", "%ld", (long) c->pid);
@ -1463,8 +1465,11 @@ format_defaults_window(struct format_tree *ft, struct window *w)
static void
format_defaults_winlink(struct format_tree *ft, struct winlink *wl)
{
struct client *c = ft->c;
struct session *s = wl->session;
struct window *w = wl->window;
int flag;
u_int ox, oy, sx, sy;
if (ft->w == NULL)
ft->w = wl->window;
@ -1472,6 +1477,15 @@ format_defaults_winlink(struct format_tree *ft, struct winlink *wl)
format_defaults_window(ft, w);
if (c != NULL) {
flag = tty_window_offset(&c->tty, &ox, &oy, &sx, &sy);
format_add(ft, "window_bigger", "%d", flag);
if (flag) {
format_add(ft, "window_offset_x", "%u", ox);
format_add(ft, "window_offset_y", "%u", oy);
}
}
format_add(ft, "window_index", "%d", wl->idx);
format_add_cb(ft, "window_stack_index", format_cb_window_stack_index);
format_add(ft, "window_flags", "%s", window_printable_flags(wl));

View File

@ -476,7 +476,9 @@ const struct options_table_entry options_table[] = {
{ .name = "status-right",
.type = OPTIONS_TABLE_STRING,
.scope = OPTIONS_TABLE_SESSION,
.default_str = " \"#{=21:pane_title}\" %H:%M %d-%b-%y"
.default_str = "#{?window_bigger,"
"[#{window_offset_x}#,#{window_offset_y}] ,}"
"\"#{=21:pane_title}\" %H:%M %d-%b-%y"
},
{ .name = "status-right-attr",

3
tmux.1
View File

@ -3921,6 +3921,7 @@ The following variables are available, where appropriate:
.It Li "window_activity_flag" Ta "" Ta "1 if window has activity"
.It Li "window_active" Ta "" Ta "1 if window active"
.It Li "window_bell_flag" Ta "" Ta "1 if window has bell"
.It Li "window_bigger" Ta "" Ta "1 if window is larger than client"
.It Li "window_flags" Ta "#F" Ta "Window flags"
.It Li "window_format" Ta "" Ta "1 if format is for a window (not assuming the current)"
.It Li "window_height" Ta "" Ta "Height of window"
@ -3930,6 +3931,8 @@ The following variables are available, where appropriate:
.It Li "window_layout" Ta "" Ta "Window layout description, ignoring zoomed window panes"
.It Li "window_linked" Ta "" Ta "1 if window is linked across sessions"
.It Li "window_name" Ta "#W" Ta "Name of window"
.It Li "window_offset_x" Ta "" Ta "X offset into window if larger than client"
.It Li "window_offset_y" Ta "" Ta "Y offset into window if larger than client"
.It Li "window_panes" Ta "" Ta "Number of panes in window"
.It Li "window_silence_flag" Ta "" Ta "1 if window has silence alert"
.It Li "window_stack_index" Ta "" Ta "Index in session most recent stack"

2
tty.c
View File

@ -815,7 +815,7 @@ tty_update_client_offset(struct client *c)
c->tty.osx = sx;
c->tty.osy = sy;
c->flags |= CLIENT_REDRAWWINDOW;
c->flags |= (CLIENT_REDRAWWINDOW|CLIENT_REDRAWSTATUS);
}
/*