version 1.63, 2011/01/25 22:31:50 |
version 1.64, 2011/03/27 20:27:27 |
|
|
/* Global window list. */ |
/* Global window list. */ |
struct windows windows; |
struct windows windows; |
|
|
|
/* Global panes tree. */ |
|
struct window_pane_tree all_window_panes; |
|
u_int next_window_pane; |
|
|
void window_pane_read_callback(struct bufferevent *, void *); |
void window_pane_read_callback(struct bufferevent *, void *); |
void window_pane_error_callback(struct bufferevent *, short, void *); |
void window_pane_error_callback(struct bufferevent *, short, void *); |
|
|
|
|
return (wl1->idx - wl2->idx); |
return (wl1->idx - wl2->idx); |
} |
} |
|
|
|
RB_GENERATE(window_pane_tree, window_pane, tree_entry, window_pane_cmp); |
|
|
|
int |
|
window_pane_cmp(struct window_pane *wp1, struct window_pane *wp2) |
|
{ |
|
return (wp1->id - wp2->id); |
|
} |
|
|
struct winlink * |
struct winlink * |
winlink_find_by_window(struct winlinks *wwl, struct window *w) |
winlink_find_by_window(struct winlinks *wwl, struct window *w) |
{ |
{ |
|
|
return (xstrdup(flags)); |
return (xstrdup(flags)); |
} |
} |
|
|
|
/* Find pane in global tree by id. */ |
struct window_pane * |
struct window_pane * |
|
window_pane_find_by_id(u_int id) |
|
{ |
|
struct window_pane wp; |
|
|
|
wp.id = id; |
|
return (RB_FIND(window_pane_tree, &all_window_panes, &wp)); |
|
} |
|
|
|
struct window_pane * |
window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit) |
window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit) |
{ |
{ |
struct window_pane *wp; |
struct window_pane *wp; |
|
|
wp = xcalloc(1, sizeof *wp); |
wp = xcalloc(1, sizeof *wp); |
wp->window = w; |
wp->window = w; |
|
|
|
wp->id = next_window_pane++; |
|
RB_INSERT(window_pane_tree, &all_window_panes, wp); |
|
|
wp->cmd = NULL; |
wp->cmd = NULL; |
wp->shell = NULL; |
wp->shell = NULL; |
wp->cwd = NULL; |
wp->cwd = NULL; |
|
|
bufferevent_free(wp->pipe_event); |
bufferevent_free(wp->pipe_event); |
} |
} |
|
|
|
RB_REMOVE(window_pane_tree, &all_window_panes, wp); |
|
|
if (wp->cwd != NULL) |
if (wp->cwd != NULL) |
xfree(wp->cwd); |
xfree(wp->cwd); |
if (wp->shell != NULL) |
if (wp->shell != NULL) |
|
|
const char *cwd, struct environ *env, struct termios *tio, char **cause) |
const char *cwd, struct environ *env, struct termios *tio, char **cause) |
{ |
{ |
struct winsize ws; |
struct winsize ws; |
char *argv0; |
char *argv0, paneid[16]; |
const char *ptr; |
const char *ptr; |
struct termios tio2; |
struct termios tio2; |
|
|
|
|
|
|
closefrom(STDERR_FILENO + 1); |
closefrom(STDERR_FILENO + 1); |
|
|
|
xsnprintf(paneid, sizeof paneid, "%%%u", wp->id); |
|
environ_set(env, "TMUX_PANE", paneid); |
environ_push(env); |
environ_push(env); |
|
|
clear_signals(1); |
clear_signals(1); |