diff options
| author | Louis Burda <quent.burda@gmail.com> | 2021-12-20 16:25:43 +0100 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2021-12-20 16:25:43 +0100 |
| commit | f07580d31d1148c4a1811c36b09ca0ad50d9576b (patch) | |
| tree | 05a8fbb44af81f3b5937df80c5af3305ec3ed3c9 /listnav.c | |
| parent | faee8e9c6db45c6adacfc5113d55927f92e8bf29 (diff) | |
| download | tmus-f07580d31d1148c4a1811c36b09ca0ad50d9576b.tar.gz tmus-f07580d31d1148c4a1811c36b09ca0ad50d9576b.zip | |
Restructured repository and added automatic make dependency generation
Diffstat (limited to 'listnav.c')
| -rw-r--r-- | listnav.c | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/listnav.c b/listnav.c deleted file mode 100644 index 707a973..0000000 --- a/listnav.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "listnav.h" -#include "util.h" - -#include <string.h> - -void -listnav_init(struct listnav *nav) -{ - memset(nav, 0, sizeof(struct listnav)); -} - -void -listnav_update_bounds(struct listnav *nav, int min, int max) -{ - nav->min = min; - nav->max = max; - nav->wmin = MAX(nav->wmin, nav->min); - nav->wmax = MIN(nav->wmin + nav->wlen, nav->max); - nav->sel = MIN(MAX(nav->sel, nav->wmin), nav->wmax - 1); -} - -void -listnav_update_wlen(struct listnav *nav, int wlen) -{ - nav->wlen = wlen; - nav->wmax = MIN(nav->wmin + nav->wlen, nav->max); - nav->sel = MIN(MAX(nav->sel, nav->wmin), nav->wmax - 1); -} - -void -listnav_update_sel(struct listnav *nav, int sel) -{ - nav->sel = MAX(MIN(sel, nav->max - 1), nav->min); - - if (nav->sel >= nav->wmax) { - nav->wmax = nav->sel + 1; - nav->wmin = MAX(nav->min, nav->wmax - nav->wlen); - } else if (nav->sel < nav->wmin) { - nav->wmin = nav->sel; - nav->wmax = MIN(nav->wmin + nav->wlen, nav->max); - } -} - |
