aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-02-25 21:04:52 +0100
committerbfredl <bjorn.linse@gmail.com>2023-02-25 23:29:00 +0100
commit6942528a54eacbcdcb5b40fa27f9e37ae9e80915 (patch)
treecdb531d6e3d509024f186a67b634969189ffc763
parentc1514d7e6762ed62dee027ecc29bafd4aae2206e (diff)
downloadrneovim-6942528a54eacbcdcb5b40fa27f9e37ae9e80915.tar.gz
rneovim-6942528a54eacbcdcb5b40fa27f9e37ae9e80915.tar.bz2
rneovim-6942528a54eacbcdcb5b40fa27f9e37ae9e80915.zip
refactor(ui): ui_log() can now just be a function
-rwxr-xr-xsrc/nvim/generators/gen_api_ui_events.lua1
-rw-r--r--src/nvim/ui.c42
2 files changed, 22 insertions, 21 deletions
diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua
index 827097f69d..bbc6252f14 100755
--- a/src/nvim/generators/gen_api_ui_events.lua
+++ b/src/nvim/generators/gen_api_ui_events.lua
@@ -120,7 +120,6 @@ for i = 1, #events do
if ev.remote_only then
call_output:write(' Array args = call_buf;\n')
write_arglist(call_output, ev)
- call_output:write(' UI_LOG('..ev.name..');\n')
call_output:write(' ui_call_event("'..ev.name..'", args);\n')
elseif ev.compositor_impl then
call_output:write(' ui_comp_'..ev.name)
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 1693595ce8..a2c6d9431c 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -64,31 +64,31 @@ static int pending_has_mouse = -1;
static Array call_buf = ARRAY_DICT_INIT;
#if MIN_LOG_LEVEL > LOGLVL_DBG
-# define UI_LOG(funname)
+# define ui_log(funname)
#else
static size_t uilog_seen = 0;
-static char uilog_last_event[1024] = { 0 };
+static const char *uilog_last_event = NULL;
+static void ui_log(const char *funname)
+{
# ifndef EXITFREE
-# define entered_free_all_mem false
+ if (entered_free_all_mem) {
+ return; // do nothing, we cannot log now
+ }
# endif
-# define UI_LOG(funname) \
- do { \
- if (entered_free_all_mem) { \
- /* do nothing, we cannot log now */ \
- } else if (strequal(uilog_last_event, STR(funname))) { \
- uilog_seen++; \
- } else { \
- if (uilog_seen > 0) { \
- logmsg(LOGLVL_DBG, "UI: ", NULL, -1, true, \
- "%s (+%zu times...)", uilog_last_event, uilog_seen); \
- } \
- logmsg(LOGLVL_DBG, "UI: ", NULL, -1, true, STR(funname)); \
- uilog_seen = 0; \
- xstrlcpy(uilog_last_event, STR(funname), sizeof(uilog_last_event)); \
- } \
- } while (0)
+ if (uilog_last_event == funname) {
+ uilog_seen++;
+ } else {
+ if (uilog_seen > 0) {
+ logmsg(LOGLVL_DBG, "UI: ", NULL, -1, true,
+ "%s (+%zu times...)", uilog_last_event, uilog_seen);
+ }
+ logmsg(LOGLVL_DBG, "UI: ", NULL, -1, true, "%s", funname);
+ uilog_seen = 0;
+ uilog_last_event = funname;
+ }
+}
#endif
// UI_CALL invokes a function on all registered UI instances.
@@ -105,7 +105,7 @@ static char uilog_last_event[1024] = { 0 };
} \
} \
if (any_call) { \
- UI_LOG(funname); \
+ ui_log(STR(funname)); \
} \
} while (0)
@@ -654,6 +654,8 @@ void ui_call_event(char *name, Array args)
if (!handled) {
UI_CALL(true, event, ui, name, args);
}
+
+ ui_log(name);
}
void ui_cb_update_ext(void)