35 lines
811 B
Standard ML
35 lines
811 B
Standard ML
structure AppUpdate =
|
|
struct
|
|
open AppType
|
|
|
|
open MailboxType
|
|
open DrawMsg
|
|
open InputMsg
|
|
|
|
fun resizeText (app: app_type, newWidth, newHeight) =
|
|
let
|
|
val {buffer, windowWidth, windowHeight, startLine, cursorIdx} = app
|
|
|
|
val newBuffer = LineGap.goToLine (startLine, buffer)
|
|
val drawMsg = TextBuilder.build
|
|
(startLine, cursorIdx, newBuffer, newWidth, newHeight)
|
|
|
|
val newApp = AppWith.bufferAndSize (app, newBuffer, newWidth, newHeight)
|
|
in
|
|
(newApp, drawMsg)
|
|
end
|
|
|
|
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
|