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:
parent
dbcdc4331a
commit
4616b28c7b
1 changed files with 6 additions and 3 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue