mirror of
https://github.com/tmux/tmux.git
synced 2026-10-09 11:44:23 +00:00
Merge branch 'obsd-master'
This commit is contained in:
131
server-client.c
131
server-client.c
@@ -485,10 +485,7 @@ server_client_lost(struct client *c)
|
||||
free(c->message_string);
|
||||
if (event_initialized(&c->message_timer))
|
||||
evtimer_del(&c->message_timer);
|
||||
|
||||
free(c->prompt_saved);
|
||||
free(c->prompt_string);
|
||||
free(c->prompt_buffer);
|
||||
prompt_free(c->prompt);
|
||||
|
||||
format_lost_client(c);
|
||||
environ_free(c->environ);
|
||||
@@ -1460,6 +1457,7 @@ server_client_handle_key0(struct client *c, struct key_event *event,
|
||||
{
|
||||
struct session *s = c->session;
|
||||
struct cmdq_item *item;
|
||||
struct window_pane *wp;
|
||||
|
||||
/* Check the client is good to accept input. */
|
||||
if (s == NULL || (c->flags & CLIENT_UNATTACHEDFLAGS))
|
||||
@@ -1489,6 +1487,7 @@ server_client_handle_key0(struct client *c, struct key_event *event,
|
||||
return (0);
|
||||
status_message_clear(c);
|
||||
}
|
||||
|
||||
if (c->overlay_key != NULL) {
|
||||
switch (c->overlay_key(c, c->overlay_data, event)) {
|
||||
case 0:
|
||||
@@ -1498,9 +1497,10 @@ server_client_handle_key0(struct client *c, struct key_event *event,
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
server_client_clear_overlay(c);
|
||||
if (c->prompt_string != NULL) {
|
||||
switch (status_prompt_key(c, event->key)) {
|
||||
if (c->prompt != NULL) {
|
||||
switch (status_prompt_key(c, event->key, &event->m)) {
|
||||
case PROMPT_KEY_HANDLED:
|
||||
case PROMPT_KEY_CLOSE:
|
||||
return (0);
|
||||
@@ -1509,6 +1509,29 @@ server_client_handle_key0(struct client *c, struct key_event *event,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wp = s->curw->window->active;
|
||||
if (wp == NULL || !window_pane_has_prompt(wp)) {
|
||||
TAILQ_FOREACH(wp, &s->curw->window->panes, entry) {
|
||||
if (window_pane_has_prompt(wp) &&
|
||||
window_pane_is_visible(wp))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (wp != NULL &&
|
||||
window_pane_has_prompt(wp) &&
|
||||
window_pane_is_visible(wp)) {
|
||||
switch (window_pane_prompt_key(wp, c, event->key, &event->m)) {
|
||||
case PROMPT_KEY_HANDLED:
|
||||
case PROMPT_KEY_CLOSE:
|
||||
case PROMPT_KEY_MOVE:
|
||||
return (0);
|
||||
case PROMPT_KEY_NOT_HANDLED:
|
||||
if (KEYC_IS_MOUSE(event->key))
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1780,6 +1803,42 @@ out:
|
||||
bufferevent_enable(wp->event, EV_READ);
|
||||
}
|
||||
|
||||
/* Move cursor for pane prompt. */
|
||||
static int
|
||||
server_client_prompt_cursor(struct client *c, struct window_pane *wp, int *mode,
|
||||
u_int *cx, u_int *cy)
|
||||
{
|
||||
struct tty *tty = &c->tty;
|
||||
struct visible_ranges *r;
|
||||
u_int ox, oy, sx, sy;
|
||||
int px, py;
|
||||
|
||||
if (!window_pane_has_prompt(wp))
|
||||
return (0);
|
||||
*mode &= ~MODE_CURSOR;
|
||||
|
||||
tty_window_offset(tty, &ox, &oy, &sx, &sy);
|
||||
if (status_at_line(c) == 0)
|
||||
py = wp->yoff;
|
||||
else
|
||||
py = wp->yoff + wp->sy - 1;
|
||||
px = wp->xoff + wp->prompt_cx;
|
||||
if (px < (int)ox || px > (int)(ox + sx) ||
|
||||
py < (int)oy || py > (int)(oy + sy))
|
||||
return (1);
|
||||
|
||||
*cx = px - ox;
|
||||
*cy = py - oy;
|
||||
|
||||
r = window_visible_ranges(wp, *cx, *cy, 1, NULL);
|
||||
if (window_position_is_visible(r, *cx)) {
|
||||
if (status_at_line(c) == 0)
|
||||
*cy += status_line_size(c);
|
||||
*mode |= MODE_CURSOR;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update cursor position and mode settings. The scroll region and attributes
|
||||
* are cleared when idle (waiting for an event) as this is the most likely time
|
||||
@@ -1798,7 +1857,7 @@ server_client_reset_state(struct client *c)
|
||||
struct screen *s = NULL;
|
||||
struct options *oo = c->session->options;
|
||||
int mode = 0, cursor, flags, pane_mode = 0;
|
||||
u_int cx = 0, cy = 0, ox, oy, sx, sy, n;
|
||||
u_int cx = 0, cy = 0, ox, oy, sx, sy, prompt = 0;
|
||||
struct visible_ranges *r;
|
||||
|
||||
if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED))
|
||||
@@ -1812,7 +1871,7 @@ server_client_reset_state(struct client *c)
|
||||
if (c->overlay_draw != NULL) {
|
||||
if (c->overlay_mode != NULL)
|
||||
s = c->overlay_mode(c, c->overlay_data, &cx, &cy);
|
||||
} else if (wp != NULL && c->prompt_string == NULL)
|
||||
} else if (wp != NULL && c->prompt == NULL)
|
||||
s = wp->screen;
|
||||
else
|
||||
s = c->status.active;
|
||||
@@ -1828,42 +1887,36 @@ server_client_reset_state(struct client *c)
|
||||
tty_margin_off(tty);
|
||||
|
||||
/* Move cursor to pane cursor and offset. */
|
||||
if (c->prompt_string != NULL) {
|
||||
n = options_get_number(oo, "status-position");
|
||||
if (n == 0)
|
||||
cy = status_prompt_line_at(c);
|
||||
else {
|
||||
n = status_line_size(c) - status_prompt_line_at(c);
|
||||
if (n <= tty->sy)
|
||||
cy = tty->sy - n;
|
||||
else
|
||||
cy = tty->sy - 1;
|
||||
}
|
||||
cx = c->prompt_cursor;
|
||||
if (c->prompt != NULL) {
|
||||
prompt = 1;
|
||||
status_prompt_cursor(c, &cx, &cy);
|
||||
} else if (wp != NULL && c->overlay_draw == NULL) {
|
||||
cursor = 0;
|
||||
pane_mode = wp->base.mode;
|
||||
prompt = server_client_prompt_cursor(c, wp, &mode, &cx, &cy);
|
||||
if (!prompt) {
|
||||
cursor = 0;
|
||||
pane_mode = wp->base.mode;
|
||||
|
||||
tty_window_offset(tty, &ox, &oy, &sx, &sy);
|
||||
if (wp->xoff + (int)s->cx >= (int)ox &&
|
||||
wp->xoff + (int)s->cx <= (int)ox + (int)sx &&
|
||||
wp->yoff + (int)s->cy >= (int)oy &&
|
||||
wp->yoff + (int)s->cy <= (int)oy + (int)sy) {
|
||||
cursor = 1;
|
||||
tty_window_offset(tty, &ox, &oy, &sx, &sy);
|
||||
if (wp->xoff + (int)s->cx >= (int)ox &&
|
||||
wp->xoff + (int)s->cx <= (int)ox + (int)sx &&
|
||||
wp->yoff + (int)s->cy >= (int)oy &&
|
||||
wp->yoff + (int)s->cy <= (int)oy + (int)sy) {
|
||||
cursor = 1;
|
||||
|
||||
cx = wp->xoff + (int)s->cx - (int)ox;
|
||||
cy = wp->yoff + (int)s->cy - (int)oy;
|
||||
cx = wp->xoff + (int)s->cx - (int)ox;
|
||||
cy = wp->yoff + (int)s->cy - (int)oy;
|
||||
|
||||
r = window_visible_ranges(wp, cx, cy, 1, NULL);
|
||||
if (!window_position_is_visible(r, cx))
|
||||
cursor = 0;
|
||||
r = window_visible_ranges(wp, cx, cy, 1, NULL);
|
||||
if (!window_position_is_visible(r, cx))
|
||||
cursor = 0;
|
||||
|
||||
if (status_at_line(c) == 0)
|
||||
cy += status_line_size(c);
|
||||
if (status_at_line(c) == 0)
|
||||
cy += status_line_size(c);
|
||||
}
|
||||
|
||||
if ((pane_mode & MODE_SYNC) || !cursor)
|
||||
mode &= ~MODE_CURSOR;
|
||||
}
|
||||
|
||||
if ((pane_mode & MODE_SYNC) || !cursor)
|
||||
mode &= ~MODE_CURSOR;
|
||||
} else if (c->overlay_mode == NULL || s == NULL)
|
||||
mode &= ~MODE_CURSOR;
|
||||
if (~pane_mode & MODE_SYNC) {
|
||||
@@ -1891,7 +1944,7 @@ server_client_reset_state(struct client *c)
|
||||
}
|
||||
|
||||
/* Clear bracketed paste mode if at the prompt. */
|
||||
if (c->overlay_draw == NULL && c->prompt_string != NULL)
|
||||
if (c->overlay_draw == NULL && prompt)
|
||||
mode &= ~MODE_BRACKETPASTE;
|
||||
|
||||
/* Set the terminal mode and reset attributes. */
|
||||
|
||||
Reference in New Issue
Block a user