Files
sml-projects/fcore/app-update.sml
2024-10-08 08:53:43 +01:00

26 lines
642 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} = app
val newBuffer = LineGap.goToLine (startLine, buffer)
val textVec =
TextBuilder.build (startLine, newBuffer, newWidth, newHeight)
val newApp = AppWith.bufferAndSize (app, newBuffer, newWidth, newHeight)
val msg = REDRAW_TEXT textVec
in
(newApp, [DRAW msg])
end
fun update (app, msg) =
case msg of RESIZE_EVENT (width, height) => resizeText (app, width, height)
end