mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
Tidy command prompt callbacks and pass in the client.
This commit is contained in:
23
status.c
23
status.c
@ -656,8 +656,7 @@ status_message_redraw(struct client *c)
|
||||
/* Enable status line prompt. */
|
||||
void
|
||||
status_prompt_set(struct client *c, const char *msg, const char *input,
|
||||
int (*callbackfn)(void *, const char *, int), void (*freefn)(void *),
|
||||
void *data, int flags)
|
||||
prompt_input_cb inputcb, prompt_free_cb freecb, void *data, int flags)
|
||||
{
|
||||
struct format_tree *ft;
|
||||
time_t t;
|
||||
@ -677,8 +676,8 @@ status_prompt_set(struct client *c, const char *msg, const char *input,
|
||||
c->prompt_buffer = utf8_fromcstr(tmp);
|
||||
c->prompt_index = utf8_strlen(c->prompt_buffer);
|
||||
|
||||
c->prompt_callbackfn = callbackfn;
|
||||
c->prompt_freefn = freefn;
|
||||
c->prompt_inputcb = inputcb;
|
||||
c->prompt_freecb = freecb;
|
||||
c->prompt_data = data;
|
||||
|
||||
c->prompt_hindex = 0;
|
||||
@ -692,7 +691,7 @@ status_prompt_set(struct client *c, const char *msg, const char *input,
|
||||
|
||||
if ((flags & PROMPT_INCREMENTAL) && *tmp != '\0') {
|
||||
xasprintf(&cp, "=%s", tmp);
|
||||
c->prompt_callbackfn(c->prompt_data, cp, 0);
|
||||
c->prompt_inputcb(c, c->prompt_data, cp, 0);
|
||||
free(cp);
|
||||
}
|
||||
|
||||
@ -707,8 +706,8 @@ status_prompt_clear(struct client *c)
|
||||
if (c->prompt_string == NULL)
|
||||
return;
|
||||
|
||||
if (c->prompt_freefn != NULL && c->prompt_data != NULL)
|
||||
c->prompt_freefn(c->prompt_data);
|
||||
if (c->prompt_freecb != NULL && c->prompt_data != NULL)
|
||||
c->prompt_freecb(c->prompt_data);
|
||||
|
||||
free(c->prompt_string);
|
||||
c->prompt_string = NULL;
|
||||
@ -995,7 +994,7 @@ status_prompt_key(struct client *c, key_code key)
|
||||
if (key >= '0' && key <= '9')
|
||||
goto append_key;
|
||||
s = utf8_tocstr(c->prompt_buffer);
|
||||
c->prompt_callbackfn(c->prompt_data, s, 1);
|
||||
c->prompt_inputcb(c, c->prompt_data, s, 1);
|
||||
status_prompt_clear(c);
|
||||
free(s);
|
||||
return (1);
|
||||
@ -1276,13 +1275,13 @@ process_key:
|
||||
s = utf8_tocstr(c->prompt_buffer);
|
||||
if (*s != '\0')
|
||||
status_prompt_add_history(s);
|
||||
if (c->prompt_callbackfn(c->prompt_data, s, 1) == 0)
|
||||
if (c->prompt_inputcb(c, c->prompt_data, s, 1) == 0)
|
||||
status_prompt_clear(c);
|
||||
free(s);
|
||||
break;
|
||||
case '\033': /* Escape */
|
||||
case '\003': /* C-c */
|
||||
if (c->prompt_callbackfn(c->prompt_data, NULL, 1) == 0)
|
||||
if (c->prompt_inputcb(c, c->prompt_data, NULL, 1) == 0)
|
||||
status_prompt_clear(c);
|
||||
break;
|
||||
case '\022': /* C-r */
|
||||
@ -1330,7 +1329,7 @@ append_key:
|
||||
s = utf8_tocstr(c->prompt_buffer);
|
||||
if (strlen(s) != 1)
|
||||
status_prompt_clear(c);
|
||||
else if (c->prompt_callbackfn(c->prompt_data, s, 1) == 0)
|
||||
else if (c->prompt_inputcb(c, c->prompt_data, s, 1) == 0)
|
||||
status_prompt_clear(c);
|
||||
free(s);
|
||||
}
|
||||
@ -1340,7 +1339,7 @@ changed:
|
||||
if (c->prompt_flags & PROMPT_INCREMENTAL) {
|
||||
s = utf8_tocstr(c->prompt_buffer);
|
||||
xasprintf(&cp, "%c%s", prefix, s);
|
||||
c->prompt_callbackfn(c->prompt_data, cp, 0);
|
||||
c->prompt_inputcb(c, c->prompt_data, cp, 0);
|
||||
free(cp);
|
||||
free(s);
|
||||
}
|
||||
|
Reference in New Issue
Block a user