rudus/sandbox.ld

35 lines
638 B
Plaintext
Raw Normal View History

2025-07-01 20:30:17 +00:00
fn inputter () -> {
if do input > unbox > empty?
then {
yield! ()
inputter ()
}
else receive {
(:get, pid) -> send (pid, (:reply, unbox (input)))
(:flush, pid) -> {
send (pid, (:reply, unbox (input)))
store! (input, "")
}
(:clear) -> store! (input, "")
}
}
fn clear_input () -> store! (input, "")
fn read_input () -> {
let reader = spawn! (inputter)
send (reader, (:get, self ()))
receive {
(:reply, msg) -> msg
}
}
fn flush_input () -> {
let reader = spawn! (inputter)
send (reader, (:flush, self ()))
receive {
(:reply, msg) -> msg
}
}