|
|
@ -390,27 +390,29 @@ void tns_highlight(tns_t *tns, int n, bool hl) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool tns_move_selection(tns_t *tns, direction_t dir, int count) {
|
|
|
|
bool tns_move_selection(tns_t *tns, direction_t dir, int cnt) {
|
|
|
|
int old;
|
|
|
|
int old, max;
|
|
|
|
int c = (count > 0 ? count : 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (tns == NULL || tns->thumbs == NULL)
|
|
|
|
if (tns == NULL || tns->thumbs == NULL)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
old = tns->sel;
|
|
|
|
old = tns->sel;
|
|
|
|
|
|
|
|
cnt = cnt > 1 ? cnt : 1;
|
|
|
|
|
|
|
|
|
|
|
|
switch (dir) {
|
|
|
|
switch (dir) {
|
|
|
|
case DIR_UP:
|
|
|
|
case DIR_UP:
|
|
|
|
tns->sel = MAX(tns->sel - c * tns->cols, tns->sel % tns->cols);
|
|
|
|
tns->sel = MAX(tns->sel - cnt * tns->cols, tns->sel % tns->cols);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DIR_DOWN:
|
|
|
|
case DIR_DOWN:
|
|
|
|
tns->sel = MIN(tns->sel + c * tns->cols, tns->cols * ((tns->cnt - 1) / tns->cols) + MIN((tns->cnt - 1) % tns->cols, tns->sel % tns->cols));
|
|
|
|
max = tns->cols * ((tns->cnt - 1) / tns->cols) +
|
|
|
|
|
|
|
|
MIN((tns->cnt - 1) % tns->cols, tns->sel % tns->cols);
|
|
|
|
|
|
|
|
tns->sel = MIN(tns->sel + cnt * tns->cols, max);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DIR_LEFT:
|
|
|
|
case DIR_LEFT:
|
|
|
|
tns->sel = MAX(tns->sel - c, 0);
|
|
|
|
tns->sel = MAX(tns->sel - cnt, 0);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DIR_RIGHT:
|
|
|
|
case DIR_RIGHT:
|
|
|
|
tns->sel = MIN(tns->sel + c, tns->cnt - 1);
|
|
|
|
tns->sel = MIN(tns->sel + cnt, tns->cnt - 1);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|