From 132d72d28a63e58ec7f5e6fc955be140ee5844b0 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 11 Oct 2021 21:35:16 -0700 Subject: . --- html/browse-slack/environment.mu.html | 282 +++++++++++++++++----------------- 1 file changed, 141 insertions(+), 141 deletions(-) (limited to 'html/browse-slack/environment.mu.html') diff --git a/html/browse-slack/environment.mu.html b/html/browse-slack/environment.mu.html index 131badd0..7aa80b46 100644 --- a/html/browse-slack/environment.mu.html +++ b/html/browse-slack/environment.mu.html @@ -130,7 +130,7 @@ if ('onhashchange' in window) { 66 67 ### Render 68 - 69 fn render-environment screen: (addr screen), _env: (addr environment), users: (addr array user), channels: (addr array channel), items: (addr item-list) { + 69 fn render-environment screen: (addr screen), _env: (addr environment), users: (addr array user), channels: (addr array channel), items: (addr item-list) { 70 var env/esi: (addr environment) <- copy _env 71 { 72 var dirty?/eax: (addr boolean) <- get env, dirty? @@ -141,9 +141,9 @@ if ('onhashchange' in window) { 77 var cursor-in-search?/eax: (addr boolean) <- get env, cursor-in-search? 78 compare *cursor-in-search?, 0/false 79 break-if-= - 80 render-search-input screen, env - 81 clear-rect screen, 0/x 0x2f/y, 0x80/x 0x30/y, 0/bg - 82 render-search-menu screen, env + 80 render-search-input screen, env + 81 clear-rect screen, 0/x 0x2f/y, 0x80/x 0x30/y, 0/bg + 82 render-search-menu screen, env 83 return 84 } 85 # minimize repaints when focus in channel nav @@ -151,23 +151,23 @@ if ('onhashchange' in window) { 87 var cursor-in-channels?/eax: (addr boolean) <- get env, cursor-in-channels? 88 compare *cursor-in-channels?, 0/false 89 break-if-= - 90 render-channels screen, env, channels - 91 clear-rect screen, 0/x 0x2f/y, 0x80/x 0x30/y, 0/bg - 92 render-channels-menu screen, env + 90 render-channels screen, env, channels + 91 clear-rect screen, 0/x 0x2f/y, 0x80/x 0x30/y, 0/bg + 92 render-channels-menu screen, env 93 return 94 } 95 } 96 # full repaint - 97 clear-screen screen - 98 render-search-input screen, env - 99 render-channels screen, env, channels - 100 render-item-list screen, env, users, channels, items - 101 render-menu screen, env + 97 clear-screen screen + 98 render-search-input screen, env + 99 render-channels screen, env, channels + 100 render-item-list screen, env, users, channels, items + 101 render-menu screen, env 102 var dirty?/eax: (addr boolean) <- get env, dirty? 103 copy-to *dirty?, 0/false 104 } 105 - 106 fn render-channels screen: (addr screen), _env: (addr environment), _channels: (addr array channel) { + 106 fn render-channels screen: (addr screen), _env: (addr environment), _channels: (addr array channel) { 107 var env/esi: (addr environment) <- copy _env 108 var cursor-index/edi: int <- copy -1 109 { @@ -194,19 +194,19 @@ if ('onhashchange' in window) { 130 var name/eax: (addr array byte) <- lookup *name-ah 131 compare name, 0 132 break-if-= - 133 set-cursor-position screen, 2/x y + 133 set-cursor-position screen, 2/x y 134 { 135 compare cursor-index, i 136 break-if-= - 137 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "#", 7/grey 0/black - 138 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, name, 7/grey 0/black + 137 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "#", 7/grey 0/black + 138 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, name, 7/grey 0/black 139 } 140 { 141 compare cursor-index, i 142 break-if-!= 143 # cursor; reverse video - 144 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "#", 0/black 0xf/white - 145 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, name, 0/black 0xf/white + 144 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "#", 0/black 0xf/white + 145 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, name, 0/black 0xf/white 146 } 147 y <- add 2/channel-padding 148 i <- increment @@ -214,11 +214,11 @@ if ('onhashchange' in window) { 150 } 151 } 152 - 153 fn render-item-list screen: (addr screen), _env: (addr environment), users: (addr array user), channels: (addr array channel), items: (addr item-list) { + 153 fn render-item-list screen: (addr screen), _env: (addr environment), users: (addr array user), channels: (addr array channel), items: (addr item-list) { 154 var env/esi: (addr environment) <- copy _env 155 var tmp-width/eax: int <- copy 0 156 var tmp-height/ecx: int <- copy 0 - 157 tmp-width, tmp-height <- screen-size screen + 157 tmp-width, tmp-height <- screen-size screen 158 var screen-width: int 159 copy-to screen-width, tmp-width 160 var screen-height: int @@ -241,48 +241,48 @@ if ('onhashchange' in window) { 177 break-if-!= 178 copy-to show-cursor?, 1/true 179 } - 180 render-tab screen, current-tab, show-cursor?, users, channels, items, screen-height + 180 render-tab screen, current-tab, show-cursor?, users, channels, items, screen-height 181 var top/eax: int <- copy screen-height 182 top <- subtract 2/menu-space-ver - 183 clear-rect screen, 0 top, screen-width screen-height, 0/bg + 183 clear-rect screen, 0 top, screen-width screen-height, 0/bg 184 } 185 - 186 fn render-tab screen: (addr screen), _current-tab: (addr tab), show-cursor?: boolean, users: (addr array user), channels: (addr array channel), items: (addr item-list), screen-height: int { + 186 fn render-tab screen: (addr screen), _current-tab: (addr tab), show-cursor?: boolean, users: (addr array user), channels: (addr array channel), items: (addr item-list), screen-height: int { 187 var current-tab/esi: (addr tab) <- copy _current-tab 188 var current-tab-type/eax: (addr int) <- get current-tab, type 189 compare *current-tab-type, 0/all-items 190 { 191 break-if-!= - 192 render-all-items screen, current-tab, show-cursor?, items, users, screen-height + 192 render-all-items screen, current-tab, show-cursor?, items, users, screen-height 193 return 194 } 195 compare *current-tab-type, 1/channel 196 { 197 break-if-!= - 198 render-channel-tab screen, current-tab, show-cursor?, users, channels, items, screen-height + 198 render-channel-tab screen, current-tab, show-cursor?, users, channels, items, screen-height 199 return 200 } 201 compare *current-tab-type, 2/search 202 { 203 break-if-!= - 204 render-search-tab screen, current-tab, show-cursor?, users, channels, items, screen-height + 204 render-search-tab screen, current-tab, show-cursor?, users, channels, items, screen-height 205 return 206 } 207 compare *current-tab-type, 3/thread 208 { 209 break-if-!= - 210 render-thread-tab screen, current-tab, show-cursor?, users, channels, items, screen-height + 210 render-thread-tab screen, current-tab, show-cursor?, users, channels, items, screen-height 211 return 212 } 213 } 214 - 215 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 { + 215 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 { 216 var current-tab/esi: (addr tab) <- copy _current-tab 217 var items/edi: (addr item-list) <- copy _items 218 var newest-item/eax: (addr int) <- get current-tab, item-index 219 var i/ebx: int <- copy *newest-item 220 var items-data-first-free-addr/eax: (addr int) <- get items, data-first-free - 221 render-progress screen, i, *items-data-first-free-addr + 221 render-progress screen, i, *items-data-first-free-addr 222 var items-data-ah/eax: (addr handle array item) <- get items, data 223 var _items-data/eax: (addr array item) <- lookup *items-data-ah 224 var items-data/edi: (addr array item) <- copy _items-data @@ -302,7 +302,7 @@ if ('onhashchange' in window) { 238 break-if->= 239 var offset/eax: (offset item) <- compute-offset items-data, i 240 var curr-item/eax: (addr item) <- index items-data, offset - 241 y <- render-item screen, curr-item, users, show-cursor?, y, screen-height + 241 y <- render-item screen, curr-item, users, show-cursor?, y, screen-height 242 # cursor always at top item 243 copy-to show-cursor?, 0/false 244 i <- decrement @@ -310,7 +310,7 @@ if ('onhashchange' in window) { 246 } 247 } 248 - 249 fn render-channel-tab screen: (addr screen), _current-tab: (addr tab), show-cursor?: boolean, users: (addr array user), _channels: (addr array channel), _items: (addr item-list), screen-height: int { + 249 fn render-channel-tab screen: (addr screen), _current-tab: (addr tab), show-cursor?: boolean, users: (addr array user), _channels: (addr array channel), _items: (addr item-list), screen-height: int { 250 var current-tab/esi: (addr tab) <- copy _current-tab 251 var items/edi: (addr item-list) <- copy _items 252 var channels/ebx: (addr array channel) <- copy _channels @@ -324,9 +324,9 @@ if ('onhashchange' in window) { 260 var current-channel-first-channel-item-addr/eax: (addr int) <- get current-tab, item-index 261 var i/ebx: int <- copy *current-channel-first-channel-item-addr 262 var current-channel-posts-first-free-addr/eax: (addr int) <- get current-channel, posts-first-free - 263 set-cursor-position 0/screen, 0x68/x 0/y - 264 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "channel", 7/fg 0/bg - 265 render-progress screen, i, *current-channel-posts-first-free-addr + 263 set-cursor-position 0/screen, 0x68/x 0/y + 264 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "channel", 7/fg 0/bg + 265 render-progress screen, i, *current-channel-posts-first-free-addr 266 var items-data-ah/eax: (addr handle array item) <- get items, data 267 var _items-data/eax: (addr array item) <- lookup *items-data-ah 268 var items-data/edi: (addr array item) <- copy _items-data @@ -341,7 +341,7 @@ if ('onhashchange' in window) { 277 var item-index/eax: int <- copy *item-index-addr 278 var item-offset/eax: (offset item) <- compute-offset items-data, item-index 279 var curr-item/eax: (addr item) <- index items-data, item-offset - 280 y <- render-item screen, curr-item, users, show-cursor?, y, screen-height + 280 y <- render-item screen, curr-item, users, show-cursor?, y, screen-height 281 # cursor always at top item 282 copy-to show-cursor?, 0/false 283 i <- decrement @@ -349,7 +349,7 @@ if ('onhashchange' in window) { 285 } 286 } 287 - 288 fn render-search-tab screen: (addr screen), _current-tab: (addr tab), show-cursor?: boolean, users: (addr array user), channels: (addr array channel), _items: (addr item-list), screen-height: int { + 288 fn render-search-tab screen: (addr screen), _current-tab: (addr tab), show-cursor?: boolean, users: (addr array user), channels: (addr array channel), _items: (addr item-list), screen-height: int { 289 var current-tab/esi: (addr tab) <- copy _current-tab 290 var items/edi: (addr item-list) <- copy _items 291 var current-tab-search-items-ah/eax: (addr handle array int) <- get current-tab, search-items @@ -358,14 +358,14 @@ if ('onhashchange' in window) { 294 var current-tab-top-item-addr/eax: (addr int) <- get current-tab, item-index 295 var i/edx: int <- copy *current-tab-top-item-addr 296 var current-tab-search-items-first-free-addr/eax: (addr int) <- get current-tab, search-items-first-free - 297 set-cursor-position 0/screen, 0x68/x 0/y - 298 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "search", 7/fg 0/bg - 299 render-progress screen, i, *current-tab-search-items-first-free-addr + 297 set-cursor-position 0/screen, 0x68/x 0/y + 298 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "search", 7/fg 0/bg + 299 render-progress screen, i, *current-tab-search-items-first-free-addr 300 { 301 compare *current-tab-search-items-first-free-addr, 0x100/max-search-results 302 break-if-< - 303 set-cursor-position 0/screen, 0x68/x 1/y - 304 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "too many results", 4/fg 0/bg + 303 set-cursor-position 0/screen, 0x68/x 1/y + 304 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "too many results", 4/fg 0/bg 305 } 306 var items-data-ah/eax: (addr handle array item) <- get items, data 307 var _items-data/eax: (addr array item) <- lookup *items-data-ah @@ -381,7 +381,7 @@ if ('onhashchange' in window) { 317 var item-index/eax: int <- copy *item-index-addr 318 var item-offset/eax: (offset item) <- compute-offset items-data, item-index 319 var curr-item/eax: (addr item) <- index items-data, item-offset - 320 y <- render-item screen, curr-item, users, show-cursor?, y, screen-height + 320 y <- render-item screen, curr-item, users, show-cursor?, y, screen-height 321 # cursor always at top item 322 copy-to show-cursor?, 0/false 323 i <- decrement @@ -389,7 +389,7 @@ if ('onhashchange' in window) { 325 } 326 } 327 - 328 fn render-thread-tab screen: (addr screen), _current-tab: (addr tab), show-cursor?: boolean, users: (addr array user), channels: (addr array channel), _items: (addr item-list), screen-height: int { + 328 fn render-thread-tab screen: (addr screen), _current-tab: (addr tab), show-cursor?: boolean, users: (addr array user), channels: (addr array channel), _items: (addr item-list), screen-height: int { 329 var current-tab/esi: (addr tab) <- copy _current-tab 330 var items/eax: (addr item-list) <- copy _items 331 var items-data-ah/eax: (addr handle array item) <- get items, data @@ -402,9 +402,9 @@ if ('onhashchange' in window) { 338 var current-tab-top-item-addr/eax: (addr int) <- get current-tab, item-index 339 var i/edx: int <- copy *current-tab-top-item-addr 340 var post-comments-first-free-addr/eax: (addr int) <- get post, comments-first-free - 341 set-cursor-position 0/screen, 0x68/x 0/y - 342 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "thread", 7/fg 0/bg - 343 render-progress screen, i, *post-comments-first-free-addr + 341 set-cursor-position 0/screen, 0x68/x 0/y + 342 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "thread", 7/fg 0/bg + 343 render-progress screen, i, *post-comments-first-free-addr 344 var post-comments-ah/eax: (addr handle array int) <- get post, comments 345 var post-comments/eax: (addr array int) <- lookup *post-comments-ah 346 var y/ecx: int <- copy 2/search-space-ver @@ -418,146 +418,146 @@ if ('onhashchange' in window) { 354 var item-index/eax: int <- copy *item-index-addr 355 var item-offset/eax: (offset item) <- compute-offset items-data, item-index 356 var curr-item/eax: (addr item) <- index items-data, item-offset - 357 y <- render-item screen, curr-item, users, show-cursor?, y, screen-height + 357 y <- render-item screen, curr-item, users, show-cursor?, y, screen-height 358 # cursor always at top item 359 copy-to show-cursor?, 0/false 360 i <- decrement 361 loop 362 } 363 # finally render the parent -- though we'll never focus on it - 364 y <- render-item screen, post, users, 0/no-cursor, y, screen-height + 364 y <- render-item screen, post, users, 0/no-cursor, y, screen-height 365 } 366 367 # side-effect: mutates cursor position - 368 fn render-progress screen: (addr screen), curr: int, max: int { - 369 set-cursor-position 0/screen, 0x70/x 0/y + 368 fn render-progress screen: (addr screen), curr: int, max: int { + 369 set-cursor-position 0/screen, 0x70/x 0/y 370 var top-index/eax: int <- copy max 371 top-index <- subtract curr # happy accident: 1-based - 372 draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen screen, top-index, 7/fg 0/bg - 373 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "/", 7/fg 0/bg - 374 draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen screen, max, 7/fg 0/bg + 372 draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen screen, top-index, 7/fg 0/bg + 373 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "/", 7/fg 0/bg + 374 draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen screen, max, 7/fg 0/bg 375 } 376 - 377 fn render-search-input screen: (addr screen), _env: (addr environment) { + 377 fn render-search-input screen: (addr screen), _env: (addr environment) { 378 var env/esi: (addr environment) <- copy _env 379 var cursor-in-search?/ecx: (addr boolean) <- get env, cursor-in-search? - 380 set-cursor-position 0/screen, 0x22/x=search-position-x 1/y - 381 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "search ", 7/fg 0/bg + 380 set-cursor-position 0/screen, 0x22/x=search-position-x 1/y + 381 draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "search ", 7/fg 0/bg 382 var search-terms-ah/eax: (addr handle gap-buffer) <- get env, search-terms 383 var search-terms/eax: (addr gap-buffer) <- lookup *search-terms-ah 384 rewind-gap-buffer search-terms - 385 var x/eax: int <- render-gap-buffer screen, search-terms, 0x2a/x 1/y, *cursor-in-search?, 0xf/fg 0/bg + 385 var x/eax: int <- render-gap-buffer screen, search-terms, 0x2a/x 1/y, *cursor-in-search?, 0xf/fg 0/bg 386 { 387 compare x, 0x4a/end-search 388 break-if-> 389 var y/ecx: int <- copy 0 - 390 x, y <- render-code-point screen, 0x5f/underscore, 0/xmin 1/ymin, 0x80/xmax, 1/ymax, x, 1/y, 0xf/fg 0/bg + 390 x, y <- render-code-point screen, 0x5f/underscore, 0/xmin 1/ymin, elimiter">} 393 } 394 395 # not used in search mode - 396 fn render-menu screen: (addr screen), _env: (addr environment) { + 396 fn render-menu screen: (addr screen), _env: (addr environment) { 397 var env/edi: (addr environment) <- copy _env 398 { 399 var cursor-in-search?/eax: (addr boolean) <- get env, cursor-in-search? 400 compare *cursor-in-search?, 0/false 401 break-if-= - 402 render-search-menu screen, env + 402 render-search-menu screen, env 403 return 404 } 405 var cursor-in-channels?/eax: (addr boolean) <- get env, cursor-in-channels? 406 compare *cursor-in-channels?, 0/false 407 { 408 break-if-= - 409 render-channels-menu screen, env + 409 render-channels-menu screen, env 410 return 411 } - 412 render-main-menu screen, env + 412 render-main-menu screen, env 413 } 414 - 415 fn render-main-menu screen: (addr screen), _env: (addr environment) { + 415 fn render-main-menu screen: (addr screen), _env: (addr environment) { 416 var width/eax: int <- copy 0 417 var y/ecx: int <- copy 0 - 418 width, y <- screen-size screen + 418 width, y <- screen-size screen 419 y <- decrement - 420 set-cursor-position screen, 2/x, y + 420 set-cursor-position screen, 2/x, y 421 { 422 var env/edi: (addr environment) <- copy _env 423 var num-tabs/edi: (addr int) <- get env, current-tab-index 424 compare *num-tabs, 0 425 break-if-<= - 426 draw-text-rightward-from-cursor screen, " Esc ", width, 0/fg 0xf/bg - 427 draw-text-rightward-from-cursor screen, " go back ", width, 0xf/fg, 0/bg + 426 draw-text-rightward-from-cursor screen, " Esc ", width, 0/fg 0xf/bg + 427 draw-text-rightward-from-cursor screen, " go back ", width, 0xf/fg, 0/bg 428 } - 429 draw-text-rightward-from-cursor screen, " / ", width, 0/fg 0xf/bg - 430 draw-text-rightward-from-cursor screen, " search ", width, 0xf/fg, 0/bg - 431 draw-text-rightward-from-cursor screen, " Tab ", width, 0/fg 0xf/bg - 432 draw-text-rightward-from-cursor screen, " go to channels ", width, 0xf/fg, 0/bg - 433 draw-text-rightward-from-cursor screen, " Enter ", width, 0/fg 0xf/bg - 434 draw-text-rightward-from-cursor screen, " go to thread ", width, 0xf/fg, 0/bg + 429 draw-text-rightward-from-cursor screen, " / ", width, 0/fg 0xf/bg + 430 draw-text-rightward-from-cursor screen, " search ", width, 0xf/fg, 0/bg + 431 draw-text-rightward-from-cursor screen, " Tab ", width, 0/fg 0xf/bg + 432 draw-text-rightward-from-cursor screen, " go to channels ", width, 0xf/fg, 0/bg + 433 draw-text-rightward-from-cursor screen, " Enter ", width, 0/fg 0xf/bg + 434 draw-text-rightward-from-cursor screen, " go to thread ", width, 0xf/fg, 0/bg 435 { 436 { 437 var is-all-items-or-channel?/eax: boolean <- current-tab-is-all-items-or-channel? _env 438 compare is-all-items-or-channel?, 0/false 439 } 440 break-if-= - 441 draw-text-rightward-from-cursor screen, " ^h ", width, 0/fg 0xf/bg - 442 draw-text-rightward-from-cursor screen, " hide thread ", width, 0xf/fg, 0/bg - 443 draw-text-rightward-from-cursor screen, " ^u ", width, 0/fg 0xf/bg - 444 draw-text-rightward-from-cursor screen, " unhide all ", width, 0xf/fg, 0/bg + 441 draw-text-rightward-from-cursor screen, " ^h ", width, 0/fg 0xf/bg + 442 draw-text-rightward-from-cursor screen, " hide thread ", width, 0xf/fg, 0/bg + 443 draw-text-rightward-from-cursor screen, " ^u ", width, 0/fg 0xf/bg + 444 draw-text-rightward-from-cursor screen, " unhide all ", width, 0xf/fg, 0/bg 445 } - 446 draw-text-rightward-from-cursor screen, " ^b ", width, 0/fg 0xf/bg - 447 draw-text-rightward-from-cursor screen, " << page ", width, 0xf/fg, 0/bg - 448 draw-text-rightward-from-cursor screen, " ^f ", width, 0/fg 0xf/bg - 449 draw-text-rightward-from-cursor screen, " page >> ", width, 0xf/fg, 0/bg + 446 draw-text-rightward-from-cursor screen, " ^b ", width, 0/fg 0xf/bg + 447 draw-text-rightward-from-cursor screen, " << page ", width, 0xf/fg, 0/bg + 448 draw-text-rightward-from-cursor screen, " ^f ", width, 0/fg 0xf/bg + 449 draw-text-rightward-from-cursor screen, " page >> ", width, 0xf/fg, 0/bg 450 } 451 - 452 fn render-channels-menu screen: (addr screen), _env: (addr environment) { + 452 fn render-channels-menu screen: (addr screen), _env: (addr environment) { 453 var width/eax: int <- copy 0 454 var y/ecx: int <- copy 0 - 455 width, y <- screen-size screen + 455 width, y <- screen-size screen 456 y <- decrement - 457 set-cursor-position screen, 2/x, y + 457 set-cursor-position screen, 2/x, y 458 { 459 var env/edi: (addr environment) <- copy _env 460 var num-tabs/edi: (addr int) <- get env, current-tab-index 461 compare *num-tabs, 0 462 break-if-<= - 463 draw-text-rightward-from-cursor screen, " Esc ", width, 0/fg 0xf/bg - 464 draw-text-rightward-from-cursor screen, " go back ", width, 0xf/fg, 0/bg + 463 draw-text-rightward-from-cursor screen, " Esc ", width, 0/fg 0xf/bg + 464 draw-text-rightward-from-cursor screen, " go back ", width, 0xf/fg, 0/bg 465 } - 466 draw-text-rightward-from-cursor screen, " / ", width, 0/fg 0xf/bg - 467 draw-text-rightward-from-cursor screen, " search ", width, 0xf/fg, 0/bg - 468 draw-text-rightward-from-cursor screen, " Tab ", width, 0/fg 0xf/bg - 469 draw-text-rightward-from-cursor screen, " go to items ", width, 0xf/fg, 0/bg - 470 draw-text-rightward-from-cursor screen, " Enter ", width, 0/fg 0xf/bg - 471 draw-text-rightward-from-cursor screen, " select ", width, 0xf/fg, 0/bg + 466 draw-text-rightward-from-cursor screen, " / ", width, 0/fg 0xf/bg + 467 draw-text-rightward-from-cursor screen, " search ", width, 0xf/fg, 0/bg + 468 draw-text-rightward-from-cursor screen, " Tab ", width, 0/fg 0xf/bg + 469 draw-text-rightward-from-cursor screen, " go to items ", width, 0xf/fg, 0/bg + 470 draw-text-rightward-from-cursor screen, " Enter ", width, 0/fg 0xf/bg + 471 draw-text-rightward-from-cursor screen, " select ", width, 0xf/fg, 0/bg 472 } 473 - 474 fn render-search-menu screen: (addr screen), _env: (addr environment) { + 474 fn render-search-menu screen: (addr screen), _env: (addr environment) { 475 var width/eax: int <- copy 0 476 var y/ecx: int <- copy 0 - 477 width, y <- screen-size screen + 477 width, y <- screen-size screen 478 y <- decrement - 479 set-cursor-position screen, 2/x, y - 480 draw-text-rightward-from-cursor screen, " Esc ", width, 0/fg 0xf/bg - 481 draw-text-rightward-from-cursor screen, " cancel ", width, 0xf/fg, 0/bg - 482 draw-text-rightward-from-cursor screen, "'") end -- compute uri if user hasn't overriden nreqt.uri = reqt.uri or adjusturi(nreqt) -- adjust headers in request nreqt.headers = adjustheaders(nreqt) -- ajust host and port if there is a proxy nreqt.host, nreqt.port = adjustproxy(nreqt) return nreqt end local function shouldredirect(reqt, code, headers) local location = headers.location if not location then return false end location = string.gsub(location, "%s", "") if location == "" then return false end local scheme = url.parse(location).scheme if scheme and (not SCHEMES[scheme]) then return false end -- avoid https downgrades if ('https' == reqt.scheme) and ('https' ~= scheme) then return false end return (reqt.redirect ~= false) and (code == 301 or code == 302 or code == 303 or code == 307) and (not reqt.method or reqt.method == "GET" or reqt.method == "HEAD") and ((false == reqt.maxredirects) or ((reqt.nredirects or 0) < (reqt.maxredirects or 5))) end local function shouldreceivebody(reqt, code) if reqt.method == "HEAD" then return nil end if code == 204 or code == 304 then return nil end if code >= 100 and code < 200 then return nil end return 1 end -- forward declarations local trequest, tredirect --[[local]] function tredirect(reqt, location) -- the RFC says the redirect URL has to be absolute, but some -- servers do not respect that local newurl = url.absolute(reqt.url, location) -- if switching schemes, reset port and create function if url.parse(newurl).scheme ~= reqt.scheme then reqt.port = nil reqt.create = nil end -- make new request local result, code, headers, status = trequest { url = newurl, source = reqt.source, sink = reqt.sink, headers = reqt.headers, proxy = reqt.proxy, maxredirects = reqt.maxredirects, nredirects = (reqt.nredirects or 0) + 1, create = reqt.create } -- pass location header back as a hint we redirected headers = headers or {} headers.location = headers.location or location return result, code, headers, status end --[[local]] function trequest(reqt) -- we loop until we get what we want, or -- until we are sure there is no way to get it local nreqt = adjustrequest(reqt) local h = _M.open(nreqt.host, nreqt.port, nreqt.create) -- send request line and headers h:sendrequestline(nreqt.method, nreqt.uri) h:sendheaders(nreqt.headers) -- if there is a body, send it if nreqt.source then h:sendbody(nreqt.headers, nreqt.source, nreqt.step) end local code, status = h:receivestatusline() -- if it is an HTTP/0.9 server, simply get the body and we are done if not code then h:receive09body(status, nreqt.sink, nreqt.step) return 1, 200 elseif code == 408 then return 1, code end local headers -- ignore any 100-continue messages while code == 100 do headers = h:receiveheaders() code, status = h:receivestatusline() end headers = h:receiveheaders() -- at this point we should have a honest reply from the server -- we can't redirect if we already used the source, so we report the error if shouldredirect(nreqt, code, headers) and not nreqt.source then h:close() return tredirect(reqt, headers.location) end -- here we are finally done if shouldreceivebody(nreqt, code) then h:receivebody(headers, nreqt.sink, nreqt.step) end h:close() return 1, code, headers, status end -- turns an url and a body into a generic request local function genericform(u, b) local t = {} local reqt = { url = u, sink = ltn12.sink.table(t), target = t } if b then reqt.source = ltn12.source.string(b) reqt.headers = { ["content-length"] = string.len(b), ["content-type"] = "application/x-www-form-urlencoded" } reqt.method = "POST" end return reqt end _M.genericform = genericform local function srequest(u, b) local reqt = genericform(u, b) local _, code, headers, status = trequest(reqt) return table.concat(reqt.target), code, headers, status end _M.request = socket.protect(function(reqt, body) if type(reqt) == "string" then return srequest(reqt, body) else return trequest(reqt) end end) _M.schemes = SCHEMES return _M stream/edi: (addr stream byte) <- address stream-storage 577 var text/esi: (addr array byte) <- copy _text @@ -652,7 +652,7 @@ if ('onhashchange' in window) { 588 } 589 var x/eax: int <- copy _x 590 var y/ecx: int <- copy _y - 591 x, y <- draw-json-stream-wrapping-right-then-down screen, stream, xmin, ymin, xmax, ymax, x, y, color, background-color + 591 x, y <- draw-json-stream-wrapping-right-then-down screen, stream, xmin, ymin, xmax, ymax, x, y, color, background-color 592 return x, y 593 } 594 @@ -660,7 +660,7 @@ if ('onhashchange' in window) { 596 # return the next (x, y) coordinate in raster order where drawing stopped 597 # that way the caller can draw more if given the same min and max bounding-box. 598 # if there isn't enough space, truncate - 599 fn draw-json-stream-wrapping-right-then-down screen: (addr screen), stream: (addr stream byte), xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int { + 599 fn draw-json-stream-wrapping-right-then-down screen: (addr screen), stream: (addr stream byte), xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int { 600 var xcurr/ecx: int <- copy x 601 var ycurr/edx: int <- copy y 602 var c/ebx: code-point <- copy 0 @@ -683,19 +683,19 @@ if ('onhashchange' in window) { 619 compare c, 0x5c/backslash 620 { 621 break-if-!= - 622 xcurr, ycurr <- render-json-escaped-code-point screen, stream, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + 622 xcurr, ycurr <- render-json-escaped-code-point screen, stream, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color 623 break $draw-json-stream-wrapping-right-then-down:render-grapheme 624 } 625 compare c, 0xa/newline 626 { 627 break-if-!= 628 # minimum effort to clear cursor - 629 var dummy/eax: int <- draw-code-point screen, 0x20/space, xcurr, ycurr, color, background-color + 629 var dummy/eax: int <- draw-code-point screen, 0x20/space, xcurr, ycurr, color, background-color 630 xcurr <- copy xmin 631 ycurr <- increment 632 break $draw-json-stream-wrapping-right-then-down:render-grapheme 633 } - 634 var offset/eax: int <- draw-code-point screen, c, xcurr, ycurr, color, background-color + 634 var offset/eax: int <- draw-code-point screen, c, xcurr, ycurr, color, background-color 635 # overlay a combining character if necessary 636 $draw-json-stream-wrapping-right-then-down:read-combiner: { 637 var done?/eax: boolean <- stream-empty? stream @@ -718,7 +718,7 @@ if ('onhashchange' in window) { 654 # otherwise overlay it without saving its width 655 # This means strange results if a base and its combiner have different 656 # widths. We'll always follow the base width. - 657 var dummy/eax: int <- overlay-code-point screen, c, xcurr, ycurr, color, background-color + 657 var dummy/eax: int <- overlay-code-point screen, c, xcurr, ycurr, color, background-color 658 } 659 xcurr <- add offset 660 compare xcurr, xmax @@ -730,7 +730,7 @@ if ('onhashchange' in window) { 666 } 667 loop 668 } - 669 set-cursor-position screen, xcurr, ycurr + 669 set-cursor-position screen, xcurr, ycurr 670 return xcurr, ycurr 671 } 672 @@ -743,7 +743,7 @@ if ('onhashchange' in window) { 679 680 # '\' encountered 681 # https://www.json.org/json-en.html - 682 fn render-json-escaped-code-point screen: (addr screen), stream: (addr stream byte), xmin: int, ymin: int, xmax: int, ymax: int, xcurr: int, ycurr: int, color: int, background-color: int -> _/ecx: int, _/edx: int { + 682 fn render-json-escaped-code-point screen: (addr screen), stream: (addr stream byte), xmin: int, ymin: int, xmax: int, ymax: int, xcurr: int, ycurr: int, color: int, background-color: int -> _/ecx: int, _/edx: int { 683 var g/ebx: code-point <- read-json-code-point stream 684 compare g, 0xffffffff/end-of-file 685 { @@ -784,19 +784,19 @@ if ('onhashchange' in window) { 720 { 721 compare g, 0x75/u 722 break-if-!= - 723 x, y <- render-json-escaped-unicode-code-point screen, stream, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + 723 x, y <- render-json-escaped-unicode-code-point screen, stream, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color 724 var y/edx: int <- copy y 725 return x, y 726 } 727 # most characters escape to themselves 728 # combining characters not supported after backslash - 729 x, y <- render-code-point screen, g, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + 729 x, y <- render-code-point screen, g, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color 730 var y/edx: int <- copy y 731 return x, y 732 } 733 734 # '\u' encountered - 735 fn render-json-escaped-unicode-code-point screen: (addr screen), stream: (addr stream byte), xmin: int, ymin: int, xmax: int, ymax: int, xcurr: int, ycurr: int, color: int, background-color: int -> _/eax: int, _/ecx: int { + 735 fn render-json-escaped-unicode-code-point screen: (addr screen), stream: (addr stream byte), xmin: int, ymin: int, xmax: int, ymax: int, xcurr: int, ycurr: int, color: int, background-color: int -> _/eax: int, _/ecx: int { 736 var hex-digits-storage: (array byte 4) 737 var hex-digits/esi: (addr array byte) <- address hex-digits-storage 738 # slurp 4 bytes exactly @@ -819,7 +819,7 @@ if ('onhashchange' in window) { 755 break-if-= 756 var x/eax: int <- copy 0 757 var y/ecx: int <- copy 0 - 758 x, y <- render-code-point screen, 0x2d/dash, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + 758 x, y <- render-code-point screen, 0x2d/dash, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color 759 return x, y 760 } 761 # \u2014 = - @@ -829,7 +829,7 @@ if ('onhashchange' in window) { 765 break-if-= 766 var x/eax: int <- copy 0 767 var y/ecx: int <- copy 0 - 768 x, y <- render-code-point screen, 0x2d/dash, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + 768 x, y <- render-code-point screen, 0x2d/dash, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color 769 return x, y 770 } 771 # \u2018 = ' @@ -839,7 +839,7 @@ if ('onhashchange' in window) { 775 break-if-= 776 var x/eax: int <- copy 0 777 var y/ecx: int <- copy 0 - 778 x, y <- render-code-point screen, 0x27/quote, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + 778 x, y <- render-code-point screen, 0x27/quote, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color 779 return x, y 780 } 781 # \u2019 = ' @@ -849,7 +849,7 @@ if ('onhashchange' in window) { 785 break-if-= 786 var x/eax: int <- copy 0 787 var y/ecx: int <- copy 0 - 788 x, y <- render-code-point screen, 0x27/quote, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + 788 x, y <- render-code-point screen, 0x27/quote, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color 789 return x, y 790 } 791 # \u201c = " @@ -859,7 +859,7 @@ if ('onhashchange' in window) { 795 break-if-= 796 var x/eax: int <- copy 0 797 var y/ecx: int <- copy 0 - 798 x, y <- render-code-point screen, 0x22/dquote, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + 798 x, y <- render-code-point screen, 0x22/dquote, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color 799 return x, y 800 } 801 # \u201d = " @@ -869,7 +869,7 @@ if ('onhashchange' in window) { 805 break-if-= 806 var x/eax: int <- copy 0 807 var y/ecx: int <- copy 0 - 808 x, y <- render-code-point screen, 0x22/dquote, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + 808 x, y <- render-code-point screen, 0x22/dquote, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color 809 return x, y 810 } 811 # \u2022 = * @@ -879,7 +879,7 @@ if ('onhashchange' in window) { 815 break-if-= 816 var x/eax: int <- copy 0 817 var y/ecx: int <- copy 0 - 818 x, y <- render-code-point screen, 0x2a/asterisk, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + 818 x, y <- render-code-point screen, 0x2a/asterisk, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color 819 return x, y 820 } 821 # \u2026 = ... @@ -889,14 +889,14 @@ if ('onhashchange' in window) { 825 break-if-= 826 var x/eax: int <- copy 0 827 var y/ecx: int <- copy 0 - 828 x, y <- draw-text-wrapping-right-then-down screen, "...", xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + 828 x, y <- draw-text-wrapping-right-then-down screen, "...", xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color 829 return x, y 830 } 831 var n/eax: int <- parse-hex-int hex-digits 832 var c/edx: code-point <- copy n 833 var x/eax: int <- copy 0 834 var y/ecx: int <- copy 0 - 835 x, y <- render-code-point screen, c, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color + 835 x, y <- render-code-point screen, c, xmin, ymin, xmax, ymax, xcurr, ycurr, color, background-color 836 return x, y 837 } 838 -- cgit 1.4.1-2-gfad0