remove some dead code
This commit is contained in:
@@ -59,79 +59,6 @@ struct
|
|||||||
val viL = ViLDfa.next
|
val viL = ViLDfa.next
|
||||||
val viH = ViHDfa.prev
|
val viH = ViHDfa.prev
|
||||||
|
|
||||||
fun helpGetCursorColumn (distanceFromLine, strList, lineList) =
|
|
||||||
case (strList, lineList) of
|
|
||||||
(strHd :: strTl, lnHd :: lnTl) =>
|
|
||||||
if Vector.length lnHd = 0 then
|
|
||||||
(* lnHd is empty, so line is not here *)
|
|
||||||
helpGetCursorColumn
|
|
||||||
(distanceFromLine + String.size strHd, strTl, lnTl)
|
|
||||||
else
|
|
||||||
(* lnHd is not empty, meaning last lineIdx is closest linebreak *)
|
|
||||||
let
|
|
||||||
val lineIdx = Vector.sub (lnHd, Vector.length lnHd - 1)
|
|
||||||
(* number of chars after the lineIdx *)
|
|
||||||
val idxAfterLn = String.size strHd - lineIdx
|
|
||||||
in
|
|
||||||
distanceFromLine + idxAfterLn - 1
|
|
||||||
end
|
|
||||||
| (_, _) => distanceFromLine
|
|
||||||
|
|
||||||
fun helpGetCursorColumnLeft (leftStrings, leftLines, cursorIdx) =
|
|
||||||
case (leftStrings, leftLines) of
|
|
||||||
(lshd :: lstl, llhd :: lltl) =>
|
|
||||||
let
|
|
||||||
val cursorIdx = cursorIdx - String.size lshd
|
|
||||||
in
|
|
||||||
if Vector.length llhd > 0 then
|
|
||||||
let val lnIdx = Vector.sub (llhd, Vector.length llhd - 1)
|
|
||||||
in lnIdx + cursorIdx
|
|
||||||
end
|
|
||||||
else
|
|
||||||
helpGetCursorColumnLeft (lstl, lltl, cursorIdx)
|
|
||||||
end
|
|
||||||
| (_, _) => Int.max (cursorIdx, 0)
|
|
||||||
|
|
||||||
fun getCursorColumn (strIdx, strHd, lnHd, leftStrings, leftLines, cursorIdx) =
|
|
||||||
if Vector.length lnHd > 0 then
|
|
||||||
let
|
|
||||||
val firstLn = Vector.sub (lnHd, 0)
|
|
||||||
in
|
|
||||||
if firstLn > strIdx then
|
|
||||||
(* search left strings/lines *)
|
|
||||||
let
|
|
||||||
val lineIdx =
|
|
||||||
helpGetCursorColumnLeft
|
|
||||||
(leftStrings, leftLines, cursorIdx - strIdx)
|
|
||||||
in
|
|
||||||
if lineIdx = 0 then cursorIdx else cursorIdx - lineIdx - 1
|
|
||||||
end
|
|
||||||
else if firstLn < strIdx then
|
|
||||||
(* binary search in here
|
|
||||||
* because we know lnHd definitely contains
|
|
||||||
* a lineIdx less or equal to strIdx *)
|
|
||||||
let
|
|
||||||
(* todo: what if BinSearch doesn't find anything? *)
|
|
||||||
val lnIdx = BinSearch.equalOrLess (strIdx, lnHd)
|
|
||||||
val lnIdx = Vector.sub (lnHd, lnIdx)
|
|
||||||
in
|
|
||||||
if lnIdx < strIdx then strIdx - lnIdx - 1
|
|
||||||
else (* firstLn = strIdx *) 0
|
|
||||||
end
|
|
||||||
else
|
|
||||||
(* firstLn = strIdx
|
|
||||||
* meaning that we are already at a line break
|
|
||||||
* and that the column is 0 *)
|
|
||||||
0
|
|
||||||
end
|
|
||||||
else
|
|
||||||
let
|
|
||||||
val lineIdx =
|
|
||||||
helpGetCursorColumnLeft (leftStrings, leftLines, cursorIdx - strIdx)
|
|
||||||
in
|
|
||||||
if lineIdx = 0 then cursorIdx else cursorIdx - lineIdx - 1
|
|
||||||
end
|
|
||||||
|
|
||||||
(* equivalent of vi's 'w' command *)
|
(* equivalent of vi's 'w' command *)
|
||||||
val nextWord = ViWordDfa.startOfNextWord
|
val nextWord = ViWordDfa.startOfNextWord
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user