expand comment to reflect a bit of planning

This commit is contained in:
2024-10-09 00:02:12 +01:00
parent 6e4cc9acff
commit 1ae15e5585
2 changed files with 18 additions and 12 deletions

View File

@@ -15,10 +15,16 @@ struct
(* builds text from a string with char-wrap. (* builds text from a string with char-wrap.
* char-wrap is a similar concept to word-wrap, * char-wrap is a similar concept to word-wrap,
* but it breaks on character in the middle of a word. * but it breaks on character in the middle of a word.
*
* Will likely want multiple versions of these two mutually recursive
* functions for each selection and cursor type:
* cursor over an individual character,
* range selection where multiple characters are selected, etc.
*
* Todo: * Todo:
* - Possibly add visual horizontal indentation when char-wrap occurs * - Possibly add visual horizontal indentation when char-wrap occurs
* on an indented line *) * on an indented line *)
fun buildTextString fun buildTextStringAfterCursor
( pos, str, acc, posX, posY, startX ( pos, str, acc, posX, posY, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight , windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b, tl , r, g, b, tl
@@ -28,7 +34,7 @@ struct
#" " => #" " =>
(* if space, then proceed forward one char (* if space, then proceed forward one char
* without adding to acc *) * without adding to acc *)
buildTextString buildTextStringAfterCursor
( pos + 1, str, acc, posX + xSpace, posY, startX ( pos + 1, str, acc, posX + xSpace, posY, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight , windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b, tl , r, g, b, tl
@@ -36,7 +42,7 @@ struct
| #"\t" => | #"\t" =>
(* if tab, proceed forward one char, (* if tab, proceed forward one char,
* and jump visually forwards three chars *) * and jump visually forwards three chars *)
buildTextString buildTextStringAfterCursor
( pos + 1, str, acc, posX + xSpace3, posY, startX ( pos + 1, str, acc, posX + xSpace3, posY, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight , windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b, tl , r, g, b, tl
@@ -46,7 +52,7 @@ struct
* assuming we have not exceeded the window's height. * assuming we have not exceeded the window's height.
* If we have exceeded the window's height, just return acc. *) * If we have exceeded the window's height, just return acc. *)
if posY + ySpace < windowHeight then if posY + ySpace < windowHeight then
buildTextString buildTextStringAfterCursor
( pos + 1, str, acc, startX, posY + ySpace, startX ( pos + 1, str, acc, startX, posY + ySpace, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight , windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b, tl , r, g, b, tl
@@ -62,13 +68,13 @@ struct
pos < String.size str - 1 pos < String.size str - 1
andalso String.sub (str, pos + 1) = #"\n" andalso String.sub (str, pos + 1) = #"\n"
then then
buildTextString buildTextStringAfterCursor
( pos + 2, str, acc, startX, posY + ySpace, startX ( pos + 2, str, acc, startX, posY + ySpace, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight , windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b, tl , r, g, b, tl
) )
else else
buildTextString buildTextStringAfterCursor
( pos + 1, str, acc, startX, posY + ySpace, startX ( pos + 1, str, acc, startX, posY + ySpace, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight , windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b, tl , r, g, b, tl
@@ -89,7 +95,7 @@ struct
(posX, posY, fontSize, fontSize, fWindowWidth, fWindowHeight, r, g, b) (posX, posY, fontSize, fontSize, fWindowWidth, fWindowHeight, r, g, b)
val acc = chrVec :: acc val acc = chrVec :: acc
in in
buildTextString buildTextStringAfterCursor
( pos + 1, str, acc, posX + xSpace, posY, startX ( pos + 1, str, acc, posX + xSpace, posY, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight , windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b, tl , r, g, b, tl
@@ -105,7 +111,7 @@ struct
) )
val acc = chrVec :: acc val acc = chrVec :: acc
in in
buildTextString buildTextStringAfterCursor
( pos + 1, str, acc, startX + xSpace, posY + ySpace, startX ( pos + 1, str, acc, startX + xSpace, posY + ySpace, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight , windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b, tl , r, g, b, tl
@@ -118,20 +124,20 @@ struct
else else
(* if we reached the end of the string, (* if we reached the end of the string,
* call function to build next string *) * call function to build next string *)
continueBuildTextLineGap continueBuildTextLineGapAfterCursor
( tl, acc, posX, posY, startX ( tl, acc, posX, posY, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight , windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b , r, g, b
) )
and continueBuildTextLineGap and continueBuildTextLineGapAfterCursor
( strList, acc, posX, posY, startX ( strList, acc, posX, posY, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight , windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b , r, g, b
) = ) =
case strList of case strList of
hd :: tl => hd :: tl =>
buildTextString buildTextStringAfterCursor
( 0, hd, acc, posX, posY, startX ( 0, hd, acc, posX, posY, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight , windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b, tl , r, g, b, tl
@@ -167,7 +173,7 @@ struct
else else
0 0
in in
buildTextString buildTextStringAfterCursor
( startIdx, rStrHd, [] ( startIdx, rStrHd, []
, 5, 5, 5 , 5, 5, 5
, windowWidth, windowHeight , windowWidth, windowHeight

BIN
shf

Binary file not shown.