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-14 18:02:57 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-14 18:02:57 -0700
commitbfe3a175be9048a5dc7425569969a2edd66de3c3 (patch)
treeabbfac88bd8ccea2fa2f015beb73bdf26aaace83 /browse-slack/environment.mu
parenta3ffd93c57cc24666dc622fc2666b165e083502f (diff)
downloadmu-bfe3a175be9048a5dc7425569969a2edd66de3c3.tar.gz
slack: quick 'n' dirty thread screen
Diffstat (limited to 'browse-slack/environment.mu')
-rw-r--r--browse-slack/environment.mu45
1 files changed, 45 insertions, 0 deletions
diff --git a/browse-slack/environment.mu b/browse-slack/environment.mu
index d1b6a9db..d5e04175 100644
--- a/browse-slack/environment.mu
+++ b/browse-slack/environment.mu
@@ -190,6 +190,12 @@ fn render-tab screen: (addr screen), _current-tab: (addr tab), show-cursor?: boo
     render-search-tab screen, current-tab, show-cursor?, items, channels, users, screen-height
     return
   }
+  compare *current-tab-type, 3/thread
+  {
+    break-if-!=
+    render-thread-tab screen, current-tab, show-cursor?, items, channels, users, screen-height
+    return
+  }
 }
 
 fn render-all-items screen: (addr screen), _current-tab: (addr tab), show-cursor?: boolean, _items: (addr item-list), users: (addr array user), screen-height: int {
@@ -298,6 +304,45 @@ fn render-search-tab screen: (addr screen), _current-tab: (addr tab), show-curso
   }
 }
 
+fn render-thread-tab screen: (addr screen), _current-tab: (addr tab), show-cursor?: boolean, _items: (addr item-list), channels: (addr array channel), users: (addr array user), screen-height: int {
+  var current-tab/esi: (addr tab) <- copy _current-tab
+  var items/eax: (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/edi: (addr array item) <- copy _items-data
+  var post-index-addr/eax: (addr int) <- get current-tab, root-index
+  var post-index/eax: int <- copy *post-index-addr
+  var post-offset/eax: (offset item) <- compute-offset items-data, post-index
+  var post/ebx: (addr item) <- index items-data, post-offset
+  var current-tab-top-item-addr/eax: (addr int) <- get current-tab, item-index
+  var i/edx: int <- copy *current-tab-top-item-addr
+  var post-comments-first-free-addr/eax: (addr int) <- get post, comments-first-free
+  set-cursor-position 0/screen, 0x68/x 0/y
+  draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "thread", 7/fg 0/bg
+  render-progress screen, i, *post-comments-first-free-addr
+  var post-comments-ah/eax: (addr handle array int) <- get post, comments
+  var post-comments/eax: (addr array int) <- lookup *post-comments-ah
+  var y/ecx: int <- copy 2/search-space-ver
+  y <- add 1/item-padding-ver
+  {
+    compare i, 0
+    break-if-<
+    compare y, screen-height
+    break-if->=
+    var item-index-addr/eax: (addr int) <- index post-comments, i
+    var item-index/eax: int <- copy *item-index-addr
+    var item-offset/eax: (offset item) <- compute-offset items-data, item-index
+    var curr-item/eax: (addr item) <- index items-data, item-offset
+    y <- render-item screen, curr-item, users, show-cursor?, y, screen-height
+    # cursor always at top item
+    copy-to show-cursor?, 0/false
+    i <- decrement
+    loop
+  }
+  # finally render the parent -- though we'll never focus on it
+  y <- render-item screen, post, users, 0/no-cursor, y, screen-height
+}
+
 # side-effect: mutates cursor position
 fn render-progress screen: (addr screen), curr: int, max: int {
   set-cursor-position 0/screen, 0x70/x 0/y