Files
sml-projects/fcore/app-update.sml

26 lines
664 B
Standard ML
Raw Normal View History

2024-10-06 09:32:56 +01:00
structure AppUpdate =
struct
open AppType
open MailboxType
open DrawMsg
open InputMsg
fun resizeText (app: app_type, newWidth, newHeight) =
let
2024-10-09 10:59:32 +01:00
val {buffer, windowWidth, windowHeight, startLine, cursorIdx} = app
2024-10-06 09:32:56 +01:00
2024-10-08 08:53:43 +01:00
val newBuffer = LineGap.goToLine (startLine, buffer)
2024-10-09 10:53:00 +01:00
val textVec = TextBuilder.build
(startLine, cursorIdx, newBuffer, newWidth, newHeight)
2024-10-08 08:53:43 +01:00
val newApp = AppWith.bufferAndSize (app, newBuffer, newWidth, newHeight)
2024-10-06 09:32:56 +01:00
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