summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-find.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2016-10-16 19:04:06 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2016-10-16 19:04:06 +0000
commit3f0dad54b9b7fbe7e951cb592fa147fbdc7bdde6 (patch)
treea685fa2872c014d3bc9be168c7338d3974fcab39 /usr.bin/tmux/cmd-find.c
parentf71299d662dee69becff6a71ecf049a77fbacd95 (diff)
Mass rename struct cmd_q to struct cmdq_item and related.
Diffstat (limited to 'usr.bin/tmux/cmd-find.c')
-rw-r--r--usr.bin/tmux/cmd-find.c84
1 files changed, 43 insertions, 41 deletions
diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c
index a31193f9529..89dc15d3496 100644
--- a/usr.bin/tmux/cmd-find.c
+++ b/usr.bin/tmux/cmd-find.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-find.c,v 1.36 2016/10/16 17:55:14 nicm Exp $ */
+/* $OpenBSD: cmd-find.c,v 1.37 2016/10/16 19:04:05 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -38,7 +38,7 @@ static int cmd_find_best_winlink_with_window(struct cmd_find_state *);
static int cmd_find_current_session_with_client(struct cmd_find_state *);
static int cmd_find_current_session(struct cmd_find_state *);
-static struct client *cmd_find_current_client(struct cmd_q *);
+static struct client *cmd_find_current_client(struct cmdq_item *);
static const char *cmd_find_map_table(const char *[][2], const char *);
@@ -192,8 +192,8 @@ cmd_find_best_session_with_window(struct cmd_find_state *fs)
u_int ssize;
struct session *s;
- if (fs->cmdq != NULL && fs->cmdq->client != NULL) {
- fs->s = cmd_find_try_TMUX(fs->cmdq->client, fs->w);
+ if (fs->item != NULL && fs->item->client != NULL) {
+ fs->s = cmd_find_try_TMUX(fs->item->client, fs->w);
if (fs->s != NULL)
return (cmd_find_best_winlink_with_window(fs));
}
@@ -256,9 +256,9 @@ cmd_find_current_session_with_client(struct cmd_find_state *fs)
* sessions to those containing that pane (we still use the current
* window in the best session).
*/
- if (fs->cmdq != NULL && fs->cmdq->client->tty.path != NULL) {
+ if (fs->item != NULL && fs->item->client->tty.path != NULL) {
RB_FOREACH(wp, window_pane_tree, &all_window_panes) {
- if (strcmp(wp->tty, fs->cmdq->client->tty.path) == 0)
+ if (strcmp(wp->tty, fs->item->client->tty.path) == 0)
break;
}
} else
@@ -292,8 +292,8 @@ cmd_find_current_session_with_client(struct cmd_find_state *fs)
unknown_pane:
fs->s = NULL;
- if (fs->cmdq != NULL)
- fs->s = cmd_find_try_TMUX(fs->cmdq->client, NULL);
+ if (fs->item != NULL)
+ fs->s = cmd_find_try_TMUX(fs->item->client, NULL);
if (fs->s == NULL)
fs->s = cmd_find_best_session(NULL, 0, fs->flags);
if (fs->s == NULL)
@@ -314,12 +314,12 @@ static int
cmd_find_current_session(struct cmd_find_state *fs)
{
/* If we know the current client, use it. */
- if (fs->cmdq != NULL && fs->cmdq->client != NULL) {
- log_debug("%s: have client %p%s", __func__, fs->cmdq->client,
- fs->cmdq->client->session == NULL ? "" : " (with session)");
- if (fs->cmdq->client->session == NULL)
+ if (fs->item != NULL && fs->item->client != NULL) {
+ log_debug("%s: have client %p%s", __func__, fs->item->client,
+ fs->item->client->session == NULL ? "" : " (with session)");
+ if (fs->item->client->session == NULL)
return (cmd_find_current_session_with_client(fs));
- fs->s = fs->cmdq->client->session;
+ fs->s = fs->item->client->session;
fs->wl = fs->s->curw;
fs->idx = fs->wl->idx;
fs->w = fs->wl->window;
@@ -341,7 +341,7 @@ cmd_find_current_session(struct cmd_find_state *fs)
/* Work out the best current client. */
static struct client *
-cmd_find_current_client(struct cmd_q *cmdq)
+cmd_find_current_client(struct cmdq_item *item)
{
struct cmd_find_state current;
struct session *s;
@@ -349,14 +349,14 @@ cmd_find_current_client(struct cmd_q *cmdq)
u_int csize;
/* If the queue client has a session, use it. */
- if (cmdq->client != NULL && cmdq->client->session != NULL) {
- log_debug("%s: using cmdq %p client %p", __func__, cmdq,
- cmdq->client);
- return (cmdq->client);
+ if (item->client != NULL && item->client->session != NULL) {
+ log_debug("%s: using item %p client %p", __func__, item,
+ item->client);
+ return (item->client);
}
/* Otherwise find the current session. */
- cmd_find_clear_state(&current, cmdq, 0);
+ cmd_find_clear_state(&current, item, 0);
if (cmd_find_current_session(&current) != 0)
return (NULL);
@@ -793,11 +793,12 @@ cmd_find_get_pane_with_window(struct cmd_find_state *fs, const char *pane)
/* Clear state. */
void
-cmd_find_clear_state(struct cmd_find_state *fs, struct cmd_q *cmdq, int flags)
+cmd_find_clear_state(struct cmd_find_state *fs, struct cmdq_item *item,
+ int flags)
{
memset(fs, 0, sizeof *fs);
- fs->cmdq = cmdq;
+ fs->item = item;
fs->flags = flags;
fs->idx = -1;
@@ -952,12 +953,12 @@ cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp)
/* Find current state. */
int
-cmd_find_current(struct cmd_find_state *fs, struct cmd_q *cmdq, int flags)
+cmd_find_current(struct cmd_find_state *fs, struct cmdq_item *item, int flags)
{
- cmd_find_clear_state(fs, cmdq, flags);
+ cmd_find_clear_state(fs, item, flags);
if (cmd_find_current_session(fs) != 0) {
if (~flags & CMD_FIND_QUIET)
- cmdq_error(cmdq, "no current session");
+ cmdq_error(item, "no current session");
return (-1);
}
return (0);
@@ -969,7 +970,8 @@ cmd_find_current(struct cmd_find_state *fs, struct cmd_q *cmdq, int flags)
*/
int
cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current,
- struct cmd_q *cmdq, const char *target, enum cmd_find_type type, int flags)
+ struct cmdq_item *item, const char *target, enum cmd_find_type type,
+ int flags)
{
struct mouse_event *m;
char *colon, *period, *copy = NULL;
@@ -980,17 +982,17 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current,
log_debug("%s: target none, type %d", __func__, type);
else
log_debug("%s: target %s, type %d", __func__, target, type);
- log_debug("%s: cmdq %p, flags %#x", __func__, cmdq, flags);
+ log_debug("%s: item %p, flags %#x", __func__, item, flags);
/* Clear new state. */
- cmd_find_clear_state(fs, cmdq, flags);
+ cmd_find_clear_state(fs, item, flags);
/* Find current state. */
if (server_check_marked() && (flags & CMD_FIND_DEFAULT_MARKED)) {
fs->current = &marked_pane;
log_debug(" current is marked pane");
- } else if (cmd_find_valid_state(&cmdq->current)) {
- fs->current = &cmdq->current;
+ } else if (cmd_find_valid_state(&item->current)) {
+ fs->current = &item->current;
log_debug(" current is from queue");
} else {
fs->current = current;
@@ -1006,7 +1008,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current,
/* Mouse target is a plain = or {mouse}. */
if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) {
- m = &cmdq->mouse;
+ m = &item->mouse;
switch (type) {
case CMD_FIND_PANE:
fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl);
@@ -1024,7 +1026,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current,
}
if (fs->wp == NULL) {
if (~flags & CMD_FIND_QUIET)
- cmdq_error(cmdq, "no mouse target");
+ cmdq_error(item, "no mouse target");
goto error;
}
goto found;
@@ -1034,7 +1036,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current,
if (strcmp(target, "~") == 0 || strcmp(target, "{marked}") == 0) {
if (!server_check_marked()) {
if (~flags & CMD_FIND_QUIET)
- cmdq_error(cmdq, "no marked target");
+ cmdq_error(item, "no marked target");
goto error;
}
cmd_find_copy_state(fs, &marked_pane);
@@ -1120,7 +1122,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current,
/* No pane is allowed if want an index. */
if (pane != NULL && (flags & CMD_FIND_WINDOW_INDEX)) {
if (~flags & CMD_FIND_QUIET)
- cmdq_error(cmdq, "can't specify pane here");
+ cmdq_error(item, "can't specify pane here");
goto error;
}
@@ -1219,23 +1221,23 @@ found:
no_session:
if (~flags & CMD_FIND_QUIET)
- cmdq_error(cmdq, "can't find session %s", session);
+ cmdq_error(item, "can't find session %s", session);
goto error;
no_window:
if (~flags & CMD_FIND_QUIET)
- cmdq_error(cmdq, "can't find window %s", window);
+ cmdq_error(item, "can't find window %s", window);
goto error;
no_pane:
if (~flags & CMD_FIND_QUIET)
- cmdq_error(cmdq, "can't find pane %s", pane);
+ cmdq_error(item, "can't find pane %s", pane);
goto error;
}
/* Find the target client or report an error and return NULL. */
struct client *
-cmd_find_client(struct cmd_q *cmdq, const char *target, int quiet)
+cmd_find_client(struct cmdq_item *item, const char *target, int quiet)
{
struct client *c;
char *copy;
@@ -1243,10 +1245,10 @@ cmd_find_client(struct cmd_q *cmdq, const char *target, int quiet)
const char *path;
/* A NULL argument means the current client. */
- if (cmdq != NULL && target == NULL) {
- c = cmd_find_current_client(cmdq);
+ if (item != NULL && target == NULL) {
+ c = cmd_find_current_client(item);
if (c == NULL && !quiet)
- cmdq_error(cmdq, "no current client");
+ cmdq_error(item, "no current client");
log_debug("%s: no target, return %p", __func__, c);
return (c);
}
@@ -1276,7 +1278,7 @@ cmd_find_client(struct cmd_q *cmdq, const char *target, int quiet)
/* If no client found, report an error. */
if (c == NULL && !quiet)
- cmdq_error(cmdq, "can't find client %s", copy);
+ cmdq_error(item, "can't find client %s", copy);
free(copy);
log_debug("%s: target %s, return %p", __func__, target, c);