diff --git a/src/platform/widget_builder_text_document.nim b/src/platform/widget_builder_text_document.nim index 337a81e4..5a35b7ec 100644 --- a/src/platform/widget_builder_text_document.nim +++ b/src/platform/widget_builder_text_document.nim @@ -2,12 +2,15 @@ import std/[strformat, tables, sugar, sequtils, strutils] import util, app, document_editor, text/text_editor, custom_logger, widgets, platform, theme, custom_unicode, config_provider import scripting_api except DocumentEditor, TextDocumentEditor, AstDocumentEditor import vmath, bumpy, chroma +import custom_logger import ui/node # Mark this entire file as used, otherwise we get warnings when importing it but only calling a method {.used.} +logCategory "widget_builder_text" + type CursorLocationInfo = tuple[node: UINode, text: string, bounds: Rect] when defined(js): @@ -62,18 +65,21 @@ proc renderLine*( if lineNumberText.len > 0: builder.panel(&{UINodeFlag.FillBackground, SizeToContentY}, w = lineNumberTotalWidth, backgroundColor = backgroundColor): - builder.panel(&{DrawText, SizeToContentX, SizeToContentY}, text = lineNumberText, x = lineNumberX, textColor = textColor): - lastPartXW = currentNode.bounds.xw + builder.panel(&{DrawText, SizeToContentX, SizeToContentY}, text = lineNumberText, x = lineNumberX, textColor = textColor) + lastPartXW = lineNumberTotalWidth for part in line.parts: defer: start += part.text.len startRune += part.text.runeLen + var partNode: UINode builder.panel(&{DrawText, FillBackground, SizeToContentX, SizeToContentY}, text = part.text): currentNode.backgroundColor = backgroundColor currentNode.textColor = if part.scope.len == 0: textColor else: app.theme.tokenColor(part, textColor) + partNode = currentNode + onClick Left: echo "clicked " @@ -85,7 +91,7 @@ proc renderLine*( let cursorX = builder.textWidth(int(selectionLastRune - startRune)).round result = some (currentNode, $part.text[selectionLastRune - startRune], rect(cursorX, 0, builder.charWidth, builder.textHeight)) - lastPartXW = currentNode.bounds.xw + lastPartXW = partNode.bounds.xw # cursor after latest char if curs.getSome(curs) and curs == lineOriginal.len: diff --git a/src/ui/node.nim b/src/ui/node.nim index 1ee42331..ce2c254a 100644 --- a/src/ui/node.nim +++ b/src/ui/node.nim @@ -452,6 +452,10 @@ proc returnNode*(builder: UINodeBuilder, node: UINode) = node.lastRenderTime = 0 node.mText = "" + node.mTextRuneLen = 0 + + node.pivot.x = 0 + node.pivot.y = 0 node.boundsOld.x = 0 node.boundsOld.y = 0 diff --git a/tests/unit/input/tinput.nim b/tests/unit/input/tinput.nim index 4362e5f6..83169210 100644 --- a/tests/unit/input/tinput.nim +++ b/tests/unit/input/tinput.nim @@ -2,7 +2,7 @@ discard """ action: "run" cmd: "nim $target --nimblePath:./nimbleDir/simplePkgs $options $file" timeout: 60 - targets: "c js vcc" + targets: "c js" matrix: "" """