enum cmd_retval cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; struct winlink *wl; struct window_pane *wp; if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) { wl = cmd_find_window(cmdq, args_get(args, 't'), NULL); if (wl == NULL) return (CMD_RETURN_ERROR); if (wl->window->last == NULL) { cmdq_error(cmdq, "no last pane"); return (CMD_RETURN_ERROR); } server_unzoom_window(wl->window); window_set_active_pane(wl->window, wl->window->last); server_status_window(wl->window); server_redraw_window_borders(wl->window); return (CMD_RETURN_NORMAL); } if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL) return (CMD_RETURN_ERROR); server_unzoom_window(wp->window); if (!window_pane_visible(wp)) { cmdq_error(cmdq, "pane not visible"); return (CMD_RETURN_ERROR); } if (args_has(self->args, 'L')) wp = window_pane_find_left(wp); else if (args_has(self->args, 'R')) wp = window_pane_find_right(wp); else if (args_has(self->args, 'U')) wp = window_pane_find_up(wp); else if (args_has(self->args, 'D')) wp = window_pane_find_down(wp); if (wp == NULL) { cmdq_error(cmdq, "pane not found"); return (CMD_RETURN_ERROR); } window_set_active_pane(wl->window, wp); server_status_window(wl->window); server_redraw_window_borders(wl->window); return (CMD_RETURN_NORMAL); }
int cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; struct winlink *wl; struct window_pane *wp; if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) { wl = cmd_find_window(ctx, args_get(args, 't'), NULL); if (wl == NULL) return (-1); if (wl->window->last == NULL) { ctx->error(ctx, "no last pane"); return (-1); } window_set_active_pane(wl->window, wl->window->last); server_status_window(wl->window); server_redraw_window_borders(wl->window); return (0); } if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL) return (-1); if (!window_pane_visible(wp)) { ctx->error(ctx, "pane not visible"); return (-1); } if (args_has(self->args, 'L')) wp = window_pane_find_left(wp); else if (args_has(self->args, 'R')) wp = window_pane_find_right(wp); else if (args_has(self->args, 'U')) wp = window_pane_find_up(wp); else if (args_has(self->args, 'D')) wp = window_pane_find_down(wp); if (wp == NULL) { ctx->error(ctx, "pane not found"); return (-1); } window_set_active_pane(wl->window, wp); server_status_window(wl->window); server_redraw_window_borders(wl->window); return (0); }
int cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; struct winlink *wl; struct window_pane *wp; if ((wl = cmd_find_pane(ctx, data->target, NULL, &wp)) == NULL) return (-1); if (!window_pane_visible(wp)) { ctx->error(ctx, "pane not visible: %s", data->target); return (-1); } if (cmd_check_flag(data->chflags, 'L')) wp = window_pane_find_left(wp); else if (cmd_check_flag(data->chflags, 'R')) wp = window_pane_find_right(wp); else if (cmd_check_flag(data->chflags, 'U')) wp = window_pane_find_up(wp); else if (cmd_check_flag(data->chflags, 'D')) wp = window_pane_find_down(wp); if (wp == NULL) { ctx->error(ctx, "pane not found"); return (-1); } window_set_active_pane(wl->window, wp); server_status_window(wl->window); server_redraw_window_borders(wl->window); return (0); }
enum cmd_retval cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; struct winlink *wl; struct window *w; struct window_pane *wp; struct session *s; struct environ *env; const char *path; char *cause; u_int idx; struct environ_entry *envent; if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL) return (CMD_RETURN_ERROR); w = wl->window; if (!args_has(self->args, 'k') && wp->fd != -1) { if (window_pane_index(wp, &idx) != 0) fatalx("index not found"); cmdq_error(cmdq, "pane still active: %s:%d.%u", s->name, wl->idx, idx); return (CMD_RETURN_ERROR); } env = environ_create(); environ_copy(global_environ, env); environ_copy(s->environ, env); server_fill_environ(s, env); window_pane_reset_mode(wp); screen_reinit(&wp->base); input_init(wp); path = NULL; if (cmdq->client != NULL && cmdq->client->session == NULL) envent = environ_find(cmdq->client->environ, "PATH"); else envent = environ_find(s->environ, "PATH"); if (envent != NULL) path = envent->value; if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, -1, env, s->tio, &cause) != 0) { cmdq_error(cmdq, "respawn pane failed: %s", cause); free(cause); environ_free(env); return (CMD_RETURN_ERROR); } wp->flags |= PANE_REDRAW; server_status_window(w); environ_free(env); return (CMD_RETURN_NORMAL); }
// cmd_select_pane_exec int cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx) { struct window *w; struct winlink *wl; struct window_pane *wp; struct window_pane *tar_wp; struct cmd_target_data *data = self->data; int dir; bool (*filt)(struct window_pane *our, struct window_pane *their); int (*sort)(const void *a, const void *b); if ((wl = cmd_find_pane(ctx, data->target, NULL, &wp)) == NULL) return (-1); w = wl->window; if (!window_pane_visible(wp)) { ctx->error(ctx, "pane not visible: %s", data->target); return (-1); } if (!data->chflags) { window_set_active_pane(wl->window, wp); return (0); } // directions if (cmd_check_flag(data->chflags, 'L')) { filt = wp_next_l_filt; sort = wp_next_l_sort; dir = WP_L; } if (cmd_check_flag(data->chflags, 'R')) { filt = wp_next_r_filt; sort = wp_next_r_sort; dir= WP_R; } if (cmd_check_flag(data->chflags, 'U')) { filt = wp_next_u_filt; sort = wp_next_u_sort; dir = WP_U; } if (cmd_check_flag(data->chflags, 'D')) { filt = wp_next_d_filt; sort = wp_next_d_sort; dir = WP_D; } if (filt && sort) if ((tar_wp = wp_next(wp, dir, filt, sort)) != NULL) { window_set_active_pane(wl->window, tar_wp); server_status_window(wl->window); } return (0); }
/* APC terminator (ST) received. */ void input_exit_apc(struct input_ctx *ictx) { if (ictx->flags & INPUT_DISCARD) return; log_debug("%s: \"%s\"", __func__, ictx->input_buf); screen_set_title(ictx->ctx.s, ictx->input_buf); server_status_window(ictx->wp->window); }
void check_window_name(struct window *w) { struct timeval tv, next; char *name; int left; if (w->active == NULL) return; if (!options_get_number(w->options, "automatic-rename")) return; if (~w->active->flags & PANE_CHANGED) { log_debug("@%u active pane not changed", w->id); return; } log_debug("@%u active pane changed", w->id); gettimeofday(&tv, NULL); left = name_time_expired(w, &tv); if (left != 0) { if (!event_initialized(&w->name_event)) evtimer_set(&w->name_event, name_time_callback, w); if (!evtimer_pending(&w->name_event, NULL)) { log_debug("@%u name timer queued (%d left)", w->id, left); timerclear(&next); next.tv_usec = left; event_add(&w->name_event, &next); } else { log_debug("@%u name timer already queued (%d left)", w->id, left); } return; } memcpy(&w->name_time, &tv, sizeof w->name_time); if (event_initialized(&w->name_event)) evtimer_del(&w->name_event); w->active->flags &= ~PANE_CHANGED; name = format_window_name(w); if (strcmp(name, w->name) != 0) { log_debug("@%u new name %s (was %s)", w->id, name, w->name); window_set_name(w, name); server_status_window(w); } else log_debug("@%u name not changed (still %s)", w->id, w->name); free(name); }
enum cmd_retval cmd_rename_window_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; struct winlink *wl = cmdq->state.tflag.wl; window_set_name(wl->window, args->argv[0]); options_set_number(wl->window->options, "automatic-rename", 0); server_status_window(wl->window); return (CMD_RETURN_NORMAL); }
/* Rename terminator (ST) received. */ void input_exit_rename(struct input_ctx *ictx) { if (ictx->flags & INPUT_DISCARD) return; log_debug("%s: \"%s\"", __func__, ictx->input_buf); xfree(ictx->wp->window->name); ictx->wp->window->name = xstrdup(ictx->input_buf); options_set_number(&ictx->wp->window->options, "automatic-rename", 0); server_status_window(ictx->wp->window); }
int cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; struct winlink *wl; struct window *w; struct window_pane *wp; struct session *s; struct environ env; const char *cmd; char *cause; u_int idx; if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL) return (-1); w = wl->window; if (!args_has(self->args, 'k') && wp->fd != -1) { if (window_pane_index(wp, &idx) != 0) fatalx("index not found"); ctx->error(ctx, "pane still active: %s:%u.%u", s->name, wl->idx, idx); return (-1); } environ_init(&env); environ_copy(&global_environ, &env); environ_copy(&s->environ, &env); server_fill_environ(s, &env); window_pane_reset_mode(wp); screen_reinit(&wp->base); input_init(wp); if (args->argc != 0) cmd = args->argv[0]; else cmd = NULL; if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) { ctx->error(ctx, "respawn pane failed: %s", cause); xfree(cause); environ_free(&env); return (-1); } wp->flags |= PANE_REDRAW; server_status_window(w); environ_free(&env); return (0); }
/* Rename terminator (ST) received. */ void input_exit_rename(struct input_ctx *ictx) { if (ictx->flags & INPUT_DISCARD) return; if (!options_get_number(ictx->wp->window->options, "allow-rename")) return; log_debug("%s: \"%s\"", __func__, ictx->input_buf); window_set_name(ictx->wp->window, ictx->input_buf); options_set_number(ictx->wp->window->options, "automatic-rename", 0); server_status_window(ictx->wp->window); }
static enum cmd_retval cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; struct winlink *wl = item->target.wl; struct window *w = wl->window; struct window_pane *wp = item->target.wp; struct session *s = item->target.s; struct environ *env; const char *path; char *cause; u_int idx; struct environ_entry *envent; if (!args_has(self->args, 'k') && wp->fd != -1) { if (window_pane_index(wp, &idx) != 0) fatalx("index not found"); cmdq_error(item, "pane still active: %s:%d.%u", s->name, wl->idx, idx); return (CMD_RETURN_ERROR); } window_pane_reset_mode(wp); screen_reinit(&wp->base); input_init(wp); path = NULL; if (item->client != NULL && item->client->session == NULL) envent = environ_find(item->client->environ, "PATH"); else envent = environ_find(s->environ, "PATH"); if (envent != NULL) path = envent->value; env = environ_for_session(s, 0); if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env, s->tio, &cause) != 0) { cmdq_error(item, "respawn pane failed: %s", cause); free(cause); environ_free(env); return (CMD_RETURN_ERROR); } environ_free(env); wp->flags |= PANE_REDRAW; server_status_window(w); return (CMD_RETURN_NORMAL); }
/* OSC terminator (ST) received. */ void input_exit_osc(struct input_ctx *ictx) { if (ictx->flags & INPUT_DISCARD) return; log_debug("%s: \"%s\"", __func__, ictx->input_buf); if (ictx->input_len < 2 || ictx->input_buf[1] != ';') return; if (ictx->input_buf[0] != '0' && ictx->input_buf[0] != '2') return; screen_set_title(ictx->ctx.s, ictx->input_buf + 2); server_status_window(ictx->wp->window); }
void window_name_callback(unused int fd, unused short events, void *data) { struct window *w = data; char *name, *wname; if (w->active == NULL) return; if (!options_get_number(&w->options, "automatic-rename")) { if (event_initialized(&w->name_timer)) event_del(&w->name_timer); return; } queue_window_name(w); if (w->active->screen != &w->active->base) name = NULL; else name = osdep_get_name(w->active->fd, w->active->tty); if (name == NULL) wname = default_window_name(w); else { /* * If tmux is using the default command, it will be a login * shell and argv[0] may have a - prefix. Remove this if it is * present. Ick. */ if (w->active->cmd != NULL && *w->active->cmd == '\0' && name != NULL && name[0] == '-' && name[1] != '\0') wname = parse_window_name(name + 1); else wname = parse_window_name(name); free(name); } if (w->active->fd == -1) { xasprintf(&name, "%s[dead]", wname); free(wname); wname = name; } if (strcmp(wname, w->name)) { window_set_name(w, wname); server_status_window(w); } free(wname); }
enum cmd_retval cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; struct session *s; struct winlink *wl; if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL) return (CMD_RETURN_ERROR); window_set_name(wl->window, args->argv[0]); options_set_number(&wl->window->options, "automatic-rename", 0); server_status_window(wl->window); return (CMD_RETURN_NORMAL); }
int cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; struct session *s; struct winlink *wl; if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL) return (-1); xfree(wl->window->name); wl->window->name = xstrdup(data->arg); options_set_number(&wl->window->options, "automatic-rename", 0); server_status_window(wl->window); return (0); }
int cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_target_data *data = self->data; struct winlink *wl; struct window *w; if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) return (-1); w = wl->window; do { w->active = TAILQ_NEXT(w->active, entry); if (w->active == NULL) w->active = TAILQ_FIRST(&w->panes); } while (!window_pane_visible(w->active)); server_status_window(wl->window); return (0); }
static enum cmd_retval cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; struct spawn_context sc; struct session *s = item->target.s; struct winlink *wl = item->target.wl; struct window_pane *wp = item->target.wp; char *cause = NULL; memset(&sc, 0, sizeof sc); sc.item = item; sc.s = s; sc.wl = wl; sc.wp0 = wp; sc.lc = NULL; sc.name = NULL; sc.argc = args->argc; sc.argv = args->argv; sc.idx = -1; sc.cwd = args_get(args, 'c'); sc.flags = SPAWN_RESPAWN; if (args_has(args, 'k')) sc.flags |= SPAWN_KILL; if (spawn_pane(&sc, &cause) == NULL) { cmdq_error(item, "respawn pane failed: %s", cause); free(cause); return (CMD_RETURN_ERROR); } wp->flags |= PANE_REDRAW; server_status_window(wp->window); return (CMD_RETURN_NORMAL); }
/* OSC terminator (ST) received. */ void input_exit_osc(struct input_ctx *ictx) { u_char *p = ictx->input_buf; int option; if (ictx->flags & INPUT_DISCARD) return; if (ictx->input_len < 1 || *p < '0' || *p > '9') return; log_debug("%s: \"%s\"", __func__, p); option = 0; while (*p >= '0' && *p <= '9') option = option * 10 + *p++ - '0'; if (*p == ';') p++; switch (option) { case 0: case 2: screen_set_title(ictx->ctx.s, p); server_status_window(ictx->wp->window); break; case 12: if (*p != '?') /* ? is colour request */ screen_set_cursor_colour(ictx->ctx.s, p); break; case 112: if (*p == '\0') /* no arguments allowed */ screen_set_cursor_colour(ictx->ctx.s, ""); break; default: log_debug("%s: unknown '%u'", __func__, option); break; } }
static enum cmd_retval cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; struct cmd_find_state *current = &item->shared->current; struct client *c = cmd_find_client(item, NULL, 1); struct winlink *wl = item->target.wl; struct window *w = wl->window; struct session *s = item->target.s; struct window_pane *wp = item->target.wp, *lastwp, *markedwp; char *pane_title; const char *style; if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) { lastwp = w->last; if (lastwp == NULL) { cmdq_error(item, "no last pane"); return (CMD_RETURN_ERROR); } if (args_has(self->args, 'e')) lastwp->flags &= ~PANE_INPUTOFF; else if (args_has(self->args, 'd')) lastwp->flags |= PANE_INPUTOFF; else { server_unzoom_window(w); window_redraw_active_switch(w, lastwp); if (window_set_active_pane(w, lastwp)) { cmd_find_from_winlink(current, wl, 0); server_status_window(w); server_redraw_window_borders(w); } } return (CMD_RETURN_NORMAL); } if (args_has(args, 'm') || args_has(args, 'M')) { if (args_has(args, 'm') && !window_pane_visible(wp)) return (CMD_RETURN_NORMAL); lastwp = marked_pane.wp; if (args_has(args, 'M') || server_is_marked(s, wl, wp)) server_clear_marked(); else server_set_marked(s, wl, wp); markedwp = marked_pane.wp; if (lastwp != NULL) { server_redraw_window_borders(lastwp->window); server_status_window(lastwp->window); } if (markedwp != NULL) { server_redraw_window_borders(markedwp->window); server_status_window(markedwp->window); } return (CMD_RETURN_NORMAL); } if (args_has(self->args, 'P') || args_has(self->args, 'g')) { if (args_has(args, 'P')) { style = args_get(args, 'P'); if (style_parse(&grid_default_cell, &wp->colgc, style) == -1) { cmdq_error(item, "bad style: %s", style); return (CMD_RETURN_ERROR); } wp->flags |= PANE_REDRAW; } if (args_has(self->args, 'g')) cmdq_print(item, "%s", style_tostring(&wp->colgc)); return (CMD_RETURN_NORMAL); } if (args_has(self->args, 'L')) { server_unzoom_window(wp->window); wp = window_pane_find_left(wp); } else if (args_has(self->args, 'R')) { server_unzoom_window(wp->window); wp = window_pane_find_right(wp); } else if (args_has(self->args, 'U')) { server_unzoom_window(wp->window); wp = window_pane_find_up(wp); } else if (args_has(self->args, 'D')) { server_unzoom_window(wp->window); wp = window_pane_find_down(wp); } if (wp == NULL) return (CMD_RETURN_NORMAL); if (args_has(self->args, 'e')) { wp->flags &= ~PANE_INPUTOFF; return (CMD_RETURN_NORMAL); } if (args_has(self->args, 'd')) { wp->flags |= PANE_INPUTOFF; return (CMD_RETURN_NORMAL); } if (args_has(self->args, 'T')) { pane_title = format_single(item, args_get(self->args, 'T'), c, s, wl, wp); screen_set_title(&wp->base, pane_title); server_status_window(wp->window); free(pane_title); } if (wp == w->active) return (CMD_RETURN_NORMAL); server_unzoom_window(wp->window); if (!window_pane_visible(wp)) { cmdq_error(item, "pane not visible"); return (CMD_RETURN_ERROR); } window_redraw_active_switch(w, wp); if (window_set_active_pane(w, wp)) { cmd_find_from_winlink_pane(current, wl, wp, 0); hooks_insert(s->hooks, item, current, "after-select-pane"); server_status_window(w); server_redraw_window_borders(w); } return (CMD_RETURN_NORMAL); }
enum cmd_retval cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; struct winlink *wl; struct window_pane *wp; const char *style; if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) { wl = cmd_find_window(cmdq, args_get(args, 't'), NULL); if (wl == NULL) return (CMD_RETURN_ERROR); if (wl->window->last == NULL) { cmdq_error(cmdq, "no last pane"); return (CMD_RETURN_ERROR); } if (args_has(self->args, 'e')) wl->window->last->flags &= ~PANE_INPUTOFF; else if (args_has(self->args, 'd')) wl->window->last->flags |= PANE_INPUTOFF; else { server_unzoom_window(wl->window); window_set_active_pane(wl->window, wl->window->last); server_status_window(wl->window); server_redraw_window_borders(wl->window); } return (CMD_RETURN_NORMAL); } if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL) return (CMD_RETURN_ERROR); server_unzoom_window(wp->window); if (!window_pane_visible(wp)) { cmdq_error(cmdq, "pane not visible"); return (CMD_RETURN_ERROR); } if (args_has(self->args, 'P') || args_has(self->args, 'g')) { if (args_has(args, 'P')) { style = args_get(args, 'P'); if (style_parse(&grid_default_cell, &wp->colgc, style) == -1) { cmdq_error(cmdq, "bad style: %s", style); return (CMD_RETURN_ERROR); } wp->flags |= PANE_REDRAW; } if (args_has(self->args, 'g')) cmdq_print(cmdq, "%s", style_tostring(&wp->colgc)); return (CMD_RETURN_NORMAL); } if (args_has(self->args, 'L')) wp = window_pane_find_left(wp); else if (args_has(self->args, 'R')) wp = window_pane_find_right(wp); else if (args_has(self->args, 'U')) wp = window_pane_find_up(wp); else if (args_has(self->args, 'D')) wp = window_pane_find_down(wp); if (wp == NULL) { cmdq_error(cmdq, "pane not found"); return (CMD_RETURN_ERROR); } if (args_has(self->args, 'e')) wp->flags &= ~PANE_INPUTOFF; else if (args_has(self->args, 'd')) wp->flags |= PANE_INPUTOFF; else if (window_set_active_pane(wl->window, wp)) { server_status_window(wl->window); server_redraw_window_borders(wl->window); } return (CMD_RETURN_NORMAL); }
static enum cmd_retval cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; struct winlink *wl = item->state.tflag.wl; struct window *w = wl->window; struct session *s = item->state.tflag.s; struct window_pane *wp = item->state.tflag.wp, *lastwp, *markedwp; const char *style; if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) { if (wl->window->last == NULL) { cmdq_error(item, "no last pane"); return (CMD_RETURN_ERROR); } if (args_has(self->args, 'e')) w->last->flags &= ~PANE_INPUTOFF; else if (args_has(self->args, 'd')) w->last->flags |= PANE_INPUTOFF; else { server_unzoom_window(w); window_redraw_active_switch(w, w->last); if (window_set_active_pane(w, w->last)) { server_status_window(w); server_redraw_window_borders(w); } } return (CMD_RETURN_NORMAL); } if (args_has(args, 'm') || args_has(args, 'M')) { if (args_has(args, 'm') && !window_pane_visible(wp)) return (CMD_RETURN_NORMAL); lastwp = marked_pane.wp; if (args_has(args, 'M') || server_is_marked(s, wl, wp)) server_clear_marked(); else server_set_marked(s, wl, wp); markedwp = marked_pane.wp; if (lastwp != NULL) { server_redraw_window_borders(lastwp->window); server_status_window(lastwp->window); } if (markedwp != NULL) { server_redraw_window_borders(markedwp->window); server_status_window(markedwp->window); } return (CMD_RETURN_NORMAL); } if (args_has(self->args, 'P') || args_has(self->args, 'g')) { if (args_has(args, 'P')) { style = args_get(args, 'P'); if (style_parse(&grid_default_cell, &wp->colgc, style) == -1) { cmdq_error(item, "bad style: %s", style); return (CMD_RETURN_ERROR); } wp->flags |= PANE_REDRAW; } if (args_has(self->args, 'g')) cmdq_print(item, "%s", style_tostring(&wp->colgc)); return (CMD_RETURN_NORMAL); } if (args_has(self->args, 'L')) { server_unzoom_window(wp->window); wp = window_pane_find_left(wp); } else if (args_has(self->args, 'R')) { server_unzoom_window(wp->window); wp = window_pane_find_right(wp); } else if (args_has(self->args, 'U')) { server_unzoom_window(wp->window); wp = window_pane_find_up(wp); } else if (args_has(self->args, 'D')) { server_unzoom_window(wp->window); wp = window_pane_find_down(wp); } if (wp == NULL) return (CMD_RETURN_NORMAL); if (args_has(self->args, 'e')) { wp->flags &= ~PANE_INPUTOFF; return (CMD_RETURN_NORMAL); } if (args_has(self->args, 'd')) { wp->flags |= PANE_INPUTOFF; return (CMD_RETURN_NORMAL); } if (wp == w->active) return (CMD_RETURN_NORMAL); server_unzoom_window(wp->window); if (!window_pane_visible(wp)) { cmdq_error(item, "pane not visible"); return (CMD_RETURN_ERROR); } window_redraw_active_switch(w, wp); if (window_set_active_pane(w, wp)) { server_status_window(w); server_redraw_window_borders(w); } return (CMD_RETURN_NORMAL); }
enum cmd_retval cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; struct winlink *wl; struct window *w; const char *errstr; char *cause; struct window_pane *wp; u_int adjust; int x, y; if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL) return (CMD_RETURN_ERROR); w = wl->window; if (args_has(args, 'Z')) { if (w->flags & WINDOW_ZOOMED) window_unzoom(w); else window_zoom(wp); server_redraw_window(w); server_status_window(w); return (CMD_RETURN_NORMAL); } server_unzoom_window(w); if (args->argc == 0) adjust = 1; else { adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr); if (errstr != NULL) { cmdq_error(cmdq, "adjustment %s", errstr); return (CMD_RETURN_ERROR); } } if (args_has(self->args, 'x')) { x = args_strtonum(self->args, 'x', PANE_MINIMUM, INT_MAX, &cause); if (cause != NULL) { cmdq_error(cmdq, "width %s", cause); free(cause); return (CMD_RETURN_ERROR); } layout_resize_pane_to(wp, LAYOUT_LEFTRIGHT, x); } if (args_has(self->args, 'y')) { y = args_strtonum(self->args, 'y', PANE_MINIMUM, INT_MAX, &cause); if (cause != NULL) { cmdq_error(cmdq, "height %s", cause); free(cause); return (CMD_RETURN_ERROR); } layout_resize_pane_to(wp, LAYOUT_TOPBOTTOM, y); } if (args_has(self->args, 'L')) layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust); else if (args_has(self->args, 'R')) layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust); else if (args_has(self->args, 'U')) layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust); else if (args_has(self->args, 'D')) layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust); server_redraw_window(wl->window); return (CMD_RETURN_NORMAL); }