diff --git a/fcore/text-builder.sml b/fcore/text-builder.sml index 71ebb5d..cb27c58 100644 --- a/fcore/text-builder.sml +++ b/fcore/text-builder.sml @@ -26,6 +26,34 @@ struct [DRAW textMsg, DRAW cursorMsg] 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. * char-wrap is a similar concept to word-wrap, * but it breaks on character in the middle of a word. @@ -298,6 +326,11 @@ struct | chr => let val chrFun = Vector.sub (CozetteAscii.asciiTable, Char.ord chr) + val cursorAcc = + if absIdx <> cursorPos then + buildCursor (posX, posY, fWindowWidth, fWindowHeight) + else + cursorAcc in if posX + xSpace < windowWidth then let diff --git a/shell/gl-draw.sml b/shell/gl-draw.sml index 588bb50..fbee559 100644 --- a/shell/gl-draw.sml +++ b/shell/gl-draw.sml @@ -157,6 +157,7 @@ struct , cursorProgram , ... } = drawObject + val _ = drawXyrgb (cursorVertexBuffer, cursorProgram, cursorDrawLength) val _ = drawXyrgb (textVertexBuffer, textProgram, textDrawLength) in diff --git a/shf b/shf index e68c042..d1cffd4 100755 Binary files a/shf and b/shf differ diff --git a/shf.mlb b/shf.mlb index 0f47832..4131f39 100644 --- a/shf.mlb +++ b/shf.mlb @@ -11,7 +11,11 @@ message-types/mailbox-type.sml fcore/app-type.sml fcore/app-with.sml -fcore/text-builder.sml +ann + "allowVectorExps true" +in + fcore/text-builder.sml +end fcore/app-update.sml (* IMPERATIVE SHELL *)