diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-down-pane.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-rotate-window.c | 13 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-select-pane.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-swap-pane.c | 10 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-up-pane.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/layout-manual.c | 45 | ||||
-rw-r--r-- | usr.bin/tmux/layout.c | 67 | ||||
-rw-r--r-- | usr.bin/tmux/resize.c | 17 | ||||
-rw-r--r-- | usr.bin/tmux/screen-redraw.c | 7 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tty-write.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/window.c | 22 |
12 files changed, 104 insertions, 103 deletions
diff --git a/usr.bin/tmux/cmd-down-pane.c b/usr.bin/tmux/cmd-down-pane.c index 9af424b93ae..d93fe3dc3a3 100644 --- a/usr.bin/tmux/cmd-down-pane.c +++ b/usr.bin/tmux/cmd-down-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-down-pane.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-down-pane.c,v 1.3 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -55,7 +55,7 @@ cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx) if (w->active == NULL) w->active = TAILQ_FIRST(&w->panes); layout_refresh(w, 1); - } while (w->active->flags & PANE_HIDDEN); + } while (!window_pane_visible(w->active)); return (0); } diff --git a/usr.bin/tmux/cmd-rotate-window.c b/usr.bin/tmux/cmd-rotate-window.c index 38006b6010c..dd728565c47 100644 --- a/usr.bin/tmux/cmd-rotate-window.c +++ b/usr.bin/tmux/cmd-rotate-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-rotate-window.c,v 1.5 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-rotate-window.c,v 1.6 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -60,7 +60,6 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx) struct window *w; struct window_pane *wp, *wp2; u_int sx, sy, xoff, yoff; - int flags; if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) return (-1); @@ -73,18 +72,13 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx) xoff = wp->xoff; yoff = wp->yoff; sx = wp->sx; sy = wp->sy; - flags = wp->flags; TAILQ_FOREACH(wp, &w->panes, entry) { if ((wp2 = TAILQ_NEXT(wp, entry)) == NULL) break; wp->xoff = wp2->xoff; wp->yoff = wp2->yoff; - wp->flags &= ~PANE_HIDDEN; - wp->flags |= wp2->flags & PANE_HIDDEN; window_pane_resize(wp, wp2->sx, wp2->sy); } wp->xoff = xoff; wp->yoff = yoff; - wp->flags &= ~PANE_HIDDEN; - wp->flags |= flags & PANE_HIDDEN; window_pane_resize(wp, sx, sy); if ((wp = TAILQ_PREV(w->active, window_panes, entry)) == NULL) @@ -97,18 +91,13 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx) xoff = wp->xoff; yoff = wp->yoff; sx = wp->sx; sy = wp->sy; - flags = wp->flags; TAILQ_FOREACH_REVERSE(wp, &w->panes, window_panes, entry) { if ((wp2 = TAILQ_PREV(wp, window_panes, entry)) == NULL) break; wp->xoff = wp2->xoff; wp->yoff = wp2->yoff; - wp->flags &= ~PANE_HIDDEN; - wp->flags |= wp2->flags & PANE_HIDDEN; window_pane_resize(wp, wp2->sx, wp2->sy); } wp->xoff = xoff; wp->yoff = yoff; - wp->flags &= ~PANE_HIDDEN; - wp->flags |= flags & PANE_HIDDEN; window_pane_resize(wp, sx, sy); if ((wp = TAILQ_NEXT(w->active, entry)) == NULL) diff --git a/usr.bin/tmux/cmd-select-pane.c b/usr.bin/tmux/cmd-select-pane.c index 44ca00fba00..dfed7e9bbe9 100644 --- a/usr.bin/tmux/cmd-select-pane.c +++ b/usr.bin/tmux/cmd-select-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-select-pane.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-select-pane.c,v 1.3 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -58,8 +58,8 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx) } } - if (wp->flags & PANE_HIDDEN) { - ctx->error(ctx, "pane %d is hidden", data->pane); + if (!window_pane_visible(wp)) { + ctx->error(ctx, "pane %d is not visible", data->pane); return (-1); } window_set_active_pane(wl->window, wp); diff --git a/usr.bin/tmux/cmd-swap-pane.c b/usr.bin/tmux/cmd-swap-pane.c index f88ca0acf07..85ecde214fc 100644 --- a/usr.bin/tmux/cmd-swap-pane.c +++ b/usr.bin/tmux/cmd-swap-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-swap-pane.c,v 1.3 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-swap-pane.c,v 1.4 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -158,7 +158,6 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx) struct window *w; struct window_pane *tmp_wp, *src_wp, *dst_wp; u_int xx, yy; - int flags; if (data == NULL) return (0); @@ -210,15 +209,10 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx) xx = src_wp->xoff; yy = src_wp->yoff; - flags = src_wp->flags; src_wp->xoff = dst_wp->xoff; src_wp->yoff = dst_wp->yoff; - src_wp->flags &= ~PANE_HIDDEN; - src_wp->flags |= dst_wp->flags & PANE_HIDDEN; dst_wp->xoff = xx; dst_wp->yoff = yy; - dst_wp->flags &= ~PANE_HIDDEN; - dst_wp->flags |= flags & PANE_HIDDEN; xx = src_wp->sx; yy = src_wp->sy; @@ -227,7 +221,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx) if (!data->flag_detached) { tmp_wp = dst_wp; - if (tmp_wp->flags & PANE_HIDDEN) + if (!window_pane_visible(tmp_wp)) tmp_wp = src_wp; window_set_active_pane(w, tmp_wp); layout_refresh(w, 0); diff --git a/usr.bin/tmux/cmd-up-pane.c b/usr.bin/tmux/cmd-up-pane.c index 40526bff502..b0e371f7a6d 100644 --- a/usr.bin/tmux/cmd-up-pane.c +++ b/usr.bin/tmux/cmd-up-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-up-pane.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-up-pane.c,v 1.3 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -55,7 +55,7 @@ cmd_up_pane_exec(struct cmd *self, struct cmd_ctx *ctx) if (w->active == NULL) w->active = TAILQ_LAST(&w->panes, window_panes); layout_refresh(w, 1); - } while (w->active->flags & PANE_HIDDEN); + } while (!window_pane_visible(w->active)); return (0); } diff --git a/usr.bin/tmux/layout-manual.c b/usr.bin/tmux/layout-manual.c index 66d472d620b..c2ee82c3cb2 100644 --- a/usr.bin/tmux/layout-manual.c +++ b/usr.bin/tmux/layout-manual.c @@ -1,4 +1,4 @@ -/* $OpenBSD: layout-manual.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ +/* $OpenBSD: layout-manual.c,v 1.2 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -26,7 +26,7 @@ void layout_manual_v_refresh(struct window *w, unused int active_only) { struct window_pane *wp; - u_int npanes, canfit, total; + u_int npanes, total, height; int left; if (active_only) @@ -35,34 +35,25 @@ layout_manual_v_refresh(struct window *w, unused int active_only) if (TAILQ_EMPTY(&w->panes)) return; - /* Clear hidden flags. */ - TAILQ_FOREACH(wp, &w->panes, entry) - wp->flags &= ~PANE_HIDDEN; - /* Check the new size. */ npanes = window_count_panes(w); if (w->sy <= PANE_MINIMUM * npanes) { - /* How many can we fit? */ - canfit = w->sy / PANE_MINIMUM; - if (canfit == 0) { - /* None. Just use this size for the first. */ - TAILQ_FOREACH(wp, &w->panes, entry) { - if (wp == TAILQ_FIRST(&w->panes)) - wp->sy = w->sy; - else - wp->flags |= PANE_HIDDEN; - } - } else { - /* >=1, set minimum for them all. */ - TAILQ_FOREACH(wp, &w->panes, entry) { - if (canfit-- > 0) - wp->sy = PANE_MINIMUM - 1; - else - wp->flags |= PANE_HIDDEN; - } - /* And increase the first by the rest. */ - TAILQ_FIRST(&w->panes)->sy += 1 + w->sy % PANE_MINIMUM; + /* + * Make the first pane the smaller of the minimum and total (it + * must fit to be visible) and the rest the minimum size. + */ + height = PANE_MINIMUM; + if (height > w->sy) + height = w->sy + 1; + TAILQ_FOREACH(wp, &w->panes, entry) { + if (wp == TAILQ_FIRST(&w->panes)) + wp->sy = height - 1; + else + wp->sy = PANE_MINIMUM - 1; } + /* And increase the first by the rest if possible. */ + if (w->sy >= PANE_MINIMUM) + TAILQ_FIRST(&w->panes)->sy += 1 + w->sy % PANE_MINIMUM; } else { /* In theory they will all fit. Find the current total. */ total = 0; @@ -174,8 +165,6 @@ layout_manual_v_update_offsets(struct window *w) yoff = 0; TAILQ_FOREACH(wp, &w->panes, entry) { - if (wp->flags & PANE_HIDDEN) - continue; wp->xoff = 0; wp->yoff = yoff; yoff += wp->sy + 1; diff --git a/usr.bin/tmux/layout.c b/usr.bin/tmux/layout.c index 62657a4bab7..f4511e06286 100644 --- a/usr.bin/tmux/layout.c +++ b/usr.bin/tmux/layout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: layout.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ +/* $OpenBSD: layout.c,v 1.2 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -125,14 +125,19 @@ void layout_active_only_refresh(struct window *w, unused int active_only) { struct window_pane *wp; + u_int xoff; + xoff = w->sx; TAILQ_FOREACH(wp, &w->panes, entry) { - if (wp == w->active) { - wp->flags &= ~PANE_HIDDEN; - wp->xoff = wp->yoff = 0; - window_pane_resize(wp, w->sx, w->sy); - } else - wp->flags |= PANE_HIDDEN; + /* Put the active pane on screen and the rest to the right. */ + if (wp == w->active) + wp->xoff = 0; + else { + wp->xoff = xoff; + xoff += w->sx; + } + wp->yoff = 0; + window_pane_resize(wp, w->sx, w->sy); } } @@ -145,6 +150,12 @@ layout_even_h_refresh(struct window *w, int active_only) if (active_only) return; + /* If the screen is too small, show active only. */ + if (w->sx < PANE_MINIMUM || w->sy < PANE_MINIMUM) { + layout_active_only_refresh(w, active_only); + return; + } + /* Get number of panes. */ n = window_count_panes(w); if (n == 0) @@ -153,19 +164,13 @@ layout_even_h_refresh(struct window *w, int active_only) /* How many can we fit? */ if (w->sx / n < PANE_MINIMUM) { width = PANE_MINIMUM; - n = w->sx / PANE_MINIMUM; + n = UINT_MAX; } else width = w->sx / n; /* Fit the panes. */ i = xoff = 0; TAILQ_FOREACH(wp, &w->panes, entry) { - if (i > n) { - wp->flags |= PANE_HIDDEN; - continue; - } - wp->flags &= ~PANE_HIDDEN; - wp->xoff = xoff; wp->yoff = 0; if (i != n - 1) @@ -193,6 +198,12 @@ layout_even_v_refresh(struct window *w, int active_only) if (active_only) return; + /* If the screen is too small, show active only. */ + if (w->sx < PANE_MINIMUM || w->sy < PANE_MINIMUM) { + layout_active_only_refresh(w, active_only); + return; + } + /* Get number of panes. */ n = window_count_panes(w); if (n == 0) @@ -201,19 +212,13 @@ layout_even_v_refresh(struct window *w, int active_only) /* How many can we fit? */ if (w->sy / n < PANE_MINIMUM) { height = PANE_MINIMUM; - n = w->sy / PANE_MINIMUM; + n = UINT_MAX; } else height = w->sy / n; /* Fit the panes. */ i = yoff = 0; TAILQ_FOREACH(wp, &w->panes, entry) { - if (i > n) { - wp->flags |= PANE_HIDDEN; - continue; - } - wp->flags &= ~PANE_HIDDEN; - wp->xoff = 0; wp->yoff = yoff; if (i != n - 1) @@ -250,7 +255,8 @@ layout_main_v_refresh(struct window *w, int active_only) mainwidth = options_get_number(&w->options, "main-pane-width") + 1; /* Need >1 pane and minimum columns; if fewer, display active only. */ - if (n == 1 || w->sx < mainwidth + PANE_MINIMUM) { + if (n == 1 || + w->sx < mainwidth + PANE_MINIMUM || w->sy < PANE_MINIMUM) { layout_active_only_refresh(w, active_only); return; } @@ -270,16 +276,9 @@ layout_main_v_refresh(struct window *w, int active_only) wp->xoff = 0; wp->yoff = 0; window_pane_resize(wp, mainwidth - 1, w->sy); - wp->flags &= ~PANE_HIDDEN; continue; } - if (i > n) { - wp->flags |= PANE_HIDDEN; - continue; - } - wp->flags &= ~PANE_HIDDEN; - wp->xoff = mainwidth; wp->yoff = yoff; if (i != n - 1) @@ -320,7 +319,8 @@ layout_main_h_refresh(struct window *w, int active_only) mainheight = options_get_number(&w->options, "main-pane-height") + 1; /* Need >1 pane and minimum rows; if fewer, display active only. */ - if (n == 1 || w->sy < mainheight + PANE_MINIMUM) { + if (n == 1 || + w->sy < mainheight + PANE_MINIMUM || w->sx < PANE_MINIMUM) { layout_active_only_refresh(w, active_only); return; } @@ -340,15 +340,8 @@ layout_main_h_refresh(struct window *w, int active_only) wp->xoff = 0; wp->yoff = 0; window_pane_resize(wp, w->sx, mainheight - 1); - wp->flags &= ~PANE_HIDDEN; - continue; - } - - if (i > n) { - wp->flags |= PANE_HIDDEN; continue; } - wp->flags &= ~PANE_HIDDEN; wp->xoff = xoff; wp->yoff = mainheight; diff --git a/usr.bin/tmux/resize.c b/usr.bin/tmux/resize.c index e272f0fab28..29d9f883bbb 100644 --- a/usr.bin/tmux/resize.c +++ b/usr.bin/tmux/resize.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resize.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ +/* $OpenBSD: resize.c,v 1.2 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -48,6 +48,7 @@ recalculate_sizes(void) struct session *s; struct client *c; struct window *w; + struct window_pane *wp; u_int i, j, ssx, ssy, has, limit; int flag; @@ -132,6 +133,20 @@ recalculate_sizes(void) "window size %u,%u (was %u,%u)", ssx, ssy, w->sx, w->sy); window_resize(w, ssx, ssy); + + /* + * If the current pane is now not visible, move to the next + * that is. + */ + wp = w->active; + while (!window_pane_visible(w->active)) { + w->active = TAILQ_PREV(w->active, window_panes, entry); + if (w->active == NULL) + w->active = TAILQ_LAST(&w->panes, window_panes); + if (w->active == wp) + break; + } + server_redraw_window(w); layout_refresh(w, 0); } diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c index 76ea1148132..5d785e2e0b2 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.2 2009/06/25 05:56:44 nicm Exp $ */ +/* $OpenBSD: screen-redraw.c,v 1.3 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,6 +35,9 @@ screen_redraw_check_cell(struct client *c, u_int px, u_int py) return (0); TAILQ_FOREACH(wp, &w->panes, entry) { + if (!window_pane_visible(wp)) + continue; + /* Inside pane. */ if (px >= wp->xoff && px < wp->xoff + wp->sx && py >= wp->yoff && py < wp->yoff + wp->sy) @@ -104,7 +107,7 @@ screen_redraw_screen(struct client *c) /* Draw the panes. */ TAILQ_FOREACH(wp, &w->panes, entry) { - if (wp->flags & PANE_HIDDEN) + if (!window_pane_visible(wp)) continue; tty_reset(tty); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 6ebd7028e3b..5449b2deaed 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.27 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.28 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -48,7 +48,7 @@ extern const char *__progname; #define PROMPT_HISTORY 100 /* Minimum pane size. */ -#define PANE_MINIMUM 4 /* includes separator line */ +#define PANE_MINIMUM 5 /* includes separator line */ /* Automatic name refresh interval, in milliseconds. */ #define NAME_INTERVAL 500 @@ -600,8 +600,7 @@ struct window_pane { u_int yoff; int flags; -#define PANE_HIDDEN 0x1 -#define PANE_REDRAW 0x2 +#define PANE_REDRAW 0x1 char *cmd; char *cwd; @@ -1454,6 +1453,7 @@ void window_pane_parse(struct window_pane *); void window_pane_key(struct window_pane *, struct client *, int); void window_pane_mouse(struct window_pane *, struct client *, u_char, u_char, u_char); +int window_pane_visible(struct window_pane *); char *window_pane_search( struct window_pane *, const char *, u_int *); diff --git a/usr.bin/tmux/tty-write.c b/usr.bin/tmux/tty-write.c index 4d31e172913..1fb875d9927 100644 --- a/usr.bin/tmux/tty-write.c +++ b/usr.bin/tmux/tty-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-write.c,v 1.3 2009/06/25 06:15:04 nicm Exp $ */ +/* $OpenBSD: tty-write.c,v 1.4 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -44,7 +44,7 @@ tty_vwrite_cmd(struct window_pane *wp, enum tty_cmd cmd, va_list ap) if (wp->window->flags & WINDOW_REDRAW || wp->flags & PANE_REDRAW) return; - if (wp->window->flags & WINDOW_HIDDEN || wp->flags & PANE_HIDDEN) + if (wp->window->flags & WINDOW_HIDDEN || !window_pane_visible(wp)) return; for (i = 0; i < ARRAY_LENGTH(&clients); i++) { diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index 0a0325d91b9..f3ecc658a82 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.9 2009/07/13 10:43:52 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.10 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -291,8 +291,14 @@ void window_set_active_pane(struct window *w, struct window_pane *wp) { w->active = wp; - while (w->active->flags & PANE_HIDDEN) + + while (!window_pane_visible(w->active)) { w->active = TAILQ_PREV(w->active, window_panes, entry); + if (w->active == NULL) + w->active = TAILQ_LAST(&w->panes, window_panes); + if (w->active == wp) + return; + } } struct window_pane * @@ -607,6 +613,18 @@ window_pane_mouse( input_mouse(wp, b, x, y); } +int +window_pane_visible(struct window_pane *wp) +{ + struct window *w = wp->window; + + if (wp->xoff >= w->sx || wp->yoff >= w->sy) + return (0); + if (wp->xoff + wp->sx > w->sx || wp->yoff + wp->sy > w->sy) + return (0); + return (1); +} + char * window_pane_search(struct window_pane *wp, const char *searchstr, u_int *lineno) { |