remove code which became dead after reimplementing vi's 'k' motion

This commit is contained in:
2025-09-19 05:27:10 +01:00
parent 9ec8891ce5
commit 2c88341c37
2 changed files with 0 additions and 212 deletions

View File

@@ -273,217 +273,6 @@ struct
| (_, _) => (* nowhere to go rightward, so return cursorIdx *) cursorIdx | (_, _) => (* nowhere to go rightward, so return cursorIdx *) cursorIdx
end end
structure ViK =
MakeIfCharFolderPrev
(struct
type env = unit
fun helpViK
( strPos
, str
, absIdx
, lineColumn
, preferredColumn
, hasPassedLine
, strTl
, lineHd
, lineTl
) =
if strPos < 0 then
case (strTl, lineTl) of
(shd :: stl, lhd :: ltl) =>
helpViK
( String.size shd - 1
, shd
, absIdx
, lineColumn
, preferredColumn
, hasPassedLine
, stl
, lhd
, ltl
)
| (_, _) => (* empty, so return start of previous string *)
absIdx + 1
else
case String.sub (str, strPos) of
#"\n" =>
if hasPassedLine then
(* reached line break twice,
* but line has fewer chars than preferredColumn
* so go back to chr immediately after this second line break *)
absIdx + 1
else
(* reached start of line once;
* have to check if this is a double linebreak,
* and return idx of second linebreak if so *)
let
(* have to calculate column of current line
* so we know which line to stop searching at *)
val lineColumn = getCursorColumn
(strPos - 1, str, lineHd, strTl, lineTl, absIdx - 1)
in
helpViK
( strPos - 1
, str
, absIdx - 1
, lineColumn
, preferredColumn
, true
, strTl
, lineHd
, lineTl
)
end
| _ =>
if lineColumn <= preferredColumn andalso hasPassedLine then
(* We're at or before the preferredColumn so return absIdx
* context: current line may have fewer columns
* than our preferred column value.
* If this is the case, we want to check
* "is lineColumn equal to or before preferredColumn?". *)
absIdx
else
(* we're not in the preferred column, so keep iterating *)
helpViK
( strPos - 1
, str
, absIdx - 1
, lineColumn - 1
, preferredColumn
, hasPassedLine
, strTl
, lineHd
, lineTl
)
fun fStart (strIdx, shd, lhd, cursorIdx, leftStrings, leftLines, _) =
if String.sub (shd, strIdx) = #"\n" then
(* ? -> ? -> \n *)
if strIdx > 0 then
(* strIdx - 1 is in shd *)
if String.sub (shd, strIdx - 1) = #"\n" then
(* ? -> \n -> \n *)
if strIdx > 1 then
(* strIdx - 2 is in shd *)
if String.sub (shd, strIdx - 2) = #"\n" then
(* \n -> \n -> \n
* so it is safe to decrement cursorIdx by 1 *)
cursorIdx - 1
else
(* graphical-chr -> \n -> \n
* so go to beginning of line,
* starting from graphical-chr *)
startVi0
( strIdx - 2
, shd
, lhd
, cursorIdx - 2
, leftStrings
, leftLines
)
else
(* strIdx - 2 is in leftStrings *)
case (leftStrings, leftLines) of
(lshd :: lstl, llhd :: lltl) =>
if String.sub (lshd, String.size lshd - 1) = #"\n" then
(* \n -> \n -> \n
* so it is safe to decrement cursorIdx by 1 *)
cursorIdx - 1
else
(* graphical-chr -> \n -> \n
* so go to beginning of line,
* starting from graphical-chr *)
startVi0
( String.size lshd - 1
, lshd
, llhd
, cursorIdx - 2
, lstl
, lltl
)
| (_, _) =>
(* nothing to the left, so we are at start of buffer *)
0
else
(* ? -> graphical-chr -> \n
* Don't expect this case to happen
* but if it does, go to start of line. *)
startVi0
(strIdx - 1, shd, lhd, cursorIdx - 1, leftStrings, leftLines)
else
(* strIdx - 1 is in leftStrings *)
case (leftStrings, leftLines) of
(lshd :: lstl, llhd :: lltl) =>
if String.sub (lshd, String.size lshd - 1) = #"\n" then
(* ? -> \n -> \n *)
if String.size lshd > 1 then
(* cursorIdx - 2 is in this string *)
if String.sub (lshd, String.size lshd - 2) = #"\n" then
(* \n -> \n -> \n *)
cursorIdx - 1
else
(* graphical-chr -> \n -> \n *)
startVi0
( String.size lshd - 2
, lshd
, llhd
, cursorIdx - 2
, lstl
, lltl
)
else
(* cursorIdx - 2 is in lstl *)
(case (lstl, lltl) of
(stlhd :: stltl, ltlhd :: lltl) =>
if String.sub (stlhd, String.size stlhd - 1) = #"\n" then
(* \n -> \n -> \n *)
cursorIdx - 1
else
(* graphical-chr -> \n -> \n *)
startVi0
( String.size stlhd - 1
, stlhd
, ltlhd
, cursorIdx - 2
, lstl
, lltl
)
| (_, _) => 0)
else
(* ? -> graphical-chr -> \n *)
startVi0
( String.size lshd - 1
, lshd
, llhd
, cursorIdx - 1
, leftStrings
, leftLines
)
| (_, _) => (* leftStrings is empty so go to start of buffer *) 0
else
(* ? -> ? -> graphical-chr
* Normal case where we call startViK. *)
let
val lineColumn = getCursorColumn
(strIdx, shd, lhd, leftStrings, leftLines, cursorIdx)
in
helpViK
( strIdx
, shd
, cursorIdx
, lineColumn
, lineColumn
, false
, leftStrings
, lhd
, leftLines
)
end
end)
fun viK (lineGap, cursorIdx) = ViK.foldPrev (lineGap, cursorIdx, ())
(* equivalent of vi's 'w' command *) (* equivalent of vi's 'w' command *)
val nextWord = ViWordDfa.startOfNextWord val nextWord = ViWordDfa.startOfNextWord

View File

@@ -43,7 +43,6 @@ struct
end end
structure MoveViJ = MakeMove (struct val fMove = Cursor.viJ end) structure MoveViJ = MakeMove (struct val fMove = Cursor.viJ end)
structure MoveViK = MakeMove (struct val fMove = Cursor.viK end)
structure MoveToStartOfLine = MakeMove (struct val fMove = Cursor.vi0 end) structure MoveToStartOfLine = MakeMove (struct val fMove = Cursor.vi0 end)