summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorS. Gilles <sgilles@math.umd.edu>2017-10-18 03:24:53 -0400
committerOri Bernstein <ori@eigenstate.org>2017-10-28 17:11:00 -0700
commit3e004af4a5622781f469d228a2bd4eee2ed17071 (patch)
tree3b012d9724861eb1d4b0ff0619c1e22255e61b85
parent00e2ace07c80f00e9910f3e3787c874a504327ff (diff)
downloadlibtermdraw-3e004af4a5622781f469d228a2bd4eee2ed17071.tar.gz
Add termdraw.poll
-rw-r--r--event.myr16
1 files changed, 16 insertions, 0 deletions
diff --git a/event.myr b/event.myr
index f55b87c..a08d79f 100644
--- a/event.myr
+++ b/event.myr
@@ -7,6 +7,7 @@ use "termios"
pkg termdraw =
const event : (t : term# -> event)
+ const poll : (t : term# -> std.option(event))
const checksize : (t : term# -> void)
;;
@@ -50,6 +51,21 @@ const event = {t
-> `Gone
}
+const poll = {t
+ var c = winchanges
+ if c > winreported
+ winreported = c
+ checksize(t)
+ -> `std.Some `Winsz (t.x, t.y)
+ ;;
+
+ if t.nextb == 0
+ -> `std.None
+ ;;
+
+ -> readkey(t)
+}
+
const checksize = {t
var wc, x, y