modify 'TextBuilder.initEnv' function to take 'startX' and 'startY' parameters, instead of hardcoding the startX/Y inside the function, and change width/height calculations to take these parameters into account

This commit is contained in:
2025-09-14 08:24:37 +01:00
parent 2ab48626cd
commit 120568a18d
2 changed files with 63 additions and 65 deletions

View File

@@ -35,7 +35,9 @@ struct
if searchPos = ~1 then Vector.length searchList else searchPos
val env = Utils.initEnv
( windowWidth
( 5
, 5
, windowWidth
, windowHeight
, floatWindowWidth
, floatWindowHeight

View File

@@ -44,7 +44,9 @@ struct
}
fun initEnv
( endX
( startX
, startY
, endX
, endY
, floatWindowWidth
, floatWindowHeight
@@ -53,7 +55,17 @@ struct
, visualScrollColumn
, startLine
) : env_data =
if TC.textLineWidth > endX then
let
val width = endX - startX
val lastLineNumber =
let
val height = endY - startY
val howManyLines = height div TC.ySpace
in
startLine + howManyLines
end
in
if TC.textLineWidth > width then
{ charR = 0.67
, charG = 0.51
, charB = 0.83
@@ -82,17 +94,8 @@ struct
, startY = 5
, scrollColumnStart = visualScrollColumn
, scrollColumnEnd = let val width = endX - 5
in width div TC.xSpace + visualScrollColumn
end
, lastLineNumber =
let
val height = endY - 5
val howManyLines = height div TC.ySpace
in
startLine + howManyLines
end
, scrollColumnEnd = width div TC.xSpace + visualScrollColumn
, lastLineNumber = lastLineNumber
, fw = floatWindowWidth
, fh = floatWindowHeight
@@ -103,7 +106,6 @@ struct
else
let
val startX = (endX - TC.textLineWidth) div 2
val finishWidth = startX + TC.textLineWidth
in
{ charR = 0.67
, charG = 0.51
@@ -130,18 +132,11 @@ struct
, highlightZ = 0.05
, startX = startX
, startY = 5
, startY = startY
, scrollColumnStart = visualScrollColumn
, scrollColumnEnd = visualScrollColumn + TC.textLineCount
, lastLineNumber =
let
val height = endY - 5
val howManyLines = height div TC.ySpace
in
startLine + howManyLines
end
, lastLineNumber = lastLineNumber
, fw = floatWindowWidth
, fh = floatWindowHeight
@@ -150,6 +145,7 @@ struct
, searchLen = searchLen
}
end
end
(* different functions to make vectors of different things we want to draw. *)
fun makeCursor (posX, posY, env: env_data) =