From: NeilBrown Date: Wed, 19 Jul 2023 08:41:22 +0000 (+1000) Subject: doc-email: switch to embedded data. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=8fce1de07afd82cf3a907c82a7dca2055ec833dd;p=edlib.git doc-email: switch to embedded data. struct email_view is now embedded in the pane, no found by a pointer deref. Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index 56a2358c..4687dac8 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -4,10 +4,33 @@ To-do list for edlib Current priorities ------------------ -All of these, except Trivial, are references to todo items elsewhere in +All of these, except Triage, are references to todo items elsewhere in the file. -### Trivial +### Triage + +- [ ] If a pane with shift-disabled has cursor past the right edge, the + cursor gets positioned outside the window +- [ ] when find-file dialog shifts left, it doesn't shift back until + cursor is v.close to left, even when the rest of the line is blank +- [ ] line-count in make output is weird. Second line can be thousands +- [ ] Make sometimes doesn't follow output, though usually it does +- [ ] If dynamic-complete only finds one completion, does it still want + a menu? +- [ ] When merge makes a change, highlight the new content. +- [ ] Review the options for editing a merge - it doesn't always do what + I want. Maybe have a menu of choices to remind me +- [ ] cursor is sometimes off-screen when it shouldn't be. I don't know + what cause this yet, but I will try to remember to take notes next + time. + When seaching backwards and result is just above display, the + result doesn't get shown. Sometimes. +- [ ] visiting a new file from a 44 popup is weird. +- [ ] search in history always finds a new history line. It doesn't + check if new patterns still matches this line. +- [ ] in notmuch cursor should go to search result when changing + messages. +- [ ] menu for address completions in email-compose - [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() diff --git a/doc-email.c b/doc-email.c index 0bbb9483..fa782da1 100644 --- a/doc-email.c +++ b/doc-email.c @@ -40,9 +40,19 @@ #include #include #include + +#define PANE_DATA_TYPE struct email_view + #include "core.h" #include "misc.h" +struct email_view { + int parts; + char *invis safe; +}; + +#include "core-pane.h" + static inline bool is_orig(int p) { return p >= 0 && p % 3 == 0; @@ -947,17 +957,11 @@ out: return Efail; } -struct email_view { - int parts; - char *invis safe; -}; - DEF_CMD(email_view_free) { - struct email_view *evi = ci->home->data; + struct email_view *evi = &ci->home->data; free(evi->invis); - unalloc(evi, pane); return 1; } @@ -980,7 +984,7 @@ static int email_step(struct pane *home safe, struct mark *mark safe, int forward, int move) { struct pane *p = home; - struct email_view *evi = p->data; + struct email_view *evi = &p->data; wint_t ret; int n = -1; @@ -1058,7 +1062,7 @@ DEF_CMD(email_content) * what is invisible, marking all spacers as invisible */ struct pane *p = ci->home; - struct email_view *evi = p->data; + struct email_view *evi = &p->data; char *invis2 = strsave(p, evi->invis); int i; @@ -1074,7 +1078,7 @@ DEF_CMD(email_content) DEF_CMD(email_set_ref) { struct pane *p = ci->home; - struct email_view *evi = p->data; + struct email_view *evi = &p->data; if (!ci->mark) return Enoarg; @@ -1086,7 +1090,7 @@ DEF_CMD(email_set_ref) DEF_CMD(email_step_part) { struct pane *p = ci->home; - struct email_view *evi = p->data; + struct email_view *evi = &p->data; if (!ci->mark) return Enoarg; @@ -1098,7 +1102,7 @@ DEF_CMD(email_view_get_attr) { int p; char *v; - struct email_view *evi = ci->home->data; + struct email_view *evi = &ci->home->data; if (!ci->str || !ci->mark) return Enoarg; @@ -1124,7 +1128,7 @@ DEF_CMD(email_view_get_attr) DEF_CMD(email_view_set_attr) { int p; - struct email_view *evi = ci->home->data; + struct email_view *evi = &ci->home->data; if (!ci->str || !ci->mark) return Enoarg; @@ -1206,7 +1210,10 @@ DEF_CMD(attach_email_view) if (n <= 0 || n > 1000 ) return Einval; - alloc(evi, pane); + p = pane_register(ci->focus, 0, &email_view_handle.c); + if (!p) + return Efail; + evi = &p->data; evi->parts = n; evi->invis = calloc(n+1, sizeof(char)); for (i = 0; i < n; i++) { @@ -1220,11 +1227,6 @@ DEF_CMD(attach_email_view) /* Everything else default to invisible */ evi->invis[i] = 'i'; } - p = pane_register(ci->focus, 0, &email_view_handle.c, evi); - if (!p) { - free(evi); - return Efail; - } p2 = call_ret(pane, "attach-line-count", p); if (p2) p = p2;