diff options
author | bptato <nincsnevem662@gmail.com> | 2021-11-13 00:44:40 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2021-11-13 00:51:24 +0100 |
commit | 5ed6ccd8e2422c28734842488896f5cbb012916c (patch) | |
tree | b3ad995d9e3f05a2c0d61240a5a6fb112483ff0f /src/io | |
parent | 07552bcd0fb7bfed92321cc2e7e421846670ce95 (diff) | |
download | chawan-5ed6ccd8e2422c28734842488896f5cbb012916c.tar.gz |
Implement text-decoration
Diffstat (limited to 'src/io')
-rw-r--r-- | src/io/buffer.nim | 15 | ||||
-rw-r--r-- | src/io/cell.nim | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/io/buffer.nim b/src/io/buffer.nim index 47148363..79f8415b 100644 --- a/src/io/buffer.nim +++ b/src/io/buffer.nim @@ -76,8 +76,7 @@ func generateFullOutput*(buffer: Buffer): seq[string] = result.add(s) x = 0 s = "" - - s &= "\e[0m" + s &= "\e[m" if cell.fgcolor != defaultColor: var color = cell.fgcolor if color.rgb: @@ -100,6 +99,10 @@ func generateFullOutput*(buffer: Buffer): seq[string] = s &= "\e[3m" if cell.underline: s &= "\e[4m" + if cell.strike: + s &= "\e[9m" + if cell.overline: + s &= "\e[53m" s &= $cell.runes inc x @@ -556,6 +559,12 @@ func cellFromLine(line: CSSRowBox, i: int): FlexibleCell = result.italic = true if line.fontweight > 500: result.bold = true + if line.textdecoration == TEXT_DECORATION_UNDERLINE: + result.underline = true + if line.textdecoration == TEXT_DECORATION_OVERLINE: + result.overline = true + if line.textdecoration == TEXT_DECORATION_LINE_THROUGH: + result.strike = true proc setRowBox(buffer: Buffer, line: CSSRowBox) = let x = line.x @@ -639,6 +648,8 @@ proc refreshDisplay*(buffer: Buffer) = buffer.display[dls + j - n].italic = line[i].italic buffer.display[dls + j - n].bold = line[i].bold buffer.display[dls + j - n].underline = line[i].underline + buffer.display[dls + j - n].strike = line[i].strike + buffer.display[dls + j - n].overline = line[i].overline j += line[i].rune.width() inc i diff --git a/src/io/cell.nim b/src/io/cell.nim index 6ea887e3..50094e88 100644 --- a/src/io/cell.nim +++ b/src/io/cell.nim @@ -10,6 +10,8 @@ type italic*: bool bold*: bool underline*: bool + strike*: bool + overline*: bool FlexibleCell* = object of Cell rune*: Rune |