remove browse mode and code that became dead as a result of its removal, because the new plan is to launch the program from the terminal (and terminal navigation is okay)
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
||||
[submodule "cozette-sml"]
|
||||
path = cozette-sml
|
||||
url = https://github.com/hummy123/cozette-sml
|
||||
Submodule cozette-sml deleted from 25eee9f3e6
@@ -26,7 +26,6 @@ ann
|
||||
"allowVectorExps true"
|
||||
in
|
||||
fcore/ndc.sml
|
||||
cozette-sml/fonts/cozette-ascii.mlb
|
||||
end
|
||||
|
||||
fcore/graph-lines.sml
|
||||
@@ -43,7 +42,6 @@ fcore/quad-tree.sml
|
||||
|
||||
fcore/common-update.sml
|
||||
fcore/normal-mode.sml
|
||||
fcore/browse-mode.sml
|
||||
fcore/move-mode.sml
|
||||
fcore/app-update.sml
|
||||
|
||||
|
||||
@@ -39,8 +39,6 @@ struct
|
||||
, arrowX = 0
|
||||
, arrowY = 0
|
||||
, openFilePath = ""
|
||||
, fileBrowser = Vector.fromList []
|
||||
, fileBrowserIdx = 0
|
||||
, r = 0
|
||||
, g = 0
|
||||
, b = 0
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
structure AppType =
|
||||
struct
|
||||
datatype app_mode = NORMAL_MODE | BROWSE_MODE | MOVE_MODE
|
||||
|
||||
datatype file_browser_item = IS_FILE of string | IS_FOLDER of string
|
||||
datatype app_mode = NORMAL_MODE | MOVE_MODE
|
||||
|
||||
type square = {r: int, g: int, b: int, a: int}
|
||||
|
||||
@@ -26,8 +24,6 @@ struct
|
||||
, arrowX: int
|
||||
, arrowY: int
|
||||
, openFilePath: string
|
||||
, fileBrowser: file_browser_item vector
|
||||
, fileBrowserIdx: int
|
||||
, r: int
|
||||
, g: int
|
||||
, b: int
|
||||
|
||||
@@ -5,6 +5,5 @@ struct
|
||||
fun update (model: app_type, inputMsg) =
|
||||
case #mode model of
|
||||
NORMAL_MODE => NormalMode.update (model, inputMsg)
|
||||
| BROWSE_MODE => BrowseMode.update (model, inputMsg)
|
||||
| MOVE_MODE => MoveMode.update (model, inputMsg)
|
||||
end
|
||||
|
||||
@@ -19,8 +19,6 @@ struct
|
||||
, mouseX
|
||||
, mouseY
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -44,8 +42,6 @@ struct
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -73,8 +69,6 @@ struct
|
||||
, mouseX
|
||||
, mouseY
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -98,8 +92,6 @@ struct
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -127,8 +119,6 @@ struct
|
||||
, mouseX
|
||||
, mouseY
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -156,8 +146,6 @@ struct
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -185,8 +173,6 @@ struct
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -210,8 +196,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -239,8 +223,6 @@ struct
|
||||
|
||||
, showGraph = _
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -264,8 +246,6 @@ struct
|
||||
|
||||
, showGraph = shouldShowGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -293,8 +273,6 @@ struct
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -318,116 +296,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, a = a
|
||||
, layer = layer
|
||||
, layerTree = layerTree
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun fileBrowserAndPath (app: app_type, fileBrowser, path) =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, mouseX
|
||||
, mouseY
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, arrowX
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
|
||||
, showGraph
|
||||
, openFilePath = _
|
||||
, fileBrowser = _
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, a
|
||||
, layer
|
||||
, layerTree
|
||||
, modalNum
|
||||
} = app
|
||||
in
|
||||
{ mode = mode
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = path
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = 0
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
, a = a
|
||||
, layer = layer
|
||||
, layerTree = layerTree
|
||||
, modalNum = modalNum
|
||||
}
|
||||
end
|
||||
|
||||
fun fileBrowserIdx (app: app_type, newFileBrowserIdx) =
|
||||
let
|
||||
val
|
||||
{ mode
|
||||
, mouseX
|
||||
, mouseY
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, arrowX
|
||||
, arrowY
|
||||
, canvasWidth
|
||||
, canvasHeight
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx = _
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
, a
|
||||
, layer
|
||||
, layerTree
|
||||
, modalNum
|
||||
} = app
|
||||
in
|
||||
{ mode = mode
|
||||
, mouseX = mouseX
|
||||
, mouseY = mouseY
|
||||
, arrowX = arrowX
|
||||
, arrowY = arrowY
|
||||
, canvasWidth = canvasWidth
|
||||
, canvasHeight = canvasHeight
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, xClickPoints = xClickPoints
|
||||
, yClickPoints = yClickPoints
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = newFileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -455,8 +323,6 @@ struct
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -482,8 +348,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -511,8 +375,6 @@ struct
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r = _
|
||||
, g
|
||||
, b
|
||||
@@ -538,8 +400,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -567,8 +427,6 @@ struct
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g = _
|
||||
, b
|
||||
@@ -594,8 +452,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -623,8 +479,6 @@ struct
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b = _
|
||||
@@ -650,8 +504,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -679,8 +531,6 @@ struct
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -706,8 +556,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -735,8 +583,6 @@ struct
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -762,8 +608,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -791,8 +635,6 @@ struct
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -816,8 +658,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -845,8 +685,6 @@ struct
|
||||
, mouseX
|
||||
, mouseY
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -875,8 +713,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -904,8 +740,6 @@ struct
|
||||
, mouseX
|
||||
, mouseY
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -934,8 +768,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -963,8 +795,6 @@ struct
|
||||
, mouseX
|
||||
, mouseY
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r = _
|
||||
, g = _
|
||||
, b = _
|
||||
@@ -988,8 +818,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
@@ -1018,8 +846,6 @@ struct
|
||||
|
||||
, showGraph
|
||||
, openFilePath
|
||||
, fileBrowser
|
||||
, fileBrowserIdx
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
@@ -1051,8 +877,6 @@ struct
|
||||
|
||||
, showGraph = showGraph
|
||||
, openFilePath = openFilePath
|
||||
, fileBrowser = fileBrowser
|
||||
, fileBrowserIdx = fileBrowserIdx
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
structure BrowseMode =
|
||||
struct
|
||||
open AppType
|
||||
|
||||
open DrawMessage
|
||||
open FileMessage
|
||||
open InputMessage
|
||||
open UpdateMessage
|
||||
|
||||
fun stringToVec
|
||||
(pos, str, acc, startX, startY, windowWidth, windowHeight, r, g, b) =
|
||||
if pos = String.size str then
|
||||
acc
|
||||
else
|
||||
let
|
||||
val chr = String.sub (str, pos)
|
||||
|
||||
val chrFun = Vector.sub (CozetteAscii.asciiTable, Char.ord chr)
|
||||
val chrVec = chrFun
|
||||
(startX, startY, 25.0, 25.0, windowWidth, windowHeight, r, g, b)
|
||||
|
||||
val acc = chrVec :: acc
|
||||
in
|
||||
stringToVec
|
||||
( pos + 1
|
||||
, str
|
||||
, acc
|
||||
, startX + 12
|
||||
, startY
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, r
|
||||
, g
|
||||
, b
|
||||
)
|
||||
end
|
||||
|
||||
fun buildFileBrowserText
|
||||
(pos, fileBrowser, acc, startY, windowWidth, windowHeight, selectedIdx) =
|
||||
if pos = Vector.length fileBrowser then
|
||||
Vector.concat acc
|
||||
else
|
||||
let
|
||||
val item = Vector.sub (fileBrowser, pos)
|
||||
val itemText =
|
||||
case item of
|
||||
IS_FILE str => str
|
||||
| IS_FOLDER str => str
|
||||
val acc =
|
||||
if pos <> selectedIdx then
|
||||
stringToVec
|
||||
( 0
|
||||
, itemText
|
||||
, acc
|
||||
, 10
|
||||
, startY
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, 0.0
|
||||
, 0.0
|
||||
, 0.0
|
||||
)
|
||||
else
|
||||
stringToVec
|
||||
( 0
|
||||
, itemText
|
||||
, acc
|
||||
, 10
|
||||
, startY
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, 0.35
|
||||
, 0.35
|
||||
, 0.75
|
||||
)
|
||||
in
|
||||
buildFileBrowserText
|
||||
( pos + 1
|
||||
, fileBrowser
|
||||
, acc
|
||||
, startY + 23
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, selectedIdx
|
||||
)
|
||||
end
|
||||
|
||||
fun redrawFileBrowser (model: app_type) =
|
||||
let
|
||||
val {windowWidth, windowHeight, fileBrowser, fileBrowserIdx, ...} = model
|
||||
val ww = Real32.fromInt windowWidth
|
||||
val wh = Real32.fromInt windowHeight
|
||||
val textVec = buildFileBrowserText
|
||||
(0, fileBrowser, [], 10, ww, wh, fileBrowserIdx)
|
||||
|
||||
val drawMsg = DRAW_MODAL_TEXT textVec
|
||||
in
|
||||
(model, [DRAW drawMsg])
|
||||
end
|
||||
|
||||
fun handleFileBrowserAndPathInBrowseMode (model, fileBrowser, path) =
|
||||
let val model = AppWith.fileBrowserAndPath (model, fileBrowser, path)
|
||||
in redrawFileBrowser model
|
||||
end
|
||||
|
||||
fun browseModeArrowUp (model: app_type) =
|
||||
let
|
||||
val {fileBrowser, fileBrowserIdx, ...} = model
|
||||
|
||||
val fileBrowserIdx =
|
||||
if fileBrowserIdx > 0 then fileBrowserIdx - 1
|
||||
else Int.max (0, Vector.length fileBrowser - 1)
|
||||
|
||||
val model = AppWith.fileBrowserIdx (model, fileBrowserIdx)
|
||||
in
|
||||
redrawFileBrowser model
|
||||
end
|
||||
|
||||
fun browseModeArrowDown (model: app_type) =
|
||||
let
|
||||
val {fileBrowser, fileBrowserIdx, ...} = model
|
||||
|
||||
val fileBrowserIdx =
|
||||
if fileBrowserIdx = Vector.length fileBrowser - 1 then 0
|
||||
else fileBrowserIdx + 1
|
||||
|
||||
val model = AppWith.fileBrowserIdx (model, fileBrowserIdx)
|
||||
in
|
||||
redrawFileBrowser model
|
||||
end
|
||||
|
||||
fun selectCurrentFileItem model =
|
||||
let
|
||||
val {fileBrowser, fileBrowserIdx, openFilePath, ...} = model
|
||||
in
|
||||
if Vector.length fileBrowser > 0 then
|
||||
let
|
||||
val path =
|
||||
case Vector.sub (fileBrowser, fileBrowserIdx) of
|
||||
IS_FILE str => str
|
||||
| IS_FOLDER str => str
|
||||
val path = String.concat [openFilePath, "/", path]
|
||||
val fileMsg = SELECT_PATH path
|
||||
in
|
||||
(model, [FILE fileMsg])
|
||||
end
|
||||
else
|
||||
(model, [])
|
||||
end
|
||||
|
||||
fun update (model: app_type, inputMsg) =
|
||||
case inputMsg of
|
||||
ARROW_UP => browseModeArrowUp model
|
||||
| ARROW_DOWN => browseModeArrowDown model
|
||||
(* todo:
|
||||
| ARROW_LEFT =>
|
||||
*)
|
||||
| ARROW_RIGHT => selectCurrentFileItem model
|
||||
| KEY_ENTER => selectCurrentFileItem model
|
||||
| KEY_SPACE => selectCurrentFileItem model
|
||||
| FILE_BROWSER_AND_PATH {fileBrowser, path} =>
|
||||
handleFileBrowserAndPathInBrowseMode (model, fileBrowser, path)
|
||||
| SQUARES_LOAD_ERROR => CommonUpdate.squaresLoadError model
|
||||
| _ => (model, [])
|
||||
end
|
||||
@@ -349,26 +349,11 @@ struct
|
||||
getDrawMessage (model, initialMsg)
|
||||
end
|
||||
|
||||
fun enterBrowseMode model =
|
||||
let
|
||||
val model = AppWith.mode (model, AppType.BROWSE_MODE)
|
||||
(* todo: should draw modal window as well *)
|
||||
val fileMsg = LOAD_FILES (#openFilePath model)
|
||||
val fileMsg = [FILE fileMsg]
|
||||
in
|
||||
(model, fileMsg)
|
||||
end
|
||||
|
||||
fun enterMoveMode model =
|
||||
let val model = AppWith.mode (model, AppType.MOVE_MODE)
|
||||
in (model, [])
|
||||
end
|
||||
|
||||
fun handleFileBrowserAndPathInNormalMode (model, fileBrowser, path) =
|
||||
let val model = AppWith.fileBrowserAndPath (model, fileBrowser, path)
|
||||
in (model, [])
|
||||
end
|
||||
|
||||
fun flipHorizontally (model: app_type) =
|
||||
let
|
||||
val {layerTree, arrowX, arrowY, ...} = model
|
||||
@@ -409,7 +394,6 @@ struct
|
||||
| USE_LAYERS {tree, canvasWidth, canvasHeight} =>
|
||||
useLayers (model, tree, canvasWidth, canvasHeight)
|
||||
| SQUARES_LOAD_ERROR => CommonUpdate.squaresLoadError model
|
||||
| KEY_CTRL_O => enterBrowseMode model
|
||||
| ARROW_UP => moveArrowUp model
|
||||
| ARROW_LEFT => moveArrowLeft model
|
||||
| ARROW_RIGHT => moveArrowRight model
|
||||
@@ -417,6 +401,4 @@ struct
|
||||
| KEY_BACKSPACE => backspace model
|
||||
| KEY_ENTER => enterOrSpaceCoordinates model
|
||||
| KEY_SPACE => enterOrSpaceCoordinates model
|
||||
| FILE_BROWSER_AND_PATH {fileBrowser, path} =>
|
||||
handleFileBrowserAndPathInNormalMode (model, fileBrowser, path)
|
||||
end
|
||||
|
||||
@@ -45,36 +45,6 @@ struct
|
||||
TextIO.closeOut io
|
||||
end
|
||||
|
||||
fun getDirList (dir, acc, rootPath) =
|
||||
case OS.FileSys.readDir dir of
|
||||
SOME path =>
|
||||
let
|
||||
val folderPath = String.concat [rootPath, "/", path]
|
||||
in
|
||||
if OS.FileSys.isDir folderPath then
|
||||
getDirList (dir, AppType.IS_FOLDER path :: acc, rootPath)
|
||||
else if OS.FileSys.isLink folderPath then
|
||||
getDirList (dir, acc, rootPath)
|
||||
else
|
||||
getDirList (dir, AppType.IS_FILE path :: acc, rootPath)
|
||||
end
|
||||
| NONE => let val acc = List.rev acc in Vector.fromList acc end
|
||||
|
||||
fun loadFiles (path, inputMailbox) =
|
||||
let
|
||||
val path = if String.size path = 0 then OS.FileSys.getDir () else path
|
||||
val dir = OS.FileSys.openDir path
|
||||
val dirList = getDirList (dir, [], path)
|
||||
val _ = OS.FileSys.closeDir dir
|
||||
val inputMsg = FILE_BROWSER_AND_PATH {fileBrowser = dirList, path = path}
|
||||
in
|
||||
Mailbox.send (inputMailbox, inputMsg)
|
||||
end
|
||||
|
||||
fun selectPath (path, inputMailbox) =
|
||||
if OS.FileSys.isDir path then loadFiles (path, inputMailbox)
|
||||
else loadSquares (path, inputMailbox)
|
||||
|
||||
fun run (fileMailbox, inputMailbox) =
|
||||
let
|
||||
val _ =
|
||||
@@ -83,8 +53,6 @@ struct
|
||||
| EXPORT_SQUARES str => saveString (exportFilename, str)
|
||||
| EXPORT_COLLISIONS str => saveString (collisionFilename, str)
|
||||
| LOAD_SQUARES => loadSquares (filename, inputMailbox)
|
||||
| LOAD_FILES path => loadFiles (path, inputMailbox)
|
||||
| SELECT_PATH path => selectPath (path, inputMailbox)
|
||||
in
|
||||
run (fileMailbox, inputMailbox)
|
||||
end
|
||||
|
||||
@@ -128,10 +128,6 @@ 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 if
|
||||
key = Input.KEY_0 () andalso action = Input.PRESS () andalso mods = 0
|
||||
then
|
||||
|
||||
@@ -5,6 +5,4 @@ struct
|
||||
| LOAD_SQUARES
|
||||
| EXPORT_SQUARES of string
|
||||
| EXPORT_COLLISIONS of string
|
||||
| LOAD_FILES of string
|
||||
| SELECT_PATH of string
|
||||
end
|
||||
|
||||
@@ -22,7 +22,6 @@ struct
|
||||
| KEY_CTRL_S
|
||||
| KEY_CTRL_L
|
||||
| KEY_CTRL_E
|
||||
| KEY_CTRL_O
|
||||
| KEY_CTRL_C
|
||||
| KEY_ESC
|
||||
| NUM of int
|
||||
@@ -34,6 +33,4 @@ struct
|
||||
| KEY_SPACE
|
||||
| USE_LAYERS of {tree: LayerTree.t, canvasWidth: int, canvasHeight: int}
|
||||
| SQUARES_LOAD_ERROR
|
||||
| FILE_BROWSER_AND_PATH of
|
||||
{fileBrowser: AppType.file_browser_item vector, path: string}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user