=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/window.c,v retrieving revision 1.13 retrieving revision 1.14 diff -c -r1.13 -r1.14 *** src/usr.bin/tmux/window.c 2009/07/17 18:45:08 1.13 --- src/usr.bin/tmux/window.c 2009/07/19 13:21:40 1.14 *************** *** 1,4 **** ! /* $OpenBSD: window.c,v 1.13 2009/07/17 18:45:08 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: window.c,v 1.14 2009/07/19 13:21:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 35,41 **** #include "tmux.h" /* ! * Each window is attached to one or two panes, each of which is a pty. This * file contains code to handle them. * * A pane has two buffers attached, these are filled and emptied by the main --- 35,41 ---- #include "tmux.h" /* ! * Each window is attached to a number of panes, each of which is a pty. This * file contains code to handle them. * * A pane has two buffers attached, these are filled and emptied by the main *************** *** 230,237 **** TAILQ_INIT(&w->panes); w->active = NULL; - w->layout = 0; w->sx = sx; w->sy = sy; --- 230,239 ---- TAILQ_INIT(&w->panes); w->active = NULL; + w->layout = 0; + w->layout_root = NULL; + w->sx = sx; w->sy = sy; *************** *** 254,268 **** window_create(const char *name, const char *cmd, const char *cwd, const char **envp, u_int sx, u_int sy, u_int hlimit, char **cause) { ! struct window *w; w = window_create1(sx, sy); ! if (window_add_pane(w, -1, cmd, cwd, envp, hlimit, cause) == NULL) { window_destroy(w); return (NULL); } w->active = TAILQ_FIRST(&w->panes); - if (name != NULL) { w->name = xstrdup(name); options_set_number(&w->options, "automatic-rename", 0); --- 256,275 ---- window_create(const char *name, const char *cmd, const char *cwd, const char **envp, u_int sx, u_int sy, u_int hlimit, char **cause) { ! struct window *w; ! struct window_pane *wp; w = window_create1(sx, sy); ! if ((wp = window_add_pane(w, hlimit, cause)) == NULL) { window_destroy(w); return (NULL); } + layout_init(w); + if (window_pane_spawn(wp, cmd, cwd, envp, cause) != 0) { + window_destroy(w); + return (NULL); + } w->active = TAILQ_FIRST(&w->panes); if (name != NULL) { w->name = xstrdup(name); options_set_number(&w->options, "automatic-rename", 0); *************** *** 282,287 **** --- 289,297 ---- while (!ARRAY_EMPTY(&windows) && ARRAY_LAST(&windows) == NULL) ARRAY_TRUNC(&windows, 1); + if (w->layout_root != NULL) + layout_free(w); + options_free(&w->options); window_destroy_panes(w); *************** *** 304,310 **** window_set_active_pane(struct window *w, struct window_pane *wp) { w->active = wp; - while (!window_pane_visible(w->active)) { w->active = TAILQ_PREV(w->active, window_panes, entry); if (w->active == NULL) --- 314,319 ---- *************** *** 315,355 **** } struct window_pane * ! window_add_pane(struct window *w, int wanty, const char *cmd, ! const char *cwd, const char **envp, u_int hlimit, char **cause) { struct window_pane *wp; - u_int sizey; if (TAILQ_EMPTY(&w->panes)) - wanty = w->sy; - else { - sizey = w->active->sy - 1; /* for separator */ - if (sizey < PANE_MINIMUM * 2) { - *cause = xstrdup("pane too small"); - return (NULL); - } - - if (wanty == -1) - wanty = sizey / 2; - - if (wanty < PANE_MINIMUM) - wanty = PANE_MINIMUM; - if ((u_int) wanty > sizey - PANE_MINIMUM) - wanty = sizey - PANE_MINIMUM; - - window_pane_resize(w->active, w->sx, sizey - wanty); - } - - wp = window_pane_create(w, w->sx, wanty, hlimit); - if (TAILQ_EMPTY(&w->panes)) TAILQ_INSERT_HEAD(&w->panes, wp, entry); else TAILQ_INSERT_AFTER(&w->panes, w->active, wp, entry); - if (window_pane_spawn(wp, cmd, cwd, envp, cause) != 0) { - window_remove_pane(w, wp); - return (NULL); - } return (wp); } --- 324,338 ---- } struct window_pane * ! window_add_pane(struct window *w, u_int hlimit, unused char **cause) { struct window_pane *wp; + wp = window_pane_create(w, w->sx, w->sy, hlimit); if (TAILQ_EMPTY(&w->panes)) TAILQ_INSERT_HEAD(&w->panes, wp, entry); else TAILQ_INSERT_AFTER(&w->panes, w->active, wp, entry); return (wp); } *************** *** 434,439 **** --- 417,424 ---- wp->out = buffer_create(BUFSIZ); wp->mode = NULL; + + wp->layout_cell = NULL; wp->xoff = 0; wp->yoff = 0;