summary refs log blame commit diff stats
path: root/ranger.py
blob: 754f0a8f954c339ffbbafb7fc094752969db5e47 (plain) (tree)
an class="nv">boolean, quit?:boolean [ local-scope load-ingredients x:event, console, found?:boolean, quit?:boolean <- read-event console return-if quit?, 0, console/same-as-ingredient:0, found?, quit? return-unless found?, 0, console/same-as-ingredient:0, found?, quit? c:character, converted?:boolean <- maybe-convert x, text:variant return-unless converted?, 0, console/same-as-ingredient:0, 0/found, 0/quit return c, console/same-as-ingredient:0, 1/found, 0/quit ] def send-keys-to-channel console:address:console, chan:address:sink:character, screen:address:screen -> console:address:console, chan:address:sink:character, screen:address:screen [ local-scope load-ingredients { c:character, console, found?:boolean, quit?:boolean <- read-key console loop-unless found? break-if quit? assert c, [invalid event, expected text] screen <- print screen, c chan <- write chan, c loop } chan <- close chan ] def wait-for-event console:address:console -> console:address:console [ local-scope load-ingredients { _, console, found?:boolean <- read-event console loop-unless found? } ] # use this helper to skip rendering if there's lots of other events queued up def has-more-events? console:address:console -> result:boolean [ local-scope load-ingredients { break-unless console # fake consoles should be plenty fast; never skip return 0/false } result <- interactions-left? ]