ref: 4d649c3f4a466315c341169fbe7182c43dd69b3c
parent: 16cfcf740580aa7bf875b1628a9ac92ca19e56cb
author: Sigrid Haflínudóttir <[email protected]>
date: Mon Aug 31 08:27:41 EDT 2020
make currently playing/found item appear on the window on "o", search, and shuffle
--- a/zuke.c
+++ b/zuke.c
@@ -164,6 +164,12 @@
}
static void
+updatescrollsz(void)
+{
+ scrollsz = (Dy(screen->r) - f->height - 4) / f->height - 1;
+}
+
+static void
redraw(int full)
{
Image *col;
@@ -173,7 +179,7 @@
char tmp[32];
lockdisplay(display);
- scrollsz = (Dy(screen->r) - f->height - 4) / f->height - 1;
+ updatescrollsz();
left = screen->r.min.x;
if(scrollsz < plnum) /* adjust for scrollbar */
left += Scrollwidth + 1;
@@ -721,6 +727,15 @@
}
static void
+recenter(void)
+{
+ updatescrollsz();
+ scroll = pcur - scrollsz/2;
+ if(scroll < 0)
+ scroll = 0;
+}
+
+static void
search(char d)
{
Meta *m;
@@ -749,6 +764,7 @@
}
if(i >= 0 && i < plnum){
pcur = i;
+ recenter();
redraw(1);
}
}
@@ -927,6 +943,7 @@
if(shuffled){
pcur = nrand(plnum);
toggleshuffle();
+ recenter();
}
themeinit();
@@ -1067,6 +1084,7 @@
if(pcur == pcurplaying)
oldpcur = -1;
pcur = pcurplaying;
+ recenter();
break;
case 'b':
case '>':
@@ -1111,6 +1129,7 @@
break;
case 's':
toggleshuffle();
+ recenter();
redraw(1);
break;
case 'c':