mirror of
https://github.com/neovim/neovim.git
synced 2024-12-21 19:55:04 -07:00
refactor(ui): ui_log() can now just be a function
This commit is contained in:
parent
c1514d7e67
commit
6942528a54
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user