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 if searchPos = ~1 then Vector.length searchList else searchPos
val env = Utils.initEnv val env = Utils.initEnv
( windowWidth ( 5
, 5
, windowWidth
, windowHeight , windowHeight
, floatWindowWidth , floatWindowWidth
, floatWindowHeight , floatWindowHeight

View File

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