[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.49

1.49    ! nicm        1: /* $OpenBSD: cmd-choose-tree.c,v 1.48 2021/04/12 06:50:25 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.49    ! nicm       33:        .args = { "F:f:GK:NO:rst:wZ", 0, 1, NULL },
1.48      nicm       34:        .usage = "[-GNrswZ] [-F format] [-f filter] [-K key-format] "
                     35:                 "[-O sort-order] " 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.49    ! nicm       47:        .args = { "F:f:K:NO:rt:Z", 0, 1, NULL },
1.48      nicm       48:        .usage = "[-NrZ] [-F format] [-f filter] [-K key-format] "
                     49:                 "[-O sort-order] " 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.49    ! nicm       61:        .args = { "F:f:K:NO:rt:Z", 0, 1, NULL },
1.48      nicm       62:        .usage = "[-NrZ] [-F format] [-f filter] [-K key-format] "
                     63:                 "[-O sort-order] " 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.47      nicm       71: const struct cmd_entry cmd_customize_mode_entry = {
                     72:        .name = "customize-mode",
                     73:        .alias = NULL,
                     74:
1.49    ! nicm       75:        .args = { "F:f:Nt:Z", 0, 0, NULL },
1.47      nicm       76:        .usage = "[-NZ] [-F format] [-f filter] " CMD_TARGET_PANE_USAGE,
                     77:
                     78:        .target = { 't', CMD_FIND_PANE, 0 },
                     79:
                     80:        .flags = 0,
                     81:        .exec = cmd_choose_tree_exec
                     82: };
                     83:
1.32      nicm       84: static enum cmd_retval
1.33      nicm       85: cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
1.1       nicm       86: {
1.45      nicm       87:        struct args                     *args = cmd_get_args(self);
1.46      nicm       88:        struct cmd_find_state           *target = cmdq_get_target(item);
                     89:        struct window_pane              *wp = target->wp;
1.35      nicm       90:        const struct window_mode        *mode;
                     91:
1.45      nicm       92:        if (cmd_get_entry(self) == &cmd_choose_buffer_entry) {
1.35      nicm       93:                if (paste_get_top(NULL) == NULL)
                     94:                        return (CMD_RETURN_NORMAL);
                     95:                mode = &window_buffer_mode;
1.45      nicm       96:        } else if (cmd_get_entry(self) == &cmd_choose_client_entry) {
1.35      nicm       97:                if (server_client_how_many() == 0)
                     98:                        return (CMD_RETURN_NORMAL);
                     99:                mode = &window_client_mode;
1.47      nicm      100:        } else if (cmd_get_entry(self) == &cmd_customize_mode_entry)
                    101:                mode = &window_customize_mode;
                    102:        else
1.35      nicm      103:                mode = &window_tree_mode;
1.1       nicm      104:
1.46      nicm      105:        window_pane_set_mode(wp, NULL, mode, target, args);
1.4       nicm      106:        return (CMD_RETURN_NORMAL);
1.1       nicm      107: }