diff options
| -rw-r--r-- | cmd-break-pane.c | 6 | ||||
| -rw-r--r-- | cmd-choose-window.c | 6 | ||||
| -rw-r--r-- | cmd-down-pane.c | 3 | ||||
| -rw-r--r-- | cmd-kill-pane.c | 4 | ||||
| -rw-r--r-- | cmd-list-windows.c | 7 | ||||
| -rw-r--r-- | cmd-next-layout.c | 7 | ||||
| -rw-r--r-- | cmd-previous-layout.c | 9 | ||||
| -rw-r--r-- | cmd-resize-pane.c | 37 | ||||
| -rw-r--r-- | cmd-respawn-window.c | 4 | ||||
| -rw-r--r-- | cmd-rotate-window.c | 21 | ||||
| -rw-r--r-- | cmd-select-layout.c | 24 | ||||
| -rw-r--r-- | cmd-select-pane.c | 3 | ||||
| -rw-r--r-- | cmd-split-window.c | 99 | ||||
| -rw-r--r-- | cmd-swap-pane.c | 16 | ||||
| -rw-r--r-- | cmd-up-pane.c | 3 | ||||
| -rw-r--r-- | key-bindings.c | 15 | ||||
| -rw-r--r-- | layout-manual.c | 172 | ||||
| -rw-r--r-- | layout-set.c | 436 | ||||
| -rw-r--r-- | layout.c | 789 | ||||
| -rw-r--r-- | resize.c | 4 | ||||
| -rw-r--r-- | server.c | 8 | ||||
| -rw-r--r-- | tmux.1 | 83 | ||||
| -rw-r--r-- | tmux.h | 85 | ||||
| -rw-r--r-- | window.c | 55 |
24 files changed, 1279 insertions, 617 deletions
diff --git a/cmd-break-pane.c b/cmd-break-pane.c index 0c4b89e4..a1e195b9 100644 --- a/cmd-break-pane.c +++ b/cmd-break-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-break-pane.c,v 1.4 2009-07-14 06:43:32 nicm Exp $ */ +/* $Id: cmd-break-pane.c,v 1.5 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -74,17 +74,17 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx) if (wl->window->active == NULL) wl->window->active = TAILQ_NEXT(wp, entry); } - layout_refresh(wl->window, 0); + layout_close_pane(wp); w = wp->window = window_create1(s->sx, s->sy); TAILQ_INSERT_HEAD(&w->panes, wp, entry); w->active = wp; w->name = default_window_name(w); + layout_init(w); wl = session_attach(s, w, -1, &cause); /* can't fail */ if (!(data->chflags & CMD_CHFLAG('d'))) session_select(s, wl->idx); - layout_refresh(w, 0); server_redraw_session(s); diff --git a/cmd-choose-window.c b/cmd-choose-window.c index 130a4cf8..ee49c769 100644 --- a/cmd-choose-window.c +++ b/cmd-choose-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-choose-window.c,v 1.11 2009-07-17 12:12:54 nicm Exp $ */ +/* $Id: cmd-choose-window.c,v 1.12 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -76,8 +76,8 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx) idx++; window_choose_add(wl->window->active, - wm->idx, "%3d: %s [%ux%u %s] (%u panes)", wm->idx, w->name, - w->sx, w->sy, layout_name(w), window_count_panes(w)); + wm->idx, "%3d: %s [%ux%u] (%u panes)", + wm->idx, w->name, w->sx, w->sy, window_count_panes(w)); } cdata = xmalloc(sizeof *cdata); diff --git a/cmd-down-pane.c b/cmd-down-pane.c index 71b19bbe..ba5d9fcc 100644 --- a/cmd-down-pane.c +++ b/cmd-down-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-down-pane.c,v 1.9 2009-07-15 17:42:43 nicm Exp $ */ +/* $Id: cmd-down-pane.c,v 1.10 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -54,7 +54,6 @@ cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx) w->active = TAILQ_NEXT(w->active, entry); if (w->active == NULL) w->active = TAILQ_FIRST(&w->panes); - layout_refresh(w, 1); } while (!window_pane_visible(w->active)); return (0); diff --git a/cmd-kill-pane.c b/cmd-kill-pane.c index e796d78d..9966ea9f 100644 --- a/cmd-kill-pane.c +++ b/cmd-kill-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-pane.c,v 1.9 2009-07-18 11:07:14 nicm Exp $ */ +/* $Id: cmd-kill-pane.c,v 1.10 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -66,8 +66,8 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx) return (0); } + layout_close_pane(wp); window_remove_pane(wl->window, wp); server_redraw_window(wl->window); - layout_refresh(wl->window, 0); return (0); } diff --git a/cmd-list-windows.c b/cmd-list-windows.c index bafb55b7..511f9069 100644 --- a/cmd-list-windows.c +++ b/cmd-list-windows.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-windows.c,v 1.36 2009-07-14 06:43:32 nicm Exp $ */ +/* $Id: cmd-list-windows.c,v 1.37 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -78,9 +78,8 @@ cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx) else name = "unknown"; ctx->print(ctx, - " %s [%ux%u %s] [history %u/%u, %llu bytes]", - name, wp->sx, wp->sy, layout_name(w), gd->hsize, - gd->hlimit, size); + " %s [%ux%u] [history %u/%u, %llu bytes]", + name, wp->sx, wp->sy, gd->hsize, gd->hlimit, size); } } diff --git a/cmd-next-layout.c b/cmd-next-layout.c index 1f58b32d..79cda557 100644 --- a/cmd-next-layout.c +++ b/cmd-next-layout.c @@ -1,4 +1,4 @@ -/* $Id: cmd-next-layout.c,v 1.3 2009-07-14 06:43:32 nicm Exp $ */ +/* $Id: cmd-next-layout.c,v 1.4 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -44,12 +44,13 @@ cmd_next_layout_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; struct winlink *wl; + u_int layout; if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) return (-1); - layout_next(wl->window); - ctx->info(ctx, "layout now: %s", layout_name(wl->window)); + layout = layout_set_next(wl->window); + ctx->info(ctx, "arranging in: %s", layout_set_name(layout)); return (0); } diff --git a/cmd-previous-layout.c b/cmd-previous-layout.c index b84bd5a1..158c9edd 100644 --- a/cmd-previous-layout.c +++ b/cmd-previous-layout.c @@ -1,4 +1,4 @@ -/* $Id: cmd-previous-layout.c,v 1.2 2009-07-14 06:43:32 nicm Exp $ */ +/* $Id: cmd-previous-layout.c,v 1.3 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -44,12 +44,13 @@ cmd_previous_layout_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; struct winlink *wl; - + u_int layout; + if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) return (-1); - layout_previous(wl->window); - ctx->info(ctx, "layout now: %s", layout_name(wl->window)); + layout = layout_set_previous(wl->window); + ctx->info(ctx, "arranging in: %s", layout_set_name(layout)); return (0); } diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c index 8dac1343..d32dbc25 100644 --- a/cmd-resize-pane.c +++ b/cmd-resize-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-resize-pane.c,v 1.8 2009-07-14 06:43:32 nicm Exp $ */ +/* $Id: cmd-resize-pane.c,v 1.9 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,7 +32,8 @@ int cmd_resize_pane_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_resize_pane_entry = { "resize-pane", "resizep", CMD_PANE_WINDOW_USAGE "[-DU] [adjustment]", - CMD_ARG01, CMD_CHFLAG('D')|CMD_CHFLAG('U'), + CMD_ARG01, + CMD_CHFLAG('D')|CMD_CHFLAG('L')|CMD_CHFLAG('R')|CMD_CHFLAG('U'), cmd_resize_pane_init, cmd_pane_parse, cmd_resize_pane_exec, @@ -50,15 +51,31 @@ cmd_resize_pane_init(struct cmd *self, int key) cmd_pane_init(self, key); data = self->data; + if (key == KEYC_ADDCTL(KEYC_UP)) + data->chflags |= CMD_CHFLAG('U'); if (key == KEYC_ADDCTL(KEYC_DOWN)) data->chflags |= CMD_CHFLAG('D'); + if (key == KEYC_ADDCTL(KEYC_LEFT)) + data->chflags |= CMD_CHFLAG('L'); + if (key == KEYC_ADDCTL(KEYC_RIGHT)) + data->chflags |= CMD_CHFLAG('R'); - if (key == KEYC_ADDESC(KEYC_UP)) + if (key == KEYC_ADDESC(KEYC_UP)) { + data->chflags |= CMD_CHFLAG('U'); data->arg = xstrdup("5"); + } if (key == KEYC_ADDESC(KEYC_DOWN)) { data->chflags |= CMD_CHFLAG('D'); data->arg = xstrdup("5"); } + if (key == KEYC_ADDESC(KEYC_LEFT)) { + data->chflags |= CMD_CHFLAG('L'); + data->arg = xstrdup("5"); + } + if (key == KEYC_ADDESC(KEYC_RIGHT)) { + data->chflags |= CMD_CHFLAG('R'); + data->arg = xstrdup("5"); + } } int @@ -92,12 +109,14 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx) } } - if (!(data->chflags & CMD_CHFLAG('D'))) - adjust = -adjust; - if (layout_resize(wp, adjust) != 0) { - ctx->error(ctx, "layout %s " - "does not support resizing", layout_name(wp->window)); - return (-1); + if (data->chflags & (CMD_CHFLAG('L')|CMD_CHFLAG('R'))) { + if (data->chflags & CMD_CHFLAG('L')) + adjust = -adjust; + layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust); + } else { + if (data->chflags & CMD_CHFLAG('U')) + adjust = -adjust; + layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust); } server_redraw_window(wl->window); diff --git a/cmd-respawn-window.c b/cmd-respawn-window.c index 11e31e66..cdfb0656 100644 --- a/cmd-respawn-window.c +++ b/cmd-respawn-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-respawn-window.c,v 1.15 2009-07-14 06:43:32 nicm Exp $ */ +/* $Id: cmd-respawn-window.c,v 1.16 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -70,6 +70,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx) wp = TAILQ_FIRST(&w->panes); TAILQ_REMOVE(&w->panes, wp, entry); + layout_free(w); window_destroy_panes(w); TAILQ_INSERT_HEAD(&w->panes, wp, entry); window_pane_resize(wp, w->sx, w->sy); @@ -78,6 +79,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx) xfree(cause); return (-1); } + layout_init(w); screen_reinit(&wp->base); recalculate_sizes(); diff --git a/cmd-rotate-window.c b/cmd-rotate-window.c index 008fcc73..17f1f25f 100644 --- a/cmd-rotate-window.c +++ b/cmd-rotate-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-rotate-window.c,v 1.6 2009-07-15 17:42:43 nicm Exp $ */ +/* $Id: cmd-rotate-window.c,v 1.7 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -59,6 +59,7 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx) struct winlink *wl; struct window *w; struct window_pane *wp, *wp2; + struct layout_cell *lc; u_int sx, sy, xoff, yoff; if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) @@ -70,42 +71,56 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx) TAILQ_REMOVE(&w->panes, wp, entry); TAILQ_INSERT_HEAD(&w->panes, wp, entry); + lc = wp->layout_cell; xoff = wp->xoff; yoff = wp->yoff; sx = wp->sx; sy = wp->sy; TAILQ_FOREACH(wp, &w->panes, entry) { if ((wp2 = TAILQ_NEXT(wp, entry)) == NULL) break; + wp->layout_cell = wp2->layout_cell; + if (wp->layout_cell != NULL) + wp->layout_cell->wp = wp; wp->xoff = wp2->xoff; wp->yoff = wp2->yoff; window_pane_resize(wp, wp2->sx, wp2->sy); } + wp->layout_cell = lc; + if (wp->layout_cell != NULL) + wp->layout_cell->wp = wp; wp->xoff = xoff; wp->yoff = yoff; window_pane_resize(wp, sx, sy); if ((wp = TAILQ_PREV(w->active, window_panes, entry)) == NULL) wp = TAILQ_LAST(&w->panes, window_panes); window_set_active_pane(w, wp); + server_redraw_window(w); } else { wp = TAILQ_FIRST(&w->panes); TAILQ_REMOVE(&w->panes, wp, entry); TAILQ_INSERT_TAIL(&w->panes, wp, entry); + lc = wp->layout_cell; xoff = wp->xoff; yoff = wp->yoff; sx = wp->sx; sy = wp->sy; TAILQ_FOREACH_REVERSE(wp, &w->panes, window_panes, entry) { if ((wp2 = TAILQ_PREV(wp, window_panes, entry)) == NULL) break; + wp->layout_cell = wp2->layout_cell; + if (wp->layout_cell != NULL) + wp->layout_cell->wp = wp; wp->xoff = wp2->xoff; wp->yoff = wp2->yoff; window_pane_resize(wp, wp2->sx, wp2->sy); } + wp->layout_cell = lc; + if (wp->layout_cell != NULL) + wp->layout_cell->wp = wp; wp->xoff = xoff; wp->yoff = yoff; window_pane_resize(wp, sx, sy); if ((wp = TAILQ_NEXT(w->active, entry)) == NULL) wp = TAILQ_FIRST(&w->panes); window_set_active_pane(w, wp); + server_redraw_window(w); } - layout_refresh(w, 0); - return (0); } diff --git a/cmd-select-layout.c b/cmd-select-layout.c index 20e2ad28..acca099f 100644 --- a/cmd-select-layout.c +++ b/cmd-select-layout.c @@ -1,4 +1,4 @@ -/* $Id: cmd-select-layout.c,v 1.4 2009-07-14 06:43:32 nicm Exp $ */ +/* $Id: cmd-select-layout.c,v 1.5 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -49,17 +49,17 @@ cmd_select_layout_init(struct cmd *self, int key) data = self->data; switch (key) { - case KEYC_ADDESC('0'): - data->arg = xstrdup("manual-vertical"); - break; case KEYC_ADDESC('1'): data->arg = xstrdup("even-horizontal"); break; case KEYC_ADDESC('2'): data->arg = xstrdup("even-vertical"); break; - case KEYC_ADDESC('9'): - data->arg = xstrdup("active-only"); + case KEYC_ADDESC('3'): + data->arg = xstrdup("main-horizontal"); + break; + case KEYC_ADDESC('4'): + data->arg = xstrdup("main-vertical"); break; } } @@ -74,13 +74,13 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx) if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) return (-1); - if ((layout = layout_lookup(data->arg)) == -1) { - ctx->error(ctx, "unknown or ambiguous layout: %s", data->arg); - return (-1); - } + if ((layout = layout_set_lookup(data->arg)) == -1) { + ctx->error(ctx, "unknown or ambiguous layout: %s", data->arg); + return (-1); + } - if (layout_select(wl->window, layout) == 0) - ctx->info(ctx, "layout now: %s", layout_name(wl->window)); + layout = layout_set_select(wl->window, layout); + ctx->info(ctx, "arranging in: %s", layout_set_name(layout)); return (0); } diff --git a/cmd-select-pane.c b/cmd-select-pane.c index b185a5d5..e92add94 100644 --- a/cmd-select-pane.c +++ b/cmd-select-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-select-pane.c,v 1.6 2009-07-15 17:42:43 nicm Exp $ */ +/* $Id: cmd-select-pane.c,v 1.7 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -63,7 +63,6 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); } window_set_active_pane(wl->window, wp); - layout_refresh(wl->window, 1); return (0); } diff --git a/cmd-split-window.c b/cmd-split-window.c index f8e35fb6..e9d51fe2 100644 --- a/cmd-split-window.c +++ b/cmd-split-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-split-window.c,v 1.18 2009-07-14 06:43:33 nicm Exp $ */ +/* $Id: cmd-split-window.c,v 1.19 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -39,13 +39,14 @@ struct cmd_split_window_data { char *target; char *cmd; int flag_detached; + int flag_horizontal; int percentage; - int lines; + int size; }; const struct cmd_entry cmd_split_window_entry = { "split-window", "splitw", - "[-d] [-p percentage|-l lines] [-t target-window] [command]", + "[-dhv] [-p percentage|-l size] [-t target-window] [command]", 0, 0, cmd_split_window_init, cmd_split_window_parse, @@ -57,7 +58,7 @@ const struct cmd_entry cmd_split_window_entry = { }; void -cmd_split_window_init(struct cmd *self, unused int arg) +cmd_split_window_init(struct cmd *self, int key) { struct cmd_split_window_data *data; @@ -65,50 +66,63 @@ cmd_split_window_init(struct cmd *self, unused int arg) data->target = NULL; data->cmd = NULL; data->flag_detached = 0; + data->flag_horizontal = 0; data->percentage = -1; - data->lines = -1; + data->size = -1; + + switch (key) { + case '%': + data->flag_horizontal = 1; + break; + case '"': + data->flag_horizontal = 0; + break; + } } int cmd_split_window_parse(struct cmd *self, int argc, char **argv, char **cause) { struct cmd_split_window_data *data; - int opt, n; + int opt; const char *errstr; self->entry->init(self, 0); data = self->data; - while ((opt = getopt(argc, argv, "dl:p:t:")) != -1) { + while ((opt = getopt(argc, argv, "dhl:p:t:v")) != -1) { switch (opt) { case 'd': data->flag_detached = 1; break; + case 'h': + data->flag_horizontal = 1; + break; case 't': if (data->target == NULL) data->target = xstrdup(optarg); break; case 'l': - if (data->percentage == -1 && data->lines == -1) { - n = strtonum(optarg, 1, INT_MAX, &errstr); - if (errstr != NULL) { - xasprintf(cause, "lines %s", errstr); - goto error; - } - data->lines = n; + if (data->percentage != -1 || data->size != -1) + break; + data->size = strtonum(optarg, 1, INT_MAX, &errstr); + if (errstr != NULL) { + xasprintf(cause, "size %s", errstr); + goto error; } break; case 'p': - if (data->lines == -1 && data->percentage == -1) { - n = strtonum(optarg, 1, 100, &errstr); - if (errstr != NULL) { - xasprintf( - cause, "percentage %s", errstr); - goto error; - } - data->percentage = n; + if (data->size != -1 || data->percentage != -1) + break; + data->percentage = strtonum(optarg, 1, 100, &errstr); + if (errstr != NULL) { + xasprintf(cause, "percentage %s", errstr); + goto error; } break; + case 'v': + data->flag_horizontal = 0; + break; default: goto usage; } @@ -142,7 +156,8 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) const char **env; char *cmd, *cwd, *cause; u_int hlimit; - int lines; + int size; + enum layout_type type; if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL) return (-1); @@ -158,19 +173,27 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) else cwd = ctx->cmdclient->cwd; - lines = -1; - if (data->lines != -1) - lines = data->lines; + size = -1; + if (data->size != -1) + size = data->size; else if (data->percentage != -1) - lines = (w->active->sy * data->percentage) / 100; - + size = (w->active->sy * data->percentage) / 100; hlimit = options_get_number(&s->options, "history-limit"); - wp = window_add_pane(w, lines, cmd, cwd, env, hlimit, &cause); - if (wp == NULL) { - ctx->error(ctx, "create pane failed: %s", cause); - xfree(cause); - return (-1); + + type = LAYOUT_TOPBOTTOM; + if (data->flag_horizontal) + type = LAYOUT_LEFTRIGHT; + + wp = window_add_pane(w, hlimit, &cause); + if (wp == NULL) + goto error; + if (window_pane_spawn(wp, cmd, cwd, env, &cause) != 0) + goto error; + if (layout_split_pane(w->active, type, size, wp) != 0) { + cause = xstrdup("pane too small"); + goto error; } + server_redraw_window(w); if (!data->flag_detached) { @@ -179,9 +202,15 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) server_redraw_session(s); } else server_status_session(s); - layout_refresh(w, 0); return (0); + +error: + if (wp != NULL) + window_remove_pane(w, wp); + ctx->error(ctx, "create pane failed: %s", cause); + xfree(cause); + return (-1); } void @@ -228,6 +257,8 @@ cmd_split_window_print(struct cmd *self, char *buf, size_t len) return (off); if (off < len && data->flag_detached) off += xsnprintf(buf + off, len - off, " -d"); + if (off < len && data->flag_horizontal) + off += xsnprintf(buf + off, len - off, " -h"); if (off < len && data->target != NULL) off += cmd_prarg(buf + off, len - off, " -t ", data->target); if (off < len && data->cmd != NULL) diff --git a/cmd-swap-pane.c b/cmd-swap-pane.c index e3066ce7..76b18d07 100644 --- a/cmd-swap-pane.c +++ b/cmd-swap-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-swap-pane.c,v 1.8 2009-07-15 17:42:43 nicm Exp $ */ +/* $Id: cmd-swap-pane.c,v 1.9 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -157,6 +157,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx) struct winlink *wl; struct window *w; struct window_pane *tmp_wp, *src_wp, *dst_wp; + struct layout_cell *lc; u_int xx, yy; if (data == NULL) @@ -207,12 +208,15 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx) else TAILQ_INSERT_AFTER(&w->panes, tmp_wp, src_wp, entry); + lc = src_wp->layout_cell; xx = src_wp->xoff; yy = src_wp->yoff; - src_wp->xoff = dst_wp->xoff; - src_wp->yoff = dst_wp->yoff; - dst_wp->xoff = xx; - dst_wp->yoff = yy; + src_wp->layout_cell = dst_wp->layout_cell; + if (src_wp->layout_cell != NULL) + src_wp->layout_cell->wp = src_wp; + dst_wp->layout_cell = lc; + if (dst_wp->layout_cell != NULL) + dst_wp->layout_cell->wp = dst_wp; xx = src_wp->sx; yy = src_wp->sy; @@ -224,8 +228,8 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx) if (!window_pane_visible(tmp_wp)) tmp_wp = src_wp; window_set_active_pane(w, tmp_wp); - layout_refresh(w, 0); } + server_redraw_window(w); return (0); } diff --git a/cmd-up-pane.c b/cmd-up-pane.c index fb5828b6..36a83965 100644 --- a/cmd-up-pane.c +++ b/cmd-up-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-up-pane.c,v 1.9 2009-07-15 17:42:43 nicm Exp $ */ +/* $Id: cmd-up-pane.c,v 1.10 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -54,7 +54,6 @@ cmd_up_pane_exec(struct cmd *self, struct cmd_ctx *ctx) w->active = TAILQ_PREV(w->active, window_panes, entry); if (w->active == NULL) w->active = TAILQ_LAST(&w->panes, window_panes); - layout_refresh(w, 1); } while (!window_pane_visible(w->active)); return (0); diff --git a/key-bindings.c b/key-bindings.c index a9cea9a4..cd8cac67 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -1,4 +1,4 @@ -/* $Id: key-bindings.c,v 1.76 2009-07-18 11:05:45 nicm Exp $ */ +/* $Id: key-bindings.c,v 1.77 2009-07-20 15:42:05 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -93,7 +93,8 @@ key_bindings_init(void) } table[] = { { ' ', 0, &cmd_next_layout_entry }, { '!', 0, &cmd_break_pane_entry }, - { '"', 0, &cmd_split_window_entry }, + { '"', 0, &cmd_split_window_entry }, + { '%', 0, &cmd_split_window_entry }, { '#', 0, &cmd_list_buffers_entry }, { '&', 0, &cmd_confirm_before_entry }, { ',', 0, &cmd_command_prompt_entry }, @@ -132,10 +133,10 @@ key_bindings_init(void) { '{', 0, &cmd_swap_pane_entry }, { '}', 0, &cmd_swap_pane_entry }, { '\002', 0, &cmd_send_prefix_entry }, - { KEYC_ADDESC('0'), 0, &cmd_select_layout_entry }, { KEYC_ADDESC('1'), 0, &cmd_select_layout_entry }, { KEYC_ADDESC('2'), 0, &cmd_select_layout_entry }, - { KEYC_ADDESC('9'), 0, &cmd_select_layout_entry }, + { KEYC_ADDESC('3'), 0, &cmd_select_layout_entry }, + { KEYC_ADDESC('4'), 0, &cmd_select_layout_entry }, { KEYC_PPAGE, 0, &cmd_scroll_mode_entry }, { KEYC_ADDESC('n'), 0, &cmd_next_window_entry }, { KEYC_ADDESC('p'), 0, &cmd_previous_window_entry }, @@ -143,8 +144,12 @@ key_bindings_init(void) { KEYC_DOWN, 0, &cmd_down_pane_entry }, { KEYC_ADDESC(KEYC_UP), 1, &cmd_resize_pane_entry }, { KEYC_ADDESC(KEYC_DOWN), 1, &cmd_resize_pane_entry }, + { KEYC_ADDESC(KEYC_LEFT), 1, &cmd_resize_pane_entry }, + { KEYC_ADDESC(KEYC_RIGHT),1, &cmd_resize_pane_entry }, { KEYC_ADDCTL(KEYC_UP), 1, &cmd_resize_pane_entry }, - { KEYC_ADDCTL(KEYC_DOWN), 1, &cmd_resize_pane_entry }, + { KEYC_ADDCTL(KEYC_DOWN), 1, &cmd_resize_pane_entry }, + { KEYC_ADDCTL(KEYC_LEFT), 1, &cmd_resize_pane_entry }, + { KEYC_ADDCTL(KEYC_RIGHT),1, &cmd_resize_pane_entry }, { KEYC_ADDESC('o'), 0, &cmd_rotate_window_entry }, { '\017', 0, &cmd_rotate_window_entry }, }; diff --git a/layout-manual.c b/layout-manual.c deleted file mode 100644 index 9798b8ca..00000000 --- a/layout-manual.c +++ /dev/null @@ -1,172 +0,0 @@ -/* $Id: layout-manual.c,v 1.4 2009-07-15 17:42:44 nicm Exp $ */ - -/* - * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include "tmux.h" - -void layout_manual_v_update_offsets(struct window *); - -void -layout_manual_v_refresh(struct window *w, unused int active_only) -{ - struct window_pane *wp; - u_int npanes, total, height; - int left; - - if (active_only) - return; - - if (TAILQ_EMPTY(&w->panes)) - return; - - /* Check the new size. */ - npanes = window_count_panes(w); - if (w->sy <= PANE_MINIMUM * npanes) { - /* - * 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; - TAILQ_FOREACH(wp, &w->panes, entry) - total += wp->sy; - total += npanes - 1; - - /* Growing or shrinking? */ - left = w->sy - total; - if (left > 0) { - /* Growing. Expand evenly. */ - while (left > 0) { - TAILQ_FOREACH(wp, &w->panes, entry) { - wp->sy++; - if (--left == 0) - break; - } - } - } else { - /* Shrinking. Reduce evenly down to minimum. */ - while (left < 0) { - TAILQ_FOREACH(wp, &w->panes, entry) { - if (wp->sy <= PANE_MINIMUM - 1) - continue; - wp->sy--; - if (++left == 0) - break; - } - } - } - } - - /* Now do the resize. */ - TAILQ_FOREACH(wp, &w->panes, entry) { - wp->sy--; - window_pane_resize(wp, w->sx, wp->sy + 1); - } - - /* Fill in the offsets. */ - layout_manual_v_update_offsets(w); - - /* Switch the active window if necessary. */ - window_set_active_pane(w, w->active); -} - -void -layout_manual_v_resize(struct window_pane *wp, int adjust) -{ - struct window *w = wp->window; - struct window_pane *wq; - - if (adjust > 0) { - /* - * If this is not the last pane, keep trying to increase size - * and remove it from the next panes. If it is the last, do - * so on the previous pane. - */ - if (TAILQ_NEXT(wp, entry) == NULL) { - if (wp == TAILQ_FIRST(&w->panes)) { - /* Only one pane. */ - return; - } - wp = TAILQ_PREV(wp, window_panes, entry); - } - while (adjust-- > 0) { - wq = wp; - while ((wq = TAILQ_NEXT(wq, entry)) != NULL) { - if (wq->sy <= PANE_MINIMUM) - continue; - window_pane_resize(wq, wq->sx, wq->sy - 1); - break; - } - if (wq == NULL) - break; - window_pane_resize(wp, wp->sx, wp->sy + 1); - } - } else { - adjust = -adjust; - /* - * If this is not the last pane, keep trying to reduce size - * and add to the following pane. If it is the last, do so on - * the previous pane. - */ - wq = TAILQ_NEXT(wp, entry); - if (wq == NULL) { - if (wp == TAILQ_FIRST(&w->panes)) { - /* Only one pane. */ - return; - } - wq = wp; - wp = TAILQ_PREV(wq, window_panes, entry); - } - while (adjust-- > 0) { - if (wp->sy <= PANE_MINIMUM) - break; - window_pane_resize(wq, wq->sx, wq->sy + 1); - window_pane_resize(wp, wp->sx, wp->sy - 1); - } - } - - layout_manual_v_update_offsets(w); -} - -void -layout_manual_v_update_offsets(struct window *w) -{ - struct window_pane *wp; - u_int yoff; - - yoff = 0; - TAILQ_FOREACH(wp, &w->panes, entry) { - wp->xoff = 0; - wp->yoff = yoff; - yoff += wp->sy + 1; - } -} diff --git a/layout-set.c b/layout-set.c new file mode 100644 index 00000000..46d2e1ef --- /dev/null +++ b/layout-set.c @@ -0,0 +1,436 @@ +/* $Id: layout-set.c,v 1.1 2009-07-20 15:42:05 tcunha Exp $ */ + +/* + * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/types.h> + +#include <string.h> + |