diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-08-11 21:58:47 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-08-11 21:58:47 -0700 |
commit | faf242c49860ba627d0ea4b6af9d4ae0b76e03ba (patch) | |
tree | 891e3c5b3e77e260469ceab687e926db5ba3571e /browse-slack | |
parent | 9c25023a20c5b4c26030d0b759b0c96999343a46 (diff) | |
download | mu-faf242c49860ba627d0ea4b6af9d4ae0b76e03ba.tar.gz |
experiment: more granular scrolling
Diffstat (limited to 'browse-slack')
-rw-r--r-- | browse-slack/environment.mu | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/browse-slack/environment.mu b/browse-slack/environment.mu index 13ef1c36..c7333adf 100644 --- a/browse-slack/environment.mu +++ b/browse-slack/environment.mu @@ -109,6 +109,10 @@ fn render-menu screen: (addr screen) { draw-text-rightward-from-cursor screen, " next page ", width, 0xf/fg, 0/bg draw-text-rightward-from-cursor screen, " ^b ", width, 0/fg 0xf/bg draw-text-rightward-from-cursor screen, " previous page ", width, 0xf/fg, 0/bg + draw-text-rightward-from-cursor screen, " ^n ", width, 0/fg 0xf/bg + draw-text-rightward-from-cursor screen, " next (older) item ", width, 0xf/fg, 0/bg + draw-text-rightward-from-cursor screen, " ^p ", width, 0/fg 0xf/bg + draw-text-rightward-from-cursor screen, " previous (more recent) item ", width, 0xf/fg, 0/bg } fn render-item screen: (addr screen), _item: (addr item), _users: (addr array user), y: int, screen-height: int -> _/ecx: int { @@ -174,6 +178,18 @@ fn render-item screen: (addr screen), _item: (addr item), _users: (addr array us fn update-environment env: (addr environment), key: byte, items: (addr item-list) { { + compare key, 0xe/ctrl-n + break-if-!= + next-item env, items + return + } + { + compare key, 0x10/ctrl-p + break-if-!= + previous-item env, items + return + } + { compare key, 6/ctrl-f break-if-!= page-down env, items @@ -187,6 +203,25 @@ fn update-environment env: (addr environment), key: byte, items: (addr item-list } } +fn next-item _env: (addr environment), _items: (addr item-list) { + var env/edi: (addr environment) <- copy _env + var dest/eax: (addr int) <- get env, item-index + compare *dest, 0 + break-if-<= + decrement *dest +} + +fn previous-item _env: (addr environment), _items: (addr item-list) { + var env/edi: (addr environment) <- copy _env + var items/esi: (addr item-list) <- copy _items + var newest-item-index-a/ecx: (addr int) <- get items, newest + var newest-item-index/ecx: int <- copy *newest-item-index-a + var dest/eax: (addr int) <- get env, item-index + compare *dest, newest-item-index + break-if->= + increment *dest +} + fn page-down _env: (addr environment), _items: (addr item-list) { var env/edi: (addr environment) <- copy _env var items/esi: (addr item-list) <- copy _items |