Define a common function for each choose command's callback() function when running the defined action, and setting out the command context, etc. --- trunk/window-choose.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/trunk/window-choose.c b/trunk/window-choose.c index 7e14cf5..c7d46d4 100644 --- a/trunk/window-choose.c +++ b/trunk/window-choose.c @@ -20,6 +20,8 @@ #include <string.h> +#include <ctype.h> + #include "tmux.h" struct screen *window_choose_init(struct window_pane *); @@ -470,3 +472,36 @@ window_choose_scroll_down(struct window_pane *wp) window_choose_write_line(wp, &ctx, screen_size_y(s) - 2); screen_write_stop(&ctx); } + +void +window_choose_ctx(struct window_choose_data *cdata) +{ + struct cmd_ctx ctx; + struct cmd_list *cmdlist; + char *template, *cause; + + template = cmd_template_replace(cdata->template, cdata->raw_format, 1); + + if (cmd_string_parse(template, &cmdlist, &cause) != 0) { + if (cause != NULL) { + *cause = toupper((u_char) *cause); + status_message_set(cdata->client, "%s", cause); + xfree(cause); + } + xfree(template); + return; + } + xfree(template); + + ctx.msgdata = NULL; + ctx.curclient = cdata->client; + + ctx.error = key_bindings_error; + ctx.print = key_bindings_print; + ctx.info = key_bindings_info; + + ctx.cmdclient = NULL; + + cmd_list_exec(cmdlist, &ctx); + cmd_list_free(cmdlist); +} -- 1.7.10 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users