about summary refs log tree commit diff stats
path: root/browse-slack
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-08-11 18:16:12 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-11 18:16:12 -0700
commit6aa3d287b1aee3fc1943ef854989c31e6f0b48af (patch)
treeba3ce80a7344d37cd98c05805af4a5a46f596234 /browse-slack
parenta0550a55fdac81bc36f68b2f3386e3f35ba4cbc1 (diff)
downloadmu-6aa3d287b1aee3fc1943ef854989c31e6f0b48af.tar.gz
slack: ctrl-b for page-up
Diffstat (limited to 'browse-slack')
-rw-r--r--browse-slack/environment.mu28
1 files changed, 28 insertions, 0 deletions
diff --git a/browse-slack/environment.mu b/browse-slack/environment.mu
index 24ef1c38..5e48c7e7 100644
--- a/browse-slack/environment.mu
+++ b/browse-slack/environment.mu
@@ -221,6 +221,34 @@ fn page-down _env: (addr environment), _items: (addr item-list) {
 }
 
 fn page-up _env: (addr environment), _items: (addr item-list) {
+  var env/edi: (addr environment) <- copy _env
+  var items/esi: (addr item-list) <- copy _items
+  var items-data-ah/eax: (addr handle array item) <- get items, data
+  var _items-data/eax: (addr array item) <- lookup *items-data-ah
+  var items-data/ebx: (addr array item) <- copy _items-data
+  var newest-item-index-a/esi: (addr int) <- get items, newest
+  var src/eax: (addr int) <- get env, item-index
+  var new-item-index/ecx: int <- copy *src
+  var y/edx: int <- copy 2
+  {
+    compare new-item-index, *newest-item-index-a
+    break-if->
+    compare y, 0x28/screen-height-minus-menu
+    break-if->=
+    var offset/eax: (offset item) <- compute-offset items-data, new-item-index
+    var item/eax: (addr item) <- index items-data, offset
+    var item-text-ah/eax: (addr handle array byte) <- get item, text
+    var item-text/eax: (addr array byte) <- lookup *item-text-ah
+    var h/eax: int <- estimate-height item-text
+    set-cursor-position 0/screen, 0 0
+    draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, h, 4/fg 0/bg
+    y <- add h
+    new-item-index <- increment
+    loop
+  }
+  new-item-index <- decrement
+  var dest/eax: (addr int) <- get env, item-index
+  copy-to *dest, new-item-index
 }
 
 # keep sync'd with render-item