diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2023-12-21 16:50:05 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-21 16:50:05 +0800 |
| commit | 8533adb4844b771b84dac2141fa2fa60e0487b47 (patch) | |
| tree | 5eabff8fb1eee869b733dbb01f739ee2cad2915d /src/nvim/os | |
| parent | 8c611f53feaeb6110875499cec9097c93b892c8c (diff) | |
| download | rneovim-8533adb4844b771b84dac2141fa2fa60e0487b47.tar.gz rneovim-8533adb4844b771b84dac2141fa2fa60e0487b47.tar.bz2 rneovim-8533adb4844b771b84dac2141fa2fa60e0487b47.zip | |
refactor(IWYU): move decor provider types to decoration_defs.h (#26692)
Diffstat (limited to 'src/nvim/os')
| -rw-r--r-- | src/nvim/os/os.h | 2 | ||||
| -rw-r--r-- | src/nvim/os/os_win_console.c | 38 | ||||
| -rw-r--r-- | src/nvim/os/pty_conpty_win.c | 1 | ||||
| -rw-r--r-- | src/nvim/os/pty_process_win.c | 1 | ||||
| -rw-r--r-- | src/nvim/os/tty.c | 52 | ||||
| -rw-r--r-- | src/nvim/os/tty.h | 5 |
6 files changed, 41 insertions, 58 deletions
diff --git a/src/nvim/os/os.h b/src/nvim/os/os.h index 302d84d066..7ba5f05448 100644 --- a/src/nvim/os/os.h +++ b/src/nvim/os/os.h @@ -4,11 +4,11 @@ #include <stdint.h> // IWYU pragma: keep #include <uv.h> // IWYU pragma: keep -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/garray_defs.h" // IWYU pragma: keep #include "nvim/os/os_defs.h" // IWYU pragma: export #include "nvim/os/stdpaths_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep #define HAVE_PATHDEF diff --git a/src/nvim/os/os_win_console.c b/src/nvim/os/os_win_console.c index 816e81e997..953d291290 100644 --- a/src/nvim/os/os_win_console.c +++ b/src/nvim/os/os_win_console.c @@ -1,6 +1,7 @@ #include <string.h> #include "nvim/globals.h" +#include "nvim/memory.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" #include "nvim/os/os.h" @@ -105,3 +106,40 @@ void os_title_reset(void) { SetConsoleTitle(origTitle); } + +#if !defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) +# define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 +#endif +/// Guesses the terminal-type. Calls SetConsoleMode() and uv_set_vterm_state() +/// if appropriate. +/// +/// @param[in,out] term Name of the guessed terminal, statically-allocated +/// @param out_fd stdout file descriptor +void os_tty_guess_term(const char **term, int out_fd) +{ + bool conemu_ansi = strequal(os_getenv("ConEmuANSI"), "ON"); + bool vtp = false; + + HANDLE handle = (HANDLE)_get_osfhandle(out_fd); + DWORD dwMode; + if (handle != INVALID_HANDLE_VALUE && GetConsoleMode(handle, &dwMode)) { + dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + if (SetConsoleMode(handle, dwMode)) { + vtp = true; + } + } + + if (*term == NULL) { + if (vtp) { + *term = "vtpcon"; + } else if (conemu_ansi) { + *term = "conemu"; + } else { + *term = "win32con"; + } + } + + if (conemu_ansi) { + uv_tty_set_vterm_state(UV_TTY_SUPPORTED); + } +} diff --git a/src/nvim/os/pty_conpty_win.c b/src/nvim/os/pty_conpty_win.c index 53169c0ef8..e7697880af 100644 --- a/src/nvim/os/pty_conpty_win.c +++ b/src/nvim/os/pty_conpty_win.c @@ -1,5 +1,6 @@ #include <uv.h> +#include "nvim/log.h" #include "nvim/os/os.h" #include "nvim/os/pty_conpty_win.h" #include "nvim/vim_defs.h" diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index ca2dce36ea..563a79358c 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -4,6 +4,7 @@ #include "nvim/ascii_defs.h" #include "nvim/eval/typval.h" +#include "nvim/log.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/os/os.h" diff --git a/src/nvim/os/tty.c b/src/nvim/os/tty.c deleted file mode 100644 index 57325c312f..0000000000 --- a/src/nvim/os/tty.c +++ /dev/null @@ -1,52 +0,0 @@ -// -// Terminal/console utils -// - -#ifdef MSWIN -# include "nvim/memory.h" -# include "nvim/os/os.h" -#endif -#include "nvim/os/tty.h" - -#ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/tty.c.generated.h" // IWYU pragma: export -#endif - -#ifdef MSWIN -# if !defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) -# define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 -# endif -/// Guesses the terminal-type. Calls SetConsoleMode() and uv_set_vterm_state() -/// if appropriate. -/// -/// @param[in,out] term Name of the guessed terminal, statically-allocated -/// @param out_fd stdout file descriptor -void os_tty_guess_term(const char **term, int out_fd) -{ - bool conemu_ansi = strequal(os_getenv("ConEmuANSI"), "ON"); - bool vtp = false; - - HANDLE handle = (HANDLE)_get_osfhandle(out_fd); - DWORD dwMode; - if (handle != INVALID_HANDLE_VALUE && GetConsoleMode(handle, &dwMode)) { - dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; - if (SetConsoleMode(handle, dwMode)) { - vtp = true; - } - } - - if (*term == NULL) { - if (vtp) { - *term = "vtpcon"; - } else if (conemu_ansi) { - *term = "conemu"; - } else { - *term = "win32con"; - } - } - - if (conemu_ansi) { - uv_tty_set_vterm_state(UV_TTY_SUPPORTED); - } -} -#endif diff --git a/src/nvim/os/tty.h b/src/nvim/os/tty.h deleted file mode 100644 index 3a78573189..0000000000 --- a/src/nvim/os/tty.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/tty.h.generated.h" -#endif |