diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2014-11-14 02:19:48 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2014-11-14 02:19:48 +0000 |
commit | c441472a32bbc7572a4ff7cb9eae3c36bef52e46 (patch) | |
tree | d213398f96789a49f5ac0683e640511c784a6f45 /usr.bin/tmux | |
parent | f713ea62a9adc61ec3e5eba4151e2da8ce573cb9 (diff) |
Label windows which are smaller than expected with a reason.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/resize.c | 16 | ||||
-rw-r--r-- | usr.bin/tmux/screen-redraw.c | 45 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 6 |
3 files changed, 58 insertions, 9 deletions
diff --git a/usr.bin/tmux/resize.c b/usr.bin/tmux/resize.c index 661b316f841..8a2dcf63500 100644 --- a/usr.bin/tmux/resize.c +++ b/usr.bin/tmux/resize.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resize.c,v 1.13 2014/11/12 16:00:03 nicm Exp $ */ +/* $OpenBSD: resize.c,v 1.14 2014/11/14 02:19:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -50,7 +50,7 @@ recalculate_sizes(void) struct window *w; struct window_pane *wp; u_int i, j, ssx, ssy, has, limit; - int flag, has_status, is_zoomed; + int flag, has_status, is_zoomed, forced; RB_FOREACH(s, sessions, &sessions) { has_status = options_get_number(&s->options, "status"); @@ -116,18 +116,26 @@ recalculate_sizes(void) if (ssx == UINT_MAX || ssy == UINT_MAX) continue; + forced = 0; limit = options_get_number(&w->options, "force-width"); - if (limit >= PANE_MINIMUM && ssx > limit) + if (limit >= PANE_MINIMUM && ssx > limit) { ssx = limit; + forced |= WINDOW_FORCEWIDTH; + } limit = options_get_number(&w->options, "force-height"); - if (limit >= PANE_MINIMUM && ssy > limit) + if (limit >= PANE_MINIMUM && ssy > limit) { ssy = limit; + forced |= WINDOW_FORCEHEIGHT; + } if (w->sx == ssx && w->sy == ssy) continue; log_debug("window size %u,%u (was %u,%u)", ssx, ssy, w->sx, w->sy); + w->flags &= ~(WINDOW_FORCEWIDTH|WINDOW_FORCEHEIGHT); + w->flags |= forced; + is_zoomed = w->flags & WINDOW_ZOOMED; if (is_zoomed) window_unzoom(w); diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c index 76e7887521c..158cede3285 100644 --- a/usr.bin/tmux/screen-redraw.c +++ b/usr.bin/tmux/screen-redraw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-redraw.c,v 1.27 2014/03/31 21:34:08 nicm Exp $ */ +/* $OpenBSD: screen-redraw.c,v 1.28 2014/11/14 02:19:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -278,8 +278,37 @@ screen_redraw_draw_borders(struct client *c, int status, u_int top) struct options *oo = &c->session->options; struct tty *tty = &c->tty; struct window_pane *wp; - struct grid_cell active_gc, other_gc; - u_int i, j, type; + struct grid_cell active_gc, other_gc, msg_gc; + u_int i, j, type, msgx = 0, msgy = 0; + int small, flags; + char msg[256]; + const char *tmp; + size_t msglen = 0; + + small = (tty->sy - status + top > w->sy) || (tty->sx > w->sx); + if (small) { + flags = w->flags & (WINDOW_FORCEWIDTH|WINDOW_FORCEHEIGHT); + if (flags == (WINDOW_FORCEWIDTH|WINDOW_FORCEHEIGHT)) + tmp = "force-width, force-height"; + else if (flags == WINDOW_FORCEWIDTH) + tmp = "force-width"; + else if (flags == WINDOW_FORCEHEIGHT) + tmp = "force-height"; + else + tmp = "a smaller client"; + xsnprintf(msg, sizeof msg, "(size %ux%u from %s)", + w->sx, w->sy, tmp); + msglen = strlen(msg); + + if (tty->sy - 1 - status + top > w->sy && tty->sx >= msglen) { + msgx = tty->sx - msglen; + msgy = tty->sy - 1 - status + top; + } else if (tty->sx - w->sx > msglen) { + msgx = tty->sx - msglen; + msgy = tty->sy - 1 - status + top; + } else + small = 0; + } style_apply(&other_gc, oo, "pane-border-style"); style_apply(&active_gc, oo, "pane-active-border-style"); @@ -290,6 +319,9 @@ screen_redraw_draw_borders(struct client *c, int status, u_int top) type = screen_redraw_check_cell(c, i, j, &wp); if (type == CELL_INSIDE) continue; + if (type == CELL_OUTSIDE && + small && i > msgx && j == msgy) + continue; if (screen_redraw_check_active(i, j, type, w, wp)) tty_attributes(tty, &active_gc); else @@ -298,6 +330,13 @@ screen_redraw_draw_borders(struct client *c, int status, u_int top) tty_putc(tty, CELL_BORDERS[type]); } } + + if (small) { + memcpy(&msg_gc, &grid_default_cell, sizeof msg_gc); + tty_attributes(tty, &msg_gc); + tty_cursor(tty, msgx, msgy); + tty_puts(tty, msg); + } } /* Draw the panes. */ diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index d7a68a28c0e..ec33367a884 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.480 2014/11/06 09:17:26 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.481 2014/11/14 02:19:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -946,7 +946,9 @@ struct window { #define WINDOW_ACTIVITY 0x2 #define WINDOW_REDRAW 0x4 #define WINDOW_SILENCE 0x8 -#define WINDOW_ZOOMED 0x10 +#define WINDOW_ZOOMED 0x1000 +#define WINDOW_FORCEWIDTH 0x2000 +#define WINDOW_FORCEHEIGHT 0x4000 #define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE) struct options options; |