From be89d520d7e9ad6c574c259a10f282177fb5dd4a Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 13 Nov 2024 13:25:10 +0100 Subject: refactor(windows)!: only support UCRT, even for mingw The newer UCRT runtime has native support for UTF-8, including forcing it as the active codepage even before `main()` is called. This means the c runtime will properly convert windows WCHAR:s into UTF-8 bytes, as early as the argv/argc params to `main()` . Whereas MSVCRT does not support this reliably and required us to use `wmain()`. Only MSVC supports using manifest files directly as source files. The solution for other Windows toolchains is to use a .rc file. --- src/nvim/os/nvim.rc | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/nvim/os/nvim.rc (limited to 'src/nvim/os') diff --git a/src/nvim/os/nvim.rc b/src/nvim/os/nvim.rc new file mode 100644 index 0000000000..e838c93c16 --- /dev/null +++ b/src/nvim/os/nvim.rc @@ -0,0 +1,2 @@ +#include "winuser.h" +2 RT_MANIFEST nvim.manifest -- cgit From 2a7d0ed6145bf3f8b139c2694563f460f829813a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 23 Dec 2024 05:43:52 -0800 Subject: refactor: iwyu #31637 Result of `make iwyu` (after some "fixups"). --- src/nvim/os/env.c | 1 - src/nvim/os/fileio.c | 7 ++----- src/nvim/os/input.c | 3 ++- src/nvim/os/pty_proc_unix.c | 1 + 4 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index ccf6c9554a..733e52e69c 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -15,7 +15,6 @@ #include "nvim/cmdexpand.h" #include "nvim/cmdexpand_defs.h" #include "nvim/eval.h" -#include "nvim/gettext_defs.h" #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/macros_defs.h" diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index 1981d0dfd4..1b202fdc59 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -8,16 +8,13 @@ #include #include #include -#include +#include #include #include "auto/config.h" -#include "nvim/gettext_defs.h" -#include "nvim/globals.h" #include "nvim/log.h" #include "nvim/macros_defs.h" #include "nvim/memory.h" -#include "nvim/message.h" #include "nvim/os/fileio.h" #include "nvim/os/fs.h" #include "nvim/os/os_defs.h" @@ -28,7 +25,7 @@ #endif #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/fileio.c.generated.h" +# include "os/fileio.c.generated.h" // IWYU pragma: keep #endif /// Open file diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 2d17581bac..579b08c554 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -13,7 +14,6 @@ #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" #include "nvim/event/rstream.h" -#include "nvim/event/stream.h" #include "nvim/getchar.h" #include "nvim/gettext_defs.h" #include "nvim/globals.h" @@ -29,6 +29,7 @@ #include "nvim/profile.h" #include "nvim/state.h" #include "nvim/state_defs.h" +#include "nvim/types_defs.h" #define READ_BUFFER_SIZE 0xfff #define INPUT_BUFFER_SIZE ((READ_BUFFER_SIZE * 4) + MAX_KEY_CODE_LEN) diff --git a/src/nvim/os/pty_proc_unix.c b/src/nvim/os/pty_proc_unix.c index 3bca065d2d..10a464bbc3 100644 --- a/src/nvim/os/pty_proc_unix.c +++ b/src/nvim/os/pty_proc_unix.c @@ -30,6 +30,7 @@ #endif #include "auto/config.h" +#include "klib/kvec.h" #include "nvim/eval/typval.h" #include "nvim/event/defs.h" #include "nvim/event/loop.h" -- cgit From 9d114b720514b0bde96dbdd9b6ef328d232a1589 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Wed, 1 Jan 2025 19:45:14 +0600 Subject: refactor(options): use `const` in more places (#31791) --- src/nvim/os/env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 733e52e69c..3126881266 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -580,7 +580,7 @@ void expand_env(char *src, char *dst, int dstlen) /// @param esc Escape spaces in expanded variables /// @param one `srcp` is a single filename /// @param prefix Start again after this (can be NULL) -void expand_env_esc(char *restrict srcp, char *restrict dst, int dstlen, bool esc, bool one, +void expand_env_esc(const char *restrict srcp, char *restrict dst, int dstlen, bool esc, bool one, char *prefix) FUNC_ATTR_NONNULL_ARG(1, 2) { -- cgit From 5bae80899d9d29d80c129ca92cde75a1583b5efe Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Tue, 14 Jan 2025 12:05:23 +0100 Subject: feat(messages): add :!cmd shell message kinds Also print stderr error messages with ErrorMsg highlight group. --- src/nvim/os/shell.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 81b75dc4d3..5347c8db9a 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -700,6 +700,7 @@ int os_call_shell(char *cmd, int opts, char *extra_args) } if (!emsg_silent && exitcode != 0 && !(opts & kShellOptSilent)) { + msg_ext_set_kind("shell_ret"); msg_puts(_("\nshell returned ")); msg_outnum(exitcode); msg_putchar('\n'); @@ -1067,7 +1068,7 @@ static void out_data_ring(const char *output, size_t size) } if (output == NULL && size == SIZE_MAX) { // Print mode - out_data_append_to_screen(last_skipped, &last_skipped_len, true); + out_data_append_to_screen(last_skipped, &last_skipped_len, STDOUT_FILENO, true); return; } @@ -1095,14 +1096,15 @@ static void out_data_ring(const char *output, size_t size) /// @param output Data to append to screen lines. /// @param count Size of data. /// @param eof If true, there will be no more data output. -static void out_data_append_to_screen(const char *output, size_t *count, bool eof) +static void out_data_append_to_screen(const char *output, size_t *count, int fd, bool eof) FUNC_ATTR_NONNULL_ALL { const char *p = output; const char *end = output + *count; + msg_ext_set_kind(fd == STDERR_FILENO ? "shell_err" : "shell_out"); while (p < end) { if (*p == '\n' || *p == '\r' || *p == TAB || *p == BELL) { - msg_putchar_hl((uint8_t)(*p), 0); + msg_putchar_hl((uint8_t)(*p), fd == STDERR_FILENO ? HLF_E : 0); p++; } else { // Note: this is not 100% precise: @@ -1118,7 +1120,7 @@ static void out_data_append_to_screen(const char *output, size_t *count, bool eo goto end; } - msg_outtrans_len(p, i, 0, false); + msg_outtrans_len(p, i, fd == STDERR_FILENO ? HLF_E : 0, false); p += i; } } @@ -1133,7 +1135,7 @@ static size_t out_data_cb(RStream *stream, const char *ptr, size_t count, void * // Save the skipped output. If it is the final chunk, we display it later. out_data_ring(ptr, count); } else if (count > 0) { - out_data_append_to_screen(ptr, &count, eof); + out_data_append_to_screen(ptr, &count, stream->s.fd, eof); } return count; -- cgit From 44dbfcfba4b09bb0e38f4a3f1960fa256a7bed71 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 21 Jan 2025 20:50:33 +0800 Subject: feat(tui): recognize X1 and X2 mouse events Ref: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Other-buttons --- src/nvim/os/input.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/os') diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 579b08c554..3259fb500b 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -403,6 +403,7 @@ static unsigned handle_mouse_event(const char **ptr, uint8_t *buf, unsigned bufs if (type != KS_EXTRA || !((mouse_code >= KE_LEFTMOUSE && mouse_code <= KE_RIGHTRELEASE) + || (mouse_code >= KE_X1MOUSE && mouse_code <= KE_X2RELEASE) || (mouse_code >= KE_MOUSEDOWN && mouse_code <= KE_MOUSERIGHT) || mouse_code == KE_MOUSEMOVE)) { return bufsize; -- cgit From 2470db02c5136525b8abce1ee0889d94f8d81d98 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Jan 2025 08:52:55 +0800 Subject: vim-patch:partial:9.1.1050: too many strlen() calls in os_unix.c (#32188) Problem: too many strlen() calls in os_unix.c Solution: refactor os_unix.c and remove calls to strlen() (John Marriott) closes: vim/vim#16496 https://github.com/vim/vim/commit/efc41a5958bf25b352e0916af5f57dafbbb44f17 Omit os_expand_wildcards() change: Nvim's code is more complicated and harder to refactor. Co-authored-by: John Marriott --- src/nvim/os/fs.c | 6 +++--- src/nvim/os/shell.c | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index d0da37b8e7..451994241d 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -370,8 +370,8 @@ static bool is_executable_in_path(const char *name, char **abspath) char *path = xstrdup(path_env); #endif - size_t buf_len = strlen(name) + strlen(path) + 2; - char *buf = xmalloc(buf_len); + const size_t bufsize = strlen(name) + strlen(path) + 2; + char *buf = xmalloc(bufsize); // Walk through all entries in $PATH to check if "name" exists there and // is an executable file. @@ -382,7 +382,7 @@ static bool is_executable_in_path(const char *name, char **abspath) // Combine the $PATH segment with `name`. xmemcpyz(buf, p, (size_t)(e - p)); - (void)append_path(buf, name, buf_len); + (void)append_path(buf, name, bufsize); #ifdef MSWIN if (is_executable_ext(buf, abspath)) { diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 5347c8db9a..d60d0b3e55 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -1208,10 +1208,11 @@ static void read_input(StringBuilder *buf) size_t len = 0; linenr_T lnum = curbuf->b_op_start.lnum; char *lp = ml_get(lnum); + size_t lplen = (size_t)ml_get_len(lnum); while (true) { - size_t l = strlen(lp + written); - if (l == 0) { + lplen -= written; + if (lplen == 0) { len = 0; } else if (lp[written] == NL) { // NL -> NUL translation @@ -1219,11 +1220,11 @@ static void read_input(StringBuilder *buf) kv_push(*buf, NUL); } else { char *s = vim_strchr(lp + written, NL); - len = s == NULL ? l : (size_t)(s - (lp + written)); + len = s == NULL ? lplen : (size_t)(s - (lp + written)); kv_concat_len(*buf, lp + written, len); } - if (len == l) { + if (len == lplen) { // Finished a line, add a NL, unless this line should not have one. if (lnum != curbuf->b_op_end.lnum || (!curbuf->b_p_bin && curbuf->b_p_fixeol) @@ -1236,6 +1237,7 @@ static void read_input(StringBuilder *buf) break; } lp = ml_get(lnum); + lplen = (size_t)ml_get_len(lnum); written = 0; } else if (len > 0) { written += len; -- cgit From e71d2c817d1a2475551f58a98e411f6b39a5be3f Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 13 Jan 2025 15:48:02 +0100 Subject: docs: misc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dustin S. Co-authored-by: Ferenc Fejes Co-authored-by: Maria José Solano Co-authored-by: Yochem van Rosmalen Co-authored-by: brianhuster Co-authored-by: zeertzjq --- src/nvim/os/signal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index ecedf144e5..98d13fc9d1 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -187,8 +187,7 @@ static void on_signal(SignalWatcher *handle, int signum, void *data) switch (signum) { #ifdef SIGPWR case SIGPWR: - // Signal of a power failure(eg batteries low), flush the swap files to - // be safe + // Signal of a power failure (eg batteries low), flush the swap files to be safe ml_sync_all(false, false, true); break; #endif -- cgit