GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.bin/tmux/cmd-choose-tree.c Lines: 0 11 0.0 %
Date: 2017-11-07 Branches: 0 8 0.0 %

Line Branch Exec Source
1
/* $OpenBSD: cmd-choose-tree.c,v 1.39 2017/08/23 09:39:11 nicm Exp $ */
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
/*
24
 * Enter a mode.
25
 */
26
27
static enum cmd_retval	cmd_choose_tree_exec(struct cmd *, struct cmdq_item *);
28
29
const struct cmd_entry cmd_choose_tree_entry = {
30
	.name = "choose-tree",
31
	.alias = NULL,
32
33
	.args = { "F:f:NO:st:w", 0, 1 },
34
	.usage = "[-Nsw] [-F format] [-f filter] [-O sort-order] "
35
	         CMD_TARGET_PANE_USAGE,
36
37
	.target = { 't', CMD_FIND_PANE, 0 },
38
39
	.flags = 0,
40
	.exec = cmd_choose_tree_exec
41
};
42
43
const struct cmd_entry cmd_choose_client_entry = {
44
	.name = "choose-client",
45
	.alias = NULL,
46
47
	.args = { "F:f:NO:t:", 0, 1 },
48
	.usage = "[-N] [-F format] [-f filter] [-O sort-order] "
49
	         CMD_TARGET_PANE_USAGE,
50
51
	.target = { 't', CMD_FIND_PANE, 0 },
52
53
	.flags = 0,
54
	.exec = cmd_choose_tree_exec
55
};
56
57
const struct cmd_entry cmd_choose_buffer_entry = {
58
	.name = "choose-buffer",
59
	.alias = NULL,
60
61
	.args = { "F:f:NO:t:", 0, 1 },
62
	.usage = "[-N] [-F format] [-f filter] [-O sort-order] "
63
	         CMD_TARGET_PANE_USAGE,
64
65
	.target = { 't', CMD_FIND_PANE, 0 },
66
67
	.flags = 0,
68
	.exec = cmd_choose_tree_exec
69
};
70
71
static enum cmd_retval
72
cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
73
{
74
	struct args			*args = self->args;
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;
86
	} else
87
		mode = &window_tree_mode;
88
89
	window_pane_set_mode(wp, mode, &item->target, args);
90
	return (CMD_RETURN_NORMAL);
91
}