diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-01-21 20:20:01 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-01-22 12:15:57 +0100 |
commit | f726178a4c61037da62f7dfd0c20b23a3675d6ac (patch) | |
tree | 2353116f3bd6c15b2f2fb88ea3f3926e4534d03c | |
parent | 1d6b7c5d3f09ec2118400207b81b1332f1ee319a (diff) |
add feature to go to the next bold row and previous bold row with J and K
This replaces the current J and K keybind, which was rarely useful.
Thanks to IanJ for the suggestion and feedback!
-rw-r--r-- | sfeed_curses.1 | 6 | ||||
-rw-r--r-- | sfeed_curses.c | 29 |
2 files changed, 25 insertions, 10 deletions
diff --git a/sfeed_curses.1 b/sfeed_curses.1 index 3d7fcab..9ce0bab 100644 --- a/sfeed_curses.1 +++ b/sfeed_curses.1 @@ -1,4 +1,4 @@ -.Dd January 19, 2022 +.Dd January 22, 2022 .Dt SFEED_CURSES 1 .Os .Sh NAME @@ -49,9 +49,9 @@ Go one row up. .It j, ARROW DOWN Go one row down. .It K -Go one row up and open the item. +Go to the previous bold row. .It J -Go one row down and open the item. +Go to the next bold row. .It h, ARROW LEFT Focus feeds pane. .It l, ARROW RIGHT diff --git a/sfeed_curses.c b/sfeed_curses.c index d6eb4f7..0cd7ebd 100644 --- a/sfeed_curses.c +++ b/sfeed_curses.c @@ -2125,17 +2125,11 @@ main(int argc, char *argv[]) break; keyup: case 'k': - case 'K': pane_scrolln(&panes[selpane], -1); - if (ch == 'K') - goto openitem; break; keydown: case 'j': - case 'J': pane_scrolln(&panes[selpane], +1); - if (ch == 'J') - goto openitem; break; keyleft: case 'h': @@ -2153,6 +2147,28 @@ keyright: if (layout == LayoutMonocle) updategeom(); break; + case 'K': + p = &panes[selpane]; + if (!p->nrows) + break; + for (pos = p->pos - 1; pos >= 0; pos--) { + if ((row = pane_row_get(p, pos)) && row->bold) { + pane_setpos(p, pos); + break; + } + } + break; + case 'J': + p = &panes[selpane]; + if (!p->nrows) + break; + for (pos = p->pos + 1; pos < p->nrows; pos++) { + if ((row = pane_row_get(p, pos)) && row->bold) { + pane_setpos(p, pos); + break; + } + } + break; case '\t': selpane = selpane == PaneFeeds ? PaneItems : PaneFeeds; if (layout == LayoutMonocle) @@ -2260,7 +2276,6 @@ nextpage: break; case 'o': /* feeds: load, items: plumb URL */ case '\n': -openitem: if (selpane == PaneFeeds && panes[selpane].nrows) feed_open_selected(&panes[selpane]); else if (selpane == PaneItems && panes[selpane].nrows) |