fill in todo where strIdx is in tl, in text-window.sml function 'getStartLineWithCursorCentered
This commit is contained in:
@@ -196,7 +196,7 @@ struct
|
|||||||
case stl of
|
case stl of
|
||||||
hd :: tl =>
|
hd :: tl =>
|
||||||
getCursorStartLine
|
getCursorStartLine
|
||||||
(String.size hd - 1, str, lineNum, tl, maxW, halfH)
|
(String.size hd - 1, hd, lineNum, tl, maxW, halfH)
|
||||||
| [] =>
|
| [] =>
|
||||||
0
|
0
|
||||||
else
|
else
|
||||||
@@ -212,6 +212,30 @@ struct
|
|||||||
(strPos - 1, str, lineNum, stl, maxW, halfH)
|
(strPos - 1, str, lineNum, stl, maxW, halfH)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun getLineNum (strIdx, lhd, bufferLine) =
|
||||||
|
if Vector.length lhd = 0 then
|
||||||
|
bufferLine
|
||||||
|
else if Vector.length lhd = 1 then
|
||||||
|
let
|
||||||
|
val lineIdx = Vector.sub (lhd, 0)
|
||||||
|
in
|
||||||
|
if lineIdx < strIdx then
|
||||||
|
bufferLine + 1
|
||||||
|
else
|
||||||
|
bufferLine
|
||||||
|
end
|
||||||
|
else
|
||||||
|
let
|
||||||
|
val firstLineIdx = Vector.sub (lhd, 0)
|
||||||
|
in
|
||||||
|
if firstLineIdx > strIdx then
|
||||||
|
bufferLine
|
||||||
|
else if firstLineIdx < strIdx then
|
||||||
|
Cursor.binSearch (strIdx - 1, lhd) + bufferLine
|
||||||
|
else
|
||||||
|
bufferLine + 1
|
||||||
|
end
|
||||||
|
|
||||||
(* Prerequisite: LineGap is moved to cursor *)
|
(* Prerequisite: LineGap is moved to cursor *)
|
||||||
fun getStartLineWithCursorCentered
|
fun getStartLineWithCursorCentered
|
||||||
(lineGap: LineGap.t, cursorIdx, origLine, maxWidth, maxHeight) =
|
(lineGap: LineGap.t, cursorIdx, origLine, maxWidth, maxHeight) =
|
||||||
@@ -227,36 +251,26 @@ struct
|
|||||||
if strIdx < String.size shd then
|
if strIdx < String.size shd then
|
||||||
(* strIdx is in hd *)
|
(* strIdx is in hd *)
|
||||||
let
|
let
|
||||||
val lineNum =
|
val lineNum = getLineNum (strIdx, lhd, bufferLine)
|
||||||
if Vector.length lhd = 0 then
|
|
||||||
bufferLine
|
|
||||||
else if Vector.length lhd = 1 then
|
|
||||||
let
|
|
||||||
val lineIdx = Vector.sub (lhd, 0)
|
|
||||||
in
|
|
||||||
if lineIdx < strIdx then
|
|
||||||
bufferLine + 1
|
|
||||||
else
|
|
||||||
bufferLine
|
|
||||||
end
|
|
||||||
else
|
|
||||||
let
|
|
||||||
val firstLineIdx = Vector.sub (lhd, 0)
|
|
||||||
in
|
|
||||||
if firstLineIdx > strIdx then
|
|
||||||
bufferLine
|
|
||||||
else if firstLineIdx < strIdx then
|
|
||||||
Cursor.binSearch (strIdx - 1, lhd) + bufferLine
|
|
||||||
else
|
|
||||||
bufferLine + 1
|
|
||||||
end
|
|
||||||
in
|
in
|
||||||
getCursorStartLine
|
getCursorStartLine
|
||||||
(strIdx, shd, lineNum, leftStrings, maxWidth, maxHeight)
|
(strIdx, shd, lineNum, leftStrings, maxWidth, maxHeight)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(* todo: strIdx is in tl *)
|
(* strIdx is in tl *)
|
||||||
raise Match
|
case (stl, ltl) of
|
||||||
|
(stlhd :: stltl, ltlhd :: _) =>
|
||||||
|
let
|
||||||
|
val strIdx = strIdx - String.size shd
|
||||||
|
val bufferLine = bufferLine + Vector.length lhd
|
||||||
|
val lineNum = getLineNum (strIdx, ltlhd, bufferLine)
|
||||||
|
val leftStrings = shd :: leftStrings
|
||||||
|
in
|
||||||
|
getCursorStartLine
|
||||||
|
(strIdx, stlhd, lineNum, leftStrings, maxWidth, maxHeight)
|
||||||
|
end
|
||||||
|
| (_, _) =>
|
||||||
|
origLine
|
||||||
end
|
end
|
||||||
| (_, _) =>
|
| (_, _) =>
|
||||||
origLine
|
origLine
|
||||||
|
|||||||
Reference in New Issue
Block a user