nsxiv62f4ab0
Fixed moving of selection while loading thumbnails
+4 −5
2 files changed
| @@ -32,7 +32,7 @@ void tns_init(tns_t *tns, int cnt) { | |||
| 32 | 32 | if (!tns) | |
| 33 | 33 | return; | |
| 34 | 34 | ||
| 35 | − | tns->cnt = tns->first = tns->sel = 0; | |
| 35 | + | tns->cnt = tns->first = tns->sel = tns->vis = 0; | |
| 36 | 36 | tns->thumbs = (thumb_t*) s_malloc(cnt * sizeof(thumb_t)); | |
| 37 | 37 | } | |
| 38 | 38 | ||
| @@ -115,8 +115,8 @@ void tns_render(tns_t *tns, win_t *win) { | |||
| 115 | 115 | x += thumb_dim; | |
| 116 | 116 | } | |
| 117 | 117 | } | |
| 118 | + | tns->vis = i - tns->first; | |
| 118 | 119 | ||
| 119 | − | printf("%d, %d\n", tns->sel, tns->cnt); | |
| 120 | 120 | tns_highlight(tns, win, -1); | |
| 121 | 121 | } | |
| 122 | 122 | ||
| @@ -166,7 +166,7 @@ void tns_move_selection(tns_t *tns, win_t *win, movedir_t dir) { | |||
| 166 | 166 | } | |
| 167 | 167 | break; | |
| 168 | 168 | case MOVE_DOWN: | |
| 169 | − | if (sel / tns->cols < tns->rows - 1 && sel + tns->cols < tns->cnt) { | |
| 169 | + | if (sel / tns->cols < tns->rows - 1 && sel + tns->cols < tns->vis) { | |
| 170 | 170 | tns->sel += tns->cols; | |
| 171 | 171 | tns_highlight(tns, win, sel); | |
| 172 | 172 | } | |
| @@ -45,10 +45,9 @@ typedef struct tns_s { | |||
| 45 | 45 | int rows; | |
| 46 | 46 | int first; | |
| 47 | 47 | int sel; | |
| 48 | + | int vis; | |
| 48 | 49 | } tns_t; | |
| 49 | 50 | ||
| 50 | − | extern const int thumb_dim; | |
| 51 | − | ||
| 52 | 51 | void tns_init(tns_t*, int); | |
| 53 | 52 | void tns_free(tns_t*, win_t*); | |
| 54 | 53 | ||