about summary refs log tree commit diff stats
path: root/browse-slack/environment.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-08-13 09:45:34 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-13 09:45:34 -0700
commita9273e96b70c3e2627c636f466b41d35e2887cb5 (patch)
tree9dcb1fa76c2531c3400f2d1dd720d52be9160611 /browse-slack/environment.mu
parent47771b034812806c215e2c26bc0a6ff921b6c2d7 (diff)
downloadmu-a9273e96b70c3e2627c636f466b41d35e2887cb5.tar.gz
slack: progress indicator
Diffstat (limited to 'browse-slack/environment.mu')
-rw-r--r--browse-slack/environment.mu12
1 files changed, 12 insertions, 0 deletions
diff --git a/browse-slack/environment.mu b/browse-slack/environment.mu
index 60bc00f6..9b1c3299 100644
--- a/browse-slack/environment.mu
+++ b/browse-slack/environment.mu
@@ -93,6 +93,8 @@ fn render-item-list screen: (addr screen), _env: (addr environment), _items: (ad
   var newest-item/eax: (addr int) <- get current-tab, item-index
   var i/ebx: int <- copy *newest-item
   var items/esi: (addr item-list) <- copy _items
+  var items-data-first-free-addr/eax: (addr int) <- get items, data-first-free
+  render-progress screen, i, *items-data-first-free-addr
   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/edi: (addr array item) <- copy _items-data
@@ -112,6 +114,16 @@ fn render-item-list screen: (addr screen), _env: (addr environment), _items: (ad
   clear-rect screen, 0 top, screen-width screen-height, 0/bg
 }
 
+# side-effect: mutates cursor position
+fn render-progress screen: (addr screen), curr: int, max: int {
+  set-cursor-position 0/screen, 0x70/x 0/y
+  var top-index/eax: int <- copy max
+  top-index <- subtract curr  # happy accident: 1-based
+  draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen screen, top-index, 7/fg 0/bg
+  draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "/", 7/fg 0/bg
+  draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen screen, max, 7/fg 0/bg
+}
+
 fn render-search-input screen: (addr screen), env: (addr environment) {
   set-cursor-position 0/screen, 0x22/x=search-position-x 1/y
   draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "search ", 7/fg 0/bg