[BACK]Return to cmd-choose-tree.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Annotation of src/usr.bin/tmux/cmd-choose-tree.c, Revision 1.44

1.44    ! nicm        1: /* $OpenBSD: cmd-choose-tree.c,v 1.43 2019/08/16 11:49:12 nicm Exp $ */
1.1       nicm        2:
                      3: /*
                      4:  * Copyright (c) 2012 Thomas Adam <thomas@xteddy.org>
                      5:  *
                      6:  * Permission to use, copy, modify, and distribute this software for any
                      7:  * purpose with or without fee is hereby granted, provided that the above
                      8:  * copyright notice and this permission notice appear in all copies.
                      9:  *
                     10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14:  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
                     15:  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
                     16:  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     17:  */
                     18:
                     19: #include <sys/types.h>
                     20:
                     21: #include "tmux.h"
                     22:
                     23: /*
1.35      nicm       24:  * Enter a mode.
1.1       nicm       25:  */
1.27      nicm       26:
1.33      nicm       27: static enum cmd_retval cmd_choose_tree_exec(struct cmd *, struct cmdq_item *);
1.1       nicm       28:
                     29: const struct cmd_entry cmd_choose_tree_entry = {
1.30      nicm       30:        .name = "choose-tree",
                     31:        .alias = NULL,
                     32:
1.43      nicm       33:        .args = { "F:Gf:NO:rst:wZ", 0, 1 },
                     34:        .usage = "[-GNrswZ] [-F format] [-f filter] [-O sort-order] "
1.42      kn         35:                 CMD_TARGET_PANE_USAGE " [template]",
1.30      nicm       36:
1.35      nicm       37:        .target = { 't', CMD_FIND_PANE, 0 },
1.31      nicm       38:
                     39:        .flags = 0,
1.30      nicm       40:        .exec = cmd_choose_tree_exec
1.1       nicm       41: };
                     42:
1.35      nicm       43: const struct cmd_entry cmd_choose_client_entry = {
                     44:        .name = "choose-client",
1.30      nicm       45:        .alias = NULL,
                     46:
1.43      nicm       47:        .args = { "F:f:NO:rt:Z", 0, 1 },
                     48:        .usage = "[-NrZ] [-F format] [-f filter] [-O sort-order] "
1.42      kn         49:                 CMD_TARGET_PANE_USAGE " [template]",
1.30      nicm       50:
1.35      nicm       51:        .target = { 't', CMD_FIND_PANE, 0 },
1.30      nicm       52:
1.31      nicm       53:        .flags = 0,
1.30      nicm       54:        .exec = cmd_choose_tree_exec
1.1       nicm       55: };
                     56:
1.35      nicm       57: const struct cmd_entry cmd_choose_buffer_entry = {
                     58:        .name = "choose-buffer",
1.30      nicm       59:        .alias = NULL,
                     60:
1.43      nicm       61:        .args = { "F:f:NO:rt:Z", 0, 1 },
                     62:        .usage = "[-NrZ] [-F format] [-f filter] [-O sort-order] "
1.42      kn         63:                 CMD_TARGET_PANE_USAGE " [template]",
1.30      nicm       64:
1.35      nicm       65:        .target = { 't', CMD_FIND_PANE, 0 },
1.31      nicm       66:
                     67:        .flags = 0,
1.30      nicm       68:        .exec = cmd_choose_tree_exec
1.1       nicm       69: };
                     70:
1.32      nicm       71: static enum cmd_retval
1.33      nicm       72: cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
1.1       nicm       73: {
                     74:        struct args                     *args = self->args;
1.35      nicm       75:        struct window_pane              *wp = item->target.wp;
                     76:        const struct window_mode        *mode;
                     77:
                     78:        if (self->entry == &cmd_choose_buffer_entry) {
                     79:                if (paste_get_top(NULL) == NULL)
                     80:                        return (CMD_RETURN_NORMAL);
                     81:                mode = &window_buffer_mode;
                     82:        } else if (self->entry == &cmd_choose_client_entry) {
                     83:                if (server_client_how_many() == 0)
                     84:                        return (CMD_RETURN_NORMAL);
                     85:                mode = &window_client_mode;
1.8       nicm       86:        } else
1.35      nicm       87:                mode = &window_tree_mode;
1.1       nicm       88:
1.44    ! nicm       89:        window_pane_set_mode(wp, NULL, mode, &item->target, args);
1.4       nicm       90:        return (CMD_RETURN_NORMAL);
1.1       nicm       91: }