add scaffolding in imperative shell to help update canvas width and height

This commit is contained in:
2025-07-11 17:45:16 +01:00
parent 08ed5cc3d5
commit e3729a1ce5
6 changed files with 11 additions and 3 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -252,8 +252,9 @@ struct
fun updateBlue model = (AppWith.b model, []) fun updateBlue model = (AppWith.b model, [])
fun updateAlpha model = (AppWith.a model, []) fun updateAlpha model = (AppWith.a model, [])
fun updateCanvasWidth (model, newCanvasWidth) = fun updateCanvasWidth model =
let let
val newCanvasWidth = #modalNum model
val model = AppWith.canvasWidth (model, newCanvasWidth) val model = AppWith.canvasWidth (model, newCanvasWidth)
val val
@@ -322,7 +323,7 @@ struct
| KEY_G => updateGreen model | KEY_G => updateGreen model
| KEY_B => updateBlue model | KEY_B => updateBlue model
| KEY_A => updateAlpha model | KEY_A => updateAlpha model
| KEY_W newCanvasWidth => updateCanvasWidth (model, newCanvasWidth) | KEY_W => updateCanvasWidth model
| RESIZE_WINDOW {width, height} => resizeWindow (model, width, height) | RESIZE_WINDOW {width, height} => resizeWindow (model, width, height)
| UNDO_ACTION => undoAction model | UNDO_ACTION => undoAction model
| REDO_ACTION => redoAction model | REDO_ACTION => redoAction model

View File

@@ -20,6 +20,7 @@ int KEY_I = GLFW_KEY_I;
int KEY_L = GLFW_KEY_L; int KEY_L = GLFW_KEY_L;
int KEY_O = GLFW_KEY_O; int KEY_O = GLFW_KEY_O;
int KEY_A = GLFW_KEY_A; int KEY_A = GLFW_KEY_A;
int KEY_W = GLFW_KEY_W;
int KEY_ENTER = GLFW_KEY_ENTER; int KEY_ENTER = GLFW_KEY_ENTER;
int KEY_SPACE = GLFW_KEY_SPACE; int KEY_SPACE = GLFW_KEY_SPACE;

View File

@@ -57,6 +57,8 @@ struct
_symbol "KEY_O" public : ( unit -> int ) * ( int -> unit ); _symbol "KEY_O" public : ( unit -> int ) * ( int -> unit );
val (KEY_A, _) = val (KEY_A, _) =
_symbol "KEY_A" public : ( unit -> int ) * ( int -> unit ); _symbol "KEY_A" public : ( unit -> int ) * ( int -> unit );
val (KEY_W, _) =
_symbol "KEY_W" public : ( unit -> int ) * ( int -> unit );
val (KEY_ENTER, _) = val (KEY_ENTER, _) =
_symbol "KEY_ENTER" public : ( unit -> int ) * ( int -> unit ); _symbol "KEY_ENTER" public : ( unit -> int ) * ( int -> unit );

View File

@@ -72,6 +72,10 @@ struct
key = Input.KEY_A () andalso action = Input.PRESS () andalso mods = 0 key = Input.KEY_A () andalso action = Input.PRESS () andalso mods = 0
then then
Mailbox.send (mailbox, KEY_A) Mailbox.send (mailbox, KEY_A)
else if
key = Input.KEY_W () andalso action = Input.PRESS () andalso mods = 0
then
Mailbox.send (mailbox, KEY_W)
else if else if
key = Input.KEY_UP () andalso action <> Input.RELEASE () key = Input.KEY_UP () andalso action <> Input.RELEASE ()
andalso mods = 0x0 andalso mods = 0x0

View File

@@ -12,7 +12,7 @@ struct
| KEY_B | KEY_B
| KEY_T | KEY_T
| KEY_A | KEY_A
| KEY_W of int | KEY_W
| KEY_CTRL_S | KEY_CTRL_S
| KEY_CTRL_L | KEY_CTRL_L
| KEY_CTRL_E | KEY_CTRL_E