Beispiel #1
0
int
cmd_select_prompt_callback(void *data, const char *s)
{
    struct client	*c = data;
    const char	*errstr;
    char		 msg[128];
    u_int		 idx;

    if (s == NULL || *s == '\0')
        return (0);

    idx = strtonum(s, 0, UINT_MAX, &errstr);
    if (errstr != NULL) {
        xsnprintf(msg, sizeof msg, "Index %s: %s", errstr, s);
        status_message_set(c, "%s", msg);
        return (0);
    }

    if (winlink_find_by_index(&c->session->windows, idx) == NULL) {
        xsnprintf(msg, sizeof msg,
                  "Window not found: %s:%d", c->session->name, idx);
        status_message_set(c, "%s", msg);
        return (0);
    }

    if (session_select(c->session, idx) == 0)
        server_redraw_session(c->session);
    recalculate_sizes();

    return (0);
}
Beispiel #2
0
int
cmd_confirm_before_callback(void *data, const char *s)
{
	struct cmd_confirm_before_data	*cdata = data;
	struct client			*c = cdata->c;
	struct cmd_list			*cmdlist;
	struct cmd_ctx	 	 	*ctx;
	char				*cause;

	if (s == NULL || *s == '\0')
		return (0);
	if (tolower((u_char) s[0]) != 'y' || s[1] != '\0')
		return (0);

	if (cmd_string_parse(cdata->cmd, &cmdlist, &cause) != 0) {
		if (cause != NULL) {
			*cause = toupper((u_char) *cause);
			status_message_set(c, "%s", cause);
			free(cause);
		}
		return (0);
	}

	ctx = cmd_get_ctx();
	ctx->curclient = c;
	ctx->error = key_bindings_error;
	ctx->print = key_bindings_print;
	ctx->info = key_bindings_info;

	cmd_list_exec(cmdlist, ctx);
	cmd_list_free(cmdlist);
	cmd_free_ctx(ctx);

	return (0);
}
void printflike2
key_bindings_error(struct cmd_ctx *ctx, const char *fmt, ...)
{
	va_list	ap;
	char   *msg;

	va_start(ap, fmt);
	xvasprintf(&msg, fmt, ap);
	va_end(ap);

	*msg = toupper((u_char) *msg);
 	status_message_set(ctx->curclient, "%s", msg);
	xfree(msg);
}