From 45dfc5a074e2ceae11a6d4aeae597bee1e028503 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 20 Oct 2014 22:29:25 +0000 Subject: Instead of setting up the default keys by building the key struct directly with a helper function in the cmd_entry, include a table of bind-key commands and pass them through the command parser and a temporary cmd_q. As well as being smaller, this will allow default bindings to be command sequences which will probably be needed soon. --- cmd-new-session.c | 1 - 1 file changed, 1 deletion(-) (limited to 'cmd-new-session.c') diff --git a/cmd-new-session.c b/cmd-new-session.c index 802cb6c9..e42947e7 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -40,7 +40,6 @@ const struct cmd_entry cmd_new_session_entry = { "[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] " "[-y height] [command]", CMD_STARTSERVER|CMD_CANTNEST, - NULL, cmd_new_session_exec }; -- cgit From 4c42381410891c43b1326e95f150dfcf637b1e69 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 20 Oct 2014 23:35:28 +0000 Subject: Move template defines back into .c files. --- cmd-new-session.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cmd-new-session.c') diff --git a/cmd-new-session.c b/cmd-new-session.c index e42947e7..e244f885 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -31,6 +31,8 @@ * Create a new session and attach to the current terminal unless -d is given. */ +#define NEW_SESSION_TEMPLATE "#{session_name}:" + enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_q *); const struct cmd_entry cmd_new_session_entry = { @@ -43,6 +45,14 @@ const struct cmd_entry cmd_new_session_entry = { cmd_new_session_exec }; +const struct cmd_entry cmd_has_session_entry = { + "has-session", "has", + "t:", 0, 0, + CMD_TARGET_SESSION_USAGE, + 0, + cmd_new_session_exec +}; + enum cmd_retval cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) { @@ -61,6 +71,12 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) struct format_tree *ft; struct environ_entry *envent; + if (self->entry == &cmd_has_session_entry) { + if (cmd_find_session(cmdq, args_get(args, 't'), 0) == NULL) + return (CMD_RETURN_ERROR); + return (CMD_RETURN_NORMAL); + } + if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) { cmdq_error(cmdq, "command or window name given with target"); return (CMD_RETURN_ERROR); -- cgit