mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 13:37:12 +00:00
Revert previous for now, it will break TERM=screen.
This commit is contained in:
10
input-keys.c
10
input-keys.c
@ -158,7 +158,6 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
|
|||||||
char *out;
|
char *out;
|
||||||
key_code justkey;
|
key_code justkey;
|
||||||
struct utf8_data ud;
|
struct utf8_data ud;
|
||||||
int mode;
|
|
||||||
|
|
||||||
log_debug("writing key 0x%llx (%s) to %%%u", key,
|
log_debug("writing key 0x%llx (%s) to %%%u", key,
|
||||||
key_string_lookup_key(key), wp->id);
|
key_string_lookup_key(key), wp->id);
|
||||||
@ -195,9 +194,8 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
|
|||||||
* Then try to look this up as an xterm key, if the flag to output them
|
* Then try to look this up as an xterm key, if the flag to output them
|
||||||
* is set.
|
* is set.
|
||||||
*/
|
*/
|
||||||
mode = wp->screen->mode;
|
|
||||||
if (options_get_number(wp->window->options, "xterm-keys")) {
|
if (options_get_number(wp->window->options, "xterm-keys")) {
|
||||||
if ((out = xterm_keys_lookup(key, mode)) != NULL) {
|
if ((out = xterm_keys_lookup(key)) != NULL) {
|
||||||
bufferevent_write(wp->event, out, strlen(out));
|
bufferevent_write(wp->event, out, strlen(out));
|
||||||
free(out);
|
free(out);
|
||||||
return;
|
return;
|
||||||
@ -208,9 +206,11 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
|
|||||||
for (i = 0; i < nitems(input_keys); i++) {
|
for (i = 0; i < nitems(input_keys); i++) {
|
||||||
ike = &input_keys[i];
|
ike = &input_keys[i];
|
||||||
|
|
||||||
if ((ike->flags & INPUTKEY_KEYPAD) && (~mode & MODE_KKEYPAD))
|
if ((ike->flags & INPUTKEY_KEYPAD) &&
|
||||||
|
!(wp->screen->mode & MODE_KKEYPAD))
|
||||||
continue;
|
continue;
|
||||||
if ((ike->flags & INPUTKEY_CURSOR) && (~mode & MODE_KCURSOR))
|
if ((ike->flags & INPUTKEY_CURSOR) &&
|
||||||
|
!(wp->screen->mode & MODE_KCURSOR))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((key & KEYC_ESCAPE) && (ike->key | KEYC_ESCAPE) == key)
|
if ((key & KEYC_ESCAPE) && (ike->key | KEYC_ESCAPE) == key)
|
||||||
|
2
tmux.h
2
tmux.h
@ -1888,7 +1888,7 @@ void input_parse(struct window_pane *);
|
|||||||
void input_key(struct window_pane *, key_code, struct mouse_event *);
|
void input_key(struct window_pane *, key_code, struct mouse_event *);
|
||||||
|
|
||||||
/* xterm-keys.c */
|
/* xterm-keys.c */
|
||||||
char *xterm_keys_lookup(key_code, int);
|
char *xterm_keys_lookup(key_code);
|
||||||
int xterm_keys_find(const char *, size_t, size_t *, key_code *);
|
int xterm_keys_find(const char *, size_t, size_t *, key_code *);
|
||||||
|
|
||||||
/* colour.c */
|
/* colour.c */
|
||||||
|
43
xterm-keys.c
43
xterm-keys.c
@ -50,17 +50,7 @@ struct xterm_keys_entry {
|
|||||||
const char *template;
|
const char *template;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct xterm_keys_entry xterm_keys_standard[] = {
|
static const struct xterm_keys_entry xterm_keys_table[] = {
|
||||||
{ KEYC_HOME, "\033[H" },
|
|
||||||
{ KEYC_END, "\033[F" },
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct xterm_keys_entry xterm_keys_cursor[] = {
|
|
||||||
{ KEYC_HOME, "\033OH" },
|
|
||||||
{ KEYC_END, "\033OF" },
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct xterm_keys_entry xterm_keys_modified[] = {
|
|
||||||
{ KEYC_F1, "\033[1;_P" },
|
{ KEYC_F1, "\033[1;_P" },
|
||||||
{ KEYC_F1, "\033O1;_P" },
|
{ KEYC_F1, "\033O1;_P" },
|
||||||
{ KEYC_F1, "\033O_P" },
|
{ KEYC_F1, "\033O_P" },
|
||||||
@ -199,8 +189,8 @@ xterm_keys_find(const char *buf, size_t len, size_t *size, key_code *key)
|
|||||||
int matched;
|
int matched;
|
||||||
key_code modifiers;
|
key_code modifiers;
|
||||||
|
|
||||||
for (i = 0; i < nitems(xterm_keys_modified); i++) {
|
for (i = 0; i < nitems(xterm_keys_table); i++) {
|
||||||
entry = &xterm_keys_modified[i];
|
entry = &xterm_keys_table[i];
|
||||||
|
|
||||||
matched = xterm_keys_match(entry->template, buf, len, size,
|
matched = xterm_keys_match(entry->template, buf, len, size,
|
||||||
&modifiers);
|
&modifiers);
|
||||||
@ -215,10 +205,10 @@ xterm_keys_find(const char *buf, size_t len, size_t *size, key_code *key)
|
|||||||
|
|
||||||
/* Lookup a key number from the table. */
|
/* Lookup a key number from the table. */
|
||||||
char *
|
char *
|
||||||
xterm_keys_lookup(key_code key, int mode)
|
xterm_keys_lookup(key_code key)
|
||||||
{
|
{
|
||||||
const struct xterm_keys_entry *table, *entry;
|
const struct xterm_keys_entry *entry;
|
||||||
u_int items, i;
|
u_int i;
|
||||||
key_code modifiers;
|
key_code modifiers;
|
||||||
char *out;
|
char *out;
|
||||||
|
|
||||||
@ -234,32 +224,21 @@ xterm_keys_lookup(key_code key, int mode)
|
|||||||
* If the key has no modifiers, return NULL and let it fall through to
|
* If the key has no modifiers, return NULL and let it fall through to
|
||||||
* the normal lookup.
|
* the normal lookup.
|
||||||
*/
|
*/
|
||||||
if (modifiers != 1) {
|
if (modifiers == 1)
|
||||||
table = xterm_keys_modified;
|
return (NULL);
|
||||||
items = nitems(xterm_keys_modified);
|
|
||||||
} else {
|
|
||||||
if (mode & MODE_KCURSOR) {
|
|
||||||
table = xterm_keys_cursor;
|
|
||||||
items = nitems(xterm_keys_cursor);
|
|
||||||
} else {
|
|
||||||
table = xterm_keys_standard;
|
|
||||||
items = nitems(xterm_keys_standard);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Otherwise, find the key in the table. */
|
/* Otherwise, find the key in the table. */
|
||||||
key &= ~(KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL);
|
key &= ~(KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL);
|
||||||
for (i = 0; i < items; i++) {
|
for (i = 0; i < nitems(xterm_keys_table); i++) {
|
||||||
entry = &table[i];
|
entry = &xterm_keys_table[i];
|
||||||
if (key == entry->key)
|
if (key == entry->key)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == items)
|
if (i == nitems(xterm_keys_table))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
/* Copy the template and replace the modifier. */
|
/* Copy the template and replace the modifier. */
|
||||||
out = xstrdup(entry->template);
|
out = xstrdup(entry->template);
|
||||||
if (modifiers != 1)
|
|
||||||
out[strcspn(out, "_")] = '0' + modifiers;
|
out[strcspn(out, "_")] = '0' + modifiers;
|
||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user