diff options
author | bptato <nincsnevem662@gmail.com> | 2022-08-03 17:17:09 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-08-03 17:17:09 +0200 |
commit | ad5adef77d2aa285cdfdce9917514c0e12cbc5b1 (patch) | |
tree | dfe6427bfc2c6e6223979f6c371725b92f26ae07 | |
parent | ec26d22cedb03fd8a03c110fad6b6a91c444329b (diff) | |
download | chawan-ad5adef77d2aa285cdfdce9917514c0e12cbc5b1.tar.gz |
Store FixedCell contents as str
-rw-r--r-- | src/io/buffer.nim | 17 | ||||
-rw-r--r-- | src/io/cell.nim | 7 |
2 files changed, 11 insertions, 13 deletions
diff --git a/src/io/buffer.nim b/src/io/buffer.nim index 15853da7..5a475f96 100644 --- a/src/io/buffer.nim +++ b/src/io/buffer.nim @@ -100,7 +100,7 @@ func generateFullOutput(buffer: Buffer): string = w = 0 result &= format.processFormat(cell.format) - result &= $cell.runes + result &= cell.str w += cell.width() inc x @@ -132,7 +132,7 @@ func generateSwapOutput(buffer: Buffer): string = line = "" lr = lr or (curr[i] != prev[i]) line &= format.processFormat(curr[i].format) - line &= $curr[i].runes + line &= curr[i].str inc i inc x if lr: @@ -185,7 +185,7 @@ func generateStatusMessage*(buffer: Buffer): string = var w = 0 for cell in buffer.statusmsg: result &= format.processFormat(cell.format) - result &= $cell.runes + result &= cell.str w += cell.width() if w < buffer.width: result &= EL() @@ -210,7 +210,7 @@ func acursory(buffer: Buffer): int = func cellOrigin(buffer: Buffer, x, y: int): int = let row = y * buffer.width var ox = x - while ox > 0 and buffer.display[row + ox].runes.len == 0: + while ox > 0 and buffer.display[row + ox].str.len == 0: dec ox return ox @@ -336,7 +336,7 @@ proc refreshDisplay(buffer: Buffer) = var k = 0 if w > buffer.fromx: while k < w - buffer.fromx: - buffer.display[dls + k].runes.add(Rune(' ')) + buffer.display[dls + k].str &= ' ' inc k var cf = line.findFormat(w) @@ -354,7 +354,7 @@ proc refreshDisplay(buffer: Buffer) = if nf.pos != -1 and nf.pos <= pw: cf = nf nf = line.findNextFormat(pw) - buffer.display[dls + k].runes.add(r) + buffer.display[dls + k].str &= r if cf.pos != -1: buffer.display[dls + k].format = cf.format buffer.display[dls + k].node = cf.node @@ -896,10 +896,9 @@ proc writeStatusMessage(buffer: Buffer, str: string, format: Format = Format()) for r in str.runes: i += r.width() if i >= buffer.statusmsg.len: - buffer.statusmsg[^1].runes.setLen(0) - buffer.statusmsg[^1].runes.add(Rune('$')) + buffer.statusmsg[^1].str = "$" break - buffer.statusmsg[i].runes.add(r) + buffer.statusmsg[i].str &= r buffer.statusmsg[i].format = format proc statusMsgForBuffer(buffer: Buffer) = diff --git a/src/io/cell.nim b/src/io/cell.nim index 2faced78..8c5333b1 100644 --- a/src/io/cell.nim +++ b/src/io/cell.nim @@ -2,7 +2,6 @@ import sequtils import streams import strutils import sugar -import unicode import css/stylednode import layout/box @@ -47,7 +46,7 @@ type FlexibleGrid* = seq[FlexibleLine] FixedCell* = object of Cell - runes*: seq[Rune] + str*: string FixedGrid* = seq[FixedCell] @@ -75,7 +74,7 @@ template `blink=`*(f: var Format, b: bool) = flag_template f, b, FLAG_BLINK func `==`*(a: FixedCell, b: FixedCell): bool = return a.format == b.format and - a.runes == b.runes and + a.str == b.str and a.node == b.node func newFixedGrid*(w: int, h: int = 1): FixedGrid = @@ -85,7 +84,7 @@ func width*(line: FlexibleLine): int = return line.str.width() func width*(cell: FixedCell): int = - return cell.runes.width() + return cell.str.width() func newFormat*(): Format = return Format(fgcolor: defaultColor, bgcolor: defaultColor) |