mirror of
https://github.com/tmux/tmux.git
synced 2025-11-24 19:06:07 +00:00
Send matching terminator on queued requests, reported by Henry Qin.
This commit is contained in:
33
input.c
33
input.c
@@ -51,14 +51,22 @@
|
|||||||
* be passed to the underlying terminals.
|
* be passed to the underlying terminals.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Type of terminator. */
|
||||||
|
enum input_end_type {
|
||||||
|
INPUT_END_ST,
|
||||||
|
INPUT_END_BEL
|
||||||
|
};
|
||||||
|
|
||||||
/* Request sent by a pane. */
|
/* Request sent by a pane. */
|
||||||
struct input_request {
|
struct input_request {
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct input_ctx *ictx;
|
struct input_ctx *ictx;
|
||||||
|
|
||||||
enum input_request_type type;
|
enum input_request_type type;
|
||||||
int idx;
|
|
||||||
time_t t;
|
time_t t;
|
||||||
|
enum input_end_type end;
|
||||||
|
|
||||||
|
int idx;
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
TAILQ_ENTRY(input_request) entry;
|
TAILQ_ENTRY(input_request) entry;
|
||||||
@@ -87,12 +95,6 @@ struct input_param {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Type of terminator. */
|
|
||||||
enum input_end_type {
|
|
||||||
INPUT_END_ST,
|
|
||||||
INPUT_END_BEL
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Input parser context. */
|
/* Input parser context. */
|
||||||
struct input_ctx {
|
struct input_ctx {
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
@@ -2763,7 +2765,8 @@ input_top_bit_set(struct input_ctx *ictx)
|
|||||||
|
|
||||||
/* Reply to a colour request. */
|
/* Reply to a colour request. */
|
||||||
static void
|
static void
|
||||||
input_osc_colour_reply(struct input_ctx *ictx, int add, u_int n, int idx, int c)
|
input_osc_colour_reply(struct input_ctx *ictx, int add, u_int n, int idx, int c,
|
||||||
|
enum input_end_type end_type)
|
||||||
{
|
{
|
||||||
u_char r, g, b;
|
u_char r, g, b;
|
||||||
const char *end;
|
const char *end;
|
||||||
@@ -2774,7 +2777,7 @@ input_osc_colour_reply(struct input_ctx *ictx, int add, u_int n, int idx, int c)
|
|||||||
return;
|
return;
|
||||||
colour_split_rgb(c, &r, &g, &b);
|
colour_split_rgb(c, &r, &g, &b);
|
||||||
|
|
||||||
if (ictx->input_end == INPUT_END_BEL)
|
if (end_type == INPUT_END_BEL)
|
||||||
end = "\007";
|
end = "\007";
|
||||||
else
|
else
|
||||||
end = "\033\\";
|
end = "\033\\";
|
||||||
@@ -2815,7 +2818,8 @@ input_osc_4(struct input_ctx *ictx, const char *p)
|
|||||||
if (strcmp(s, "?") == 0) {
|
if (strcmp(s, "?") == 0) {
|
||||||
c = colour_palette_get(palette, idx|COLOUR_FLAG_256);
|
c = colour_palette_get(palette, idx|COLOUR_FLAG_256);
|
||||||
if (c != -1) {
|
if (c != -1) {
|
||||||
input_osc_colour_reply(ictx, 1, 4, idx, c);
|
input_osc_colour_reply(ictx, 1, 4, idx, c,
|
||||||
|
ictx->input_end);
|
||||||
s = next;
|
s = next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -2899,7 +2903,7 @@ input_osc_10(struct input_ctx *ictx, const char *p)
|
|||||||
else
|
else
|
||||||
c = defaults.fg;
|
c = defaults.fg;
|
||||||
}
|
}
|
||||||
input_osc_colour_reply(ictx, 1, 10, 0, c);
|
input_osc_colour_reply(ictx, 1, 10, 0, c, ictx->input_end);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2942,7 +2946,7 @@ input_osc_11(struct input_ctx *ictx, const char *p)
|
|||||||
if (wp == NULL)
|
if (wp == NULL)
|
||||||
return;
|
return;
|
||||||
c = window_pane_get_bg(wp);
|
c = window_pane_get_bg(wp);
|
||||||
input_osc_colour_reply(ictx, 1, 11, 0, c);
|
input_osc_colour_reply(ictx, 1, 11, 0, c, ictx->input_end);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2986,7 +2990,7 @@ input_osc_12(struct input_ctx *ictx, const char *p)
|
|||||||
c = ictx->ctx.s->ccolour;
|
c = ictx->ctx.s->ccolour;
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
c = ictx->ctx.s->default_ccolour;
|
c = ictx->ctx.s->default_ccolour;
|
||||||
input_osc_colour_reply(ictx, 1, 12, 0, c);
|
input_osc_colour_reply(ictx, 1, 12, 0, c, ictx->input_end);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3256,6 +3260,7 @@ input_add_request(struct input_ctx *ictx, enum input_request_type type, int idx)
|
|||||||
ir = input_make_request(ictx, type);
|
ir = input_make_request(ictx, type);
|
||||||
ir->c = c;
|
ir->c = c;
|
||||||
ir->idx = idx;
|
ir->idx = idx;
|
||||||
|
ir->end = ictx->input_end;
|
||||||
TAILQ_INSERT_TAIL(&c->input_requests, ir, centry);
|
TAILQ_INSERT_TAIL(&c->input_requests, ir, centry);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -3294,7 +3299,7 @@ input_request_reply(struct client *c, enum input_request_type type, void *data)
|
|||||||
if (ir->type == INPUT_REQUEST_QUEUE)
|
if (ir->type == INPUT_REQUEST_QUEUE)
|
||||||
input_send_reply(ir->ictx, ir->data);
|
input_send_reply(ir->ictx, ir->data);
|
||||||
else if (ir == found && ir->type == INPUT_REQUEST_PALETTE) {
|
else if (ir == found && ir->type == INPUT_REQUEST_PALETTE) {
|
||||||
input_osc_colour_reply(ir->ictx, 0, 4, pd->idx, pd->c);
|
input_osc_colour_reply(ir->ictx, 0, 4, pd->idx, pd->c, ir->end);
|
||||||
complete = 1;
|
complete = 1;
|
||||||
}
|
}
|
||||||
input_free_request(ir);
|
input_free_request(ir);
|
||||||
|
|||||||
Reference in New Issue
Block a user