Krolyxon
Commit 5b64679

Branches

Refs →

nsxiv5b64679

Made remote changes adhere to code style

Author
Bert Münnich
Date
2012-07-15 18:52 +0200
Parent
c330b55
Commit
5b6467913cca4086ebb6056e7235a3c78570ce6f

+9 −7

1 file changed

  1. M thumbs.c +9 −7
M thumbs.c View
@@ -390,27 +390,29 @@ void tns_highlight(tns_t *tns, int n, bool hl) {
390390 }
391391 }
392392
393−bool tns_move_selection(tns_t *tns, direction_t dir, int count) {
394− int old;
395− int c = (count > 0 ? count : 1);
393+bool tns_move_selection(tns_t *tns, direction_t dir, int cnt) {
394+ int old, max;
396395
397396 if (tns == NULL || tns->thumbs == NULL)
398397 return false;
399398
400399 old = tns->sel;
400+ cnt = cnt > 1 ? cnt : 1;
401401
402402 switch (dir) {
403403 case DIR_UP:
404− tns->sel = MAX(tns->sel - c * tns->cols, tns->sel % tns->cols);
404+ tns->sel = MAX(tns->sel - cnt * tns->cols, tns->sel % tns->cols);
405405 break;
406406 case DIR_DOWN:
407− 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));
407+ max = tns->cols * ((tns->cnt - 1) / tns->cols) +
408+ MIN((tns->cnt - 1) % tns->cols, tns->sel % tns->cols);
409+ tns->sel = MIN(tns->sel + cnt * tns->cols, max);
408410 break;
409411 case DIR_LEFT:
410− tns->sel = MAX(tns->sel - c, 0);
412+ tns->sel = MAX(tns->sel - cnt, 0);
411413 break;
412414 case DIR_RIGHT:
413− tns->sel = MIN(tns->sel + c, tns->cnt - 1);
415+ tns->sel = MIN(tns->sel + cnt, tns->cnt - 1);
414416 break;
415417 }
416418