slack: render items in reverse chronological order
This commit is contained in:
parent
ba438e3d83
commit
5c55de64e0
|
@ -17,7 +17,7 @@ type environment {
|
||||||
# channel-offset-x # in characters
|
# channel-offset-x # in characters
|
||||||
# menu-space-ver # in characters
|
# menu-space-ver # in characters
|
||||||
|
|
||||||
fn render-environment screen: (addr screen), env: (addr environment), users: (addr array user), channels: (addr array channel), items: (addr array item) {
|
fn render-environment screen: (addr screen), env: (addr environment), users: (addr array user), channels: (addr array channel), items: (addr item-list) {
|
||||||
clear-screen screen
|
clear-screen screen
|
||||||
render-search-input screen, env
|
render-search-input screen, env
|
||||||
render-channels screen, env, channels
|
render-channels screen, env, channels
|
||||||
|
@ -49,7 +49,7 @@ fn render-channels screen: (addr screen), env: (addr environment), _channels: (a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render-item-list screen: (addr screen), env: (addr environment), _items: (addr array item), users: (addr array user) {
|
fn render-item-list screen: (addr screen), env: (addr environment), _items: (addr item-list), users: (addr array user) {
|
||||||
var tmp-width/eax: int <- copy 0
|
var tmp-width/eax: int <- copy 0
|
||||||
var tmp-height/ecx: int <- copy 0
|
var tmp-height/ecx: int <- copy 0
|
||||||
tmp-width, tmp-height <- screen-size screen
|
tmp-width, tmp-height <- screen-size screen
|
||||||
|
@ -60,18 +60,21 @@ fn render-item-list screen: (addr screen), env: (addr environment), _items: (add
|
||||||
#
|
#
|
||||||
var y/ecx: int <- copy 2/search-space-ver
|
var y/ecx: int <- copy 2/search-space-ver
|
||||||
y <- add 1/item-padding-ver
|
y <- add 1/item-padding-ver
|
||||||
var items/esi: (addr array item) <- copy _items
|
var items/esi: (addr item-list) <- copy _items
|
||||||
var i/ebx: int <- copy 0
|
var items-data-ah/eax: (addr handle array item) <- get items, data
|
||||||
var max/edx: int <- length items
|
var _items-data/eax: (addr array item) <- lookup *items-data-ah
|
||||||
|
var items-data/edi: (addr array item) <- copy _items-data
|
||||||
|
var newest-item/eax: (addr int) <- get items, newest
|
||||||
|
var i/ebx: int <- copy *newest-item
|
||||||
{
|
{
|
||||||
compare i, max
|
compare i, 0
|
||||||
break-if->=
|
break-if-<
|
||||||
compare y, screen-height
|
compare y, screen-height
|
||||||
break-if->=
|
break-if->=
|
||||||
var offset/eax: (offset item) <- compute-offset items, i
|
var offset/eax: (offset item) <- compute-offset items-data, i
|
||||||
var curr-item/eax: (addr item) <- index items, offset
|
var curr-item/eax: (addr item) <- index items-data, offset
|
||||||
y <- render-item screen, curr-item, users, y, screen-height
|
y <- render-item screen, curr-item, users, y, screen-height
|
||||||
i <- increment
|
i <- decrement
|
||||||
loop
|
loop
|
||||||
}
|
}
|
||||||
var top/eax: int <- copy screen-height
|
var top/eax: int <- copy screen-height
|
||||||
|
|
|
@ -21,6 +21,11 @@ type item {
|
||||||
newest-comment-index: int
|
newest-comment-index: int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type item-list {
|
||||||
|
data: (handle array item)
|
||||||
|
newest: int
|
||||||
|
}
|
||||||
|
|
||||||
# globals:
|
# globals:
|
||||||
# users: (handle array user)
|
# users: (handle array user)
|
||||||
# channels: (handle array channel)
|
# channels: (handle array channel)
|
||||||
|
@ -68,11 +73,10 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)
|
||||||
populate channels-ah, 0x20/num-channels
|
populate channels-ah, 0x20/num-channels
|
||||||
var _channels/eax: (addr array channel) <- lookup *channels-ah
|
var _channels/eax: (addr array channel) <- lookup *channels-ah
|
||||||
var channels/esi: (addr array channel) <- copy _channels
|
var channels/esi: (addr array channel) <- copy _channels
|
||||||
var items-h: (handle array item)
|
var items-storage: item-list
|
||||||
var items-ah/eax: (addr handle array item) <- address items-h
|
var items/edx: (addr item-list) <- address items-storage
|
||||||
populate items-ah, 0x10000/num-items
|
var items-data-ah/eax: (addr handle array item) <- get items, data
|
||||||
var _items/eax: (addr array item) <- lookup *items-ah
|
populate items-data-ah, 0x10000/num-items
|
||||||
var items/edx: (addr array item) <- copy _items
|
|
||||||
parse s, users, channels, items
|
parse s, users, channels, items
|
||||||
# render
|
# render
|
||||||
var env-storage: environment
|
var env-storage: environment
|
||||||
|
@ -89,7 +93,11 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse in: (addr stream byte), users: (addr array user), channels: (addr array channel), items: (addr array item) {
|
fn parse in: (addr stream byte), users: (addr array user), channels: (addr array channel), _items: (addr item-list) {
|
||||||
|
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/edi: (addr array item) <- copy _items-data
|
||||||
# 'in' consists of a long, flat sequence of records surrounded by parens
|
# 'in' consists of a long, flat sequence of records surrounded by parens
|
||||||
var record-storage: (stream byte 0x18000)
|
var record-storage: (stream byte 0x18000)
|
||||||
var record/ecx: (addr stream byte) <- address record-storage
|
var record/ecx: (addr stream byte) <- address record-storage
|
||||||
|
@ -117,11 +125,14 @@ fn parse in: (addr stream byte), users: (addr array user), channels: (addr array
|
||||||
{
|
{
|
||||||
compare user?, 0/false
|
compare user?, 0/false
|
||||||
break-if-!=
|
break-if-!=
|
||||||
parse-item record, channels, items, item-idx
|
parse-item record, channels, items-data, item-idx
|
||||||
item-idx <- increment
|
item-idx <- increment
|
||||||
}
|
}
|
||||||
loop
|
loop
|
||||||
}
|
}
|
||||||
|
var dest/eax: (addr int) <- get items, newest
|
||||||
|
copy-to *dest, item-idx
|
||||||
|
decrement *dest
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse-record in: (addr stream byte), out: (addr stream byte) {
|
fn parse-record in: (addr stream byte), out: (addr stream byte) {
|
||||||
|
|
Loading…
Reference in New Issue