mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-05 03:14:08 +00:00
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.
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user