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:
2025-08-26 15:36:39 +01:00
parent 6c9149bfaa
commit a98ca50cf5
14 changed files with 1 additions and 414 deletions

View File

@@ -39,8 +39,6 @@ struct
, arrowX = 0
, arrowY = 0
, openFilePath = ""
, fileBrowser = Vector.fromList []
, fileBrowserIdx = 0
, r = 0
, g = 0
, b = 0

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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