From 68d425ac92599089047d98f1c533981ea917fed1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 25 Sep 2023 12:26:01 +0200 Subject: refactor: remove 'shortmess' save/restore panic for ex commands This was only used to avoid the effect of SHM_OVERALL. This can easily be handled in isolation, instead of clearing out all of 'shortmess' which has unwanted side effects and mystifies what really is going on. --- src/nvim/message.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/message.h') diff --git a/src/nvim/message.h b/src/nvim/message.h index 191d3b8da7..78cd5b7d0e 100644 --- a/src/nvim/message.h +++ b/src/nvim/message.h @@ -68,6 +68,8 @@ EXTERN int msg_scrolled_at_flush INIT(= 0); EXTERN int msg_grid_scroll_discount INIT(= 0); +EXTERN int msg_listdo_overwrite INIT(= 0); + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "message.h.generated.h" #endif -- cgit From fd791db0ecebf5d5bf8922ba519f8dd4eef3c5e6 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 3 Oct 2023 00:19:30 +0200 Subject: fix: fix ASAN errors on clang 17 (#25469) --- src/nvim/message.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/message.h') diff --git a/src/nvim/message.h b/src/nvim/message.h index 78cd5b7d0e..6fc6674cc2 100644 --- a/src/nvim/message.h +++ b/src/nvim/message.h @@ -7,6 +7,7 @@ #include "klib/kvec.h" #include "nvim/api/private/defs.h" +#include "nvim/ex_cmds_defs.h" #include "nvim/grid_defs.h" #include "nvim/macros.h" #include "nvim/types.h" -- cgit From 5f03a1eaabfc8de2b3a9c666fcd604763f41e152 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 20 Oct 2023 15:10:33 +0200 Subject: build(lint): remove unnecessary clint.py rules Uncrustify is the source of truth where possible. Remove any redundant checks from clint.py. --- src/nvim/message.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/nvim/message.h') diff --git a/src/nvim/message.h b/src/nvim/message.h index 6fc6674cc2..efa2aa9ee8 100644 --- a/src/nvim/message.h +++ b/src/nvim/message.h @@ -49,12 +49,12 @@ extern MessageHistoryEntry *first_msg_hist; /// Last message extern MessageHistoryEntry *last_msg_hist; -EXTERN bool msg_ext_need_clear INIT(= false); +EXTERN bool msg_ext_need_clear INIT( = false); // allocated grid for messages. Used when display+=msgsep is set, or // ext_multigrid is active. See also the description at msg_scroll_flush() -EXTERN ScreenGrid msg_grid INIT(= SCREEN_GRID_INIT); -EXTERN int msg_grid_pos INIT(= 0); +EXTERN ScreenGrid msg_grid INIT( = SCREEN_GRID_INIT); +EXTERN int msg_grid_pos INIT( = 0); // "adjusted" message grid. This grid accepts positions relative to // default_grid. Internally it will be translated to a position on msg_grid @@ -62,14 +62,14 @@ EXTERN int msg_grid_pos INIT(= 0); // for legacy (display-=msgsep) message scroll behavior. // // TODO(bfredl): refactor "internal" message logic, msg_row etc // to use the correct positions already. -EXTERN ScreenGrid msg_grid_adj INIT(= SCREEN_GRID_INIT); +EXTERN ScreenGrid msg_grid_adj INIT( = SCREEN_GRID_INIT); // value of msg_scrolled at latest msg_scroll_flush. -EXTERN int msg_scrolled_at_flush INIT(= 0); +EXTERN int msg_scrolled_at_flush INIT( = 0); -EXTERN int msg_grid_scroll_discount INIT(= 0); +EXTERN int msg_grid_scroll_discount INIT( = 0); -EXTERN int msg_listdo_overwrite INIT(= 0); +EXTERN int msg_listdo_overwrite INIT( = 0); #ifdef INCLUDE_GENERATED_DECLARATIONS # include "message.h.generated.h" -- cgit From 4f8941c1a5f1ef6caa410feeb52e343db22763ce Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 10 Nov 2023 12:23:42 +0100 Subject: refactor: replace manual header guards with #pragma once It is less error-prone than manually defining header guards. Pretty much all compilers support it even if it's not part of the C standard. --- src/nvim/message.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/nvim/message.h') diff --git a/src/nvim/message.h b/src/nvim/message.h index efa2aa9ee8..95e83adb63 100644 --- a/src/nvim/message.h +++ b/src/nvim/message.h @@ -1,5 +1,4 @@ -#ifndef NVIM_MESSAGE_H -#define NVIM_MESSAGE_H +#pragma once #include #include @@ -74,4 +73,3 @@ EXTERN int msg_listdo_overwrite INIT( = 0); #ifdef INCLUDE_GENERATED_DECLARATIONS # include "message.h.generated.h" #endif -#endif // NVIM_MESSAGE_H -- cgit From 6c14ae6bfaf51415b555e9a6b85d1d280976358d Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 20:27:32 +0100 Subject: refactor: rename types.h to types_defs.h --- src/nvim/message.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/message.h') diff --git a/src/nvim/message.h b/src/nvim/message.h index 95e83adb63..2f7f67937d 100644 --- a/src/nvim/message.h +++ b/src/nvim/message.h @@ -9,7 +9,7 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/grid_defs.h" #include "nvim/macros.h" -#include "nvim/types.h" +#include "nvim/types_defs.h" // Types of dialogs passed to do_dialog(). #define VIM_GENERIC 0 -- cgit From c9f53d0e40815644bbf7c57a0792f2c793c954aa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Nov 2023 19:00:14 +0800 Subject: refactor: iwyu (#26269) --- src/nvim/message.h | 52 ++++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'src/nvim/message.h') diff --git a/src/nvim/message.h b/src/nvim/message.h index 2f7f67937d..1e6e1dec70 100644 --- a/src/nvim/message.h +++ b/src/nvim/message.h @@ -11,20 +11,24 @@ #include "nvim/macros.h" #include "nvim/types_defs.h" -// Types of dialogs passed to do_dialog(). -#define VIM_GENERIC 0 -#define VIM_ERROR 1 -#define VIM_WARNING 2 -#define VIM_INFO 3 -#define VIM_QUESTION 4 -#define VIM_LAST_TYPE 4 // sentinel value +/// Types of dialogs passed to do_dialog(). +enum { + VIM_GENERIC = 0, + VIM_ERROR = 1, + VIM_WARNING = 2, + VIM_INFO = 3, + VIM_QUESTION = 4, + VIM_LAST_TYPE = 4, ///< sentinel value +}; -// Return values for functions like vim_dialogyesno() -#define VIM_YES 2 -#define VIM_NO 3 -#define VIM_CANCEL 4 -#define VIM_ALL 5 -#define VIM_DISCARDALL 6 +/// Return values for functions like vim_dialogyesno() +enum { + VIM_YES = 2, + VIM_NO = 3, + VIM_CANCEL = 4, + VIM_ALL = 5, + VIM_DISCARDALL = 6, +}; typedef struct { String text; @@ -36,8 +40,8 @@ typedef kvec_t(HlMessageChunk) HlMessage; /// Message history for `:messages` typedef struct msg_hist { struct msg_hist *next; ///< Next message. - char *msg; ///< Message text. - const char *kind; ///< Message kind (for msg_ext) + char *msg; ///< Message text. + const char *kind; ///< Message kind (for msg_ext) int attr; ///< Message highlighting. bool multiline; ///< Multiline message. HlMessage multiattr; ///< multiattr message. @@ -50,20 +54,20 @@ extern MessageHistoryEntry *last_msg_hist; EXTERN bool msg_ext_need_clear INIT( = false); -// allocated grid for messages. Used when display+=msgsep is set, or -// ext_multigrid is active. See also the description at msg_scroll_flush() +/// allocated grid for messages. Used when display+=msgsep is set, or +/// ext_multigrid is active. See also the description at msg_scroll_flush() EXTERN ScreenGrid msg_grid INIT( = SCREEN_GRID_INIT); EXTERN int msg_grid_pos INIT( = 0); -// "adjusted" message grid. This grid accepts positions relative to -// default_grid. Internally it will be translated to a position on msg_grid -// relative to the start of the message area, or directly mapped to default_grid -// for legacy (display-=msgsep) message scroll behavior. -// // TODO(bfredl): refactor "internal" message logic, msg_row etc -// to use the correct positions already. +/// "adjusted" message grid. This grid accepts positions relative to +/// default_grid. Internally it will be translated to a position on msg_grid +/// relative to the start of the message area, or directly mapped to default_grid +/// for legacy (display-=msgsep) message scroll behavior. +/// TODO(bfredl): refactor "internal" message logic, msg_row etc +/// to use the correct positions already. EXTERN ScreenGrid msg_grid_adj INIT( = SCREEN_GRID_INIT); -// value of msg_scrolled at latest msg_scroll_flush. +/// value of msg_scrolled at latest msg_scroll_flush. EXTERN int msg_scrolled_at_flush INIT( = 0); EXTERN int msg_grid_scroll_discount INIT( = 0); -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/nvim/message.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/message.h') diff --git a/src/nvim/message.h b/src/nvim/message.h index 1e6e1dec70..04ea1a76ff 100644 --- a/src/nvim/message.h +++ b/src/nvim/message.h @@ -8,7 +8,7 @@ #include "nvim/api/private/defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/grid_defs.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/types_defs.h" /// Types of dialogs passed to do_dialog(). -- cgit From a6cba103cebce535279db197f9efeb34e9d1171f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 29 Nov 2023 20:32:40 +0800 Subject: refactor: move some constants out of vim_defs.h (#26298) --- src/nvim/message.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/nvim/message.h') diff --git a/src/nvim/message.h b/src/nvim/message.h index 04ea1a76ff..adbb40277b 100644 --- a/src/nvim/message.h +++ b/src/nvim/message.h @@ -1,15 +1,15 @@ #pragma once -#include +#include #include -#include +#include // IWYU pragma: keep +#include #include "klib/kvec.h" #include "nvim/api/private/defs.h" -#include "nvim/ex_cmds_defs.h" +#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/grid_defs.h" #include "nvim/macros_defs.h" -#include "nvim/types_defs.h" /// Types of dialogs passed to do_dialog(). enum { @@ -30,6 +30,9 @@ enum { VIM_DISCARDALL = 6, }; +/// special attribute addition: Put message in history +enum { MSG_HIST = 0x1000, }; + typedef struct { String text; int attr; @@ -77,3 +80,14 @@ EXTERN int msg_listdo_overwrite INIT( = 0); #ifdef INCLUDE_GENERATED_DECLARATIONS # include "message.h.generated.h" #endif + +// Prefer using semsg(), because perror() may send the output to the wrong +// destination and mess up the screen. +#define PERROR(msg) (void)semsg("%s: %s", (msg), strerror(errno)) + +#ifndef MSWIN +/// Headless (no UI) error message handler. +# define os_errmsg(str) fprintf(stderr, "%s", (str)) +/// Headless (no UI) message handler. +# define os_msg(str) printf("%s", (str)) +#endif -- cgit