diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-02-25 21:04:52 +0100 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2023-02-25 23:29:00 +0100 |
commit | 6942528a54eacbcdcb5b40fa27f9e37ae9e80915 (patch) | |
tree | cdb531d6e3d509024f186a67b634969189ffc763 /src/nvim/ui.c | |
parent | c1514d7e6762ed62dee027ecc29bafd4aae2206e (diff) | |
download | rneovim-6942528a54eacbcdcb5b40fa27f9e37ae9e80915.tar.gz rneovim-6942528a54eacbcdcb5b40fa27f9e37ae9e80915.tar.bz2 rneovim-6942528a54eacbcdcb5b40fa27f9e37ae9e80915.zip |
refactor(ui): ui_log() can now just be a function
Diffstat (limited to 'src/nvim/ui.c')
-rw-r--r-- | src/nvim/ui.c | 42 |
1 files changed, 22 insertions, 20 deletions
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) |