diff options
author | bptato <nincsnevem662@gmail.com> | 2024-09-28 17:29:12 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-09-28 17:54:08 +0200 |
commit | 9c257361388f5007871a36eea3abc815a8740d66 (patch) | |
tree | 3c9494ecfa6467438043402594bb2d2b7bd262eb /src/layout/renderdocument.nim | |
parent | 1bbad9a452390ebc09d038e25ed0307f3fdcd312 (diff) | |
download | chawan-9c257361388f5007871a36eea3abc815a8740d66.tar.gz |
container: fix control char display
Also, kill twidth and its friends; we haven't been using it for a while now. (In the future, a solution with PUA chars might be worth exploring.)
Diffstat (limited to 'src/layout/renderdocument.nim')
-rw-r--r-- | src/layout/renderdocument.nim | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/layout/renderdocument.nim b/src/layout/renderdocument.nim index 5c8ac4a7..7a4797ac 100644 --- a/src/layout/renderdocument.nim +++ b/src/layout/renderdocument.nim @@ -77,7 +77,7 @@ proc findFirstX(line: var FlexibleLine; x: int; outi: var int): int = while cx < x and i < line.str.len: let pi = i let u = line.str.nextUTF8(i) - let w = u.twidth(cx) + let w = u.width() # we must ensure x is max(cx, x), otherwise our assumption of cx <= x # breaks down if cx + w > x: @@ -194,13 +194,13 @@ proc setTextFormat(line: var FlexibleLine; x, cx, nx: int; ostr: string; proc setText(line: var FlexibleLine; linestr: string; x: int; format: Format; node: StyledNode) = assert x >= 0 and linestr.len != 0 - var targetX = x + linestr.twidth(x) + var targetX = x + linestr.width() var i = 0 var cx = line.findFirstX(x, i) # first x of new string (before padding) var j = i var nx = x # last x of new string while nx < targetX and j < line.str.len: - nx += line.str.nextUTF8(j).twidth(nx) + nx += line.str.nextUTF8(j).width() let ostr = line.str.substr(j) line.setTextStr(linestr, ostr, i, x, cx, nx, targetX) line.setTextFormat(x, cx, nx, ostr, format, node) @@ -210,7 +210,7 @@ proc setText(grid: var FlexibleGrid; linestr: string; x, y: int; format: Format; var x = x var i = 0 while x < 0 and i < linestr.len: - x += linestr.nextUTF8(i).twidth(x) + x += linestr.nextUTF8(i).width() if x < 0: # highest x is outside the canvas, no need to draw return |