mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 11:18:48 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
8457f54edc
@ -60,6 +60,9 @@ static struct cmdq_item *
|
||||
cmd_send_keys_inject_key(struct client *c, struct cmd_find_state *fs,
|
||||
struct cmdq_item *item, key_code key)
|
||||
{
|
||||
struct session *s = fs->s;
|
||||
struct winlink *wl = fs->wl;
|
||||
struct window_pane *wp = fs->wp;
|
||||
struct window_mode_entry *wme;
|
||||
struct key_table *table;
|
||||
struct key_binding *bd;
|
||||
@ -68,7 +71,8 @@ cmd_send_keys_inject_key(struct client *c, struct cmd_find_state *fs,
|
||||
if (wme == NULL || wme->mode->key_table == NULL) {
|
||||
if (options_get_number(fs->wp->window->options, "xterm-keys"))
|
||||
key |= KEYC_XTERM;
|
||||
window_pane_key(fs->wp, item->client, fs->s, fs->wl, key, NULL);
|
||||
if (window_pane_key(wp, item->client, s, wl, key, NULL) != 0)
|
||||
return (NULL);
|
||||
return (item);
|
||||
}
|
||||
table = key_bindings_get_table(wme->mode->key_table(wme), 1);
|
||||
@ -87,6 +91,7 @@ cmd_send_keys_inject_string(struct client *c, struct cmd_find_state *fs,
|
||||
struct cmdq_item *item, struct args *args, int i)
|
||||
{
|
||||
const char *s = args->argv[i];
|
||||
struct cmdq_item *new_item;
|
||||
struct utf8_data *ud, *uc;
|
||||
wchar_t wc;
|
||||
key_code key;
|
||||
@ -104,8 +109,11 @@ cmd_send_keys_inject_string(struct client *c, struct cmd_find_state *fs,
|
||||
literal = args_has(args, 'l');
|
||||
if (!literal) {
|
||||
key = key_string_lookup_string(s);
|
||||
if (key != KEYC_NONE && key != KEYC_UNKNOWN)
|
||||
return (cmd_send_keys_inject_key(c, fs, item, key));
|
||||
if (key != KEYC_NONE && key != KEYC_UNKNOWN) {
|
||||
new_item = cmd_send_keys_inject_key(c, fs, item, key);
|
||||
if (new_item != NULL)
|
||||
return (new_item);
|
||||
}
|
||||
literal = 1;
|
||||
}
|
||||
if (literal) {
|
||||
|
17
input-keys.c
17
input-keys.c
@ -149,7 +149,7 @@ input_split2(u_int c, u_char *dst)
|
||||
}
|
||||
|
||||
/* Translate a key code into an output key sequence. */
|
||||
void
|
||||
int
|
||||
input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
|
||||
{
|
||||
const struct input_key_ent *ike;
|
||||
@ -166,14 +166,14 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
|
||||
if (KEYC_IS_MOUSE(key)) {
|
||||
if (m != NULL && m->wp != -1 && (u_int)m->wp == wp->id)
|
||||
input_key_mouse(wp, m);
|
||||
return;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Literal keys go as themselves (can't be more than eight bits). */
|
||||
if (key & KEYC_LITERAL) {
|
||||
ud.data[0] = (u_char)key;
|
||||
bufferevent_write(wp->event, &ud.data[0], 1);
|
||||
return;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Is this backspace? */
|
||||
@ -194,15 +194,15 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
|
||||
bufferevent_write(wp->event, "\033", 1);
|
||||
ud.data[0] = justkey;
|
||||
bufferevent_write(wp->event, &ud.data[0], 1);
|
||||
return;
|
||||
return (0);
|
||||
}
|
||||
if (justkey > 0x7f && justkey < KEYC_BASE) {
|
||||
if (utf8_split(justkey, &ud) != UTF8_DONE)
|
||||
return;
|
||||
return (-1);
|
||||
if (key & KEYC_ESCAPE)
|
||||
bufferevent_write(wp->event, "\033", 1);
|
||||
bufferevent_write(wp->event, ud.data, ud.size);
|
||||
return;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -213,7 +213,7 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
|
||||
if ((out = xterm_keys_lookup(key)) != NULL) {
|
||||
bufferevent_write(wp->event, out, strlen(out));
|
||||
free(out);
|
||||
return;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
key &= ~KEYC_XTERM;
|
||||
@ -236,7 +236,7 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
|
||||
}
|
||||
if (i == nitems(input_keys)) {
|
||||
log_debug("key 0x%llx missing", key);
|
||||
return;
|
||||
return (-1);
|
||||
}
|
||||
dlen = strlen(ike->data);
|
||||
log_debug("found key 0x%llx: \"%s\"", key, ike->data);
|
||||
@ -245,6 +245,7 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
|
||||
if (key & KEYC_ESCAPE)
|
||||
bufferevent_write(wp->event, "\033", 1);
|
||||
bufferevent_write(wp->event, ike->data, dlen);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Translate mouse and output. */
|
||||
|
6
tmux.h
6
tmux.h
@ -1229,6 +1229,8 @@ struct tty {
|
||||
#define TTY_OPENED 0x20
|
||||
#define TTY_FOCUS 0x40
|
||||
#define TTY_BLOCK 0x80
|
||||
#define TTY_HAVEDA 0x100
|
||||
#define TTY_HAVEDSR 0x200
|
||||
int flags;
|
||||
|
||||
struct tty_term *term;
|
||||
@ -2277,7 +2279,7 @@ void input_parse(struct window_pane *);
|
||||
void input_parse_buffer(struct window_pane *, u_char *, size_t);
|
||||
|
||||
/* input-key.c */
|
||||
void input_key(struct window_pane *, key_code, struct mouse_event *);
|
||||
int input_key(struct window_pane *, key_code, struct mouse_event *);
|
||||
|
||||
/* xterm-keys.c */
|
||||
char *xterm_keys_lookup(key_code);
|
||||
@ -2500,7 +2502,7 @@ int window_pane_set_mode(struct window_pane *,
|
||||
struct args *);
|
||||
void window_pane_reset_mode(struct window_pane *);
|
||||
void window_pane_reset_mode_all(struct window_pane *);
|
||||
void window_pane_key(struct window_pane *, struct client *,
|
||||
int window_pane_key(struct window_pane *, struct client *,
|
||||
struct session *, struct winlink *, key_code,
|
||||
struct mouse_event *);
|
||||
int window_pane_visible(struct window_pane *);
|
||||
|
14
tty-keys.c
14
tty-keys.c
@ -1020,6 +1020,8 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
|
||||
int flags = 0;
|
||||
|
||||
*size = 0;
|
||||
if (tty->flags & TTY_HAVEDA)
|
||||
return (-1);
|
||||
|
||||
/* First three bytes are always \033[?. */
|
||||
if (buf[0] != '\033')
|
||||
@ -1064,7 +1066,10 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
|
||||
for (i = 1; i < n; i++)
|
||||
log_debug("%s: DA feature: %d", c->name, p[i]);
|
||||
log_debug("%s: received DA %.*s", c->name, (int)*size, buf);
|
||||
|
||||
tty_set_flags(tty, flags);
|
||||
tty->flags |= TTY_HAVEDA;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -1082,6 +1087,8 @@ tty_keys_device_status_report(struct tty *tty, const char *buf, size_t len,
|
||||
int flags = 0;
|
||||
|
||||
*size = 0;
|
||||
if (tty->flags & TTY_HAVEDSR)
|
||||
return (-1);
|
||||
|
||||
/* First three bytes are always \033[. */
|
||||
if (buf[0] != '\033')
|
||||
@ -1092,6 +1099,10 @@ tty_keys_device_status_report(struct tty *tty, const char *buf, size_t len,
|
||||
return (-1);
|
||||
if (len == 2)
|
||||
return (1);
|
||||
if (buf[2] != 'I')
|
||||
return (-1);
|
||||
if (len == 3)
|
||||
return (1);
|
||||
|
||||
/* Copy the rest up to a 'n'. */
|
||||
for (i = 0; i < (sizeof tmp) - 1 && buf[2 + i] != 'n'; i++) {
|
||||
@ -1108,6 +1119,9 @@ tty_keys_device_status_report(struct tty *tty, const char *buf, size_t len,
|
||||
if (strncmp(tmp, "ITERM2 ", 7) == 0)
|
||||
flags |= TERM_DECSLRM;
|
||||
log_debug("%s: received DSR %.*s", c->name, (int)*size, buf);
|
||||
|
||||
tty_set_flags(tty, flags);
|
||||
tty->flags |= TTY_HAVEDSR;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
5
tty.c
5
tty.c
@ -327,8 +327,9 @@ tty_start_tty(struct tty *tty)
|
||||
tty->flags |= TTY_FOCUS;
|
||||
tty_puts(tty, "\033[?1004h");
|
||||
}
|
||||
tty_puts(tty, "\033[c\033[1337n");
|
||||
}
|
||||
tty_puts(tty, "\033[c\033[1337n"); /* DA and DSR */
|
||||
} else
|
||||
tty->flags |= (TTY_HAVEDA|TTY_HAVEDSR);
|
||||
|
||||
tty->flags |= TTY_STARTED;
|
||||
tty_invalidate(tty);
|
||||
|
14
window.c
14
window.c
@ -1239,7 +1239,7 @@ window_pane_reset_mode_all(struct window_pane *wp)
|
||||
window_pane_reset_mode(wp);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
|
||||
struct winlink *wl, key_code key, struct mouse_event *m)
|
||||
{
|
||||
@ -1247,23 +1247,24 @@ window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
|
||||
struct window_pane *wp2;
|
||||
|
||||
if (KEYC_IS_MOUSE(key) && m == NULL)
|
||||
return;
|
||||
return (-1);
|
||||
|
||||
wme = TAILQ_FIRST(&wp->modes);
|
||||
if (wme != NULL) {
|
||||
wp->modelast = time(NULL);
|
||||
if (wme->mode->key != NULL)
|
||||
wme->mode->key(wme, c, s, wl, (key & ~KEYC_XTERM), m);
|
||||
return;
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (wp->fd == -1 || wp->flags & PANE_INPUTOFF)
|
||||
return;
|
||||
return (0);
|
||||
|
||||
input_key(wp, key, m);
|
||||
if (input_key(wp, key, m) != 0)
|
||||
return (-1);
|
||||
|
||||
if (KEYC_IS_MOUSE(key))
|
||||
return;
|
||||
return (0);
|
||||
if (options_get_number(wp->window->options, "synchronize-panes")) {
|
||||
TAILQ_FOREACH(wp2, &wp->window->panes, entry) {
|
||||
if (wp2 != wp &&
|
||||
@ -1274,6 +1275,7 @@ window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
|
||||
input_key(wp2, key, NULL);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user