add CHAR_EVENT message type (next is to handle hjkl navigation)
This commit is contained in:
@@ -19,6 +19,16 @@ struct
|
||||
(newApp, drawMsg)
|
||||
end
|
||||
|
||||
fun update (app, msg) =
|
||||
case msg of RESIZE_EVENT (width, height) => resizeText (app, width, height)
|
||||
fun handleChr (app, chr) =
|
||||
let
|
||||
val chr = Char.toString chr ^ "\n"
|
||||
val () = print chr
|
||||
in
|
||||
(app, [])
|
||||
end
|
||||
|
||||
fun update (app, msg) =
|
||||
case msg of
|
||||
RESIZE_EVENT (width, height) => resizeText (app, width, height)
|
||||
| CHAR_EVENT chr => handleChr (app, chr)
|
||||
end
|
||||
|
||||
@@ -2,10 +2,12 @@ signature INPUT_MSG =
|
||||
sig
|
||||
datatype t =
|
||||
RESIZE_EVENT of int * int
|
||||
| CHAR_EVENT of char
|
||||
end
|
||||
|
||||
structure InputMsg :> INPUT_MSG =
|
||||
struct
|
||||
datatype t =
|
||||
RESIZE_EVENT of int * int
|
||||
| CHAR_EVENT of char
|
||||
end
|
||||
|
||||
@@ -6,13 +6,12 @@ struct
|
||||
fun frameBufferSizeCallback inputMailbox (width, height) =
|
||||
Mailbox.send (inputMailbox, RESIZE_EVENT (width, height))
|
||||
|
||||
fun charCallback word =
|
||||
fun charCallback inputMailbox word =
|
||||
let
|
||||
val word = Word32.toInt word
|
||||
val chr = Char.chr word
|
||||
val s = Char.toString chr ^ "\n"
|
||||
in
|
||||
print s
|
||||
Mailbox.send (inputMailbox, CHAR_EVENT chr)
|
||||
end
|
||||
|
||||
fun registerCallbacks (inputMailbox, window) =
|
||||
@@ -21,6 +20,7 @@ struct
|
||||
val () = Input.exportFramebufferSizeCallback resizeCallback
|
||||
val () = Input.setFramebufferSizeCallback window
|
||||
|
||||
val charCallback = charCallback inputMailbox
|
||||
val () = Input.exportCharCallback charCallback
|
||||
val () = Input.setCharCallback window
|
||||
in
|
||||
|
||||
Reference in New Issue
Block a user