a little refactoring
This commit is contained in:
@@ -1290,7 +1290,7 @@ struct
|
|||||||
(* tl is empty; just return absIdx *)
|
(* tl is empty; just return absIdx *)
|
||||||
absIdx
|
absIdx
|
||||||
|
|
||||||
fun toNextChr (lineGap: LineGap.t, cursorIdx, chr) =
|
fun nextChr (lineGap: LineGap.t, cursorIdx, chr, fStart) =
|
||||||
let
|
let
|
||||||
val {rightStrings, rightLines, idx = bufferIdx, ...} = lineGap
|
val {rightStrings, rightLines, idx = bufferIdx, ...} = lineGap
|
||||||
in
|
in
|
||||||
@@ -1302,7 +1302,7 @@ struct
|
|||||||
in
|
in
|
||||||
if strIdx < String.size shd then
|
if strIdx < String.size shd then
|
||||||
(* strIdx is in this string *)
|
(* strIdx is in this string *)
|
||||||
startToNextChr
|
fStart
|
||||||
(shd, strIdx, cursorIdx, stl, ltl, chr)
|
(shd, strIdx, cursorIdx, stl, ltl, chr)
|
||||||
else
|
else
|
||||||
(* strIdx is in tl *)
|
(* strIdx is in tl *)
|
||||||
@@ -1311,7 +1311,7 @@ struct
|
|||||||
let
|
let
|
||||||
val strIdx = strIdx - String.size shd
|
val strIdx = strIdx - String.size shd
|
||||||
in
|
in
|
||||||
startToNextChr
|
fStart
|
||||||
(shd, strIdx, cursorIdx, stltl, ltltl, chr)
|
(shd, strIdx, cursorIdx, stltl, ltltl, chr)
|
||||||
end
|
end
|
||||||
| (_, _) => cursorIdx)
|
| (_, _) => cursorIdx)
|
||||||
@@ -1360,37 +1360,14 @@ struct
|
|||||||
(* tl is empty; just return absIdx *)
|
(* tl is empty; just return absIdx *)
|
||||||
absIdx
|
absIdx
|
||||||
|
|
||||||
fun tillNextChr (lineGap: LineGap.t, cursorIdx, chr) =
|
fun tillNextChr (lineGap, cursorIdx, chr) =
|
||||||
let
|
nextChr (lineGap, cursorIdx, chr, startTillNextChr)
|
||||||
val {rightStrings, rightLines, idx = bufferIdx, ...} = lineGap
|
|
||||||
in
|
fun toNextChr (lineGap, cursorIdx, chr) =
|
||||||
case (rightStrings, rightLines) of
|
nextChr (lineGap, cursorIdx, chr, startToNextChr)
|
||||||
(shd :: stl, lhd :: ltl) =>
|
|
||||||
let
|
|
||||||
(* convert absolute cursorIdx to idx relative to hd string *)
|
|
||||||
val strIdx = cursorIdx - bufferIdx
|
|
||||||
in
|
|
||||||
if strIdx < String.size shd then
|
|
||||||
(* strIdx is in this string *)
|
|
||||||
startTillNextChr
|
|
||||||
(shd, strIdx, cursorIdx, stl, ltl, chr)
|
|
||||||
else
|
|
||||||
(* strIdx is in tl *)
|
|
||||||
(case (stl, ltl) of
|
|
||||||
(stlhd :: stltl, ltlhd :: ltltl) =>
|
|
||||||
let
|
|
||||||
val strIdx = strIdx - String.size shd
|
|
||||||
in
|
|
||||||
startTillNextChr
|
|
||||||
(shd, strIdx, cursorIdx, stltl, ltltl, chr)
|
|
||||||
end
|
|
||||||
| (_, _) => cursorIdx)
|
|
||||||
end
|
|
||||||
| (_, _) => cursorIdx
|
|
||||||
end
|
|
||||||
|
|
||||||
fun helpToPrevChr (strPos, str, absIdx, stl, ltl, origIdx, findChr) =
|
fun helpToPrevChr (strPos, str, absIdx, stl, ltl, origIdx, findChr) =
|
||||||
if strPos = 0 then
|
if strPos < 0 then
|
||||||
case (stl, ltl) of
|
case (stl, ltl) of
|
||||||
(shd :: stl, lhd :: ltl) =>
|
(shd :: stl, lhd :: ltl) =>
|
||||||
helpToPrevChr
|
helpToPrevChr
|
||||||
|
|||||||
Reference in New Issue
Block a user