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