screen will be meaningless. I need to properly abort and
auto-choose a new pane.
- [ ] LOG_BT() doesn't see TYPE_pane and TYPE_comm calls.
-- [ ] give every pane a link to root/editor main and use that
+- [ ] LOG should take a pane arg, and not use any static vars.
+- [ ] reduce size of $(nm O/*.o | grep ' b ' | grep -v '_map$')
+- [X] give every pane a link to root/editor main and use that
instead of statics. Then maybe times_up() can use pane_too_long()
- [ ] teach input to allow a repeat command to be registered so that e.g.
search/replace and do a bit of work, then ask to be called again.
input can cancel this on suitable input.
- [ ] should input leave mode unchanged for key that isn't handled at
all
-- [ ] marks can be used after they go invalid too easily. How to fix??
+- [X] marks can be used after they go invalid too easily. How to fix??
- [ ] catching doc:replace in a pane doesn't catch doc:insert-file.
I need a simple way to intercept any change.
-- [ ] switch-buffer in pop-up window - shouldn't kill the popup (does it?)
+- [X] switch-buffer in pop-up window - shouldn't kill the popup (does it?)
- [ ] explicitly guard against infinite loops in consistency checks
- [ ] skip consistency checks after several with no stop for input.
- [ ] unwanted docs too easily appear high in recent-list - *Output*
char text[];
};
-static struct log {
+struct log {
struct doc doc;
struct list_head log;
int blocked;
int refresh_active;
-} *log_doc safe;
+ FILE *log_file;
+};
#include "core-pane.h"
#define LBSIZE (8192 - sizeof(struct logbuf))
-static FILE *log_file;
-
static struct logbuf *safe get_new_buf(struct log *d safe)
{
struct logbuf *b = malloc(sizeof(*b) + LBSIZE);
{
va_list ap;
unsigned int n;
+ struct log *ld;
struct logbuf *b;
struct timeval now;
- if (!(void*)log_doc || !log_pane)
+ if (!log_pane)
/* too early */
return;
if (!fmt)
return;
- if (log_doc->refresh_active) {
+ ld = log_pane->doc_data;
+ if (ld->refresh_active) {
/* Mustn't log anything if doc is being viewed */
if (pane_notify("doc:notify-viewers", log_pane))
return;
}
- if (log_doc->blocked)
+ if (ld->blocked)
return;
- log_doc->blocked = 1;
+ ld->blocked = 1;
gettimeofday(&now, NULL);
- b = get_buf(log_doc);
+ b = get_buf(ld);
va_start(ap, fmt);
- if (log_pane && edlib_testing(log_pane))
+ if (edlib_testing(log_pane))
n = 0;
else
n = snprintf(b->text + b->end, LBSIZE - b->end - 1,
if (b->end != 0 && n >= LBSIZE - b->end - 1) {
/* Didn't fit, allocate new buf */
- b = get_new_buf(log_doc);
+ b = get_new_buf(ld);
va_start(ap, fmt);
- if (log_pane && edlib_testing(log_pane))
+ if (edlib_testing(log_pane))
n = 0;
else
n = snprintf(b->text, LBSIZE - 1, "%ld.%03ld:",
b->text[b->end + n++] = '\n';
b->text[b->end + n] = '\0';
- if (log_file) {
- fwrite(b->text + b->end, 1, n, log_file);
- fflush(log_file);
+ if (ld->log_file) {
+ fwrite(b->text + b->end, 1, n, ld->log_file);
+ fflush(ld->log_file);
}
b->end += n;
- if (log_pane)
- pane_notify("doc:replaced", log_pane, 1);
- log_doc->blocked = 0;
+ pane_notify("doc:replaced", log_pane, 1);
+ ld->blocked = 0;
}
DEF_CMD(log_append)
list_del(&b->h);
free(b);
}
+ if (l->log_file && l->log_file != stderr)
+ fclose(l->log_file);
return 1;
}
static void log_init(struct pane *ed safe)
{
char *fname;
+ struct log *ld;
log_pane = doc_register(ed, &log_handle.c);
if (!log_pane)
return;
+ ld = log_pane->doc_data;
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);
+
+ INIT_LIST_HEAD(&ld->log);
call("editor:request:Refresh-active", log_pane);
if (!fname || !*fname)
return;
if (strcmp(fname, "stderr") == 0) {
- log_file = stderr;
+ ld->log_file = stderr;
return;
}
- log_file = fopen(fname, "a");
- if (!log_file)
+ ld->log_file = fopen(fname, "a");
+ if (!ld->log_file)
LOG("log: Cannot open \"%s\" for logging\n", fname);
}