------------------
- [X] spell-checker refinements
-- [ ] provide a way for ncurses to switch out of display mode
+- [X] provide a way for ncurses to switch out of display mode
and to show a URL (or similar) which can be copied from terminal
- [ ] fix bugs
- [ ] make notmuch usable
### ncurses
+- [ ] external-viewer for different host could output file in base64 for copy/paste??
- [ ] add full list of colour names (to lib-colourmap)
- [ ] allow a pane to require 'true-colour' and discover number of colours available
Colour map gets changed when it becomes the focus.
- [ ] save function - doc:save-file given file name or fd
- [ ] wiggle-highlight patches found in email
- [X] brief summary of part type in button line
-- [ ] open function
-- [ ] make URLs clickable
+- [X] open function
+- [X] make URLs clickable
- [ ] detect and hide cited text
-- [ ] detect and highlight links
+- [X] detect and highlight links
- [ ] Make long to/cc headers truncate unless selected.
- [X] select parts from multipart
- [X] buttons for non-displayable
int report_position;
long last_event;
- char *rs1, *rs2, *rs3;
+ char *rs1, *rs2, *rs3, *clear;
char attr_buf[1024];
#ifdef RECORD_REPLAY
FILE *log;
return 1;
}
+DEF_CMD(nc_external_viewer)
+{
+ struct pane *p = ci->home;
+ struct display_data *dd = p->data;
+ char *disp = pane_attr_get(p, "DISPLAY");
+ int pid;
+ char buf[100];
+ int n;
+
+ if (!ci->str)
+ return Enoarg;
+ if (disp && *disp) {
+ switch (pid = fork()) {
+ case -1:
+ return Efail;
+ case 0: /* Child */
+ setenv("DISPLAY", disp, 1);
+ /* FIXME reopen stderr etc */
+ execlp("xdg-open", "xdg-open", ci->str, NULL);
+ exit(1);
+ default: /* parent */
+ /* FIXME record pid?? */
+ break;
+ }
+ return 1;
+ }
+ /* handle no-display case */
+ set_screen(p);
+ n = 0;
+ ioctl(fileno(dd->scr_file), FIONREAD, &n);
+ if (n)
+ n -= read(fileno(dd->scr_file), buf,
+ n <= (int)sizeof(buf) ? n : (int)sizeof(buf));
+ endwin();
+
+ /* Endwin doesn't seem to reset properly, at least on xfce-terminal.
+ * So do it manually
+ */
+ if (dd->rs1)
+ tputs(dd->rs1, 1, nc_putc);
+ if (dd->rs2)
+ tputs(dd->rs2, 1, nc_putc);
+ if (dd->rs3)
+ tputs(dd->rs3, 1, nc_putc);
+ if (dd->clear)
+ tputs(dd->clear, 1, nc_putc);
+ fflush(dd->scr_file);
+
+ fprintf(dd->scr_file, "# Consider copy-pasting following\n");
+ fprintf(dd->scr_file, "xdg-open %s\n", ci->str);
+ fprintf(dd->scr_file, "# Press Enter to continue\n");
+ n = read(fileno(dd->scr_file), buf, sizeof(buf));
+ doupdate();
+ return 1;
+}
+
static void ncurses_end(struct pane *p safe)
{
struct display_data *dd = p->data;
dd->rs3 = tgetstr("rs3", &area);
if (!dd->rs3)
dd->rs3 = tgetstr("is3", &area);
+ dd->clear = tgetstr("clear", &area);
call("editor:request:all-displays", p);
if (!prepare_recrep(p)) {
key_add(nc_map, "Display:refresh", &force_redraw);
key_add(nc_map, "Display:close", &nc_close_display);
key_add(nc_map, "Display:set-noclose", &nc_set_noclose);
+ key_add(nc_map, "Display:external-viewer", &nc_external_viewer);
key_add(nc_map, "Close", &nc_close);
key_add(nc_map, "Free", &edlib_do_free);
key_add(nc_map, "pane-clear", &nc_clear);
self.win.unfullscreen()
return 1
- def handle_new(self, key, home, **a):
+ def handle_new(self, key, **a):
"handle:Display:new"
global editor
p = editor.call("attach-input", ret='focus')
p['DISPLAY'] = self['DISPLAY']
newdisp = EdDisplay(p)
- home.clone_children(newdisp)
+ self.clone_children(newdisp)
+ return 1
+
+ def handle_external(self, key, str, **a):
+ "handle:Display:external-viewer"
+ disp = self['DISPLAY']
+ if not str or not disp:
+ return edlib.Enoarg
+ env = os.environ.copy()
+ env['DISPLAY'] = disp
+
+ subprocess.Popen(["xdg-open", str], env=env,
+ stderr = subprocess.DEVNULL)
return 1
def handle_close(self, key, **a):
fd, path = tempfile.mkstemp(suffix, prefix)
os.write(fd, content)
os.close(fd)
- subprocess.Popen(["xdg-open", path], stderr = DEVNULL)
+ focus.call("Display:external-viewer", path)
return 1
def handle_map_attr(self, key, focus, mark, str, str2, comm2, **a):
url = focus.call("doc:get-attr", m, "url", ret='str')
focus.call("Message", "Opening url <%s>" % url)
- subprocess.Popen(["xdg-open", url], stderr = DEVNULL)
+ focus.call("Display:external-viewer", url)
return 1
def notmuch_doc(key, home, focus, comm2, **a):