add function to get the appropriate scroll column
This commit is contained in:
22
fcore/text-scroll.sml
Normal file
22
fcore/text-scroll.sml
Normal file
@@ -0,0 +1,22 @@
|
||||
structure TextScroll =
|
||||
struct
|
||||
structure TC = TextConstants
|
||||
|
||||
(* Preqreuisite: move buffer to cursorIdx *)
|
||||
fun getScrollColumn (buffer, cursorIdx, windowWidth) =
|
||||
let
|
||||
val startOfLine = Cursor.vi0 (buffer, cursorIdx)
|
||||
val columnDifference = cursorIdx - startOfLine
|
||||
in
|
||||
if columnDifference = 0 then
|
||||
0
|
||||
else
|
||||
let
|
||||
val howManyColumnsCanWeFit =
|
||||
if windowWidth >= TC.textLineWidth then TC.textLineCount
|
||||
else windowWidth div TC.xSpace
|
||||
in
|
||||
columnDifference mod howManyColumnsCanWeFit
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user