summaryrefslogtreecommitdiffstats
path: root/cmd-find.c
diff options
context:
space:
mode:
authornicm <nicm>2017-04-05 10:49:46 +0000
committernicm <nicm>2017-04-05 10:49:46 +0000
commit9b28200578670183a0dc70f1d16d5642101a6982 (patch)
tree745e1455c441ab36e2b39ec9398bfb40c14c9a56 /cmd-find.c
parentab4a4b2ad0ce2c8fdb485bc0fe871571181eace8 (diff)
Give each client a name. This defaults to the tty name as before but
falls back to an alternative if the tty name is not available. This is clearer than overloading the client ttyname member and allows us to remove the path stored in the tty struct, it should always be the same as the client.
Diffstat (limited to 'cmd-find.c')
-rw-r--r--cmd-find.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/cmd-find.c b/cmd-find.c
index 2f28a028..5c60f200 100644
--- a/cmd-find.c
+++ b/cmd-find.c
@@ -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->item != NULL && fs->item->client->tty.path != NULL) {
+ if (fs->item != NULL) {
RB_FOREACH(wp, window_pane_tree, &all_window_panes) {
- if (strcmp(wp->tty, fs->item->client->tty.path) == 0)
+ if (strcmp(wp->tty, fs->item->client->ttyname) == 0)
break;
}
} else
@@ -1248,7 +1248,6 @@ cmd_find_client(struct cmdq_item *item, const char *target, int quiet)
struct client *c;
char *copy;
size_t size;
- const char *path;
/* A NULL argument means the current client. */
if (item != NULL && target == NULL) {
@@ -1265,20 +1264,20 @@ cmd_find_client(struct cmdq_item *item, const char *target, int quiet)
if (size != 0 && copy[size - 1] == ':')
copy[size - 1] = '\0';
- /* Check path of each client. */
+ /* Check name and path of each client. */
TAILQ_FOREACH(c, &clients, entry) {
- if (c->session == NULL || c->tty.path == NULL)
+ if (c->session == NULL)
continue;
- path = c->tty.path;
-
- /* Try for exact match. */
- if (strcmp(copy, path) == 0)
+ if (strcmp(copy, c->name) == 0)
break;
- /* Try without leading /dev. */
- if (strncmp(path, _PATH_DEV, (sizeof _PATH_DEV) - 1) != 0)
+ if (*c->ttyname == '\0')
+ continue;
+ if (strcmp(copy, c->ttyname) == 0)
+ break;
+ if (strncmp(c->ttyname, _PATH_DEV, (sizeof _PATH_DEV) - 1) != 0)
continue;
- if (strcmp(copy, path + (sizeof _PATH_DEV) - 1) == 0)
+ if (strcmp(copy, c->ttyname + (sizeof _PATH_DEV) - 1) == 0)
break;
}