diff options
author | Kaushal Modi <kaushal.modi@gmail.com> | 2018-06-17 12:37:41 -0400 |
---|---|---|
committer | Varriount <Varriount@users.noreply.github.com> | 2018-06-17 12:37:41 -0400 |
commit | 4616b28c7b592c8204d9f77f3c1f7db2fb7186d8 (patch) | |
tree | d826c73810358be3fe48a8ad60841c528c36aaf9 | |
parent | dbcdc4331a2d87aafa06ce49d50277474595064d (diff) | |
download | Nim-4616b28c7b592c8204d9f77f3c1f7db2fb7186d8.tar.gz |
Add support for italic and strikethrough ANSI escape codes (#8048)
\e[3m -> italic \e[9m -> strikethrough On terminals not supporting italic text, the text is shown in reverse instead, and on terminals not supporting strikethrough text, the text is shown as is.
-rw-r--r-- | lib/pure/terminal.nim | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/pure/terminal.nim b/lib/pure/terminal.nim index fcca4d5d7..8ee95957d 100644 --- a/lib/pure/terminal.nim +++ b/lib/pure/terminal.nim @@ -467,16 +467,18 @@ proc resetAttributes*(f: File) = f.write(ansiResetCode) type - Style* = enum ## different styles for text output + Style* = enum ## different styles for text output styleBright = 1, ## bright text styleDim, ## dim text - styleUnknown, ## unknown + styleItalic, ## italic (or reverse on terminals not supporting) styleUnderscore = 4, ## underscored text styleBlink, ## blinking/bold text - styleReverse = 7, ## unknown + styleReverse = 7, ## reverse styleHidden ## hidden text + styleStrikethrough, ## strikethrough {.deprecated: [TStyle: Style].} +{.deprecated: [styleUnknown: styleItalic].} when not defined(windows): var @@ -843,6 +845,7 @@ when not defined(testing) and isMainModule: write(stdout, "never mind") stdout.eraseLine() stdout.styledWriteLine("styled text ", {styleBright, styleBlink, styleUnderscore}) + stdout.styledWriteLine("italic text ", {styleItalic}) stdout.setBackGroundColor(bgCyan, true) stdout.setForeGroundColor(fgBlue) stdout.writeLine("ordinary text") |