From fbc1f309d8b11f4fa06d8b2c5d71a1feb7a35248 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 7 Aug 2021 21:24:46 -0700 Subject: [PATCH] . --- browse_slack.mu | 10 ----- browse_slack/environment.mu | 26 ++++++++++++ browse_slack/main.mu | 83 +++++++++++++++++++++++++++++++++++++ browse_slack/vimrc.vim | 2 + 4 files changed, 111 insertions(+), 10 deletions(-) delete mode 100644 browse_slack.mu create mode 100644 browse_slack/environment.mu create mode 100644 browse_slack/main.mu create mode 100644 browse_slack/vimrc.vim diff --git a/browse_slack.mu b/browse_slack.mu deleted file mode 100644 index e0e2697e..00000000 --- a/browse_slack.mu +++ /dev/null @@ -1,10 +0,0 @@ -fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) { - draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "loading data disk..", 3/fg 0/bg - # too large for stack - var s-h: (handle stream byte) - var s-ah/ebx: (addr handle stream byte) <- address s-h - populate-stream s-ah, 0x4000000 - var s/eax: (addr stream byte) <- lookup *s-ah - 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 -} 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