add CHAR_EVENT message type (next is to handle hjkl navigation)

This commit is contained in:
2024-10-17 01:38:31 +01:00
parent ce23e50c8d
commit c77777cc09
4 changed files with 16 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

BIN
shf

Binary file not shown.