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-07 21:24:46 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-07 22:57:15 -0700
commitfbc1f309d8b11f4fa06d8b2c5d71a1feb7a35248 (patch)
tree8ddcb72890ab8bbd160a87aa4bff041f35600028 /browse_slack
parent3e6da6e25c74f170dd896e5e0bc82b54f21b4d8e (diff)
downloadmu-fbc1f309d8b11f4fa06d8b2c5d71a1feb7a35248.tar.gz
.
Diffstat (limited to 'browse_slack')
-rw-r--r--browse_slack/environment.mu26
-rw-r--r--browse_slack/main.mu83
-rw-r--r--browse_slack/vimrc.vim2
3 files changed, 111 insertions, 0 deletions
diff --git a/browse_slack/environment.mu b/browse_slack/environment.mu
new file mode 100644
index 00000000..8f68a3fa
--- /dev/null
+++ b/browse_slack/environment.mu
@@ -0,0 +1,26 @@
+# The environment is a thin layer in this app, just a history of 'tabs' that
+# are fully specified by the operations used to generate them.
+
+type environment {
+  tabs: (handle array tab)
+  current: int  # index into tabs
+}
+
+type tab {
+  type: int
+  # type 0: items by a user
+  # type 1: items in a channel
+  # type 2: comments for a post
+  # type 3: items containing a search (TODO)
+  root-index: int  # into either users, items or comments
+  item-index: int  # what item in the corresponding list we start rendering
+                   # the current page at
+  grapheme-index: int  # what character in the item we start rendering
+                       # the current page at
+}
+
+fn render-environment env: (addr environment), users: (addr array user), channels: (addr array channel), items: (addr array item) {
+}
+
+fn update-environment env: (addr environment), key: byte {
+}
diff --git a/browse_slack/main.mu b/browse_slack/main.mu
new file mode 100644
index 00000000..e3c5affd
--- /dev/null
+++ b/browse_slack/main.mu
@@ -0,0 +1,83 @@
+type channel {
+  id: (handle array byte)
+  name: (handle array byte)
+  posts: (handle array int)  # item indices
+  newest-post-index: int
+}
+
+type user {
+  id: (handle array byte)
+  name: (handle array byte)
+  real-name: (handle array byte)
+  avatar: (handle image)
+}
+
+type item {
+  id: (handle array byte)
+  channel: (handle array byte)
+  by: int  # user index
+  text: (handle array byte)
+  parent: int  # item index
+}
+
+type post {
+  root: int  # item index
+  comments: (handle array int)  # item indices
+}
+
+# globals:
+#   users: (handle array user)
+#   channels: (handle array channel)
+#   items: (handle array item)
+#
+# flows:
+#   channel -> posts
+#   user -> posts
+#   post -> comments
+#   keywords -> posts|comments
+
+# I try to put all the static buffer sizes in this function.
+fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
+  # load entire disk contents to a single enormous stream
+  draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "loading data disk..", 3/fg 0/bg
+  var s-h: (handle stream byte)  # the stream is too large to put on the stack
+  var s-ah/eax: (addr handle stream byte) <- address s-h
+  populate-stream s-ah, 0x4000000
+  var _s/eax: (addr stream byte) <- lookup *s-ah
+  var s/ebx: (addr stream byte) <- copy _s
+  load-sectors data-disk, 0/lba, 0x20000/sectors, s
+  draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "done", 3/fg 0/bg
+  # parse global data structures out of the stream
+  var users-h: (handle array user)
+  var users-ah/eax: (addr handle array user) <- address users-h
+  populate users-ah, 0x800
+  var _users/eax: (addr array user) <- lookup *users-ah
+  var users/edi: (addr array user) <- copy _users
+  var channels-h: (handle array channel)
+  var channels-ah/eax: (addr handle array channel) <- address channels-h
+  populate channels-ah, 0x20
+  var _channels/eax: (addr array channel) <- lookup *channels-ah
+  var channels/esi: (addr array channel) <- copy _channels
+  var items-h: (handle array item)
+  var items-ah/eax: (addr handle array item) <- address items-h
+  populate items-ah, 0x10000
+  var _items/eax: (addr array item) <- lookup *items-ah
+  var items/edx: (addr array item) <- copy _items
+  parse s, users, channels, items
+  # render
+  var env-storage: environment
+  var env/ebx: (addr environment) <- address env-storage
+  {
+    render-environment env, users, channels, items
+    {
+      var key/eax: byte <- read-key keyboard
+      compare key, 0
+      loop-if-=
+      update-environment env, key
+    }
+    loop
+  }
+}
+
+fn parse s: (addr stream byte), users: (addr array user), channels: (addr array channel), items: (addr array item) {
+}
diff --git a/browse_slack/vimrc.vim b/browse_slack/vimrc.vim
new file mode 100644
index 00000000..348fe364
--- /dev/null
+++ b/browse_slack/vimrc.vim
@@ -0,0 +1,2 @@
+" when opening files in this directory, load vimrc from cwd (top-level)
+source vimrc.vim