ircfmt: Add Reverse Colour (0x16)

This commit is contained in:
Daniel Oaks 2017-12-29 11:19:27 +10:00
parent e028586483
commit 55652e4096
2 changed files with 16 additions and 13 deletions

@ -16,18 +16,19 @@ and such.
The escape character we use in this library is the dollar sign ("$"), along
with the given escape characters:
-------------------------------
Name | Escape | Raw
-------------------------------
Dollarsign | $$ | $
Bold | $b | 0x02
Colour | $c | 0x03
Monospace | $m | 0x11
Italic | $i | 0x1d
Strikethrough | $s | 0x1e
Underscore | $u | 0x1f
Reset | $r | 0x0f
-------------------------------
--------------------------------
Name | Escape | Raw
--------------------------------
Dollarsign | $$ | $
Bold | $b | 0x02
Colour | $c | 0x03
Monospace | $m | 0x11
Reverse Colour | $v | 0x16
Italic | $i | 0x1d
Strikethrough | $s | 0x1e
Underscore | $u | 0x1f
Reset | $r | 0x0f
--------------------------------
Colours are escaped in a slightly different way, using the actual names of them
rather than just the raw numbers.

@ -12,6 +12,7 @@ const (
bold string = "\x02"
colour string = "\x03"
monospace string = "\x11"
reverseColour string = "\x16"
italic string = "\x1d"
strikethrough string = "\x1e"
underline string = "\x1f"
@ -25,7 +26,7 @@ const (
var (
// valtoescape replaces most of IRC characters with our escapes.
valtoescape = strings.NewReplacer("$", "$$", colour, "$c", bold, "$b", italic, "$i", strikethrough, "$s", underline, "$u", monospace, "$m", reset, "$r")
valtoescape = strings.NewReplacer("$", "$$", colour, "$c", reverseColour, "$v", bold, "$b", italic, "$i", strikethrough, "$s", underline, "$u", monospace, "$m", reset, "$r")
// escapetoval contains most of our escapes and how they map to real IRC characters.
// intentionally skips colour, since that's handled elsewhere.
@ -33,6 +34,7 @@ var (
'$': "$",
'b': bold,
'i': italic,
'v': reverseColour,
's': strikethrough,
'u': underline,
'm': monospace,