progress drawing cursor

This commit is contained in:
2024-10-09 11:59:41 +01:00
parent 2afc54abc5
commit 5cc4357cc7
4 changed files with 39 additions and 1 deletions

View File

@@ -26,6 +26,34 @@ struct
[DRAW textMsg, DRAW cursorMsg] [DRAW textMsg, DRAW cursorMsg]
end end
fun buildCursor (posX, posY, fWindowWidth, fWindowHeight) =
let
val top = Real32.fromInt posX
val left = Real32.fromInt posY
val right = left + fontSize
val bottom = top + fontSize
val halfHeight = fWindowHeight / 2.0
val top = (~(top - halfHeight)) / halfHeight
val bottom = (~(bottom - halfHeight)) / halfHeight
val halfWidth = fWindowWidth / 2.0
val left = (left - halfWidth) / halfWidth
val right = (right - halfWidth) / halfWidth
val vec =
#[ left, top, 1.0, 1.0, 1.0
, right, top, 1.0, 1.0, 1.0
, left, bottom, 1.0, 1.0, 1.0
, left, bottom, 1.0, 1.0, 1.0
, right, bottom, 1.0, 1.0, 1.0
, right, top, 1.0, 1.0, 1.0
]
in
[vec]
end
(* 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.
@@ -298,6 +326,11 @@ struct
| chr => | chr =>
let let
val chrFun = Vector.sub (CozetteAscii.asciiTable, Char.ord chr) val chrFun = Vector.sub (CozetteAscii.asciiTable, Char.ord chr)
val cursorAcc =
if absIdx <> cursorPos then
buildCursor (posX, posY, fWindowWidth, fWindowHeight)
else
cursorAcc
in in
if posX + xSpace < windowWidth then if posX + xSpace < windowWidth then
let let

View File

@@ -157,6 +157,7 @@ struct
, cursorProgram , cursorProgram
, ... , ...
} = drawObject } = drawObject
val _ = drawXyrgb (cursorVertexBuffer, cursorProgram, cursorDrawLength) val _ = drawXyrgb (cursorVertexBuffer, cursorProgram, cursorDrawLength)
val _ = drawXyrgb (textVertexBuffer, textProgram, textDrawLength) val _ = drawXyrgb (textVertexBuffer, textProgram, textDrawLength)
in in

BIN
shf

Binary file not shown.

View File

@@ -11,7 +11,11 @@ message-types/mailbox-type.sml
fcore/app-type.sml fcore/app-type.sml
fcore/app-with.sml fcore/app-with.sml
fcore/text-builder.sml ann
"allowVectorExps true"
in
fcore/text-builder.sml
end
fcore/app-update.sml fcore/app-update.sml
(* IMPERATIVE SHELL *) (* IMPERATIVE SHELL *)