diff options
author | bptato <nincsnevem662@gmail.com> | 2022-12-07 19:02:56 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-12-07 19:02:56 +0100 |
commit | 31162225df672187e4b73423ac2f4bc25937fd3f (patch) | |
tree | 7c52d54677897b4eaa258592bfa96d3b7b303505 /src/display | |
parent | eb61a176754a565a5c53562993897388fa2d260c (diff) | |
download | chawan-31162225df672187e4b73423ac2f4bc25937fd3f.tar.gz |
Add multiple text-decoration, overline emulation
Diffstat (limited to 'src/display')
-rw-r--r-- | src/display/term.nim | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/display/term.nim b/src/display/term.nim index eb061d99..beb84a4c 100644 --- a/src/display/term.nim +++ b/src/display/term.nim @@ -332,10 +332,27 @@ proc hideCursor*(term: Terminal) = proc showCursor*(term: Terminal) = term.outfile.showCursor() +func emulateOverline(term: Terminal): bool = + term.config.emulateoverline and FLAG_OVERLINE notin term.formatmode and + FLAG_UNDERLINE in term.formatmode + proc writeGrid*(term: Terminal, grid: FixedGrid, x = 0, y = 0) = for ly in y ..< y + grid.height: for lx in x ..< x + grid.width: - term.canvas[ly * term.canvas.width + lx] = grid[(ly - y) * grid.width + (lx - x)] + let i = ly * term.canvas.width + lx + term.canvas[i] = grid[(ly - y) * grid.width + (lx - x)] + if i >= term.canvas.width and FLAG_OVERLINE in term.canvas[i].format.flags and term.emulateOverline: + let w = grid[(ly - y) * grid.width + (lx - x)].width() + let s = i - term.canvas.width + var j = s + while j < term.canvas.len and j < s + w: + let cell = addr term.canvas[j] + cell.format.flags.incl(FLAG_UNDERLINE) + if cell.str == "": + cell.str = " " + if cell.str == " ": + cell.format.fgcolor = grid[(ly - y) * grid.width + (lx - x)].format.fgcolor + j += cell[].width() proc outputGrid*(term: Terminal) = term.outfile.write(term.resetFormat()) @@ -449,6 +466,9 @@ proc detectTermAttributes(term: Terminal) = of "24bit", "truecolor": term.colormode = TRUE_COLOR if term.config.formatmode.isSome: term.formatmode = term.config.formatmode.get + for fm in FormatFlags: + if fm in term.config.noformatmode: + term.formatmode.excl(fm) if term.config.altscreen.isSome: term.smcup = term.config.altscreen.get term.mincontrast = term.config.mincontrast |