diff options
author | Hubert Hirtz <hubert@hirtz.pm> | 2020-10-18 16:37:46 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2020-10-18 16:37:46 +0200 |
commit | c9dc688f401d4d549a3776947fbc7e3d44b8c499 (patch) | |
tree | 70661ecb9b030c64fd9607f473f06fd476b4b564 /ui/style.go | |
parent | Update screenshot URL (diff) |
Update tcell to v2 and
- enable bracketed paste
- use hex color codes instead of ansi
Diffstat (limited to '')
-rw-r--r-- | ui/style.go | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/ui/style.go b/ui/style.go index c705846..2e09506 100644 --- a/ui/style.go +++ b/ui/style.go @@ -1,7 +1,7 @@ package ui import ( - "github.com/gdamore/tcell" + "github.com/gdamore/tcell/v2" "github.com/mattn/go-runewidth" ) @@ -177,12 +177,16 @@ const ( ColorRed ) -var ansiCodes = []tcell.Color{ - // Taken from <https://modern.ircdocs.horse/formatting.html> +// Taken from <https://modern.ircdocs.horse/formatting.html> + +var baseCodes = []tcell.Color{ tcell.ColorWhite, tcell.ColorBlack, tcell.ColorBlue, tcell.ColorGreen, tcell.ColorRed, tcell.ColorBrown, tcell.ColorPurple, tcell.ColorOrange, tcell.ColorYellow, tcell.ColorLightGreen, tcell.ColorTeal, tcell.ColorLightCyan, tcell.ColorLightBlue, tcell.ColorPink, tcell.ColorGrey, tcell.ColorLightGrey, +} + +var ansiCodes = []uint64{ /* 16-27 */ 52, 94, 100, 58, 22, 29, 23, 24, 17, 54, 53, 89, /* 28-39 */ 88, 130, 142, 64, 28, 35, 30, 25, 18, 91, 90, 125, /* 40-51 */ 124, 166, 184, 106, 34, 49, 37, 33, 19, 129, 127, 161, @@ -192,11 +196,23 @@ var ansiCodes = []tcell.Color{ /* 88-98 */ 16, 233, 235, 237, 239, 241, 244, 247, 250, 254, 231, } +var hexCodes = []int32{ + 0x470000, 0x472100, 0x474700, 0x324700, 0x004700, 0x00472c, 0x004747, 0x002747, 0x000047, 0x2e0047, 0x470047, 0x47002a, + 0x740000, 0x743a00, 0x747400, 0x517400, 0x007400, 0x007449, 0x007474, 0x004074, 0x000074, 0x4b0074, 0x740074, 0x740045, + 0xb50000, 0xb56300, 0xb5b500, 0x7db500, 0x00b500, 0x00b571, 0x00b5b5, 0x0063b5, 0x0000b5, 0x7500b5, 0xb500b5, 0xb5006b, + 0xff0000, 0xff8c00, 0xffff00, 0xb2ff00, 0x00ff00, 0x00ffa0, 0x00ffff, 0x008cff, 0x0000ff, 0xa500ff, 0xff00ff, 0xff0098, + 0xff5959, 0xffb459, 0xffff71, 0xcfff60, 0x6fff6f, 0x65ffc9, 0x6dffff, 0x59b4ff, 0x5959ff, 0xc459ff, 0xff66ff, 0xff59bc, + 0xff9c9c, 0xffd39c, 0xffff9c, 0xe2ff9c, 0x9cff9c, 0x9cffdb, 0x9cffff, 0x9cd3ff, 0x9c9cff, 0xdc9cff, 0xff9cff, 0xff94d3, + 0x000000, 0x131313, 0x282828, 0x363636, 0x4d4d4d, 0x656565, 0x818181, 0x9f9f9f, 0xbcbcbc, 0xe2e2e2, 0xffffff, +} + func colorFromCode(code int) (color tcell.Color) { - if code < 0 || len(ansiCodes) <= code { + if code < 0 || 99 <= code { color = tcell.ColorDefault + } else if code < 16 { + color = baseCodes[code] } else { - color = ansiCodes[code] + color = tcell.NewHexColor(hexCodes[code-16]) } return } |