sfeed_curses

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

commit bca98c4bb714e70816d1fcda2c9fa0e3f70df003
parent 064cc8ee83271127d8b9e10084708591bf830983
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Mon,  6 Jul 2020 01:37:46 +0200

mousereport: simplify some code

- Set a variable for a "double-click" action: clicking the same row (no
  time-out interval is accounted for though).
- Set position of row (except for scrolling).
- An added intentional change: right-clicking on the feed item in the sidebar
  will now highlight it, but not load it.

Diffstat:
Msfeed_curses.1 | 7++++---
Msfeed_curses.c | 13+++++--------
2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/sfeed_curses.1 b/sfeed_curses.1 @@ -1,4 +1,4 @@ -.Dd June 29, 2020 +.Dd July 6, 2020 .Dt SFEED_CURSES 1 .Os .Sh NAME @@ -105,6 +105,7 @@ When mouse-mode is enabled the below actions are available. Feeds pane: load feed and it's items. Items pane: select item, when already selected plumb it. .It right-click +Feeds pane: select item, but do not load feed. Items pane: plumb clicked item. .It scroll up Scroll 1 page up. @@ -130,7 +131,7 @@ It can be used by the plumb or pipe program for scripting purposes. .Sh SEE ALSO .Xr sfeed 1 , .Xr sfeed_plain 1 , -.Xr sfeed 5 , -.Xr xclip 1 +.Xr xclip 1 , +.Xr sfeed 5 .Sh AUTHORS .An Hiltjo Posthuma Aq Mt hiltjo@codemadness.org diff --git a/sfeed_curses.c b/sfeed_curses.c @@ -1288,7 +1288,7 @@ mousereport(int button, int release, int x, int y) struct row *row; struct item *item; size_t i; - int changedpane, pos; + int changedpane, dblclick, pos; if (!usemouse || release || button == -1) return; @@ -1306,13 +1306,14 @@ mousereport(int button, int release, int x, int y) selpane = i; /* relative position on screen */ pos = y - p->y + p->pos - (p->pos % p->height); + dblclick = (pos == p->pos); /* clicking the same row */ switch (button) { case 0: /* left-click */ if (!p->nrows || pos >= p->nrows) break; + pane_setpos(p, pos); if (i == PaneFeeds) { - pane_setpos(p, pos); row = pane_row_get(p, pos); f = (struct feed *)row->data; feeds_set(f); @@ -1321,21 +1322,18 @@ mousereport(int button, int release, int x, int y) pane_row_draw(p, pos); updatetitle(); } else if (i == PaneItems) { - /* clicking the same highlighted row */ - if (p->pos == pos && !changedpane) { + if (dblclick && !changedpane) { row = pane_row_get(&panes[PaneItems], pos); item = (struct item *)row->data; plumb(plumber, item->fields[FieldLink]); - } else { - pane_setpos(p, pos); } } break; case 2: /* right-click */ if (!p->nrows || pos >= p->nrows) break; + pane_setpos(p, pos); if (i == PaneItems) { - pane_setpos(p, pos); p = &panes[PaneItems]; row = pane_row_get(p, p->pos); item = (struct item *)row->data; @@ -1510,7 +1508,6 @@ main(int argc, char *argv[]) updatetitle(); updatesidebar(onlynew); init(); - draw(); while ((ch = readch()) != EOF) {