add function to get the appropriate scroll column
This commit is contained in:
@@ -14,6 +14,10 @@ struct
|
|||||||
let
|
let
|
||||||
val {windowWidth, windowHeight, startLine, searchString, ...} = app
|
val {windowWidth, windowHeight, startLine, searchString, ...} = app
|
||||||
|
|
||||||
|
(* calculate scroll column *)
|
||||||
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
val visualScrollColumn = TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth)
|
||||||
|
|
||||||
(* move LineGap to first line displayed on screen *)
|
(* move LineGap to first line displayed on screen *)
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
|
||||||
|
|||||||
@@ -4,5 +4,7 @@ struct
|
|||||||
val xSpace3 = xSpace * 3
|
val xSpace3 = xSpace * 3
|
||||||
val ySpace = 25
|
val ySpace = 25
|
||||||
val scale: Real32.real = 2.0
|
val scale: Real32.real = 2.0
|
||||||
val textLineWidth = xSpace * 80
|
|
||||||
|
val textLineCount = 80
|
||||||
|
val textLineWidth = xSpace * textLineCount
|
||||||
end
|
end
|
||||||
|
|||||||
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
|
||||||
1
shf.mlb
1
shf.mlb
@@ -40,6 +40,7 @@ in
|
|||||||
end
|
end
|
||||||
fcore/cursor.sml
|
fcore/cursor.sml
|
||||||
fcore/text-window.sml
|
fcore/text-window.sml
|
||||||
|
fcore/text-scroll.sml
|
||||||
|
|
||||||
fcore/normal-mode/normal-finish.sml
|
fcore/normal-mode/normal-finish.sml
|
||||||
fcore/normal-mode/normal-search-finish.sml
|
fcore/normal-mode/normal-search-finish.sml
|
||||||
|
|||||||
Reference in New Issue
Block a user