aboutsummaryrefslogtreecommitdiffstats
path: root/src/io
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-11-21 20:18:42 +0100
committerbptato <nincsnevem662@gmail.com>2022-11-21 20:18:42 +0100
commit95444650537805d414deec706ad98e37df8b88db (patch)
tree9e7db0636bad99e934c76d7ce542c01d9dd2354c /src/io
parent652251c2f7a4ea8d8854e4987689005a3bfd318e (diff)
downloadchawan-95444650537805d414deec706ad98e37df8b88db.tar.gz
Add alt-screen option, fix an ansi color bug
Diffstat (limited to 'src/io')
-rw-r--r--src/io/term.nim14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/io/term.nim b/src/io/term.nim
index efab9468..f15eb03a 100644
--- a/src/io/term.nim
+++ b/src/io/term.nim
@@ -26,7 +26,6 @@ type
colormode: ColorMode
formatmode: FormatMode
smcup: bool
- force_minimal: bool
TermInfo = ref object
@@ -120,8 +119,8 @@ proc processFormat*(term: Terminal, format: var Format, cellf: Format): string =
if cellf.fgcolor.rgb:
if cellf.bgcolor == defaultColor:
var color = approximateANSIColor(cellf.fgcolor.rgbcolor)
- if color == int(cellf.bgcolor.color) - 40:
- color = 7 - color
+ if color == 0:
+ color = 7
if color == 7: # white
cellf.fgcolor = defaultColor
else:
@@ -130,7 +129,7 @@ proc processFormat*(term: Terminal, format: var Format, cellf: Format): string =
cellf.fgcolor = if int(cellf.bgcolor.color) - 40 < 4:
defaultColor
else:
- ColorsANSIFg[0]
+ ColorsANSIFg[7]
of MONOCHROME:
cellf.fgcolor = defaultColor
cellf.bgcolor = defaultColor
@@ -236,7 +235,8 @@ proc detectTermAttributes(term: Terminal) =
else:
term.formatmode = {low(FormatFlags)..high(FormatFlags)}
term.smcup = true
- term.outfile.write(SMCUP())
+ if term.config.altscreen.isSome:
+ term.smcup = term.config.altscreen.get
func generateFullOutput(term: Terminal, grid: FixedGrid): string =
var format = newFormat()
@@ -351,6 +351,8 @@ proc quit*(term: Terminal) =
disableRawMode()
if term.smcup:
term.outfile.write(RMCUP())
+ else:
+ term.outfile.write(HVP(term.attrs.height, 1))
term.outfile.showCursor()
term.outfile.flushFile()
@@ -361,6 +363,8 @@ proc start*(term: Terminal, infile: File) =
if term.isatty():
enableRawMode(infile.getFileHandle())
term.detectTermAttributes()
+ if term.smcup:
+ term.outfile.write(SMCUP())
proc newTerminal*(outfile: File, config: Config): Terminal =
let term = new Terminal