Support -c for new-session, based on code from J Raynor.

This commit is contained in:
nicm
2013-10-10 12:07:36 +00:00
parent fc54bfe6b0
commit b822d24b15
5 changed files with 67 additions and 49 deletions

View File

@ -35,7 +35,7 @@ cmdq_new(struct client *c)
cmdq->dead = 0;
cmdq->client = c;
cmdq->client_exit = 0;
cmdq->client_exit = -1;
TAILQ_INIT(&cmdq->queue);
cmdq->item = NULL;
@ -259,7 +259,7 @@ cmdq_continue(struct cmd_q *cmdq)
} while (cmdq->item != NULL);
empty:
if (cmdq->client_exit)
if (cmdq->client_exit > 0)
cmdq->client->flags |= CLIENT_EXIT;
if (cmdq->emptyfn != NULL)
cmdq->emptyfn(cmdq); /* may free cmdq */
@ -283,3 +283,27 @@ cmdq_flush(struct cmd_q *cmdq)
}
cmdq->item = NULL;
}
/* Get default path using command queue. */
const char *
cmdq_default_path(struct cmd_q *cmdq, const char *cwd)
{
struct client *c = cmdq->client;
struct session *s;
const char *current;
if ((s = cmd_current_session(cmdq, 0)) == NULL)
return (NULL);
if (cwd == NULL)
cwd = options_get_string(&s->options, "default-path");
if (c != NULL && c->session == NULL && c->cwd != NULL)
current = c->cwd;
else if (s->curw != NULL)
current = get_proc_cwd(s->curw->window->active->fd);
else
current = NULL;
return (cmd_default_path(s->cwd, current, cwd));
}