sfeed_curses

[fork] sfeed (atom feed) reader
Log | Files | Refs | README | LICENSE

commit 3a0aaed53b4a4f6f9d1435f99628b2d8a8f9089d
parent 293689232a132f5f5e8764209d6c84c54e9f80e2
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun, 28 Jun 2020 22:12:06 +0200

add flag to pipeitem if output is wanted or not and to restore term settings

Noticed while testing on Devuan Linux on a slower machine there was flicker in
the terminal when yanking.

This flag makes sure to not output to stdout and stderr, hopefully not changing
the terminal. It will also not cleanup and restore (which is then not needed)
causing flickering.

Diffstat:
Msfeed_curses.c | 30+++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/sfeed_curses.c b/sfeed_curses.c @@ -420,18 +420,27 @@ init(void) needcleanup = 1; } +/* pipe item to a program, if `wantoutput` is set then cleanup and restore the + terminal attribute settings, if not set then don't do that and also ignore + stdout and stderr. */ void -pipeitem(const char *cmd, struct item *item) +pipeitem(const char *cmd, struct item *item, int wantoutput) { FILE *fp; int i, pid, wpid; - cleanup(); + if (wantoutput) + cleanup(); switch ((pid = fork())) { case -1: err(1, "fork"); return; case 0: + if (!wantoutput) { + dup2(devnullfd, 1); + dup2(devnullfd, 2); + } + errno = 0; if (!(fp = popen(cmd, "we"))) { fputs("popen: ", stderr); @@ -450,9 +459,12 @@ pipeitem(const char *cmd, struct item *item) while ((wpid = wait(NULL)) >= 0 && wpid != pid) ; } - updatesidebar(onlynew); - updatetitle(); - init(); + + if (wantoutput) { + updatesidebar(onlynew); + updatetitle(); + init(); + } } void @@ -1220,7 +1232,7 @@ mousereport(int button, int release, int x, int y) p = &panes[PaneItems]; row = pane_row_get(p, p->pos); item = (struct item *)row->data; - pipeitem(piper, item); + pipeitem(piper, item, 1); } break; case 3: /* scroll up */ @@ -1589,9 +1601,9 @@ nextpage: row = pane_row_get(p, p->pos); item = (struct item *)row->data; switch (ch) { - case 'y': pipeitem("cut -f 3 | xclip -r", item); break; - case 'E': pipeitem("cut -f 8 | xclip -r", item); break; - default: pipeitem(piper, item); break; + case 'y': pipeitem("cut -f 3 | xclip -r", item, 0); break; + case 'E': pipeitem("cut -f 8 | xclip -r", item, 0); break; + default: pipeitem(piper, item, 1); break; } } break;