diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-03-27 11:10:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-27 11:10:28 +0800 |
commit | bf7c7adb40fe2634c632c2ea7a003ada8cca45c3 (patch) | |
tree | 0bba90a568110bdf16222cb32d152300c95d1976 | |
parent | fc6d713dd8066f3132f7234a94ac059ae6d596a7 (diff) | |
download | rneovim-bf7c7adb40fe2634c632c2ea7a003ada8cca45c3.tar.gz rneovim-bf7c7adb40fe2634c632c2ea7a003ada8cca45c3.tar.bz2 rneovim-bf7c7adb40fe2634c632c2ea7a003ada8cca45c3.zip |
refactor(tui): reorder functions for query and response (#28051)
- Group functions for key encoding together.
- Move the handle_modereport() branch before the handle_unknown_csi()
branch to match the order of the corresponding functions, but don't
move handle_term_response() yet, as that will be subject to further
changes (e.g. for #26744).
-rw-r--r-- | src/nvim/tui/input.c | 4 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 60 |
2 files changed, 32 insertions, 32 deletions
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 214474ff51..840e472a1c 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -442,12 +442,12 @@ static void tk_getkeys(TermInput *input, bool force) forward_modified_utf8(input, &key); } else if (key.type == TERMKEY_TYPE_MOUSE) { forward_mouse_event(input, &key); + } else if (key.type == TERMKEY_TYPE_MODEREPORT) { + handle_modereport(input, &key); } else if (key.type == TERMKEY_TYPE_UNKNOWN_CSI) { handle_unknown_csi(input, &key); } else if (key.type == TERMKEY_TYPE_OSC || key.type == TERMKEY_TYPE_DCS) { handle_term_response(input, &key); - } else if (key.type == TERMKEY_TYPE_MODEREPORT) { - handle_modereport(input, &key); } } diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 1edcde5341..96054cf5cb 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -189,36 +189,6 @@ void tui_start(TUIData **tui_p, int *width, int *height, char **term, bool *rgb) *rgb = tui->rgb; } -void tui_set_key_encoding(TUIData *tui) - FUNC_ATTR_NONNULL_ALL -{ - switch (tui->input.key_encoding) { - case kKeyEncodingKitty: - out(tui, S_LEN("\x1b[>1u")); - break; - case kKeyEncodingXterm: - out(tui, S_LEN("\x1b[>4;2m")); - break; - case kKeyEncodingLegacy: - break; - } -} - -static void tui_reset_key_encoding(TUIData *tui) - FUNC_ATTR_NONNULL_ALL -{ - switch (tui->input.key_encoding) { - case kKeyEncodingKitty: - out(tui, S_LEN("\x1b[<1u")); - break; - case kKeyEncodingXterm: - out(tui, S_LEN("\x1b[>4;0m")); - break; - case kKeyEncodingLegacy: - break; - } -} - /// Request the terminal's mode (DECRQM). /// /// @see handle_modereport @@ -270,6 +240,36 @@ static void tui_query_kitty_keyboard(TUIData *tui) out(tui, S_LEN("\x1b[?u\x1b[c")); } +void tui_set_key_encoding(TUIData *tui) + FUNC_ATTR_NONNULL_ALL +{ + switch (tui->input.key_encoding) { + case kKeyEncodingKitty: + out(tui, S_LEN("\x1b[>1u")); + break; + case kKeyEncodingXterm: + out(tui, S_LEN("\x1b[>4;2m")); + break; + case kKeyEncodingLegacy: + break; + } +} + +static void tui_reset_key_encoding(TUIData *tui) + FUNC_ATTR_NONNULL_ALL +{ + switch (tui->input.key_encoding) { + case kKeyEncodingKitty: + out(tui, S_LEN("\x1b[<1u")); + break; + case kKeyEncodingXterm: + out(tui, S_LEN("\x1b[>4;0m")); + break; + case kKeyEncodingLegacy: + break; + } +} + /// Enable the alternate screen and emit other control sequences to start the TUI. /// /// This is also called when the TUI is resumed after being suspended. We reinitialize all state |