mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 03:08:46 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
ba542e42b7
126
key-string.c
126
key-string.c
@ -242,53 +242,90 @@ key_string_lookup_string(const char *string)
|
||||
const char *
|
||||
key_string_lookup_key(key_code key)
|
||||
{
|
||||
static char out[32];
|
||||
char tmp[8];
|
||||
u_int i;
|
||||
struct utf8_data ud;
|
||||
size_t off;
|
||||
static char out[32];
|
||||
char tmp[8];
|
||||
const char *s;
|
||||
u_int i;
|
||||
struct utf8_data ud;
|
||||
size_t off;
|
||||
|
||||
*out = '\0';
|
||||
|
||||
/* Literal keys are themselves. */
|
||||
if (key & KEYC_LITERAL) {
|
||||
snprintf(out, sizeof out, "%c", (int)(key & 0xff));
|
||||
return (out);
|
||||
}
|
||||
|
||||
/* Fill in the modifiers. */
|
||||
if (key & KEYC_CTRL)
|
||||
strlcat(out, "C-", sizeof out);
|
||||
if (key & KEYC_ESCAPE)
|
||||
strlcat(out, "M-", sizeof out);
|
||||
if (key & KEYC_SHIFT)
|
||||
strlcat(out, "S-", sizeof out);
|
||||
key &= KEYC_MASK_KEY;
|
||||
|
||||
/* Handle no key. */
|
||||
if (key == KEYC_NONE)
|
||||
return ("None");
|
||||
|
||||
/* Handle special keys. */
|
||||
if (key == KEYC_UNKNOWN)
|
||||
return ("Unknown");
|
||||
if (key == KEYC_ANY)
|
||||
return ("Any");
|
||||
if (key == KEYC_FOCUS_IN)
|
||||
return ("FocusIn");
|
||||
if (key == KEYC_FOCUS_OUT)
|
||||
return ("FocusOut");
|
||||
if (key == KEYC_PASTE_START)
|
||||
return ("PasteStart");
|
||||
if (key == KEYC_PASTE_END)
|
||||
return ("PasteEnd");
|
||||
if (key == KEYC_MOUSE)
|
||||
return ("Mouse");
|
||||
if (key == KEYC_DRAGGING)
|
||||
return ("Dragging");
|
||||
if (key == KEYC_MOUSEMOVE_PANE)
|
||||
return ("MouseMovePane");
|
||||
if (key == KEYC_MOUSEMOVE_STATUS)
|
||||
return ("MouseMoveStatus");
|
||||
if (key == KEYC_MOUSEMOVE_STATUS_LEFT)
|
||||
return ("MouseMoveStatusLeft");
|
||||
if (key == KEYC_MOUSEMOVE_STATUS_RIGHT)
|
||||
return ("MouseMoveStatusRight");
|
||||
if (key == KEYC_MOUSEMOVE_BORDER)
|
||||
return ("MouseMoveBorder");
|
||||
if (key >= KEYC_USER && key < KEYC_USER + KEYC_NUSER) {
|
||||
snprintf(out, sizeof out, "User%u", (u_int)(key - KEYC_USER));
|
||||
return (out);
|
||||
if (key == KEYC_UNKNOWN) {
|
||||
s = "Unknown";
|
||||
goto append;
|
||||
}
|
||||
|
||||
/* Literal keys are themselves. */
|
||||
if (key & KEYC_LITERAL) {
|
||||
snprintf(out, sizeof out, "%c", (int)(key & 0xff));
|
||||
if (key == KEYC_ANY) {
|
||||
s = "Any";
|
||||
goto append;
|
||||
}
|
||||
if (key == KEYC_FOCUS_IN) {
|
||||
s = "FocusIn";
|
||||
goto append;
|
||||
}
|
||||
if (key == KEYC_FOCUS_OUT) {
|
||||
s = "FocusOut";
|
||||
goto append;
|
||||
}
|
||||
if (key == KEYC_PASTE_START) {
|
||||
s = "PasteStart";
|
||||
goto append;
|
||||
}
|
||||
if (key == KEYC_PASTE_END) {
|
||||
s = "PasteEnd";
|
||||
goto append;
|
||||
}
|
||||
if (key == KEYC_MOUSE) {
|
||||
s = "Mouse";
|
||||
goto append;
|
||||
}
|
||||
if (key == KEYC_DRAGGING) {
|
||||
s = "Dragging";
|
||||
goto append;
|
||||
}
|
||||
if (key == KEYC_MOUSEMOVE_PANE) {
|
||||
s = "MouseMovePane";
|
||||
goto append;
|
||||
}
|
||||
if (key == KEYC_MOUSEMOVE_STATUS) {
|
||||
s = "MouseMoveStatus";
|
||||
goto append;
|
||||
}
|
||||
if (key == KEYC_MOUSEMOVE_STATUS_LEFT) {
|
||||
s = "MouseMoveStatusLeft";
|
||||
goto append;
|
||||
}
|
||||
if (key == KEYC_MOUSEMOVE_STATUS_RIGHT) {
|
||||
s = "MouseMoveStatusRight";
|
||||
goto append;
|
||||
}
|
||||
if (key == KEYC_MOUSEMOVE_BORDER) {
|
||||
s = "MouseMoveBorder";
|
||||
goto append;
|
||||
}
|
||||
if (key >= KEYC_USER && key < KEYC_USER + KEYC_NUSER) {
|
||||
snprintf(tmp, sizeof tmp, "User%u", (u_int)(key - KEYC_USER));
|
||||
strlcat(out, tmp, sizeof out);
|
||||
return (out);
|
||||
}
|
||||
|
||||
@ -301,15 +338,6 @@ key_string_lookup_key(key_code key)
|
||||
if ((key & KEYC_MASK_KEY) == 0)
|
||||
key = ' ' | KEYC_CTRL | (key & KEYC_MASK_MOD);
|
||||
|
||||
/* Fill in the modifiers. */
|
||||
if (key & KEYC_CTRL)
|
||||
strlcat(out, "C-", sizeof out);
|
||||
if (key & KEYC_ESCAPE)
|
||||
strlcat(out, "M-", sizeof out);
|
||||
if (key & KEYC_SHIFT)
|
||||
strlcat(out, "S-", sizeof out);
|
||||
key &= KEYC_MASK_KEY;
|
||||
|
||||
/* Try the key against the string table. */
|
||||
for (i = 0; i < nitems(key_string_table); i++) {
|
||||
if (key == key_string_table[i].key)
|
||||
@ -352,4 +380,8 @@ key_string_lookup_key(key_code key)
|
||||
|
||||
strlcat(out, tmp, sizeof out);
|
||||
return (out);
|
||||
|
||||
append:
|
||||
strlcat(out, s, sizeof out);
|
||||
return (out);
|
||||
}
|
||||
|
@ -660,8 +660,7 @@ have_event:
|
||||
break;
|
||||
}
|
||||
c->tty.mouse_drag_flag = 0;
|
||||
|
||||
return (key);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Convert to a key binding. */
|
||||
@ -956,6 +955,7 @@ have_event:
|
||||
if (key == KEYC_UNKNOWN)
|
||||
return (KEYC_UNKNOWN);
|
||||
|
||||
out:
|
||||
/* Apply modifiers if any. */
|
||||
if (b & MOUSE_MASK_META)
|
||||
key |= KEYC_ESCAPE;
|
||||
@ -964,6 +964,8 @@ have_event:
|
||||
if (b & MOUSE_MASK_SHIFT)
|
||||
key |= KEYC_SHIFT;
|
||||
|
||||
if (log_get_level() != 0)
|
||||
log_debug("mouse key is %s", key_string_lookup_key (key));
|
||||
return (key);
|
||||
}
|
||||
|
||||
@ -1057,7 +1059,7 @@ server_client_key_callback(struct cmdq_item *item, void *data)
|
||||
* Mouse drag is in progress, so fire the callback (now that
|
||||
* the mouse event is valid).
|
||||
*/
|
||||
if (key == KEYC_DRAGGING) {
|
||||
if ((key & KEYC_MASK_KEY) == KEYC_DRAGGING) {
|
||||
c->tty.mouse_drag_update(c, m);
|
||||
goto out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user