diff options
| author | user <user@clank> | 2026-08-17 14:22:38 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-17 14:22:38 +0200 |
| commit | ec91ccffe631ae34b111bf6161fd0e3c487f684c (patch) | |
| tree | 4a9fdbb720d9bf03edd5f538d1d87afd2bf51bfb /src/input.c | |
| parent | sl0ppty: clang-format, and a hook that runs it on what you staged (diff) | |
| download | slosh-ec91ccffe631ae34b111bf6161fd0e3c487f684c.tar.gz slosh-ec91ccffe631ae34b111bf6161fd0e3c487f684c.tar.xz slosh-ec91ccffe631ae34b111bf6161fd0e3c487f684c.zip | |
sl0ppty: clang-format the tree
The bumpy one. `make fmt` over every `.c` and `.h` outside `vendor/`: 32 files,
1,843 lines rewritten, no behaviour changed. Nothing here is worth reading -- the
next commit adds it to `.git-blame-ignore-revs` so `git blame` walks past it.
Two thirds of it is alignment the formatter now owns: trailing comments in a
struct, continuation lines under a signature. The rest is the hand-packed tables
opening up to one entry per line -- `ACTIONS`, `NAMED_KEYS`, `ACTION_HELP`. That
is a real loss of density and a real gain in diffs: adding an action was a reflow
of the block and is now one line. Anything worth keeping packed can be fenced with
`// clang-format off`; nothing was, on the grounds that a table is the thing a
formatter is for.
**One change is not formatting.** `src/config.h` had three trailing comments glued
onto one field:
uint16_t hover_delay_ms; /* how long the pointer must rest to arm a guide */
/* how long an announcement stays up */ /* rows per wheel notch */
-- `toast_ms`'s and `scroll_lines`' comments, landed on their neighbour by an
earlier edit, documenting the wrong things ever since. It is in this commit
because it is what caught it: clang-format could not settle on that line, wrapping
it one way and then re-indenting the wrap on a second pass, so `make fmt` was not
idempotent. The comments are back where they belong and it is.
Verified after the reformat, not before: `make clean && make all` is
warning-free, `make retest` is 1801 checks green, and `make fmt` twice in a row
changes nothing the second time. A formatter that alters behaviour would be worse
than none, so the gate was the whole suite rather than a reading of the diff.
Diffstat (limited to 'src/input.c')
| -rw-r--r-- | src/input.c | 326 |
1 files changed, 182 insertions, 144 deletions
diff --git a/src/input.c b/src/input.c index 04dc0b5..47b4737 100644 --- a/src/input.c +++ b/src/input.c @@ -54,100 +54,113 @@ static int ascii_key(uint8_t c) { if (c >= 'A' && c <= 'Z') return GHOSTTY_KEY_A + (c - 'A'); if (c >= '0' && c <= '9') return GHOSTTY_KEY_DIGIT_0 + (c - '0'); switch (c) { - case ' ': return GHOSTTY_KEY_SPACE; - case '`': case '~': return GHOSTTY_KEY_BACKQUOTE; - case '-': case '_': return GHOSTTY_KEY_MINUS; - case '=': case '+': return GHOSTTY_KEY_EQUAL; - case '[': case '{': return GHOSTTY_KEY_BRACKET_LEFT; - case ']': case '}': return GHOSTTY_KEY_BRACKET_RIGHT; - case '\\': case '|': return GHOSTTY_KEY_BACKSLASH; - case ';': case ':': return GHOSTTY_KEY_SEMICOLON; - case '\'': case '"': return GHOSTTY_KEY_QUOTE; - case ',': case '<': return GHOSTTY_KEY_COMMA; - case '.': case '>': return GHOSTTY_KEY_PERIOD; - case '/': case '?': return GHOSTTY_KEY_SLASH; - case '!': return GHOSTTY_KEY_DIGIT_1; - case '@': return GHOSTTY_KEY_DIGIT_2; - case '#': return GHOSTTY_KEY_DIGIT_3; - case '$': return GHOSTTY_KEY_DIGIT_4; - case '%': return GHOSTTY_KEY_DIGIT_5; - case '^': return GHOSTTY_KEY_DIGIT_6; - case '&': return GHOSTTY_KEY_DIGIT_7; - case '*': return GHOSTTY_KEY_DIGIT_8; - case '(': return GHOSTTY_KEY_DIGIT_9; - case ')': return GHOSTTY_KEY_DIGIT_0; - default: return GHOSTTY_KEY_UNIDENTIFIED; + case ' ': return GHOSTTY_KEY_SPACE; + case '`': + case '~': return GHOSTTY_KEY_BACKQUOTE; + case '-': + case '_': return GHOSTTY_KEY_MINUS; + case '=': + case '+': return GHOSTTY_KEY_EQUAL; + case '[': + case '{': return GHOSTTY_KEY_BRACKET_LEFT; + case ']': + case '}': return GHOSTTY_KEY_BRACKET_RIGHT; + case '\\': + case '|': return GHOSTTY_KEY_BACKSLASH; + case ';': + case ':': return GHOSTTY_KEY_SEMICOLON; + case '\'': + case '"': return GHOSTTY_KEY_QUOTE; + case ',': + case '<': return GHOSTTY_KEY_COMMA; + case '.': + case '>': return GHOSTTY_KEY_PERIOD; + case '/': + case '?': return GHOSTTY_KEY_SLASH; + case '!': return GHOSTTY_KEY_DIGIT_1; + case '@': return GHOSTTY_KEY_DIGIT_2; + case '#': return GHOSTTY_KEY_DIGIT_3; + case '$': return GHOSTTY_KEY_DIGIT_4; + case '%': return GHOSTTY_KEY_DIGIT_5; + case '^': return GHOSTTY_KEY_DIGIT_6; + case '&': return GHOSTTY_KEY_DIGIT_7; + case '*': return GHOSTTY_KEY_DIGIT_8; + case '(': return GHOSTTY_KEY_DIGIT_9; + case ')': return GHOSTTY_KEY_DIGIT_0; + default: return GHOSTTY_KEY_UNIDENTIFIED; } } /* CSI <n> ~ */ static int tilde_key(int n) { switch (n) { - case 1: case 7: return GHOSTTY_KEY_HOME; - case 2: return GHOSTTY_KEY_INSERT; - case 3: return GHOSTTY_KEY_DELETE; - case 4: case 8: return GHOSTTY_KEY_END; - case 5: return GHOSTTY_KEY_PAGE_UP; - case 6: return GHOSTTY_KEY_PAGE_DOWN; - case 11: return GHOSTTY_KEY_F1; - case 12: return GHOSTTY_KEY_F2; - case 13: return GHOSTTY_KEY_F3; - case 14: return GHOSTTY_KEY_F4; - case 15: return GHOSTTY_KEY_F5; - case 17: return GHOSTTY_KEY_F6; - case 18: return GHOSTTY_KEY_F7; - case 19: return GHOSTTY_KEY_F8; - case 20: return GHOSTTY_KEY_F9; - case 21: return GHOSTTY_KEY_F10; - case 23: return GHOSTTY_KEY_F11; - case 24: return GHOSTTY_KEY_F12; - default: return GHOSTTY_KEY_UNIDENTIFIED; + case 1: + case 7: return GHOSTTY_KEY_HOME; + case 2: return GHOSTTY_KEY_INSERT; + case 3: return GHOSTTY_KEY_DELETE; + case 4: + case 8: return GHOSTTY_KEY_END; + case 5: return GHOSTTY_KEY_PAGE_UP; + case 6: return GHOSTTY_KEY_PAGE_DOWN; + case 11: return GHOSTTY_KEY_F1; + case 12: return GHOSTTY_KEY_F2; + case 13: return GHOSTTY_KEY_F3; + case 14: return GHOSTTY_KEY_F4; + case 15: return GHOSTTY_KEY_F5; + case 17: return GHOSTTY_KEY_F6; + case 18: return GHOSTTY_KEY_F7; + case 19: return GHOSTTY_KEY_F8; + case 20: return GHOSTTY_KEY_F9; + case 21: return GHOSTTY_KEY_F10; + case 23: return GHOSTTY_KEY_F11; + case 24: return GHOSTTY_KEY_F12; + default: return GHOSTTY_KEY_UNIDENTIFIED; } } /* final byte of a CSI/SS3 cursor-ish sequence */ static int final_key(uint8_t f) { switch (f) { - case 'A': return GHOSTTY_KEY_ARROW_UP; - case 'B': return GHOSTTY_KEY_ARROW_DOWN; - case 'C': return GHOSTTY_KEY_ARROW_RIGHT; - case 'D': return GHOSTTY_KEY_ARROW_LEFT; - case 'E': return GHOSTTY_KEY_NUMPAD_BEGIN; - case 'H': return GHOSTTY_KEY_HOME; - case 'F': return GHOSTTY_KEY_END; - case 'P': return GHOSTTY_KEY_F1; - case 'Q': return GHOSTTY_KEY_F2; - case 'R': return GHOSTTY_KEY_F3; - case 'S': return GHOSTTY_KEY_F4; - default: return GHOSTTY_KEY_UNIDENTIFIED; + case 'A': return GHOSTTY_KEY_ARROW_UP; + case 'B': return GHOSTTY_KEY_ARROW_DOWN; + case 'C': return GHOSTTY_KEY_ARROW_RIGHT; + case 'D': return GHOSTTY_KEY_ARROW_LEFT; + case 'E': return GHOSTTY_KEY_NUMPAD_BEGIN; + case 'H': return GHOSTTY_KEY_HOME; + case 'F': return GHOSTTY_KEY_END; + case 'P': return GHOSTTY_KEY_F1; + case 'Q': return GHOSTTY_KEY_F2; + case 'R': return GHOSTTY_KEY_F3; + case 'S': return GHOSTTY_KEY_F4; + default: return GHOSTTY_KEY_UNIDENTIFIED; } } /* kitty functional codepoints (CSI u form) */ static int kitty_key(uint32_t cp) { switch (cp) { - case 27: return GHOSTTY_KEY_ESCAPE; - case 13: return GHOSTTY_KEY_ENTER; - case 9: return GHOSTTY_KEY_TAB; - case 127: return GHOSTTY_KEY_BACKSPACE; - case 57358: return GHOSTTY_KEY_CAPS_LOCK; - case 57359: return GHOSTTY_KEY_SCROLL_LOCK; - case 57360: return GHOSTTY_KEY_NUM_LOCK; - case 57361: return GHOSTTY_KEY_PRINT_SCREEN; - case 57362: return GHOSTTY_KEY_PAUSE; - case 57363: return GHOSTTY_KEY_CONTEXT_MENU; - case 57441: return GHOSTTY_KEY_SHIFT_LEFT; - case 57442: return GHOSTTY_KEY_CONTROL_LEFT; - case 57443: return GHOSTTY_KEY_ALT_LEFT; - case 57444: return GHOSTTY_KEY_META_LEFT; - case 57447: return GHOSTTY_KEY_SHIFT_RIGHT; - case 57448: return GHOSTTY_KEY_CONTROL_RIGHT; - case 57449: return GHOSTTY_KEY_ALT_RIGHT; - case 57450: return GHOSTTY_KEY_META_RIGHT; - default: - if (cp >= 57376 && cp <= 57398) return GHOSTTY_KEY_F13 + (int)(cp - 57376); - if (cp < 128) return ascii_key((uint8_t)cp); - return GHOSTTY_KEY_UNIDENTIFIED; + case 27: return GHOSTTY_KEY_ESCAPE; + case 13: return GHOSTTY_KEY_ENTER; + case 9: return GHOSTTY_KEY_TAB; + case 127: return GHOSTTY_KEY_BACKSPACE; + case 57358: return GHOSTTY_KEY_CAPS_LOCK; + case 57359: return GHOSTTY_KEY_SCROLL_LOCK; + case 57360: return GHOSTTY_KEY_NUM_LOCK; + case 57361: return GHOSTTY_KEY_PRINT_SCREEN; + case 57362: return GHOSTTY_KEY_PAUSE; + case 57363: return GHOSTTY_KEY_CONTEXT_MENU; + case 57441: return GHOSTTY_KEY_SHIFT_LEFT; + case 57442: return GHOSTTY_KEY_CONTROL_LEFT; + case 57443: return GHOSTTY_KEY_ALT_LEFT; + case 57444: return GHOSTTY_KEY_META_LEFT; + case 57447: return GHOSTTY_KEY_SHIFT_RIGHT; + case 57448: return GHOSTTY_KEY_CONTROL_RIGHT; + case 57449: return GHOSTTY_KEY_ALT_RIGHT; + case 57450: return GHOSTTY_KEY_META_RIGHT; + default: + if (cp >= 57376 && cp <= 57398) return GHOSTTY_KEY_F13 + (int)(cp - 57376); + if (cp < 128) return ascii_key((uint8_t)cp); + return GHOSTTY_KEY_UNIDENTIFIED; } } @@ -215,9 +228,8 @@ static size_t parse_one(input_parser_t *p, input_cb_t cb, void *ud) { static const char end[] = "\x1b[201~"; for (size_t i = 0; i + sizeof end - 1 <= n; i++) { if (memcmp(b + i, end, sizeof end - 1) == 0) { - input_event_t ev = {.kind = EV_PASTE, - .paste = (const char *)b, - .paste_len = i}; + input_event_t ev = { + .kind = EV_PASTE, .paste = (const char *)b, .paste_len = i}; cb(&ev, ud); p->in_paste = false; return i + sizeof end - 1; @@ -257,7 +269,10 @@ static size_t parse_one(input_parser_t *p, input_cb_t cb, void *ud) { if (plen >= 1 && params[0] == '<' && (final == 'M' || final == 'm')) { int f[3] = {0, 0, 0}, fi = 0; for (size_t k = 1; k < plen && fi < 3; k++) { - if (params[k] == ';') { fi++; continue; } + if (params[k] == ';') { + fi++; + continue; + } if (params[k] >= '0' && params[k] <= '9') f[fi] = f[fi] * 10 + (params[k] - '0'); } @@ -271,14 +286,15 @@ static size_t parse_one(input_parser_t *p, input_cb_t cb, void *ud) { bool motion = (btn & 32) != 0; int base = btn & 0xc3; /* strip mods+motion, keep high wheel bits */ if (base >= 64 && base <= 67) { - ev.button = (uint8_t)(MBTN_FOUR + (base - 64)); /* wheel up/down/l/r */ + ev.button = + (uint8_t)(MBTN_FOUR + (base - 64)); /* wheel up/down/l/r */ ev.maction = MOUSE_PRESS; } else { switch (base & 3) { - case 0: ev.button = MBTN_LEFT; break; - case 1: ev.button = MBTN_MIDDLE; break; - case 2: ev.button = MBTN_RIGHT; break; - default: ev.button = MBTN_UNKNOWN; break; /* 3 = release/none */ + case 0: ev.button = MBTN_LEFT; break; + case 1: ev.button = MBTN_MIDDLE; break; + case 2: ev.button = MBTN_RIGHT; break; + default: ev.button = MBTN_UNKNOWN; break; /* 3 = release/none */ } ev.maction = motion ? MOUSE_MOTION : (final == 'M' ? MOUSE_PRESS : MOUSE_RELEASE); @@ -294,8 +310,10 @@ static size_t parse_one(input_parser_t *p, input_cb_t cb, void *ud) { uint8_t ch = params[k]; if (ch >= '0' && ch <= '9') { any = true; - if (sub_i == 0) nums[ncount] = nums[ncount] * 10 + (ch - '0'); - else if (sub_i <= 2) subs[ncount][sub_i] = subs[ncount][sub_i] * 10 + (ch - '0'); + if (sub_i == 0) + nums[ncount] = nums[ncount] * 10 + (ch - '0'); + else if (sub_i <= 2) + subs[ncount][sub_i] = subs[ncount][sub_i] * 10 + (ch - '0'); } else if (ch == ':') { if (sub_i < 2) sub_i++; } else if (ch == ';') { @@ -323,11 +341,13 @@ static size_t parse_one(input_parser_t *p, input_cb_t cb, void *ud) { size_t tlen = 0; /* associated text (3rd param) wins; else derive from the codepoint */ uint32_t out_cp = 0; - if (ncount >= 3 && nums[2]) out_cp = (uint32_t)nums[2]; + if (ncount >= 3 && nums[2]) + out_cp = (uint32_t)nums[2]; else if (!(mods & (MOD_CTRL | MOD_SUPER)) && cp >= 32 && cp != 127) out_cp = (mods & MOD_SHIFT) && shifted ? shifted : cp; if (out_cp) { - if (out_cp < 0x80) text[tlen++] = (char)out_cp; + if (out_cp < 0x80) + text[tlen++] = (char)out_cp; else if (out_cp < 0x800) { text[tlen++] = (char)(0xc0 | (out_cp >> 6)); text[tlen++] = (char)(0x80 | (out_cp & 0x3f)); @@ -393,20 +413,38 @@ static size_t parse_one(input_parser_t *p, input_cb_t cb, void *ud) { } /* --- C0 controls ----------------------------------------------------- */ - if (c == '\r') { emit_key(cb, ud, GHOSTTY_KEY_ENTER, 0, KEY_PRESS, "\r", 1, 13); return 1; } - if (c == '\n') { emit_key(cb, ud, GHOSTTY_KEY_ENTER, 0, KEY_PRESS, "\r", 1, 13); return 1; } - if (c == '\t') { emit_key(cb, ud, GHOSTTY_KEY_TAB, 0, KEY_PRESS, "\t", 1, 9); return 1; } - if (c == 0x7f) { emit_key(cb, ud, GHOSTTY_KEY_BACKSPACE, 0, KEY_PRESS, NULL, 0, 127); return 1; } - if (c == 0x08) { emit_key(cb, ud, GHOSTTY_KEY_BACKSPACE, 0, KEY_PRESS, NULL, 0, 8); return 1; } - if (c == 0x00) { emit_key(cb, ud, GHOSTTY_KEY_SPACE, MOD_CTRL, KEY_PRESS, NULL, 0, ' '); return 1; } + if (c == '\r') { + emit_key(cb, ud, GHOSTTY_KEY_ENTER, 0, KEY_PRESS, "\r", 1, 13); + return 1; + } + if (c == '\n') { + emit_key(cb, ud, GHOSTTY_KEY_ENTER, 0, KEY_PRESS, "\r", 1, 13); + return 1; + } + if (c == '\t') { + emit_key(cb, ud, GHOSTTY_KEY_TAB, 0, KEY_PRESS, "\t", 1, 9); + return 1; + } + if (c == 0x7f) { + emit_key(cb, ud, GHOSTTY_KEY_BACKSPACE, 0, KEY_PRESS, NULL, 0, 127); + return 1; + } + if (c == 0x08) { + emit_key(cb, ud, GHOSTTY_KEY_BACKSPACE, 0, KEY_PRESS, NULL, 0, 8); + return 1; + } + if (c == 0x00) { + emit_key(cb, ud, GHOSTTY_KEY_SPACE, MOD_CTRL, KEY_PRESS, NULL, 0, ' '); + return 1; + } if (c < 0x20) { int key; switch (c) { - case 0x1c: key = GHOSTTY_KEY_BACKSLASH; break; - case 0x1d: key = GHOSTTY_KEY_BRACKET_RIGHT; break; - case 0x1e: key = GHOSTTY_KEY_DIGIT_6; break; - case 0x1f: key = GHOSTTY_KEY_MINUS; break; - default: key = GHOSTTY_KEY_A + (c - 1); break; + case 0x1c: key = GHOSTTY_KEY_BACKSLASH; break; + case 0x1d: key = GHOSTTY_KEY_BRACKET_RIGHT; break; + case 0x1e: key = GHOSTTY_KEY_DIGIT_6; break; + case 0x1f: key = GHOSTTY_KEY_MINUS; break; + default: key = GHOSTTY_KEY_A + (c - 1); break; } uint32_t unshifted = c < 0x1b ? (uint32_t)('a' + c - 1) : 0; emit_key(cb, ud, key, MOD_CTRL, KEY_PRESS, NULL, 0, unshifted); @@ -455,23 +493,23 @@ void input_timeout(input_parser_t *p, input_cb_t cb, void *ud) { static const char *key_name(int key) { switch (key) { - case GHOSTTY_KEY_ARROW_UP: return "ARROW_UP"; - case GHOSTTY_KEY_ARROW_DOWN: return "ARROW_DOWN"; - case GHOSTTY_KEY_ARROW_LEFT: return "ARROW_LEFT"; - case GHOSTTY_KEY_ARROW_RIGHT: return "ARROW_RIGHT"; - case GHOSTTY_KEY_ENTER: return "ENTER"; - case GHOSTTY_KEY_TAB: return "TAB"; - case GHOSTTY_KEY_ESCAPE: return "ESCAPE"; - case GHOSTTY_KEY_BACKSPACE: return "BACKSPACE"; - case GHOSTTY_KEY_SPACE: return "SPACE"; - case GHOSTTY_KEY_HOME: return "HOME"; - case GHOSTTY_KEY_END: return "END"; - case GHOSTTY_KEY_INSERT: return "INSERT"; - case GHOSTTY_KEY_DELETE: return "DELETE"; - case GHOSTTY_KEY_PAGE_UP: return "PAGE_UP"; - case GHOSTTY_KEY_PAGE_DOWN: return "PAGE_DOWN"; - case GHOSTTY_KEY_UNIDENTIFIED: return "UNIDENTIFIED"; - default: break; + case GHOSTTY_KEY_ARROW_UP: return "ARROW_UP"; + case GHOSTTY_KEY_ARROW_DOWN: return "ARROW_DOWN"; + case GHOSTTY_KEY_ARROW_LEFT: return "ARROW_LEFT"; + case GHOSTTY_KEY_ARROW_RIGHT: return "ARROW_RIGHT"; + case GHOSTTY_KEY_ENTER: return "ENTER"; + case GHOSTTY_KEY_TAB: return "TAB"; + case GHOSTTY_KEY_ESCAPE: return "ESCAPE"; + case GHOSTTY_KEY_BACKSPACE: return "BACKSPACE"; + case GHOSTTY_KEY_SPACE: return "SPACE"; + case GHOSTTY_KEY_HOME: return "HOME"; + case GHOSTTY_KEY_END: return "END"; + case GHOSTTY_KEY_INSERT: return "INSERT"; + case GHOSTTY_KEY_DELETE: return "DELETE"; + case GHOSTTY_KEY_PAGE_UP: return "PAGE_UP"; + case GHOSTTY_KEY_PAGE_DOWN: return "PAGE_DOWN"; + case GHOSTTY_KEY_UNIDENTIFIED: return "UNIDENTIFIED"; + default: break; } if (key >= GHOSTTY_KEY_A && key <= GHOSTTY_KEY_Z) { static char buf[2]; @@ -503,33 +541,33 @@ void input_event_describe(const input_event_t *ev, char *buf, size_t cap) { if (ev->mods & MOD_SUPER) strcat(mods, "M"); switch (ev->kind) { - case EV_KEY: { - const char *act = ev->action == KEY_PRESS ? "press" - : ev->action == KEY_RELEASE ? "release" : "repeat"; - char text[32] = ""; - if (ev->text_len) { - snprintf(text, sizeof text, " text=%.*s", (int)ev->text_len, ev->text); - } - snprintf(buf, cap, "key %s mods=%s %s%s", key_name(ev->key), - *mods ? mods : "-", act, text); - break; - } - case EV_MOUSE: { - const char *act = ev->maction == MOUSE_PRESS ? "press" - : ev->maction == MOUSE_RELEASE ? "release" : "motion"; - snprintf(buf, cap, "mouse btn=%u %s at=%u,%u mods=%s", ev->button, act, - ev->mx, ev->my, *mods ? mods : "-"); - break; + case EV_KEY: { + const char *act = ev->action == KEY_PRESS ? "press" + : ev->action == KEY_RELEASE ? "release" + : "repeat"; + char text[32] = ""; + if (ev->text_len) { + snprintf(text, sizeof text, " text=%.*s", (int)ev->text_len, ev->text); } - case EV_PASTE: - snprintf(buf, cap, "paste len=%zu text=%.*s", ev->paste_len, - (int)(ev->paste_len > 20 ? 20 : ev->paste_len), ev->paste); - break; - case EV_FOCUS: - snprintf(buf, cap, "focus %s", ev->focused ? "in" : "out"); - break; - default: - snprintf(buf, cap, "none"); - break; + snprintf(buf, cap, "key %s mods=%s %s%s", key_name(ev->key), + *mods ? mods : "-", act, text); + break; + } + case EV_MOUSE: { + const char *act = ev->maction == MOUSE_PRESS ? "press" + : ev->maction == MOUSE_RELEASE ? "release" + : "motion"; + snprintf(buf, cap, "mouse btn=%u %s at=%u,%u mods=%s", ev->button, act, + ev->mx, ev->my, *mods ? mods : "-"); + break; + } + case EV_PASTE: + snprintf(buf, cap, "paste len=%zu text=%.*s", ev->paste_len, + (int)(ev->paste_len > 20 ? 20 : ev->paste_len), ev->paste); + break; + case EV_FOCUS: + snprintf(buf, cap, "focus %s", ev->focused ? "in" : "out"); + break; + default: snprintf(buf, cap, "none"); break; } } |
