implemented at least by lib-search, doc-text and probably many
others. It is particularly for things that are awkward to test
with the ncurses/replay test approach.
-- [ ] Send global notify before/after refresh. LOG must suspend logging
+- [X] Send global notify before/after refresh. LOG must suspend logging
(or notifications at least) during refresh if is visible anywhere
- [ ] Do I want "Display" as in "Display:close", or "window" as in
"window:notify". Decide, and make everything consistent.
static struct log {
struct doc doc;
struct list_head log;
- int blocked;
+ int blocked;
+ int refresh_active;
} *log_doc safe;
#include "core-pane.h"
struct logbuf *b;
struct timeval now;
- if (!(void*)log_doc)
+ if (!(void*)log_doc || !log_pane)
/* too early */
return;
if (!fmt)
return;
+ if (log_doc->refresh_active) {
+ /* Mustn't log anything if doc is being viewed */
+ if (pane_notify("doc:notify-viewers", log_pane))
+ return;
+ }
if (log_doc->blocked)
return;
log_doc->blocked = 1;
return 1;
}
+DEF_CMD(log_refresh_active)
+{
+ struct log *l = ci->home->doc_data;
+
+ l->refresh_active = ci->num;
+ return 1;
+}
+
static struct map *log_map;
DEF_LOOKUP_CMD(log_handle, log_map);
log_pane = doc_register(ed, &log_handle.c);
if (!log_pane)
return;
+ if (edlib_testing(ed))
+ /* line-count is SYNC when testing, and log can
+ * get big - so disable
+ */
+ attr_set_str(&log_pane->attrs, "linecount-disable", "yes");
log_doc = log_pane->doc_data;
INIT_LIST_HEAD(&log_doc->log);
+ call("editor:request:Refresh-active", log_pane);
+
fname = getenv("EDLIB_LOG");
if (!fname || !*fname)
return;
key_add(log_map, "doc:destroy", &log_destroy);
key_add(log_map, "doc:log:append", &log_append);
key_add(log_map, "Close", &log_close);
+ key_add(log_map, "Refresh-active", &log_refresh_active);
if(0)key_add(log_map, "debug:validate-marks", &log_val_marks);
log_init(ed);
if (p->damaged & DAMAGED_CLOSED)
return 1;
-
+ call("editor:notify:Refresh-active", p, 1);
time_start(TIME_REFRESH);
while (cnt-- &&
(p->damaged &
pane_do_refresh(p);
p->damaged &= ~DAMAGED_DEBUG;
}
+ if (cnt < 0)
+ p->damaged |= DAMAGED_DEBUG;
pane_do_postorder(p);
+ p->damaged &= ~DAMAGED_DEBUG;
if (p->damaged) {
static time_t last_warn;
static int rpt;
if (last_warn + 5 < time(NULL))
rpt = 0;
if (rpt++ < 5)
- LOG("WARNING %sroot pane damaged after refresh: %d",
+ LOG("WARNING %sroot pane damaged after refresh: 0x%x",
p->parent != p ? "":"non-", p->damaged);
last_warn = time(NULL);
call("editor:notify:Message:broadcast",p, 0, NULL,
"Refresh looping - see log");
}
time_stop(TIME_REFRESH);
+ call("editor:notify:Refresh-active", p, 0);
return 1;
}
/* num==1 means we don't want to wait for precision */
bool sync = ci->mark2 && ci->num != 1;
- if (strcmp(ci->key, "CountLinesAsync") == 0)
- sync = False;
count_calculate(d, ci->mark2, ci->home, cli->view_num,
sync);
return 1;