diff --git a/dotscape b/dotscape index 1da63a3..34e3b06 100755 Binary files a/dotscape and b/dotscape differ diff --git a/ffi/glfw-input.c b/ffi/glfw-input.c index e38acef..6bd6744 100644 --- a/ffi/glfw-input.c +++ b/ffi/glfw-input.c @@ -14,6 +14,7 @@ int KEY_S = GLFW_KEY_S; int KEY_E = GLFW_KEY_E; int KEY_I = GLFW_KEY_I; int KEY_L = GLFW_KEY_L; +int KEY_O = GLFW_KEY_O; int KEY_ENTER = GLFW_KEY_ENTER; int KEY_SPACE = GLFW_KEY_SPACE; diff --git a/ffi/glfw-input.sml b/ffi/glfw-input.sml index 583df8e..2d21d30 100644 --- a/ffi/glfw-input.sml +++ b/ffi/glfw-input.sml @@ -46,6 +46,8 @@ struct _symbol "KEY_I" public : ( unit -> int ) * ( int -> unit ); val (KEY_L, _) = _symbol "KEY_L" public : ( unit -> int ) * ( int -> unit ); + val (KEY_O, _) = + _symbol "KEY_O" public : ( unit -> int ) * ( int -> unit ); val (KEY_ENTER, _) = _symbol "KEY_ENTER" public : ( unit -> int ) * ( int -> unit ); diff --git a/functional-core/app/app-update.sml b/functional-core/app/app-update.sml index be26386..653fcaf 100644 --- a/functional-core/app/app-update.sml +++ b/functional-core/app/app-update.sml @@ -355,6 +355,15 @@ struct fun trianglesLoadError model = (model, NO_MAILBOX) + fun enterBrowseMode model = + let + val model = AppWith.mode (model, AppType.BROWSE_MODE) + (* should draw modal window as well, but that's not needed right now *) + val fileMsg = LOAD_FILES (#openFilePath model) + in + (model, FILE fileMsg) + end + fun updateNormalMode (model: app_type, inputMsg) = case inputMsg of MOUSE_MOVE {x = mouseX, y = mouseY} => @@ -370,6 +379,7 @@ struct | KEY_CTRL_S => getSaveTrianglesMsg model | KEY_CTRL_L => getLoadTrianglesMsg model | KEY_CTRL_E => getExportTrianglesMsg model + | KEY_CTRL_O => enterBrowseMode model | ARROW_UP => moveArrowUp model | ARROW_LEFT => moveArrowLeft model | ARROW_RIGHT => moveArrowRight model @@ -380,5 +390,7 @@ struct | TRIANGLES_LOAD_ERROR => trianglesLoadError model fun update (model: app_type, inputMsg) = - case #mode model of NORMAL_MODE => updateNormalMode (model, inputMsg) + case #mode model of + NORMAL_MODE => updateNormalMode (model, inputMsg) + | BROWSE_MODE => updateNormalMode (model, inputMsg) end diff --git a/functional-core/app/app-with.sml b/functional-core/app/app-with.sml index 18489e8..863017a 100644 --- a/functional-core/app/app-with.sml +++ b/functional-core/app/app-with.sml @@ -2,6 +2,8 @@ signature APP_WITH = sig val graphVisibility: AppType.app_type * bool -> AppType.app_type + val mode: AppType.app_type * AppType.app_mode -> AppType.app_type + val windowResize: AppType.app_type * int * int -> AppType.app_type val mousePosition: AppType.app_type * Real32.real * Real32.real @@ -489,6 +491,48 @@ struct } end + fun mode (app: app_type, newMode) = + let + val + { mode = _ + , triangleStage + , triangles + , numClickPoints + , xClickPoints + , yClickPoints + , windowWidth + , windowHeight + , undo + , redo + , mouseX + , mouseY + , arrowX + , arrowY + , showGraph + , openFilePath + , fileBrowser + } = app + in + { mode = newMode + , showGraph = showGraph + , triangleStage = triangleStage + , triangles = triangles + , undo = undo + , redo = redo + , numClickPoints = numClickPoints + , xClickPoints = xClickPoints + , yClickPoints = yClickPoints + , windowWidth = windowWidth + , windowHeight = windowHeight + , mouseX = mouseX + , mouseY = mouseY + , arrowX = arrowX + , arrowY = arrowY + , openFilePath = openFilePath + , fileBrowser = fileBrowser + } + end + fun useTriangles (app: app_type, triangles) = let val diff --git a/imperative-shell/file-thread.sml b/imperative-shell/file-thread.sml index a3df583..7dfe7d0 100644 --- a/imperative-shell/file-thread.sml +++ b/imperative-shell/file-thread.sml @@ -171,15 +171,12 @@ struct fun getDirList (dir, acc) = case OS.FileSys.readDir dir of SOME path => - let - val _ = print (path ^ "\n") - val acc = - if OS.FileSys.isDir path then (AppType.FOLDER path) :: acc - else if OS.FileSys.isLink path then acc - else (AppType.FILE path) :: acc - in + if OS.FileSys.isDir path then + getDirList (dir, AppType.FOLDER path :: acc) + else if OS.FileSys.isLink path then getDirList (dir, acc) - end + else + getDirList (dir, AppType.FILE path :: acc) | NONE => let val acc = List.rev acc in Vector.fromList acc end fun loadFiles (path, inputMailbox) = diff --git a/imperative-shell/input-callbacks.sml b/imperative-shell/input-callbacks.sml index e86671c..c0c88f5 100644 --- a/imperative-shell/input-callbacks.sml +++ b/imperative-shell/input-callbacks.sml @@ -86,6 +86,10 @@ struct andalso mods = 0x0 then Mailbox.send (mailbox, KEY_SPACE) + else if + key = Input.KEY_O () andalso action = Input.PRESS () andalso mods = 0x02 + then + Mailbox.send (mailbox, KEY_CTRL_O) else () diff --git a/message-types/input-msg.sml b/message-types/input-msg.sml index 96ef22a..c74a9ac 100644 --- a/message-types/input-msg.sml +++ b/message-types/input-msg.sml @@ -11,6 +11,7 @@ sig | KEY_CTRL_S | KEY_CTRL_L | KEY_CTRL_E + | KEY_CTRL_O | ARROW_UP | ARROW_LEFT | ARROW_RIGHT @@ -19,6 +20,7 @@ sig | KEY_SPACE | USE_TRIANGLES of AppType.triangle list | TRIANGLES_LOAD_ERROR + | FILE_BROWSER_AND_PATH of { fileBrowser: AppType.file_browser_item vector, path: string } end structure InputMessage :> INPUT_MESSAGE = @@ -34,6 +36,7 @@ struct | KEY_CTRL_S | KEY_CTRL_L | KEY_CTRL_E + | KEY_CTRL_O | ARROW_UP | ARROW_LEFT | ARROW_RIGHT @@ -42,4 +45,5 @@ struct | KEY_SPACE | USE_TRIANGLES of AppType.triangle list | TRIANGLES_LOAD_ERROR + | FILE_BROWSER_AND_PATH of { fileBrowser: AppType.file_browser_item vector, path: string } end