From 7b8229dab12ddfe34b91a6eccce7744db17d398a Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 25 May 2018 22:44:12 +0300 Subject: Update dependencies --- Gopkg.lock | 6 +- .../lucasb-eyer/go-colorful/colorgens.go | 45 +- .../github.com/lucasb-eyer/go-colorful/colors.go | 871 +++++++++++---------- .../lucasb-eyer/go-colorful/happy_palettegen.go | 23 +- .../lucasb-eyer/go-colorful/soft_palettegen.go | 280 +++---- .../lucasb-eyer/go-colorful/warm_palettegen.go | 23 +- vendor/maunium.net/go/tcell/cell.go | 8 +- vendor/maunium.net/go/tcell/console_win.go | 13 +- vendor/maunium.net/go/tcell/terminfo/README.md | 8 + vendor/maunium.net/go/tcell/terminfo/mkdatabase.sh | 189 ----- vendor/maunium.net/go/tcell/terminfo/mkinfo.go | 233 ++++-- vendor/maunium.net/go/tcell/terminfo/models.txt | 2 - vendor/maunium.net/go/tcell/terminfo/term_Eterm.go | 108 --- .../go/tcell/terminfo/term_Eterm_256color.go | 107 --- .../maunium.net/go/tcell/terminfo/term_aixterm.go | 2 + vendor/maunium.net/go/tcell/terminfo/term_aterm.go | 2 +- vendor/maunium.net/go/tcell/terminfo/term_eterm.go | 26 + vendor/maunium.net/go/tcell/terminfo/term_gnome.go | 2 +- .../go/tcell/terminfo/term_gnome_256color.go | 4 +- .../maunium.net/go/tcell/terminfo/term_hpterm.go | 2 +- .../maunium.net/go/tcell/terminfo/term_konsole.go | 251 +++--- .../go/tcell/terminfo/term_konsole_256color.go | 251 +++--- vendor/maunium.net/go/tcell/terminfo/term_kterm.go | 2 +- vendor/maunium.net/go/tcell/terminfo/term_linux.go | 4 +- vendor/maunium.net/go/tcell/terminfo/term_rxvt.go | 2 +- .../go/tcell/terminfo/term_rxvt_256color.go | 2 +- .../go/tcell/terminfo/term_rxvt_unicode.go | 2 +- .../tcell/terminfo/term_rxvt_unicode_256color.go | 2 +- .../maunium.net/go/tcell/terminfo/term_screen.go | 2 +- .../go/tcell/terminfo/term_screen_256color.go | 2 +- vendor/maunium.net/go/tcell/terminfo/term_st.go | 9 +- .../go/tcell/terminfo/term_st_256color.go | 7 +- vendor/maunium.net/go/tcell/terminfo/term_sun.go | 2 +- .../go/tcell/terminfo/term_sun_color.go | 2 +- vendor/maunium.net/go/tcell/terminfo/term_vt320.go | 2 +- vendor/maunium.net/go/tcell/terminfo/term_xfce.go | 2 +- .../maunium.net/go/tcell/terminfo/term_xnuppc.go | 2 +- vendor/maunium.net/go/tcell/terminfo/term_xterm.go | 6 +- .../go/tcell/terminfo/term_xterm_256color.go | 6 +- vendor/maunium.net/go/tcell/terminfo/terminfo.go | 77 +- vendor/maunium.net/go/tcell/tscreen.go | 6 +- 41 files changed, 1254 insertions(+), 1341 deletions(-) create mode 100644 vendor/maunium.net/go/tcell/terminfo/README.md delete mode 100755 vendor/maunium.net/go/tcell/terminfo/mkdatabase.sh delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_Eterm.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_Eterm_256color.go create mode 100644 vendor/maunium.net/go/tcell/terminfo/term_eterm.go diff --git a/Gopkg.lock b/Gopkg.lock index 9e6a213..c53fe77 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -23,7 +23,7 @@ branch = "master" name = "github.com/lucasb-eyer/go-colorful" packages = ["."] - revision = "fa0f842f26263fb2ace6d6118309c8481e029fc1" + revision = "8abd3beca3a7f5039809449d6013a0254ac22bb1" [[projects]] name = "github.com/mattn/go-runewidth" @@ -88,7 +88,7 @@ "html", "html/atom" ] - revision = "9ef9f5bb98a1fdc41f8cf6c250a4404b4085e389" + revision = "dfa909b99c79129e1100513e5cd36307665e5723" [[projects]] name = "golang.org/x/text" @@ -133,7 +133,7 @@ ".", "terminfo" ] - revision = "e03df2c40d0ab5487a6b3c06a228755cdfec1c46" + revision = "9dc7ec911605bc6db5c96f502e6a80494afe4e1b" [[projects]] branch = "master" diff --git a/vendor/github.com/lucasb-eyer/go-colorful/colorgens.go b/vendor/github.com/lucasb-eyer/go-colorful/colorgens.go index 1c5e4ca..2e2e49e 100644 --- a/vendor/github.com/lucasb-eyer/go-colorful/colorgens.go +++ b/vendor/github.com/lucasb-eyer/go-colorful/colorgens.go @@ -3,52 +3,53 @@ package colorful import ( - "math/rand" + "math/rand" ) // Creates a random dark, "warm" color through a restricted HSV space. func FastWarmColor() Color { - return Hsv( - rand.Float64() * 360.0, - 0.5 + rand.Float64()*0.3, - 0.3 + rand.Float64()*0.3) + return Hsv( + rand.Float64()*360.0, + 0.5+rand.Float64()*0.3, + 0.3+rand.Float64()*0.3) } // Creates a random dark, "warm" color through restricted HCL space. // This is slower than FastWarmColor but will likely give you colors which have // the same "warmness" if you run it many times. func WarmColor() (c Color) { - for c = randomWarm() ; !c.IsValid() ; c = randomWarm() {} - return + for c = randomWarm(); !c.IsValid(); c = randomWarm() { + } + return } func randomWarm() Color { - return Hcl( - rand.Float64() * 360.0, - 0.1 + rand.Float64()*0.3, - 0.2 + rand.Float64()*0.3) + return Hcl( + rand.Float64()*360.0, + 0.1+rand.Float64()*0.3, + 0.2+rand.Float64()*0.3) } // Creates a random bright, "pimpy" color through a restricted HSV space. func FastHappyColor() Color { - return Hsv( - rand.Float64() * 360.0, - 0.7 + rand.Float64()*0.3, - 0.6 + rand.Float64()*0.3) + return Hsv( + rand.Float64()*360.0, + 0.7+rand.Float64()*0.3, + 0.6+rand.Float64()*0.3) } // Creates a random bright, "pimpy" color through restricted HCL space. // This is slower than FastHappyColor but will likely give you colors which // have the same "brightness" if you run it many times. func HappyColor() (c Color) { - for c = randomPimp() ; !c.IsValid() ; c = randomPimp() {} - return + for c = randomPimp(); !c.IsValid(); c = randomPimp() { + } + return } func randomPimp() Color { - return Hcl( - rand.Float64() * 360.0, - 0.5 + rand.Float64()*0.3, - 0.5 + rand.Float64()*0.3) + return Hcl( + rand.Float64()*360.0, + 0.5+rand.Float64()*0.3, + 0.5+rand.Float64()*0.3) } - diff --git a/vendor/github.com/lucasb-eyer/go-colorful/colors.go b/vendor/github.com/lucasb-eyer/go-colorful/colors.go index f2fcf8c..7469cf7 100644 --- a/vendor/github.com/lucasb-eyer/go-colorful/colors.go +++ b/vendor/github.com/lucasb-eyer/go-colorful/colors.go @@ -1,52 +1,52 @@ // The colorful package provides all kinds of functions for working with colors. package colorful -import( - "fmt" - "math" - "image/color" +import ( + "fmt" + "image/color" + "math" ) // A color is stored internally using sRGB (standard RGB) values in the range 0-1 type Color struct { - R, G, B float64 + R, G, B float64 } // Implement the Go color.Color interface. func (col Color) RGBA() (r, g, b, a uint32) { - r = uint32(col.R*65535.0+0.5) - g = uint32(col.G*65535.0+0.5) - b = uint32(col.B*65535.0+0.5) - a = 0xFFFF - return + r = uint32(col.R*65535.0 + 0.5) + g = uint32(col.G*65535.0 + 0.5) + b = uint32(col.B*65535.0 + 0.5) + a = 0xFFFF + return } // Constructs a colorful.Color from something implementing color.Color func MakeColor(col color.Color) Color { - r, g, b, a := col.RGBA() + r, g, b, a := col.RGBA() - // Since color.Color is alpha pre-multiplied, we need to divide the - // RGB values by alpha again in order to get back the original RGB. - r *= 0xffff - r /= a - g *= 0xffff - g /= a - b *= 0xffff - b /= a + // Since color.Color is alpha pre-multiplied, we need to divide the + // RGB values by alpha again in order to get back the original RGB. + r *= 0xffff + r /= a + g *= 0xffff + g /= a + b *= 0xffff + b /= a - return Color{float64(r)/65535.0, float64(g)/65535.0, float64(b)/65535.0} + return Color{float64(r) / 65535.0, float64(g) / 65535.0, float64(b) / 65535.0} } // Might come in handy sometimes to reduce boilerplate code. func (col Color) RGB255() (r, g, b uint8) { - r = uint8(col.R*255.0+0.5) - g = uint8(col.G*255.0+0.5) - b = uint8(col.B*255.0+0.5) - return + r = uint8(col.R*255.0 + 0.5) + g = uint8(col.G*255.0 + 0.5) + b = uint8(col.B*255.0 + 0.5) + return } // This is the tolerance used when comparing colors using AlmostEqualRgb. -const Delta = 1.0/255.0 +const Delta = 1.0 / 255.0 // This is the default reference white point. var D65 = [3]float64{0.95047, 1.00000, 1.08883} @@ -56,58 +56,57 @@ var D50 = [3]float64{0.96422, 1.00000, 0.82521} // Checks whether the color exists in RGB space, i.e. all values are in [0..1] func (c Color) IsValid() bool { - return 0.0 <= c.R && c.R <= 1.0 && - 0.0 <= c.G && c.G <= 1.0 && - 0.0 <= c.B && c.B <= 1.0 + return 0.0 <= c.R && c.R <= 1.0 && + 0.0 <= c.G && c.G <= 1.0 && + 0.0 <= c.B && c.B <= 1.0 } func clamp01(v float64) float64 { - return math.Max(0.0, math.Min(v, 1.0)) + return math.Max(0.0, math.Min(v, 1.0)) } // Returns Clamps the color into valid range, clamping each value to [0..1] // If the color is valid already, this is a no-op. func (c Color) Clamped() Color { - return Color{clamp01(c.R), clamp01(c.G), clamp01(c.B)} + return Color{clamp01(c.R), clamp01(c.G), clamp01(c.B)} } func sq(v float64) float64 { - return v * v; + return v * v } func cub(v float64) float64 { - return v * v * v; + return v * v * v } // DistanceRgb computes the distance between two colors in RGB space. // This is not a good measure! Rather do it in Lab space. func (c1 Color) DistanceRgb(c2 Color) float64 { - return math.Sqrt(sq(c1.R-c2.R) + sq(c1.G-c2.G) + sq(c1.B-c2.B)) + return math.Sqrt(sq(c1.R-c2.R) + sq(c1.G-c2.G) + sq(c1.B-c2.B)) } // Check for equality between colors within the tolerance Delta (1/255). func (c1 Color) AlmostEqualRgb(c2 Color) bool { - return math.Abs(c1.R - c2.R) + - math.Abs(c1.G - c2.G) + - math.Abs(c1.B - c2.B) < 3.0*Delta + return math.Abs(c1.R-c2.R)+ + math.Abs(c1.G-c2.G)+ + math.Abs(c1.B-c2.B) < 3.0*Delta } // You don't really want to use this, do you? Go for BlendLab, BlendLuv or BlendHcl. func (c1 Color) BlendRgb(c2 Color, t float64) Color { - return Color{c1.R + t*(c2.R - c1.R), - c1.G + t*(c2.G - c1.G), - c1.B + t*(c2.B - c1.B)} + return Color{c1.R + t*(c2.R-c1.R), + c1.G + t*(c2.G-c1.G), + c1.B + t*(c2.B-c1.B)} } // Utility used by Hxx color-spaces for interpolating between two angles in [0,360]. func interp_angle(a0, a1, t float64) float64 { - // Based on the answer here: http://stackoverflow.com/a/14498790/2366315 - // With potential proof that it works here: http://math.stackexchange.com/a/2144499 - delta := math.Mod(math.Mod(a1 - a0, 360.0) + 540, 360.0) - 180.0 - return math.Mod(a0 + t*delta + 360.0, 360.0) + // Based on the answer here: http://stackoverflow.com/a/14498790/2366315 + // With potential proof that it works here: http://math.stackexchange.com/a/2144499 + delta := math.Mod(math.Mod(a1-a0, 360.0)+540, 360.0) - 180.0 + return math.Mod(a0+t*delta+360.0, 360.0) } - /// HSV /// /////////// // From http://en.wikipedia.org/wiki/HSL_and_HSV @@ -115,54 +114,74 @@ func interp_angle(a0, a1, t float64) float64 { // Hsv returns the Hue [0..360], Saturation and Value [0..1] of the color. func (col Color) Hsv() (h, s, v float64) { - min := math.Min(math.Min(col.R, col.G), col.B) - v = math.Max(math.Max(col.R, col.G), col.B) - C := v - min - - s = 0.0 - if v != 0.0 { - s = C / v - } - - h = 0.0 // We use 0 instead of undefined as in wp. - if min != v { - if v == col.R { h = math.Mod((col.G - col.B) / C, 6.0) } - if v == col.G { h = (col.B - col.R) / C + 2.0 } - if v == col.B { h = (col.R - col.G) / C + 4.0 } - h *= 60.0 - if h < 0.0 { h += 360.0 } - } - return + min := math.Min(math.Min(col.R, col.G), col.B) + v = math.Max(math.Max(col.R, col.G), col.B) + C := v - min + + s = 0.0 + if v != 0.0 { + s = C / v + } + + h = 0.0 // We use 0 instead of undefined as in wp. + if min != v { + if v == col.R { + h = math.Mod((col.G-col.B)/C, 6.0) + } + if v == col.G { + h = (col.B-col.R)/C + 2.0 + } + if v == col.B { + h = (col.R-col.G)/C + 4.0 + } + h *= 60.0 + if h < 0.0 { + h += 360.0 + } + } + return } // Hsv creates a new Color given a Hue in [0..360], a Saturation and a Value in [0..1] func Hsv(H, S, V float64) Color { - Hp := H/60.0 - C := V*S - X := C*(1.0-math.Abs(math.Mod(Hp, 2.0)-1.0)) - - m := V-C; - r, g, b := 0.0, 0.0, 0.0 - - switch { - case 0.0 <= Hp && Hp < 1.0: r = C; g = X - case 1.0 <= Hp && Hp < 2.0: r = X; g = C - case 2.0 <= Hp && Hp < 3.0: g = C; b = X - case 3.0 <= Hp && Hp < 4.0: g = X; b = C - case 4.0 <= Hp && Hp < 5.0: r = X; b = C - case 5.0 <= Hp && Hp < 6.0: r = C; b = X - } - - return Color{m+r, m+g, m+b} + Hp := H / 60.0 + C := V * S + X := C * (1.0 - math.Abs(math.Mod(Hp, 2.0)-1.0)) + + m := V - C + r, g, b := 0.0, 0.0, 0.0 + + switch { + case 0.0 <= Hp && Hp < 1.0: + r = C + g = X + case 1.0 <= Hp && Hp < 2.0: + r = X + g = C + case 2.0 <= Hp && Hp < 3.0: + g = C + b = X + case 3.0 <= Hp && Hp < 4.0: + g = X + b = C + case 4.0 <= Hp && Hp < 5.0: + r = X + b = C + case 5.0 <= Hp && Hp < 6.0: + r = C + b = X + } + + return Color{m + r, m + g, m + b} } // You don't really want to use this, do you? Go for BlendLab, BlendLuv or BlendHcl. func (c1 Color) BlendHsv(c2 Color, t float64) Color { - h1, s1, v1 := c1.Hsv() - h2, s2, v2 := c2.Hsv() + h1, s1, v1 := c1.Hsv() + h2, s2, v2 := c2.Hsv() - // We know that h are both in [0..360] - return Hsv(interp_angle(h1, h2, t), s1 + t*(s2 - s1), v1 + t*(v2 - v1)) + // We know that h are both in [0..360] + return Hsv(interp_angle(h1, h2, t), s1+t*(s2-s1), v1+t*(v2-v1)) } /// HSL /// @@ -170,117 +189,117 @@ func (c1 Color) BlendHsv(c2 Color, t float64) Color { // Hsl returns the Hue [0..360], Saturation [0..1], and Luminance (lightness) [0..1] of the color. func (col Color) Hsl() (h, s, l float64) { - min := math.Min(math.Min(col.R, col.G), col.B) - max := math.Max(math.Max(col.R, col.G), col.B) + min := math.Min(math.Min(col.R, col.G), col.B) + max := math.Max(math.Max(col.R, col.G), col.B) - l = (max + min) / 2 + l = (max + min) / 2 - if min == max { - s = 0 - h = 0 - } else { - if l < 0.5 { - s = (max - min) / (max + min) - } else { - s = (max - min) / (2.0 - max - min) - } + if min == max { + s = 0 + h = 0 + } else { + if l < 0.5 { + s = (max - min) / (max + min) + } else { + s = (max - min) / (2.0 - max - min) + } - if max == col.R { - h = (col.G - col.B) / (max - min) - } else if max == col.G { - h = 2.0 + (col.B-col.R)/(max-min) - } else { - h = 4.0 + (col.R-col.G)/(max-min) - } + if max == col.R { + h = (col.G - col.B) / (max - min) + } else if max == col.G { + h = 2.0 + (col.B-col.R)/(max-min) + } else { + h = 4.0 + (col.R-col.G)/(max-min) + } - h *= 60 + h *= 60 - if h < 0 { - h += 360 - } - } + if h < 0 { + h += 360 + } + } - return + return } // Hsl creates a new Color given a Hue in [0..360], a Saturation [0..1], and a Luminance (lightness) in [0..1] func Hsl(h, s, l float64) Color { - if s == 0 { - return Color{l, l, l} - } - - var r, g, b float64 - var t1 float64 - var t2 float64 - var tr float64 - var tg float64 - var tb float64 - - if l < 0.5 { - t1 = l * (1.0 + s) - } else { - t1 = l + s - l*s - } - - t2 = 2*l - t1 - h = h / 360 - tr = h + 1.0/3.0 - tg = h - tb = h - 1.0/3.0 - - if tr < 0 { - tr += 1 - } - if tr > 1 { - tr -= 1 - } - if tg < 0 { - tg += 1 - } - if tg > 1 { - tg -= 1 - } - if tb < 0 { - tb += 1 - } - if tb > 1 { - tb -= 1 - } - - // Red - if 6*tr < 1 { - r = t2 + (t1-t2)*6*tr - } else if 2*tr < 1 { - r = t1 - } else if 3*tr < 2 { - r = t2 + (t1-t2)*(2.0/3.0-tr)*6 - } else { - r = t2 - } - - // Green - if 6*tg < 1 { - g = t2 + (t1-t2)*6*tg - } else if 2*tg < 1 { - g = t1 - } else if 3*tg < 2 { - g = t2 + (t1-t2)*(2.0/3.0-tg)*6 - } else { - g = t2 - } - - // Blue - if 6*tb < 1 { - b = t2 + (t1-t2)*6*tb - } else if 2*tb < 1 { - b = t1 - } else if 3*tb < 2 { - b = t2 + (t1-t2)*(2.0/3.0-tb)*6 - } else { - b = t2 - } - - return Color{r, g, b} + if s == 0 { + return Color{l, l, l} + } + + var r, g, b float64 + var t1 float64 + var t2 float64 + var tr float64 + var tg float64 + var tb float64 + + if l < 0.5 { + t1 = l * (1.0 + s) + } else { + t1 = l + s - l*s + } + + t2 = 2*l - t1 + h = h / 360 + tr = h + 1.0/3.0 + tg = h + tb = h - 1.0/3.0 + + if tr < 0 { + tr++ + } + if tr > 1 { + tr-- + } + if tg < 0 { + tg++ + } + if tg > 1 { + tg-- + } + if tb < 0 { + tb++ + } + if tb > 1 { + tb-- + } + + // Red + if 6*tr < 1 { + r = t2 + (t1-t2)*6*tr + } else if 2*tr < 1 { + r = t1 + } else if 3*tr < 2 { + r = t2 + (t1-t2)*(2.0/3.0-tr)*6 + } else { + r = t2 + } + + // Green + if 6*tg < 1 { + g = t2 + (t1-t2)*6*tg + } else if 2*tg < 1 { + g = t1 + } else if 3*tg < 2 { + g = t2 + (t1-t2)*(2.0/3.0-tg)*6 + } else { + g = t2 + } + + // Blue + if 6*tb < 1 { + b = t2 + (t1-t2)*6*tb + } else if 2*tb < 1 { + b = t1 + } else if 3*tb < 2 { + b = t2 + (t1-t2)*(2.0/3.0-tb)*6 + } else { + b = t2 + } + + return Color{r, g, b} } /// Hex /// @@ -288,29 +307,29 @@ func Hsl(h, s, l float64) Color { // Hex returns the hex "html" representation of the color, as in #ff0080. func (col Color) Hex() string { - // Add 0.5 for rounding - return fmt.Sprintf("#%02x%02x%02x", uint8(col.R*255.0+0.5), uint8(col.G*255.0+0.5), uint8(col.B*255.0+0.5)) + // Add 0.5 for rounding + return fmt.Sprintf("#%02x%02x%02x", uint8(col.R*255.0+0.5), uint8(col.G*255.0+0.5), uint8(col.B*255.0+0.5)) } // Hex parses a "html" hex color-string, either in the 3 "#f0c" or 6 "#ff1034" digits form. func Hex(scol string) (Color, error) { - format := "#%02x%02x%02x" - factor := 1.0/255.0 - if len(scol) == 4 { - format = "#%1x%1x%1x" - factor = 1.0/15.0 - } + format := "#%02x%02x%02x" + factor := 1.0 / 255.0 + if len(scol) == 4 { + format = "#%1x%1x%1x" + factor = 1.0 / 15.0 + } - var r, g, b uint8 - n, err := fmt.Sscanf(scol, format, &r, &g, &b) - if err != nil { - return Color{}, err - } - if n != 3 { - return Color{}, fmt.Errorf("color: %v is not a hex-color", scol) - } + var r, g, b uint8 + n, err := fmt.Sscanf(scol, format, &r, &g, &b) + if err != nil { + return Color{}, err + } + if n != 3 { + return Color{}, fmt.Errorf("color: %v is not a hex-color", scol) + } - return Color{float64(r)*factor, float64(g)*factor, float64(b)*factor}, nil + return Color{float64(r) * factor, float64(g) * factor, float64(b) * factor}, nil } /// Linear /// @@ -319,98 +338,98 @@ func Hex(scol string) (Color, error) { // http://www.brucelindbloom.com/Eqn_RGB_to_XYZ.html func linearize(v float64) float64 { - if v <= 0.04045 { - return v / 12.92 - } - return math.Pow((v + 0.055)/1.055, 2.4) + if v <= 0.04045 { + return v / 12.92 + } + return math.Pow((v+0.055)/1.055, 2.4) } // LinearRgb converts the color into the linear RGB space (see http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/). func (col Color) LinearRgb() (r, g, b float64) { - r = linearize(col.R) - g = linearize(col.G) - b = linearize(col.B) - return + r = linearize(col.R) + g = linearize(col.G) + b = linearize(col.B) + return } // A much faster and still quite precise linearization using a 6th-order Taylor approximation. // See the accompanying Jupyter notebook for derivation of the constants. func linearize_fast(v float64) float64 { - v1 := v - 0.5 - v2 := v1*v1 - v3 := v2*v1 - v4 := v2*v2 - //v5 := v3*v2 - return -0.248750514614486 + 0.925583310193438*v + 1.16740237321695*v2 + 0.280457026598666*v3 - 0.0757991963780179*v4 //+ 0.0437040411548932*v5 + v1 := v - 0.5 + v2 := v1 * v1 + v3 := v2 * v1 + v4 := v2 * v2 + //v5 := v3*v2 + return -0.248750514614486 + 0.925583310193438*v + 1.16740237321695*v2 + 0.280457026598666*v3 - 0.0757991963780179*v4 //+ 0.0437040411548932*v5 } // FastLinearRgb is much faster than and almost as accurate as LinearRgb. // BUT it is important to NOTE that they only produce good results for valid colors r,g,b in [0,1]. func (col Color) FastLinearRgb() (r, g, b float64) { - r = linearize_fast(col.R) - g = linearize_fast(col.G) - b = linearize_fast(col.B) - return + r = linearize_fast(col.R) + g = linearize_fast(col.G) + b = linearize_fast(col.B) + return } func delinearize(v float64) float64 { - if v <= 0.0031308 { - return 12.92 * v - } - return 1.055 * math.Pow(v, 1.0/2.4) - 0.055 + if v <= 0.0031308 { + return 12.92 * v + } + return 1.055*math.Pow(v, 1.0/2.4) - 0.055 } // LinearRgb creates an sRGB color out of the given linear RGB color (see http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/). func LinearRgb(r, g, b float64) Color { - return Color{delinearize(r), delinearize(g), delinearize(b)} + return Color{delinearize(r), delinearize(g), delinearize(b)} } func delinearize_fast(v float64) float64 { - // This function (fractional root) is much harder to linearize, so we need to split. - if v > 0.2 { - v1 := v - 0.6 - v2 := v1*v1 - v3 := v2*v1 - v4 := v2*v2 - v5 := v3*v2 - return 0.442430344268235 + 0.592178981271708*v - 0.287864782562636*v2 + 0.253214392068985*v3 - 0.272557158129811*v4 + 0.325554383321718*v5 - } else if v > 0.03 { - v1 := v - 0.115 - v2 := v1*v1 - v3 := v2*v1 - v4 := v2*v2 - v5 := v3*v2 - return 0.194915592891669 + 1.55227076330229*v - 3.93691860257828*v2 + 18.0679839248761*v3 - 101.468750302746*v4 + 632.341487393927*v5 - } else { - v1 := v - 0.015 - v2 := v1*v1 - v3 := v2*v1 - v4 := v2*v2 - v5 := v3*v2 - // You can clearly see from the involved constants that the low-end is highly nonlinear. - return 0.0519565234928877 + 5.09316778537561*v - 99.0338180489702*v2 + 3484.52322764895*v3 - 150028.083412663*v4 + 7168008.42971613*v5 - } + // This function (fractional root) is much harder to linearize, so we need to split. + if v > 0.2 { + v1 := v - 0.6 + v2 := v1 * v1 + v3 := v2 * v1 + v4 := v2 * v2 + v5 := v3 * v2 + return 0.442430344268235 + 0.592178981271708*v - 0.287864782562636*v2 + 0.253214392068985*v3 - 0.272557158129811*v4 + 0.325554383321718*v5 + } else if v > 0.03 { + v1 := v - 0.115 + v2 := v1 * v1 + v3 := v2 * v1 + v4 := v2 * v2 + v5 := v3 * v2 + return 0.194915592891669 + 1.55227076330229*v - 3.93691860257828*v2 + 18.0679839248761*v3 - 101.468750302746*v4 + 632.341487393927*v5 + } else { + v1 := v - 0.015 + v2 := v1 * v1 + v3 := v2 * v1 + v4 := v2 * v2 + v5 := v3 * v2 + // You can clearly see from the involved constants that the low-end is highly nonlinear. + return 0.0519565234928877 + 5.09316778537561*v - 99.0338180489702*v2 + 3484.52322764895*v3 - 150028.083412663*v4 + 7168008.42971613*v5 + } } // FastLinearRgb is much faster than and almost as accurate as LinearRgb. // BUT it is important to NOTE that they only produce good results for valid inputs r,g,b in [0,1]. func FastLinearRgb(r, g, b float64) Color { - return Color{delinearize_fast(r), delinearize_fast(g), delinearize_fast(b)} + return Color{delinearize_fast(r), delinearize_fast(g), delinearize_fast(b)} } // XyzToLinearRgb converts from CIE XYZ-space to Linear RGB space. func XyzToLinearRgb(x, y, z float64) (r, g, b float64) { - r = 3.2404542*x - 1.5371385*y - 0.4985314*z - g = -0.9692660*x + 1.8760108*y + 0.0415560*z - b = 0.0556434*x - 0.2040259*y + 1.0572252*z - return + r = 3.2404542*x - 1.5371385*y - 0.4985314*z + g = -0.9692660*x + 1.8760108*y + 0.0415560*z + b = 0.0556434*x - 0.2040259*y + 1.0572252*z + return } func LinearRgbToXyz(r, g, b float64) (x, y, z float64) { - x = 0.4124564*r + 0.3575761*g + 0.1804375*b - y = 0.2126729*r + 0.7151522*g + 0.0721750*b - z = 0.0193339*r + 0.1191920*g + 0.9503041*b - return + x = 0.4124564*r + 0.3575761*g + 0.1804375*b + y = 0.2126729*r + 0.7151522*g + 0.0721750*b + z = 0.0193339*r + 0.1191920*g + 0.9503041*b + return } /// XYZ /// @@ -418,11 +437,11 @@ func LinearRgbToXyz(r, g, b float64) (x, y, z float64) { // http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/ func (col Color) Xyz() (x, y, z float64) { - return LinearRgbToXyz(col.LinearRgb()) + return LinearRgbToXyz(col.LinearRgb()) } func Xyz(x, y, z float64) Color { - return LinearRgb(XyzToLinearRgb(x, y, z)) + return LinearRgb(XyzToLinearRgb(x, y, z)) } /// xyY /// @@ -432,43 +451,43 @@ func Xyz(x, y, z float64) Color { // Well, the name is bad, since it's xyY but Golang needs me to start with a // capital letter to make the method public. func XyzToXyy(X, Y, Z float64) (x, y, Yout float64) { - return XyzToXyyWhiteRef(X, Y, Z, D65) + return XyzToXyyWhiteRef(X, Y, Z, D65) } func XyzToXyyWhiteRef(X, Y, Z float64, wref [3]float64) (x, y, Yout float64) { - Yout = Y - N := X + Y + Z - if math.Abs(N) < 1e-14 { - // When we have black, Bruce Lindbloom recommends to use - // the reference white's chromacity for x and y. - x = wref[0] / (wref[0] + wref[1] + wref[2]) - y = wref[1] / (wref[0] + wref[1] + wref[2]) - } else { - x = X / N - y = Y / N - } - return + Yout = Y + N := X + Y + Z + if math.Abs(N) < 1e-14 { + // When we have black, Bruce Lindbloom recommends to use + // the reference white's chromacity for x and y. + x = wref[0] / (wref[0] + wref[1] + wref[2]) + y = wref[1] / (wref[0] + wref[1] + wref[2]) + } else { + x = X / N + y = Y / N + } + return } func XyyToXyz(x, y, Y float64) (X, Yout, Z float64) { - Yout = Y + Yout = Y - if -1e-14 < y && y < 1e-14 { - X = 0.0 - Z = 0.0 - } else { - X = Y / y * x - Z = Y / y * (1.0 - x - y) - } + if -1e-14 < y && y < 1e-14 { + X = 0.0 + Z = 0.0 + } else { + X = Y / y * x + Z = Y / y * (1.0 - x - y) + } - return + return } // Converts the given color to CIE xyY space using D65 as reference white. // (Note that the reference white is only used for black input.) // x, y and Y are in [0..1] func (col Color) Xyy() (x, y, Y float64) { - return XyzToXyy(col.Xyz()) + return XyzToXyy(col.Xyz()) } // Converts the given color to CIE xyY space, taking into account @@ -476,14 +495,14 @@ func (col Color) Xyy() (x, y, Y float64) { // (Note that the reference white is only used for black input.) // x, y and Y are in [0..1] func (col Color) XyyWhiteRef(wref [3]float64) (x, y, Y float64) { - X, Y2, Z := col.Xyz() - return XyzToXyyWhiteRef(X, Y2, Z, wref) + X, Y2, Z := col.Xyz() + return XyzToXyyWhiteRef(X, Y2, Z, wref) } // Generates a color by using data given in CIE xyY space. // x, y and Y are in [0..1] func Xyy(x, y, Y float64) Color { - return Xyz(XyyToXyz(x, y, Y)) + return Xyz(XyyToXyz(x, y, Y)) } /// L*a*b* /// @@ -492,131 +511,131 @@ func Xyy(x, y, Y float64) Color { // For L*a*b*, we need to L*a*b*<->XYZ->RGB and the first one is device dependent. func lab_f(t float64) float64 { - if t > 6.0/29.0 * 6.0/29.0 * 6.0/29.0 { - return math.Cbrt(t) - } - return t/3.0 * 29.0/6.0 * 29.0/6.0 + 4.0/29.0 + if t > 6.0/29.0*6.0/29.0*6.0/29.0 { + return math.Cbrt(t) + } + return t/3.0*29.0/6.0*29.0/6.0 + 4.0/29.0 } func XyzToLab(x, y, z float64) (l, a, b float64) { - // Use D65 white as reference point by default. - // http://www.fredmiranda.com/forum/topic/1035332 - // http://en.wikipedia.org/wiki/Standard_illuminant - return XyzToLabWhiteRef(x, y, z, D65) + // Use D65 white as reference point by default. + // http://www.fredmiranda.com/forum/topic/1035332 + // http://en.wikipedia.org/wiki/Standard_illuminant + return XyzToLabWhiteRef(x, y, z, D65) } func XyzToLabWhiteRef(x, y, z float64, wref [3]float64) (l, a, b float64) { - fy := lab_f(y/wref[1]) - l = 1.16*fy - 0.16 - a = 5.0*(lab_f(x/wref[0]) - fy) - b = 2.0*(fy - lab_f(z/wref[2])) - return + fy := lab_f(y / wref[1]) + l = 1.16*fy - 0.16 + a = 5.0 * (lab_f(x/wref[0]) - fy) + b = 2.0 * (fy - lab_f(z/wref[2])) + return } func lab_finv(t float64) float64 { - if t > 6.0/29.0 { - return t * t * t - } - return 3.0 * 6.0/29.0 * 6.0/29.0 * (t - 4.0/29.0) + if t > 6.0/29.0 { + return t * t * t + } + return 3.0 * 6.0 / 29.0 * 6.0 / 29.0 * (t - 4.0/29.0) } func LabToXyz(l, a, b float64) (x, y, z float64) { - // D65 white (see above). - return LabToXyzWhiteRef(l, a, b, D65) + // D65 white (see above). + return LabToXyzWhiteRef(l, a, b, D65) } func LabToXyzWhiteRef(l, a, b float64, wref [3]float64) (x, y, z float64) { - l2 := (l + 0.16) / 1.16 - x = wref[0] * lab_finv(l2 + a/5.0) - y = wref[1] * lab_finv(l2) - z = wref[2] * lab_finv(l2 - b/2.0) - return + l2 := (l + 0.16) / 1.16 + x = wref[0] * lab_finv(l2+a/5.0) + y = wref[1] * lab_finv(l2) + z = wref[2] * lab_finv(l2-b/2.0) + return } // Converts the given color to CIE L*a*b* space using D65 as reference white. func (col Color) Lab() (l, a, b float64) { - return XyzToLab(col.Xyz()) + return XyzToLab(col.Xyz()) } // Converts the given color to CIE L*a*b* space, taking into account // a given reference white. (i.e. the monitor's white) func (col Color) LabWhiteRef(wref [3]float64) (l, a, b float64) { - x, y, z := col.Xyz() - return XyzToLabWhiteRef(x, y, z, wref) + x, y, z := col.Xyz() + return XyzToLabWhiteRef(x, y, z, wref) } // Generates a color by using data given in CIE L*a*b* space using D65 as reference white. // WARNING: many combinations of `l`, `a`, and `b` values do not have corresponding // valid RGB values, check the FAQ in the README if you're unsure. func Lab(l, a, b float64) Color { - return Xyz(LabToXyz(l, a, b)) + return Xyz(LabToXyz(l, a, b)) } // Generates a color by using data given in CIE L*a*b* space, taking // into account a given reference white. (i.e. the monitor's white) func LabWhiteRef(l, a, b float64, wref [3]float64) Color { - return Xyz(LabToXyzWhiteRef(l, a, b, wref)) + return Xyz(LabToXyzWhiteRef(l, a, b, wref)) } // DistanceLab is a good measure of visual similarity between two colors! // A result of 0 would mean identical colors, while a result of 1 or higher // means the colors differ a lot. func (c1 Color) DistanceLab(c2 Color) float64 { - l1, a1, b1 := c1.Lab() - l2, a2, b2 := c2.Lab() - return math.Sqrt(sq(l1-l2) + sq(a1-a2) + sq(b1-b2)) + l1, a1, b1 := c1.Lab() + l2, a2, b2 := c2.Lab() + return math.Sqrt(sq(l1-l2) + sq(a1-a2) + sq(b1-b2)) } // That's actually the same, but I don't want to break code. func (c1 Color) DistanceCIE76(c2 Color) float64 { - return c1.DistanceLab(c2) + return c1.DistanceLab(c2) } // Uses the CIE94 formula to calculate color distance. More accurate than // DistanceLab, but also more work. func (cl Color) DistanceCIE94(cr Color) float64 { - l1, a1, b1 := cl.Lab() - l2, a2, b2 := cr.Lab() + l1, a1, b1 := cl.Lab() + l2, a2, b2 := cr.Lab() - // NOTE: Since all those formulas expect L,a,b values 100x larger than we - // have them in this library, we either need to adjust all constants - // in the formula, or convert the ranges of L,a,b before, and then - // scale the distances down again. The latter is less error-prone. - l1, a1, b1 = l1*100.0, a1*100.0, b1*100.0 - l2, a2, b2 = l2*100.0, a2*100.0, b2*100.0 + // NOTE: Since all those formulas expect L,a,b values 100x larger than we + // have them in this library, we either need to adjust all constants + // in the formula, or convert the ranges of L,a,b before, and then + // scale the distances down again. The latter is less error-prone. + l1, a1, b1 = l1*100.0, a1*100.0, b1*100.0 + l2, a2, b2 = l2*100.0, a2*100.0, b2*100.0 - kl := 1.0 // 2.0 for textiles - kc := 1.0 - kh := 1.0 - k1 := 0.045 // 0.048 for textiles - k2 := 0.015 // 0.014 for textiles. + kl := 1.0 // 2.0 for textiles + kc := 1.0 + kh := 1.0 + k1 := 0.045 // 0.048 for textiles + k2 := 0.015 // 0.014 for textiles. - deltaL := l1 - l2 - c1 := math.Sqrt(sq(a1) + sq(b1)) - c2 := math.Sqrt(sq(a2) + sq(b2)) - deltaCab := c1 - c2 + deltaL := l1 - l2 + c1 := math.Sqrt(sq(a1) + sq(b1)) + c2 := math.Sqrt(sq(a2) + sq(b2)) + deltaCab := c1 - c2 - // Not taking Sqrt here for stability, and it's unnecessary. - deltaHab2 := sq(a1-a2) + sq(b1-b2) - sq(deltaCab) - sl := 1.0 - sc := 1.0 + k1*c1 - sh := 1.0 + k2*c1 + // Not taking Sqrt here for stability, and it's unnecessary. + deltaHab2 := sq(a1-a2) + sq(b1-b2) - sq(deltaCab) + sl := 1.0 + sc := 1.0 + k1*c1 + sh := 1.0 + k2*c1 - vL2 := sq(deltaL/(kl*sl)) - vC2 := sq(deltaCab/(kc*sc)) - vH2 := deltaHab2/sq(kh*sh) + vL2 := sq(deltaL / (kl * sl)) + vC2 := sq(deltaCab / (kc * sc)) + vH2 := deltaHab2 / sq(kh*sh) - return math.Sqrt(vL2 + vC2 + vH2)*0.01 // See above. + return math.Sqrt(vL2+vC2+vH2) * 0.01 // See above. } // BlendLab blends two colors in the L*a*b* color-space, which should result in a smoother blend. // t == 0 results in c1, t == 1 results in c2 func (c1 Color) BlendLab(c2 Color, t float64) Color { - l1, a1, b1 := c1.Lab() - l2, a2, b2 := c2.Lab() - return Lab(l1 + t*(l2 - l1), - a1 + t*(a2 - a1), - b1 + t*(b2 - b1)) + l1, a1, b1 := c1.Lab() + l2, a2, b2 := c2.Lab() + return Lab(l1+t*(l2-l1), + a1+t*(a2-a1), + b1+t*(b2-b1)) } /// L*u*v* /// @@ -625,74 +644,74 @@ func (c1 Color) BlendLab(c2 Color, t float64) Color { // For L*u*v*, we need to L*u*v*<->XYZ<->RGB and the first one is device dependent. func XyzToLuv(x, y, z float64) (l, a, b float64) { - // Use D65 white as reference point by default. - // http://www.fredmiranda.com/forum/topic/1035332 - // http://en.wikipedia.org/wiki/Standard_illuminant - return XyzToLuvWhiteRef(x, y, z, D65) + // Use D65 white as reference point by default. + // http://www.fredmiranda.com/forum/topic/1035332 + // http://en.wikipedia.org/wiki/Standard_illuminant + return XyzToLuvWhiteRef(x, y, z, D65) } func XyzToLuvWhiteRef(x, y, z float64, wref [3]float64) (l, u, v float64) { - if y/wref[1] <= 6.0/29.0 * 6.0/29.0 * 6.0/29.0 { - l = y/wref[1] * 29.0/3.0 * 29.0/3.0 * 29.0/3.0 - } else { - l = 1.16 * math.Cbrt(y/wref[1]) - 0.16 - } - ubis, vbis := xyz_to_uv(x, y, z) - un, vn := xyz_to_uv(wref[0], wref[1], wref[2]) - u = 13.0*l * (ubis - un) - v = 13.0*l * (vbis - vn) - return + if y/wref[1] <= 6.0/29.0*6.0/29.0*6.0/29.0 { + l = y / wref[1] * 29.0 / 3.0 * 29.0 / 3.0 * 29.0 / 3.0 + } else { + l = 1.16*math.Cbrt(y/wref[1]) - 0.16 + } + ubis, vbis := xyz_to_uv(x, y, z) + un, vn := xyz_to_uv(wref[0], wref[1], wref[2]) + u = 13.0 * l * (ubis - un) + v = 13.0 * l * (vbis - vn) + return } // For this part, we do as R's graphics.hcl does, not as wikipedia does. // Or is it the same? func xyz_to_uv(x, y, z float64) (u, v float64) { - denom := x + 15.0*y + 3.0*z - if denom == 0.0 { - u, v = 0.0, 0.0 - } else { - u = 4.0*x/denom - v = 9.0*y/denom - } - return + denom := x + 15.0*y + 3.0*z + if denom == 0.0 { + u, v = 0.0, 0.0 + } else { + u = 4.0 * x / denom + v = 9.0 * y / denom + } + return } func LuvToXyz(l, u, v float64) (x, y, z float64) { - // D65 white (see above). - return LuvToXyzWhiteRef(l, u, v, D65) + // D65 white (see above). + return LuvToXyzWhiteRef(l, u, v, D65) } func LuvToXyzWhiteRef(l, u, v float64, wref [3]float64) (x, y, z float64) { - //y = wref[1] * lab_finv((l + 0.16) / 1.16) - if l <= 0.08 { - y = wref[1] * l * 100.0 * 3.0/29.0 * 3.0/29.0 * 3.0/29.0 - } else { - y = wref[1] * cub((l+0.16)/1.16) - } - un, vn := xyz_to_uv(wref[0], wref[1], wref[2]) - if l != 0.0 { - ubis := u/(13.0*l) + un - vbis := v/(13.0*l) + vn - x = y*9.0*ubis/(4.0*vbis) - z = y*(12.0-3.0*ubis-20.0*vbis)/(4.0*vbis) - } else { - x, y = 0.0, 0.0 - } - return + //y = wref[1] * lab_finv((l + 0.16) / 1.16) + if l <= 0.08 { + y = wref[1] * l * 100.0 * 3.0 / 29.0 * 3.0 / 29.0 * 3.0 / 29.0 + } else { + y = wref[1] * cub((l+0.16)/1.16) + } + un, vn := xyz_to_uv(wref[0], wref[1], wref[2]) + if l != 0.0 { + ubis := u/(13.0*l) + un + vbis := v/(13.0*l) + vn + x = y * 9.0 * ubis / (4.0 * vbis) + z = y * (12.0 - 3.0*ubis - 20.0*vbis) / (4.0 * vbis) + } else { + x, y = 0.0, 0.0 + } + return } // Converts the given color to CIE L*u*v* space using D65 as reference white. // L* is in [0..1] and both u* and v* are in about [-1..1] func (col Color) Luv() (l, u, v float64) { - return XyzToLuv(col.Xyz()) + return XyzToLuv(col.Xyz()) } // Converts the given color to CIE L*u*v* space, taking into account // a given reference white. (i.e. the monitor's white) // L* is in [0..1] and both u* and v* are in about [-1..1] func (col Color) LuvWhiteRef(wref [3]float64) (l, u, v float64) { - x, y, z := col.Xyz() - return XyzToLuvWhiteRef(x, y, z, wref) + x, y, z := col.Xyz() + return XyzToLuvWhiteRef(x, y, z, wref) } // Generates a color by using data given in CIE L*u*v* space using D65 as reference white. @@ -700,33 +719,33 @@ func (col Color) LuvWhiteRef(wref [3]float64) (l, u, v float64) { // WARNING: many combinations of `l`, `a`, and `b` values do not have corresponding // valid RGB values, check the FAQ in the README if you're unsure. func Luv(l, u, v float64) Color { - return Xyz(LuvToXyz(l, u, v)) + return Xyz(LuvToXyz(l, u, v)) } // Generates a color by using data given in CIE L*u*v* space, taking // into account a given reference white. (i.e. the monitor's white) // L* is in [0..1] and both u* and v* are in about [-1..1] func LuvWhiteRef(l, u, v float64, wref [3]float64) Color { - return Xyz(LuvToXyzWhiteRef(l, u, v, wref)) + return Xyz(LuvToXyzWhiteRef(l, u, v, wref)) } // DistanceLuv is a good measure of visual similarity between two colors! // A result of 0 would mean identical colors, while a result of 1 or higher // means the colors differ a lot. func (c1 Color) DistanceLuv(c2 Color) float64 { - l1, u1, v1 := c1.Luv() - l2, u2, v2 := c2.Luv() - return math.Sqrt(sq(l1-l2) + sq(u1-u2) + sq(v1-v2)) + l1, u1, v1 := c1.Luv() + l2, u2, v2 := c2.Luv() + return math.Sqrt(sq(l1-l2) + sq(u1-u2) + sq(v1-v2)) } // BlendLuv blends two colors in the CIE-L*u*v* color-space, which should result in a smoother blend. // t == 0 results in c1, t == 1 results in c2 func (c1 Color) BlendLuv(c2 Color, t float64) Color { - l1, u1, v1 := c1.Luv() - l2, u2, v2 := c2.Luv() - return Luv(l1 + t*(l2 - l1), - u1 + t*(u2 - u1), - v1 + t*(v2 - v1)) + l1, u1, v1 := c1.Luv() + l2, u2, v2 := c2.Luv() + return Luv(l1+t*(l2-l1), + u1+t*(u2-u1), + v1+t*(v2-v1)) } /// HCL /// @@ -739,27 +758,27 @@ func (c1 Color) BlendLuv(c2 Color, t float64) Color { // Converts the given color to HCL space using D65 as reference white. // H values are in [0..360], C and L values are in [0..1] although C can overshoot 1.0 func (col Color) Hcl() (h, c, l float64) { - return col.HclWhiteRef(D65) + return col.HclWhiteRef(D65) } func LabToHcl(L, a, b float64) (h, c, l float64) { - // Oops, floating point workaround necessary if a ~= b and both are very small (i.e. almost zero). - if math.Abs(b - a) > 1e-4 && math.Abs(a) > 1e-4 { - h = math.Mod(57.29577951308232087721*math.Atan2(b, a) + 360.0, 360.0) // Rad2Deg - } else { - h = 0.0 - } - c = math.Sqrt(sq(a) + sq(b)) - l = L - return + // Oops, floating point workaround necessary if a ~= b and both are very small (i.e. almost zero). + if math.Abs(b-a) > 1e-4 && math.Abs(a) > 1e-4 { + h = math.Mod(57.29577951308232087721*math.Atan2(b, a)+360.0, 360.0) // Rad2Deg + } else { + h = 0.0 + } + c = math.Sqrt(sq(a) + sq(b)) + l = L + return } // Converts the given color to HCL space, taking into account // a given reference white. (i.e. the monitor's white) // H values are in [0..360], C and L values are in [0..1] func (col Color) HclWhiteRef(wref [3]float64) (h, c, l float64) { - L, a, b := col.LabWhiteRef(wref) - return LabToHcl(L, a, b) + L, a, b := col.LabWhiteRef(wref) + return LabToHcl(L, a, b) } // Generates a color by using data given in HCL space using D65 as reference white. @@ -767,31 +786,31 @@ func (col Color) HclWhiteRef(wref [3]float64) (h, c, l float64) { // WARNING: many combinations of `l`, `a`, and `b` values do not have corresponding // valid RGB values, check the FAQ in the README if you're unsure. func Hcl(h, c, l float64) Color { - return HclWhiteRef(h, c, l, D65) + return HclWhiteRef(h, c, l, D65) } func HclToLab(h, c, l float64) (L, a, b float64) { - H := 0.01745329251994329576*h // Deg2Rad - a = c*math.Cos(H) - b = c*math.Sin(H) - L = l - return + H := 0.01745329251994329576 * h // Deg2Rad + a = c * math.Cos(H) + b = c * math.Sin(H) + L = l + return } // Generates a color by using data given in HCL space, taking // into account a given reference white. (i.e. the monitor's white) // H values are in [0..360], C and L values are in [0..1] func HclWhiteRef(h, c, l float64, wref [3]float64) Color { - L, a, b := HclToLab(h, c, l) - return LabWhiteRef(L, a, b, wref) + L, a, b := HclToLab(h, c, l) + return LabWhiteRef(L, a, b, wref) } // BlendHcl blends two colors in the CIE-L*C*h° color-space, which should result in a smoother blend. // t == 0 results in c1, t == 1 results in c2 func (col1 Color) BlendHcl(col2 Color, t float64) Color { - h1, c1, l1 := col1.Hcl() - h2, c2, l2 := col2.Hcl() + h1, c1, l1 := col1.Hcl() + h2, c2, l2 := col2.Hcl() - // We know that h are both in [0..360] - return Hcl(interp_angle(h1, h2, t), c1 + t*(c2 - c1), l1 + t*(l2 - l1)) + // We know that h are both in [0..360] + return Hcl(interp_angle(h1, h2, t), c1+t*(c2-c1), l1+t*(l2-l1)) } diff --git a/vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go b/vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go index d078a8b..bb66dfa 100644 --- a/vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go +++ b/vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go @@ -1,26 +1,25 @@ package colorful import ( - "math/rand" + "math/rand" ) // Uses the HSV color space to generate colors with similar S,V but distributed // evenly along their Hue. This is fast but not always pretty. // If you've got time to spare, use Lab (the non-fast below). func FastHappyPalette(colorsCount int) (colors []Color) { - colors = make([]Color, colorsCount) + colors = make([]Color, colorsCount) - for i := 0 ; i < colorsCount ; i++ { - colors[i] = Hsv(float64(i)*(360.0/float64(colorsCount)), 0.8 + rand.Float64()*0.2, 0.65 + rand.Float64()*0.2) - } - return + for i := 0; i < colorsCount; i++ { + colors[i] = Hsv(float64(i)*(360.0/float64(colorsCount)), 0.8+rand.Float64()*0.2, 0.65+rand.Float64()*0.2) + } + return } func HappyPalette(colorsCount int) ([]Color, error) { - pimpy := func(l, a, b float64) bool { - _, c, _ := LabToHcl(l, a, b) - return 0.3 <= c && 0.4 <= l && l <= 0.8 - } - return SoftPaletteEx(colorsCount, SoftPaletteSettings{pimpy, 50, true}) + pimpy := func(l, a, b float64) bool { + _, c, _ := LabToHcl(l, a, b) + return 0.3 <= c && 0.4 <= l && l <= 0.8 + } + return SoftPaletteEx(colorsCount, SoftPaletteSettings{pimpy, 50, true}) } - diff --git a/vendor/github.com/lucasb-eyer/go-colorful/soft_palettegen.go b/vendor/github.com/lucasb-eyer/go-colorful/soft_palettegen.go index 507f2db..0154ac9 100644 --- a/vendor/github.com/lucasb-eyer/go-colorful/soft_palettegen.go +++ b/vendor/github.com/lucasb-eyer/go-colorful/soft_palettegen.go @@ -4,27 +4,27 @@ package colorful import ( - "fmt" - "math" - "math/rand" + "fmt" + "math" + "math/rand" ) // The algorithm works in L*a*b* color space and converts to RGB in the end. // L* in [0..1], a* and b* in [-1..1] type lab_t struct { - L, A, B float64 + L, A, B float64 } type SoftPaletteSettings struct { - // A function which can be used to restrict the allowed color-space. - CheckColor func(l, a, b float64) bool + // A function which can be used to restrict the allowed color-space. + CheckColor func(l, a, b float64) bool - // The higher, the better quality but the slower. Usually two figures. - Iterations int + // The higher, the better quality but the slower. Usually two figures. + Iterations int - // Use up to 160000 or 8000 samples of the L*a*b* space (and thus calls to CheckColor). - // Set this to true only if your CheckColor shapes the Lab space weirdly. - ManySamples bool + // Use up to 160000 or 8000 samples of the L*a*b* space (and thus calls to CheckColor). + // Set this to true only if your CheckColor shapes the Lab space weirdly. + ManySamples bool } // Yeah, windows-stype Foo, FooEx, screw you golang... @@ -34,152 +34,152 @@ type SoftPaletteSettings struct { // specify a CheckColor function. func SoftPaletteEx(colorsCount int, settings SoftPaletteSettings) ([]Color, error) { - // Checks whether it's a valid RGB and also fulfills the potentially provided constraint. - check := func(col lab_t) bool { - c := Lab(col.L, col.A, col.B) - return c.IsValid() && (settings.CheckColor == nil || settings.CheckColor(col.L, col.A, col.B)) - } - - // Sample the color space. These will be the points k-means is run on. - dl := 0.05 - dab := 0.1 - if settings.ManySamples { - dl = 0.01 - dab = 0.05 - } - - samples := make([]lab_t, 0, int(1.0/dl * 2.0/dab * 2.0/dab)) - for l := 0.0; l <= 1.0; l += dl { - for a := -1.0; a <= 1.0; a += dab { - for b := -1.0; b <= 1.0; b += dab { - if check(lab_t{l,a,b}) { - samples = append(samples, lab_t{l, a, b}) - } - } - } - } - - // That would cause some infinite loops down there... - if len(samples) < colorsCount { - return nil, fmt.Errorf("palettegen: more colors requested (%v) than samples available (%v). Your requested color count may be wrong, you might want to use many samples or your constraint function makes the valid color space too small.", colorsCount, len(samples)) - } else if len(samples) == colorsCount { - return labs2cols(samples), nil // Oops? - } - - // We take the initial means out of the samples, so they are in fact medoids. - // This helps us avoid infinite loops or arbitrary cutoffs with too restrictive constraints. - means := make([]lab_t, colorsCount) - for i := 0; i < colorsCount; i++ { - for means[i] = samples[rand.Intn(len(samples))] ; in(means, i, means[i]) ; means[i] = samples[rand.Intn(len(samples))] { - } - } - - clusters := make([]int, len(samples)) - samples_used := make([]bool, len(samples)) - - // The actual k-means/medoid iterations - for i := 0; i < settings.Iterations; i++ { - // Reassing the samples to clusters, i.e. to their closest mean. - // By the way, also check if any sample is used as a medoid and if so, mark that. - for isample, sample := range samples { - samples_used[isample] = false - mindist := math.Inf(+1) - for imean, mean := range means { - dist := lab_dist(sample, mean) - if dist < mindist { - mindist = dist - clusters[isample] = imean - } - - // Mark samples which are used as a medoid. - if lab_eq(sample, mean) { - samples_used[isample] = true - } - } - } - - // Compute new means according to the samples. - for imean := range means { - // The new mean is the average of all samples belonging to it.. - nsamples := 0 - newmean := lab_t{0.0, 0.0, 0.0} - for isample, sample := range samples { - if clusters[isample] == imean { - nsamples++ - newmean.L += sample.L - newmean.A += sample.A - newmean.B += sample.B - } - } - if nsamples > 0 { - newmean.L /= float64(nsamples) - newmean.A /= float64(nsamples) - newmean.B /= float64(nsamples) - } else { - // That mean doesn't have any samples? Get a new mean from the sample list! - var inewmean int - for inewmean = rand.Intn(len(samples_used)); samples_used[inewmean]; inewmean = rand.Intn(len(samples_used)) { - } - newmean = samples[inewmean] - samples_used[inewmean] = true - } - - // But now we still need to check whether the new mean is an allowed color. - if nsamples > 0 && check(newmean) { - // It does, life's good (TM) - means[imean] = newmean - } else { - // New mean isn't an allowed color or doesn't have any samples! - // Switch to medoid mode and pick the closest (unused) sample. - // This should always find something thanks to len(samples) >= colorsCount - mindist := math.Inf(+1) - for isample, sample := range samples { - if !samples_used[isample] { - dist := lab_dist(sample, newmean) - if dist < mindist { - mindist = dist - newmean = sample - } - } - } - } - } - } - return labs2cols(means), nil + // Checks whether it's a valid RGB and also fulfills the potentially provided constraint. + check := func(col lab_t) bool { + c := Lab(col.L, col.A, col.B) + return c.IsValid() && (settings.CheckColor == nil || settings.CheckColor(col.L, col.A, col.B)) + } + + // Sample the color space. These will be the points k-means is run on. + dl := 0.05 + dab := 0.1 + if settings.ManySamples { + dl = 0.01 + dab = 0.05 + } + + samples := make([]lab_t, 0, int(1.0/dl*2.0/dab*2.0/dab)) + for l := 0.0; l <= 1.0; l += dl { + for a := -1.0; a <= 1.0; a += dab { + for b := -1.0; b <= 1.0; b += dab { + if check(lab_t{l, a, b}) { + samples = append(samples, lab_t{l, a, b}) + } + } + } + } + + // That would cause some infinite loops down there... + if len(samples) < colorsCount { + return nil, fmt.Errorf("palettegen: more colors requested (%v) than samples available (%v). Your requested color count may be wrong, you might want to use many samples or your constraint function makes the valid color space too small.", colorsCount, len(samples)) + } else if len(samples) == colorsCount { + return labs2cols(samples), nil // Oops? + } + + // We take the initial means out of the samples, so they are in fact medoids. + // This helps us avoid infinite loops or arbitrary cutoffs with too restrictive constraints. + means := make([]lab_t, colorsCount) + for i := 0; i < colorsCount; i++ { + for means[i] = samples[rand.Intn(len(samples))]; in(means, i, means[i]); means[i] = samples[rand.Intn(len(samples))] { + } + } + + clusters := make([]int, len(samples)) + samples_used := make([]bool, len(samples)) + + // The actual k-means/medoid iterations + for i := 0; i < settings.Iterations; i++ { + // Reassing the samples to clusters, i.e. to their closest mean. + // By the way, also check if any sample is used as a medoid and if so, mark that. + for isample, sample := range samples { + samples_used[isample] = false + mindist := math.Inf(+1) + for imean, mean := range means { + dist := lab_dist(sample, mean) + if dist < mindist { + mindist = dist + clusters[isample] = imean + } + + // Mark samples which are used as a medoid. + if lab_eq(sample, mean) { + samples_used[isample] = true + } + } + } + + // Compute new means according to the samples. + for imean := range means { + // The new mean is the average of all samples belonging to it.. + nsamples := 0 + newmean := lab_t{0.0, 0.0, 0.0} + for isample, sample := range samples { + if clusters[isample] == imean { + nsamples++ + newmean.L += sample.L + newmean.A += sample.A + newmean.B += sample.B + } + } + if nsamples > 0 { + newmean.L /= float64(nsamples) + newmean.A /= float64(nsamples) + newmean.B /= float64(nsamples) + } else { + // That mean doesn't have any samples? Get a new mean from the sample list! + var inewmean int + for inewmean = rand.Intn(len(samples_used)); samples_used[inewmean]; inewmean = rand.Intn(len(samples_used)) { + } + newmean = samples[inewmean] + samples_used[inewmean] = true + } + + // But now we still need to check whether the new mean is an allowed color. + if nsamples > 0 && check(newmean) { + // It does, life's good (TM) + means[imean] = newmean + } else { + // New mean isn't an allowed color or doesn't have any samples! + // Switch to medoid mode and pick the closest (unused) sample. + // This should always find something thanks to len(samples) >= colorsCount + mindist := math.Inf(+1) + for isample, sample := range samples { + if !samples_used[isample] { + dist := lab_dist(sample, newmean) + if dist < mindist { + mindist = dist + newmean = sample + } + } + } + } + } + } + return labs2cols(means), nil } // A wrapper which uses common parameters. func SoftPalette(colorsCount int) ([]Color, error) { - return SoftPaletteEx(colorsCount, SoftPaletteSettings{nil, 50, false}) + return SoftPaletteEx(colorsCount, SoftPaletteSettings{nil, 50, false}) } func in(haystack []lab_t, upto int, needle lab_t) bool { - for i := 0 ; i < upto && i < len(haystack) ; i++ { - if haystack[i] == needle { - return true - } - } - return false + for i := 0; i < upto && i < len(haystack); i++ { + if haystack[i] == needle { + return true + } + } + return false } const LAB_DELTA = 1e-6 + func lab_eq(lab1, lab2 lab_t) bool { - return math.Abs(lab1.L - lab2.L) < LAB_DELTA && - math.Abs(lab1.A - lab2.A) < LAB_DELTA && - math.Abs(lab1.B - lab2.B) < LAB_DELTA + return math.Abs(lab1.L-lab2.L) < LAB_DELTA && + math.Abs(lab1.A-lab2.A) < LAB_DELTA && + math.Abs(lab1.B-lab2.B) < LAB_DELTA } // That's faster than using colorful's DistanceLab since we would have to // convert back and forth for that. Here is no conversion. func lab_dist(lab1, lab2 lab_t) float64 { - return math.Sqrt(sq(lab1.L-lab2.L) + sq(lab1.A-lab2.A) + sq(lab1.B-lab2.B)) + return math.Sqrt(sq(lab1.L-lab2.L) + sq(lab1.A-lab2.A) + sq(lab1.B-lab2.B)) } func labs2cols(labs []lab_t) (cols []Color) { - cols = make([]Color, len(labs)) - for k, v := range labs { - cols[k] = Lab(v.L, v.A, v.B) - } - return cols + cols = make([]Color, len(labs)) + for k, v := range labs { + cols[k] = Lab(v.L, v.A, v.B) + } + return cols } - diff --git a/vendor/github.com/lucasb-eyer/go-colorful/warm_palettegen.go b/vendor/github.com/lucasb-eyer/go-colorful/warm_palettegen.go index 18ff950..00f42a5 100644 --- a/vendor/github.com/lucasb-eyer/go-colorful/warm_palettegen.go +++ b/vendor/github.com/lucasb-eyer/go-colorful/warm_palettegen.go @@ -1,26 +1,25 @@ package colorful import ( - "math/rand" + "math/rand" ) // Uses the HSV color space to generate colors with similar S,V but distributed // evenly along their Hue. This is fast but not always pretty. // If you've got time to spare, use Lab (the non-fast below). func FastWarmPalette(colorsCount int) (colors []Color) { - colors = make([]Color, colorsCount) + colors = make([]Color, colorsCount) - for i := 0 ; i < colorsCount ; i++ { - colors[i] = Hsv(float64(i)*(360.0/float64(colorsCount)), 0.55 + rand.Float64()*0.2, 0.35 + rand.Float64()*0.2) - } - return + for i := 0; i < colorsCount; i++ { + colors[i] = Hsv(float64(i)*(360.0/float64(colorsCount)), 0.55+rand.Float64()*0.2, 0.35+rand.Float64()*0.2) + } + return } func WarmPalette(colorsCount int) ([]Color, error) { - warmy := func(l, a, b float64) bool { - _, c, _ := LabToHcl(l, a, b) - return 0.1 <= c && c <= 0.4 && 0.2 <= l && l <= 0.5 - } - return SoftPaletteEx(colorsCount, SoftPaletteSettings{warmy, 50, true}) + warmy := func(l, a, b float64) bool { + _, c, _ := LabToHcl(l, a, b) + return 0.1 <= c && c <= 0.4 && 0.2 <= l && l <= 0.5 + } + return SoftPaletteEx(colorsCount, SoftPaletteSettings{warmy, 50, true}) } - diff --git a/vendor/maunium.net/go/tcell/cell.go b/vendor/maunium.net/go/tcell/cell.go index b54abcb..496f10f 100644 --- a/vendor/maunium.net/go/tcell/cell.go +++ b/vendor/maunium.net/go/tcell/cell.go @@ -48,12 +48,13 @@ func (cb *CellBuffer) SetContent(x int, y int, if x >= 0 && y >= 0 && x < cb.w && y < cb.h { c := &cb.cells[(y*cb.w)+x] + c.currComb = append([]rune{}, combc...) i := 0 - for i < len(combc) { - r := combc[i] + for i < len(c.currComb) { + r := c.currComb[i] if runewidth.RuneWidth(r) != 0 { // not a combining character, yank it - combc = append(combc[:i-1], combc[i+1:]...) + c.currComb = append(c.currComb[:i-1], c.currComb[i+1:]...) continue } i++ @@ -63,7 +64,6 @@ func (cb *CellBuffer) SetContent(x int, y int, c.width = runewidth.RuneWidth(mainc) } c.currMain = mainc - c.currComb = combc c.currStyle = style } } diff --git a/vendor/maunium.net/go/tcell/console_win.go b/vendor/maunium.net/go/tcell/console_win.go index 21a235d..5957a17 100644 --- a/vendor/maunium.net/go/tcell/console_win.go +++ b/vendor/maunium.net/go/tcell/console_win.go @@ -185,7 +185,7 @@ func (s *cScreen) CharacterSet() string { } func (s *cScreen) EnableMouse() { - s.setInMode(modeResizeEn | modeMouseEn) + s.setInMode(modeResizeEn | modeMouseEn | modeExtndFlg) } func (s *cScreen) DisableMouse() { @@ -570,8 +570,14 @@ func (s *cScreen) getConsoleInput() error { if krec.ch != 0 { // synthesized key code for krec.repeat > 0 { - s.PostEvent(NewEventKey(KeyRune, rune(krec.ch), - mod2mask(krec.mod))) + // convert shift+tab to backtab + if mod2mask(krec.mod) == ModShift && krec.ch == vkTab { + s.PostEvent(NewEventKey(KeyBacktab, 0, + ModNone)) + } else { + s.PostEvent(NewEventKey(KeyRune, rune(krec.ch), + mod2mask(krec.mod))) + } krec.repeat-- } return nil @@ -925,6 +931,7 @@ func (s *cScreen) clearScreen(style Style) { } const ( + modeExtndFlg uint32 = 0x0080 modeMouseEn uint32 = 0x0010 modeResizeEn uint32 = 0x0008 modeWrapEOL uint32 = 0x0002 diff --git a/vendor/maunium.net/go/tcell/terminfo/README.md b/vendor/maunium.net/go/tcell/terminfo/README.md new file mode 100644 index 0000000..b333701 --- /dev/null +++ b/vendor/maunium.net/go/tcell/terminfo/README.md @@ -0,0 +1,8 @@ +To run the database: + +./mkinfo -all + +You can also generate a single entry: + +./mkinfo -db + diff --git a/vendor/maunium.net/go/tcell/terminfo/mkdatabase.sh b/vendor/maunium.net/go/tcell/terminfo/mkdatabase.sh deleted file mode 100755 index fd968bd..0000000 --- a/vendor/maunium.net/go/tcell/terminfo/mkdatabase.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/bash - -# Copyright 2017 The TCell Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use file except in compliance with the License. -# You may obtain a copy of the license at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# When called with no arguments, this shell script builds the Go database, -# which is somewhat minimal for size reasons (it only contains the most -# commonly used entries), and then builds the complete JSON database. -# -# To limit the action to only building one or more terminals, specify them -# on the command line: -# -# ./mkdatabase xterm -# -# The script will also find and update or add any terminal "aliases". -# It does not remove any old entries. -# -# To add to the set of terminals that we compile into the Go database, -# add their names to the models.txt file. -# - -# This script is not very efficient, but there isn't really a better way -# without writing code to decode the terminfo binary format directly. -# Its not worth worrying about. - -# This script also requires bash, although ksh93 should work as well, because -# we use arrays, which are not specified in POSIX. - -export LANG=C -export LC_CTYPE=C - -progress() -{ - typeset -i num=$1 - typeset -i tot=$2 - typeset -i x - typeset back - typeset s - - if (( tot < 1 )) - then - s=$(printf "[ %d ]" $num) - back="\b\b\b\b\b" - x=$num - while (( x >= 10 )) - do - back="${back}\b" - x=$(( x / 10 )) - done - - else - x=$(( num * 100 / tot )) - s=$(printf "<%3d%%>" $x) - back="\b\b\b\b\b\b" - fi - printf "%s${back}" "$s" -} - -ord() -{ - printf "%02x" "'$1'" -} - -goterms=( $(cat models.txt) ) -args=( $* ) -if (( ${#args[@]} == 0 )) -then - args=( $(toe -a | cut -f1) ) -fi - -printf "Scanning terminal definitions: " -i=0 -aliases=() -models=() -for term in ${args[@]} -do - case "${term}" in - *-truecolor) - line="${term}|24-bit color" - ;; - *) - line=$(infocmp $term | head -2 | tail -1) - if [[ -z "$line" ]] - then - echo "Cannot find terminfo for $term" - exit 1 - fi - # take off the trailing comma - line=${line%,} - esac - - # grab primary name - term=${line%%|*} - all+=( ${term} ) - - # should this be in our go terminals? - for model in ${goterms[@]} - do - if [[ "${model}" == "${term}" ]] - then - models+=( ${term} ) - fi - done - - # chop off primary name - line=${line#${term}} - line=${line#|} - # chop off description - line=${line%|*} - while [[ "$line" != "" ]] - do - a=${line%%|*} - aliases+=( ${a}=${term} ) - line=${line#$a} - line=${line#|} - done - i=$(( i + 1 )) - progress $i ${#args[@]} -done -echo -# make sure we have mkinfo -printf "Building mkinfo: " -go build mkinfo.go -echo "done." - -# Build all the go database files for the "interesting" terminals". -printf "Building Go database: " -i=0 -for model in ${models[@]} -do - safe=$(echo $model | tr - _) - file=term_${safe}.go - ./mkinfo -go $file $model - go fmt ${file} >/dev/null - i=$(( i + 1 )) - progress $i ${#models[@]} -done -echo - -printf "Building JSON database: " - -# The JSON files are located for each terminal in a file with the -# terminal name, in the following fashion "database/x/xterm.json - -i=0 -for model in ${all[@]} -do - letter=$(ord ${model:0:1}) - dir=database/${letter} - file=${dir}/${model}.gz - mkdir -p ${dir} - ./mkinfo -nofatal -quiet -gzip -json ${file} ${model} - i=$(( i + 1 )) - progress $i ${#all[@]} -done -echo - -printf "Building JSON aliases: " -i=0 -for model in ${aliases[@]} -do - canon=${model#*=} - model=${model%=*} - letter=$(ord ${model:0:1}) - cletter=$(ord ${canon:0:1}) - dir=database/${letter} - file=${dir}/${model} - if [[ -f database/${cletter}/${canon}.gz ]] - then - [[ -d ${dir} ]] || mkdir -p ${dir} - # Generally speaking the aliases are better uncompressed - ./mkinfo -nofatal -quiet -json ${file} ${model} - fi - i=$(( i + 1 )) - progress $i ${#aliases[@]} -done -echo diff --git a/vendor/maunium.net/go/tcell/terminfo/mkinfo.go b/vendor/maunium.net/go/tcell/terminfo/mkinfo.go index 0040e6c..9e4b710 100644 --- a/vendor/maunium.net/go/tcell/terminfo/mkinfo.go +++ b/vendor/maunium.net/go/tcell/terminfo/mkinfo.go @@ -1,6 +1,6 @@ // +build ignore -// Copyright 2017 The TCell Authors +// Copyright 2018 The TCell Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use file except in compliance with the License. @@ -22,6 +22,8 @@ // // mkinfo [-init] [-go file.go] [-json file.json] [-quiet] [-nofatal] [...] // +// -all scan terminfo to determine database entries to use +// -db generate database entries (database/*), implied for -all // -gzip specifies output should be compressed (json only) // -go specifies Go output into the named file. Use - for stdout. // -json specifies JSON output in the named file. Use - for stdout @@ -31,8 +33,10 @@ package main import ( + "bufio" "bytes" "compress/gzip" + "crypto/sha1" "encoding/json" "errors" "flag" @@ -40,6 +44,7 @@ import ( "io" "os" "os/exec" + "path" "regexp" "strconv" "strings" @@ -74,6 +79,8 @@ const ( ESC ) +var notaddressable = errors.New("terminal not cursor addressable") + func unescape(s string) string { // Various escapes are in \x format. Control codes are // encoded as ^M (carat followed by ASCII equivalent). @@ -131,6 +138,25 @@ func unescape(s string) string { return (buf.String()) } +func getallterms() ([]string, error) { + out := []string{} + cmd := exec.Command("toe", "-a") + output := &bytes.Buffer{} + cmd.Stdout = output + err := cmd.Run() + if err != nil { + return nil, err + } + lines := strings.Split(output.String(), "\n") + for _, l := range lines { + fields := strings.Fields(l) + if len(fields) > 0 { + out = append(out, fields[0]) + } + } + return out, nil +} + func (tc *termcap) setupterm(name string) error { cmd := exec.Command("infocmp", "-1", name) output := &bytes.Buffer{} @@ -183,7 +209,7 @@ func (tc *termcap) setupterm(name string) error { if k := strings.SplitN(val, "=", 2); len(k) == 2 { tc.strs[k[0]] = unescape(k[1]) } else if k := strings.SplitN(val, "#", 2); len(k) == 2 { - if u, err := strconv.ParseUint(k[1], 10, 0); err != nil { + if u, err := strconv.ParseUint(k[1], 0, 0); err != nil { return (err) } else { tc.nums[k[0]] = int(u) @@ -438,7 +464,7 @@ func getinfo(name string) (*terminfo.Terminfo, string, error) { t.Colors = 0 } if t.SetCursor == "" { - return nil, "", errors.New("terminal not cursor addressable") + return nil, "", notaddressable } // For padding, we lookup the pad char. If that isn't present, @@ -684,13 +710,135 @@ func dotGoInfo(w io.Writer, t *terminfo.Terminfo, desc string) { fmt.Fprintln(w, "}") } +var packname = "terminfo" + +func dotGoFile(fname string, term *terminfo.Terminfo, desc string, makeDir bool) error { + w := os.Stdout + var e error + if fname != "-" && fname != "" { + if makeDir { + dname := path.Dir(fname) + _ = os.Mkdir(dname, 0777) + } + if w, e = os.Create(fname); e != nil { + return e + } + } + dotGoHeader(w, packname) + dotGoInfo(w, term, desc) + dotGoTrailer(w) + if w != os.Stdout { + w.Close() + } + cmd := exec.Command("go", "fmt", fname) + cmd.Run() + return nil +} + +func dotGzFile(fname string, term *terminfo.Terminfo, makeDir bool) error { + + var w io.WriteCloser = os.Stdout + var e error + if fname != "-" && fname != "" { + if makeDir { + dname := path.Dir(fname) + _ = os.Mkdir(dname, 0777) + } + if w, e = os.Create(fname); e != nil { + return e + } + } + + w = gzip.NewWriter(w) + + js, e := json.Marshal(term) + fmt.Fprintln(w, string(js)) + + if w != os.Stdout { + w.Close() + } + return nil +} + +func jsonFile(fname string, term *terminfo.Terminfo, makeDir bool) error { + w := os.Stdout + var e error + if fname != "-" && fname != "" { + if makeDir { + dname := path.Dir(fname) + _ = os.Mkdir(dname, 0777) + } + if w, e = os.Create(fname); e != nil { + return e + } + } + + js, e := json.Marshal(term) + fmt.Fprintln(w, string(js)) + + if w != os.Stdout { + w.Close() + } + return nil +} + +func dumpDatabase(terms map[string]*terminfo.Terminfo, descs map[string]string) { + + // Load models .text + mfile, e := os.Open("models.txt") + models := make(map[string]bool) + if e != nil { + fmt.Fprintf(os.Stderr, "Failed reading models.txt: %v", e) + } + scanner := bufio.NewScanner(mfile) + for scanner.Scan() { + models[scanner.Text()] = true + } + + for name, t := range terms { + + // If this is one of our builtin models, generate the GO file + if models[name] { + desc := descs[name] + safename := strings.Replace(name, "-", "_", -1) + goname := fmt.Sprintf("term_%s.go", safename) + e = dotGoFile(goname, t, desc, true) + if e != nil { + fmt.Fprintf(os.Stderr, "Failed creating %s: %v", goname, e) + os.Exit(1) + } + continue + } + + hash := fmt.Sprintf("%x", sha1.Sum([]byte(name))) + fname := fmt.Sprintf("%s.gz", hash[0:8]) + fname = path.Join("database", hash[0:2], fname) + e = dotGzFile(fname, t, true) + if e != nil { + fmt.Fprintf(os.Stderr, "Failed creating %s: %v", fname, e) + os.Exit(1) + } + + for _, a := range t.Aliases { + hash = fmt.Sprintf("%x", sha1.Sum([]byte(a))) + fname = path.Join("database", hash[0:2], hash[0:8]) + e = jsonFile(fname, &terminfo.Terminfo{Name: t.Name}, true) + if e != nil { + fmt.Fprintf(os.Stderr, "Failed creating %s: %v", fname, e) + os.Exit(1) + } + } + } +} + func main() { gofile := "" jsonfile := "" - packname := "terminfo" nofatal := false quiet := false dogzip := false + all := false + db := false flag.StringVar(&gofile, "go", "", "generate go source in named file") flag.StringVar(&jsonfile, "json", "", "generate json in named file") @@ -698,11 +846,21 @@ func main() { flag.BoolVar(&nofatal, "nofatal", false, "errors are not fatal") flag.BoolVar(&quiet, "quiet", false, "suppress error messages") flag.BoolVar(&dogzip, "gzip", false, "compress json output") + flag.BoolVar(&all, "all", false, "load all terminals from terminfo") + flag.BoolVar(&db, "db", false, "generate json db file in place") flag.Parse() var e error - js := []byte{} args := flag.Args() + if all { + db = true // implied + allterms, e := getallterms() + if e != nil { + fmt.Fprintf(os.Stderr, "Failed: %v", e) + os.Exit(1) + } + args = append(args, allterms...) + } if len(args) == 0 { args = []string{os.Getenv("TERM")} } @@ -712,6 +870,9 @@ func main() { for _, term := range args { if t, desc, e := getinfo(term); e != nil { + if all && e == notaddressable { + continue + } if !quiet { fmt.Fprintf(os.Stderr, "Failed loading %s: %v\n", term, e) @@ -729,53 +890,33 @@ func main() { // No data. os.Exit(0) } - if gofile != "" { - w := os.Stdout - if gofile != "-" { - if w, e = os.Create(gofile); e != nil { - fmt.Fprintf(os.Stderr, "Failed: %v", e) - os.Exit(1) - } - } - dotGoHeader(w, packname) + + if db { + dumpDatabase(tdata, descs) + } else if gofile != "" { for term, t := range tdata { if t.Name == term { - dotGoInfo(w, t, descs[term]) + e = dotGoFile(gofile, t, descs[term], false) + if e != nil { + fmt.Fprintf(os.Stderr, "Failed %s: %v", gofile, e) + os.Exit(1) + } } } - dotGoTrailer(w) - if w != os.Stdout { - w.Close() - } + } else { - o := os.Stdout - if jsonfile != "-" && jsonfile != "" { - if o, e = os.Create(jsonfile); e != nil { - fmt.Fprintf(os.Stderr, "Failed: %v", e) - } - } - var w io.WriteCloser - w = o - if dogzip { - w = gzip.NewWriter(o) - } - for _, term := range args { - if t := tdata[term]; t != nil { - js, e = json.Marshal(t) - fmt.Fprintln(w, string(js)) + for _, t := range tdata { + if dogzip { + if e = dotGzFile(jsonfile, t, false); e != nil { + fmt.Fprintf(os.Stderr, "Failed %s: %v", gofile, e) + os.Exit(1) + } + } else { + if e = jsonFile(jsonfile, t, false); e != nil { + fmt.Fprintf(os.Stderr, "Failed %s: %v", gofile, e) + os.Exit(1) + } } - // arguably if there is more than one term, this - // should be a javascript array, but that's not how - // we load it. We marshal objects one at a time from - // the file. - } - if e != nil { - fmt.Fprintf(os.Stderr, "Failed: %v", e) - os.Exit(1) - } - w.Close() - if w != o { - o.Close() } } } diff --git a/vendor/maunium.net/go/tcell/terminfo/models.txt b/vendor/maunium.net/go/tcell/terminfo/models.txt index ac0676d..718eb9b 100644 --- a/vendor/maunium.net/go/tcell/terminfo/models.txt +++ b/vendor/maunium.net/go/tcell/terminfo/models.txt @@ -8,8 +8,6 @@ cygwin d200 d210 dtterm -Eterm -Eterm-256color eterm gnome gnome-256color diff --git a/vendor/maunium.net/go/tcell/terminfo/term_Eterm.go b/vendor/maunium.net/go/tcell/terminfo/term_Eterm.go deleted file mode 100644 index 30d5af3..0000000 --- a/vendor/maunium.net/go/tcell/terminfo/term_Eterm.go +++ /dev/null @@ -1,108 +0,0 @@ -// Generated automatically. DO NOT HAND-EDIT. - -package terminfo - -func init() { - // Eterm with xterm-style color support (X Window System) - AddTerminfo(&Terminfo{ - Name: "Eterm", - Aliases: []string{"Eterm-color"}, - Columns: 80, - Lines: 24, - Colors: 8, - Bell: "\a", - Clear: "\x1b[H\x1b[2J", - EnterCA: "\x1b7\x1b[?47h", - ExitCA: "\x1b[2J\x1b[?47l\x1b8", - ShowCursor: "\x1b[?25h", - HideCursor: "\x1b[?25l", - AttrOff: "\x1b[m\x0f", - Underline: "\x1b[4m", - Bold: "\x1b[1m", - Italic: "\x1b[3m", - Strikethrough: "\x1b[9m", - Blink: "\x1b[5m", - Reverse: "\x1b[7m", - SetFg: "\x1b[3%p1%dm", - SetBg: "\x1b[4%p1%dm", - SetFgBg: "\x1b[3%p1%d;4%p2%dm", - PadChar: "\x00", - AltChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", - EnterAcs: "\x0e", - ExitAcs: "\x0f", - EnableAcs: "\x1b)0", - Mouse: "\x1b[M", - MouseMode: "%?%p1%{1}%=%t%'h'%Pa%e%'l'%Pa%;\x1b[?1000%ga%c\x1b[?1002%ga%c\x1b[?1003%ga%c\x1b[?1006%ga%c", - SetCursor: "\x1b[%i%p1%d;%p2%dH", - CursorBack1: "\b", - CursorUp1: "\x1b[A", - KeyUp: "\x1b[A", - KeyDown: "\x1b[B", - KeyRight: "\x1b[C", - KeyLeft: "\x1b[D", - KeyInsert: "\x1b[2~", - KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", - KeyHome: "\x1b[7~", - KeyEnd: "\x1b[8~", - KeyPgUp: "\x1b[5~", - KeyPgDn: "\x1b[6~", - KeyF1: "\x1b[11~", - KeyF2: "\x1b[12~", - KeyF3: "\x1b[13~", - KeyF4: "\x1b[14~", - KeyF5: "\x1b[15~", - KeyF6: "\x1b[17~", - KeyF7: "\x1b[18~", - KeyF8: "\x1b[19~", - KeyF9: "\x1b[20~", - KeyF10: "\x1b[21~", - KeyF11: "\x1b[23~", - KeyF12: "\x1b[24~", - KeyF13: "\x1b[25~", - KeyF14: "\x1b[26~", - KeyF15: "\x1b[28~", - KeyF16: "\x1b[29~", - KeyF17: "\x1b[31~", - KeyF18: "\x1b[32~", - KeyF19: "\x1b[33~", - KeyF20: "\x1b[34~", - KeyF21: "\x1b[23$", - KeyF22: "\x1b[24$", - KeyF23: "\x1b[11^", - KeyF24: "\x1b[12^", - KeyF25: "\x1b[13^", - KeyF26: "\x1b[14^", - KeyF27: "\x1b[15^", - KeyF28: "\x1b[17^", - KeyF29: "\x1b[18^", - KeyF30: "\x1b[19^", - KeyF31: "\x1b[20^", - KeyF32: "\x1b[21^", - KeyF33: "\x1b[23^", - KeyF34: "\x1b[24^", - KeyF35: "\x1b[25^", - KeyF36: "\x1b[26^", - KeyF37: "\x1b[28^", - KeyF38: "\x1b[29^", - KeyF39: "\x1b[31^", - KeyF40: "\x1b[32^", - KeyF41: "\x1b[33^", - KeyF42: "\x1b[34^", - KeyF43: "\x1b[23@", - KeyF44: "\x1b[24@", - KeyHelp: "\x1b[28~", - KeyShfLeft: "\x1b[d", - KeyShfRight: "\x1b[c", - KeyShfUp: "\x1b[a", - KeyShfDown: "\x1b[b", - KeyCtrlLeft: "\x1b[Od", - KeyCtrlRight: "\x1b[Oc", - KeyCtrlUp: "\x1b[Oa", - KeyCtrlDown: "\x1b[Ob", - KeyShfHome: "\x1b[7$", - KeyShfEnd: "\x1b[8$", - KeyCtrlHome: "\x1b[7^", - KeyCtrlEnd: "\x1b[8^", - }) -} diff --git a/vendor/maunium.net/go/tcell/terminfo/term_Eterm_256color.go b/vendor/maunium.net/go/tcell/terminfo/term_Eterm_256color.go deleted file mode 100644 index 773b6c1..0000000 --- a/vendor/maunium.net/go/tcell/terminfo/term_Eterm_256color.go +++ /dev/null @@ -1,107 +0,0 @@ -// Generated automatically. DO NOT HAND-EDIT. - -package terminfo - -func init() { - // Eterm with xterm 256-colors - AddTerminfo(&Terminfo{ - Name: "Eterm-256color", - Columns: 80, - Lines: 24, - Colors: 256, - Bell: "\a", - Clear: "\x1b[H\x1b[2J", - EnterCA: "\x1b7\x1b[?47h", - ExitCA: "\x1b[2J\x1b[?47l\x1b8", - ShowCursor: "\x1b[?25h", - HideCursor: "\x1b[?25l", - AttrOff: "\x1b[m\x0f", - Underline: "\x1b[4m", - Bold: "\x1b[1m", - Italic: "\x1b[3m", - Strikethrough: "\x1b[9m", - Blink: "\x1b[5m", - Reverse: "\x1b[7m", - SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", - SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", - SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m", - PadChar: "\x00", - AltChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", - EnterAcs: "\x0e", - ExitAcs: "\x0f", - EnableAcs: "\x1b)0", - Mouse: "\x1b[M", - MouseMode: "%?%p1%{1}%=%t%'h'%Pa%e%'l'%Pa%;\x1b[?1000%ga%c\x1b[?1002%ga%c\x1b[?1003%ga%c\x1b[?1006%ga%c", - SetCursor: "\x1b[%i%p1%d;%p2%dH", - CursorBack1: "\b", - CursorUp1: "\x1b[A", - KeyUp: "\x1b[A", - KeyDown: "\x1b[B", - KeyRight: "\x1b[C", - KeyLeft: "\x1b[D", - KeyInsert: "\x1b[2~", - KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", - KeyHome: "\x1b[7~", - KeyEnd: "\x1b[8~", - KeyPgUp: "\x1b[5~", - KeyPgDn: "\x1b[6~", - KeyF1: "\x1b[11~", - KeyF2: "\x1b[12~", - KeyF3: "\x1b[13~", - KeyF4: "\x1b[14~", - KeyF5: "\x1b[15~", - KeyF6: "\x1b[17~", - KeyF7: "\x1b[18~", - KeyF8: "\x1b[19~", - KeyF9: "\x1b[20~", - KeyF10: "\x1b[21~", - KeyF11: "\x1b[23~", - KeyF12: "\x1b[24~", - KeyF13: "\x1b[25~", - KeyF14: "\x1b[26~", - KeyF15: "\x1b[28~", - KeyF16: "\x1b[29~", - KeyF17: "\x1b[31~", - KeyF18: "\x1b[32~", - KeyF19: "\x1b[33~", - KeyF20: "\x1b[34~", - KeyF21: "\x1b[23$", - KeyF22: "\x1b[24$", - KeyF23: "\x1b[11^", - KeyF24: "\x1b[12^", - KeyF25: "\x1b[13^", - KeyF26: "\x1b[14^", - KeyF27: "\x1b[15^", - KeyF28: "\x1b[17^", - KeyF29: "\x1b[18^", - KeyF30: "\x1b[19^", - KeyF31: "\x1b[20^", - KeyF32: "\x1b[21^", - KeyF33: "\x1b[23^", - KeyF34: "\x1b[24^", - KeyF35: "\x1b[25^", - KeyF36: "\x1b[26^", - KeyF37: "\x1b[28^", - KeyF38: "\x1b[29^", - KeyF39: "\x1b[31^", - KeyF40: "\x1b[32^", - KeyF41: "\x1b[33^", - KeyF42: "\x1b[34^", - KeyF43: "\x1b[23@", - KeyF44: "\x1b[24@", - KeyHelp: "\x1b[28~", - KeyShfLeft: "\x1b[d", - KeyShfRight: "\x1b[c", - KeyShfUp: "\x1b[a", - KeyShfDown: "\x1b[b", - KeyCtrlLeft: "\x1b[Od", - KeyCtrlRight: "\x1b[Oc", - KeyCtrlUp: "\x1b[Oa", - KeyCtrlDown: "\x1b[Ob", - KeyShfHome: "\x1b[7$", - KeyShfEnd: "\x1b[8$", - KeyCtrlHome: "\x1b[7^", - KeyCtrlEnd: "\x1b[8^", - }) -} diff --git a/vendor/maunium.net/go/tcell/terminfo/term_aixterm.go b/vendor/maunium.net/go/tcell/terminfo/term_aixterm.go index 9dc5f29..f8ec2d9 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_aixterm.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_aixterm.go @@ -22,6 +22,8 @@ func init() { SetFgBg: "\x1b[3%p1%d;4%p2%dm", PadChar: "\x00", AltChars: "jjkkllmmnnqqttuuvvwwxx", + EnterAcs: "\x1b(0", + ExitAcs: "\x1b(B", SetCursor: "\x1b[%i%p1%d;%p2%dH", CursorBack1: "\b", CursorUp1: "\x1b[A", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_aterm.go b/vendor/maunium.net/go/tcell/terminfo/term_aterm.go index a8d2f99..aef93f5 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_aterm.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_aterm.go @@ -43,7 +43,7 @@ func init() { KeyLeft: "\x1b[D", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1b[7~", KeyEnd: "\x1b[8~", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_eterm.go b/vendor/maunium.net/go/tcell/terminfo/term_eterm.go new file mode 100644 index 0000000..c568a47 --- /dev/null +++ b/vendor/maunium.net/go/tcell/terminfo/term_eterm.go @@ -0,0 +1,26 @@ +// Generated automatically. DO NOT HAND-EDIT. + +package terminfo + +func init() { + // gnu emacs term.el terminal emulation + AddTerminfo(&Terminfo{ + Name: "eterm", + Columns: 80, + Lines: 24, + Bell: "\a", + Clear: "\x1b[H\x1b[J", + EnterCA: "\x1b7\x1b[?47h", + ExitCA: "\x1b[2J\x1b[?47l\x1b8", + AttrOff: "\x1b[m", + Underline: "\x1b[4m", + Bold: "\x1b[1m", + Italic: "\x1b[3m", + Strikethrough: "\x1b[9m", + Reverse: "\x1b[7m", + PadChar: "\x00", + SetCursor: "\x1b[%i%p1%d;%p2%dH", + CursorBack1: "\b", + CursorUp1: "\x1b[A", + }) +} diff --git a/vendor/maunium.net/go/tcell/terminfo/term_gnome.go b/vendor/maunium.net/go/tcell/terminfo/term_gnome.go index 84c0957..aab921e 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_gnome.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_gnome.go @@ -43,7 +43,7 @@ func init() { KeyLeft: "\x1bOD", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1bOH", KeyEnd: "\x1bOF", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_gnome_256color.go b/vendor/maunium.net/go/tcell/terminfo/term_gnome_256color.go index cc504c3..cabcd93 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_gnome_256color.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_gnome_256color.go @@ -32,7 +32,7 @@ func init() { EnterAcs: "\x0e", ExitAcs: "\x0f", EnableAcs: "\x1b)0", - Mouse: "\x1b[M", + Mouse: "\x1b[<", MouseMode: "%?%p1%{1}%=%t%'h'%Pa%e%'l'%Pa%;\x1b[?1000%ga%c\x1b[?1002%ga%c\x1b[?1003%ga%c\x1b[?1006%ga%c", SetCursor: "\x1b[%i%p1%d;%p2%dH", CursorBack1: "\b", @@ -43,7 +43,7 @@ func init() { KeyLeft: "\x1bOD", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1bOH", KeyEnd: "\x1bOF", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_hpterm.go b/vendor/maunium.net/go/tcell/terminfo/term_hpterm.go index b5e0c6e..3e93a2f 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_hpterm.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_hpterm.go @@ -11,7 +11,7 @@ func init() { Lines: 24, Bell: "\a", Clear: "\x1b&a0y0C\x1bJ", - AttrOff: "\x1b&d@", + AttrOff: "\x1b&d@\x0f", Underline: "\x1b&dD", Bold: "\x1b&dB", Italic: "\x1b[3m", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_konsole.go b/vendor/maunium.net/go/tcell/terminfo/term_konsole.go index e545f4d..52fcf1f 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_konsole.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_konsole.go @@ -5,110 +5,151 @@ package terminfo func init() { // KDE console window AddTerminfo(&Terminfo{ - Name: "konsole", - Columns: 80, - Lines: 24, - Colors: 8, - Clear: "\x1b[H\x1b[2J", - EnterCA: "\x1b7\x1b[?47h", - ExitCA: "\x1b[2J\x1b[?47l\x1b8", - ShowCursor: "\x1b[?25h", - HideCursor: "\x1b[?25l", - AttrOff: "\x1b[0m\x0f", - Underline: "\x1b[4m", - Bold: "\x1b[1m", - Italic: "\x1b[3m", - Strikethrough: "\x1b[9m", - Blink: "\x1b[5m", - Reverse: "\x1b[7m", - EnterKeypad: "\x1b[?1h\x1b=", - ExitKeypad: "\x1b[?1l\x1b>", - SetFg: "\x1b[3%p1%dm", - SetBg: "\x1b[4%p1%dm", - SetFgBg: "\x1b[3%p1%d;4%p2%dm", - AltChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", - EnterAcs: "\x0e", - ExitAcs: "\x0f", - EnableAcs: "\x1b)0", - Mouse: "\x1b[M", - MouseMode: "%?%p1%{1}%=%t%'h'%Pa%e%'l'%Pa%;\x1b[?1000%ga%c\x1b[?1002%ga%c\x1b[?1003%ga%c\x1b[?1006%ga%c", - SetCursor: "\x1b[%i%p1%d;%p2%dH", - CursorBack1: "\b", - CursorUp1: "\x1b[A", - KeyUp: "\x1bOA", - KeyDown: "\x1bOB", - KeyRight: "\x1bOC", - KeyLeft: "\x1bOD", - KeyInsert: "\x1b[2~", - KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", - KeyHome: "\x1bOH", - KeyEnd: "\x1bOF", - KeyPgUp: "\x1b[5~", - KeyPgDn: "\x1b[6~", - KeyF1: "\x1bOP", - KeyF2: "\x1bOQ", - KeyF3: "\x1bOR", - KeyF4: "\x1bOS", - KeyF5: "\x1b[15~", - KeyF6: "\x1b[17~", - KeyF7: "\x1b[18~", - KeyF8: "\x1b[19~", - KeyF9: "\x1b[20~", - KeyF10: "\x1b[21~", - KeyF11: "\x1b[23~", - KeyF12: "\x1b[24~", - KeyF13: "\x1bO2P", - KeyF14: "\x1bO2Q", - KeyF15: "\x1bO2R", - KeyF16: "\x1bO2S", - KeyF17: "\x1b[15;2~", - KeyF18: "\x1b[17;2~", - KeyF19: "\x1b[18;2~", - KeyF20: "\x1b[19;2~", - KeyF21: "\x1b[20;2~", - KeyF22: "\x1b[21;2~", - KeyF23: "\x1b[23;2~", - KeyF24: "\x1b[24;2~", - KeyF25: "\x1bO5P", - KeyF26: "\x1bO5Q", - KeyF27: "\x1bO5R", - KeyF28: "\x1bO5S", - KeyF29: "\x1b[15;5~", - KeyF30: "\x1b[17;5~", - KeyF31: "\x1b[18;5~", - KeyF32: "\x1b[19;5~", - KeyF33: "\x1b[20;5~", - KeyF34: "\x1b[21;5~", - KeyF35: "\x1b[23;5~", - KeyF36: "\x1b[24;5~", - KeyF37: "\x1bO6P", - KeyF38: "\x1bO6Q", - KeyF39: "\x1bO6R", - KeyF40: "\x1bO6S", - KeyF41: "\x1b[15;6~", - KeyF42: "\x1b[17;6~", - KeyF43: "\x1b[18;6~", - KeyF44: "\x1b[19;6~", - KeyF45: "\x1b[20;6~", - KeyF46: "\x1b[21;6~", - KeyF47: "\x1b[23;6~", - KeyF48: "\x1b[24;6~", - KeyF49: "\x1bO3P", - KeyF50: "\x1bO3Q", - KeyF51: "\x1bO3R", - KeyF52: "\x1bO3S", - KeyF53: "\x1b[15;3~", - KeyF54: "\x1b[17;3~", - KeyF55: "\x1b[18;3~", - KeyF56: "\x1b[19;3~", - KeyF57: "\x1b[20;3~", - KeyF58: "\x1b[21;3~", - KeyF59: "\x1b[23;3~", - KeyF60: "\x1b[24;3~", - KeyF61: "\x1bO4P", - KeyF62: "\x1bO4Q", - KeyF63: "\x1bO4R", - KeyBacktab: "\x1b[Z", + Name: "konsole", + Columns: 80, + Lines: 24, + Colors: 8, + Clear: "\x1b[H\x1b[2J", + EnterCA: "\x1b7\x1b[?47h", + ExitCA: "\x1b[2J\x1b[?47l\x1b8", + ShowCursor: "\x1b[?25h", + HideCursor: "\x1b[?25l", + AttrOff: "\x1b[0m\x0f", + Underline: "\x1b[4m", + Bold: "\x1b[1m", + Italic: "\x1b[3m", + Strikethrough: "\x1b[9m", + Dim: "\x1b[2m", + Blink: "\x1b[5m", + Reverse: "\x1b[7m", + EnterKeypad: "\x1b[?1h\x1b=", + ExitKeypad: "\x1b[?1l\x1b>", + SetFg: "\x1b[3%p1%dm", + SetBg: "\x1b[4%p1%dm", + SetFgBg: "\x1b[3%p1%d;4%p2%dm", + AltChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", + EnterAcs: "\x0e", + ExitAcs: "\x0f", + EnableAcs: "\x1b)0", + Mouse: "\x1b[M", + MouseMode: "%?%p1%{1}%=%t%'h'%Pa%e%'l'%Pa%;\x1b[?1000%ga%c\x1b[?1002%ga%c\x1b[?1003%ga%c\x1b[?1006%ga%c", + SetCursor: "\x1b[%i%p1%d;%p2%dH", + CursorBack1: "\b", + CursorUp1: "\x1b[A", + KeyUp: "\x1bOA", + KeyDown: "\x1bOB", + KeyRight: "\x1bOC", + KeyLeft: "\x1bOD", + KeyInsert: "\x1b[2~", + KeyDelete: "\x1b[3~", + KeyBackspace: "\xff", + KeyHome: "\x1bOH", + KeyEnd: "\x1bOF", + KeyPgUp: "\x1b[5~", + KeyPgDn: "\x1b[6~", + KeyF1: "\x1bOP", + KeyF2: "\x1bOQ", + KeyF3: "\x1bOR", + KeyF4: "\x1bOS", + KeyF5: "\x1b[15~", + KeyF6: "\x1b[17~", + KeyF7: "\x1b[18~", + KeyF8: "\x1b[19~", + KeyF9: "\x1b[20~", + KeyF10: "\x1b[21~", + KeyF11: "\x1b[23~", + KeyF12: "\x1b[24~", + KeyF13: "\x1bO2P", + KeyF14: "\x1bO2Q", + KeyF15: "\x1bO2R", + KeyF16: "\x1bO2S", + KeyF17: "\x1b[15;2~", + KeyF18: "\x1b[17;2~", + KeyF19: "\x1b[18;2~", + KeyF20: "\x1b[19;2~", + KeyF21: "\x1b[20;2~", + KeyF22: "\x1b[21;2~", + KeyF23: "\x1b[23;2~", + KeyF24: "\x1b[24;2~", + KeyF25: "\x1bO5P", + KeyF26: "\x1bO5Q", + KeyF27: "\x1bO5R", + KeyF28: "\x1bO5S", + KeyF29: "\x1b[15;5~", + KeyF30: "\x1b[17;5~", + KeyF31: "\x1b[18;5~", + KeyF32: "\x1b[19;5~", + KeyF33: "\x1b[20;5~", + KeyF34: "\x1b[21;5~", + KeyF35: "\x1b[23;5~", + KeyF36: "\x1b[24;5~", + KeyF37: "\x1bO6P", + KeyF38: "\x1bO6Q", + KeyF39: "\x1bO6R", + KeyF40: "\x1bO6S", + KeyF41: "\x1b[15;6~", + KeyF42: "\x1b[17;6~", + KeyF43: "\x1b[18;6~", + KeyF44: "\x1b[19;6~", + KeyF45: "\x1b[20;6~", + KeyF46: "\x1b[21;6~", + KeyF47: "\x1b[23;6~", + KeyF48: "\x1b[24;6~", + KeyF49: "\x1bO3P", + KeyF50: "\x1bO3Q", + KeyF51: "\x1bO3R", + KeyF52: "\x1bO3S", + KeyF53: "\x1b[15;3~", + KeyF54: "\x1b[17;3~", + KeyF55: "\x1b[18;3~", + KeyF56: "\x1b[19;3~", + KeyF57: "\x1b[20;3~", + KeyF58: "\x1b[21;3~", + KeyF59: "\x1b[23;3~", + KeyF60: "\x1b[24;3~", + KeyF61: "\x1bO4P", + KeyF62: "\x1bO4Q", + KeyF63: "\x1bO4R", + KeyBacktab: "\x1b[Z", + KeyShfLeft: "\x1b[1;2D", + KeyShfRight: "\x1b[1;2C", + KeyShfUp: "\x1b[1;2A", + KeyShfDown: "\x1b[1;2B", + KeyCtrlLeft: "\x1b[1;5D", + KeyCtrlRight: "\x1b[1;5C", + KeyCtrlUp: "\x1b[1;5A", + KeyCtrlDown: "\x1b[1;5B", + KeyMetaLeft: "\x1b[1;9D", + KeyMetaRight: "\x1b[1;9C", + KeyMetaUp: "\x1b[1;9A", + KeyMetaDown: "\x1b[1;9B", + KeyAltLeft: "\x1b[1;3D", + KeyAltRight: "\x1b[1;3C", + KeyAltUp: "\x1b[1;3A", + KeyAltDown: "\x1b[1;3B", + KeyAltShfLeft: "\x1b[1;4D", + KeyAltShfRight: "\x1b[1;4C", + KeyAltShfUp: "\x1b[1;4A", + KeyAltShfDown: "\x1b[1;4B", + KeyMetaShfLeft: "\x1b[1;10D", + KeyMetaShfRight: "\x1b[1;10C", + KeyMetaShfUp: "\x1b[1;10A", + KeyMetaShfDown: "\x1b[1;10B", + KeyCtrlShfLeft: "\x1b[1;6D", + KeyCtrlShfRight: "\x1b[1;6C", + KeyCtrlShfUp: "\x1b[1;6A", + KeyCtrlShfDown: "\x1b[1;6B", + KeyShfHome: "\x1b[1;2H", + KeyShfEnd: "\x1b[1;2F", + KeyCtrlHome: "\x1b[1;5H", + KeyCtrlEnd: "\x1b[1;5F", + KeyAltHome: "\x1b[1;9H", + KeyAltEnd: "\x1b[1;9F", + KeyCtrlShfHome: "\x1b[1;6H", + KeyCtrlShfEnd: "\x1b[1;6F", + KeyMetaShfHome: "\x1b[1;10H", + KeyMetaShfEnd: "\x1b[1;10F", + KeyAltShfHome: "\x1b[1;4H", + KeyAltShfEnd: "\x1b[1;4F", }) } diff --git a/vendor/maunium.net/go/tcell/terminfo/term_konsole_256color.go b/vendor/maunium.net/go/tcell/terminfo/term_konsole_256color.go index fb4e317..3f6def0 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_konsole_256color.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_konsole_256color.go @@ -5,110 +5,151 @@ package terminfo func init() { // KDE console window with xterm 256-colors AddTerminfo(&Terminfo{ - Name: "konsole-256color", - Columns: 80, - Lines: 24, - Colors: 256, - Clear: "\x1b[H\x1b[2J", - EnterCA: "\x1b7\x1b[?47h", - ExitCA: "\x1b[2J\x1b[?47l\x1b8", - ShowCursor: "\x1b[?25h", - HideCursor: "\x1b[?25l", - AttrOff: "\x1b[0m\x0f", - Underline: "\x1b[4m", - Bold: "\x1b[1m", - Italic: "\x1b[3m", - Strikethrough: "\x1b[9m", - Blink: "\x1b[5m", - Reverse: "\x1b[7m", - EnterKeypad: "\x1b[?1h\x1b=", - ExitKeypad: "\x1b[?1l\x1b>", - SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", - SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", - SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m", - AltChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", - EnterAcs: "\x0e", - ExitAcs: "\x0f", - EnableAcs: "\x1b)0", - Mouse: "\x1b[M", - MouseMode: "%?%p1%{1}%=%t%'h'%Pa%e%'l'%Pa%;\x1b[?1000%ga%c\x1b[?1002%ga%c\x1b[?1003%ga%c\x1b[?1006%ga%c", - SetCursor: "\x1b[%i%p1%d;%p2%dH", - CursorBack1: "\b", - CursorUp1: "\x1b[A", - KeyUp: "\x1bOA", - KeyDown: "\x1bOB", - KeyRight: "\x1bOC", - KeyLeft: "\x1bOD", - KeyInsert: "\x1b[2~", - KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", - KeyHome: "\x1bOH", - KeyEnd: "\x1bOF", - KeyPgUp: "\x1b[5~", - KeyPgDn: "\x1b[6~", - KeyF1: "\x1bOP", - KeyF2: "\x1bOQ", - KeyF3: "\x1bOR", - KeyF4: "\x1bOS", - KeyF5: "\x1b[15~", - KeyF6: "\x1b[17~", - KeyF7: "\x1b[18~", - KeyF8: "\x1b[19~", - KeyF9: "\x1b[20~", - KeyF10: "\x1b[21~", - KeyF11: "\x1b[23~", - KeyF12: "\x1b[24~", - KeyF13: "\x1bO2P", - KeyF14: "\x1bO2Q", - KeyF15: "\x1bO2R", - KeyF16: "\x1bO2S", - KeyF17: "\x1b[15;2~", - KeyF18: "\x1b[17;2~", - KeyF19: "\x1b[18;2~", - KeyF20: "\x1b[19;2~", - KeyF21: "\x1b[20;2~", - KeyF22: "\x1b[21;2~", - KeyF23: "\x1b[23;2~", - KeyF24: "\x1b[24;2~", - KeyF25: "\x1bO5P", - KeyF26: "\x1bO5Q", - KeyF27: "\x1bO5R", - KeyF28: "\x1bO5S", - KeyF29: "\x1b[15;5~", - KeyF30: "\x1b[17;5~", - KeyF31: "\x1b[18;5~", - KeyF32: "\x1b[19;5~", - KeyF33: "\x1b[20;5~", - KeyF34: "\x1b[21;5~", - KeyF35: "\x1b[23;5~", - KeyF36: "\x1b[24;5~", - KeyF37: "\x1bO6P", - KeyF38: "\x1bO6Q", - KeyF39: "\x1bO6R", - KeyF40: "\x1bO6S", - KeyF41: "\x1b[15;6~", - KeyF42: "\x1b[17;6~", - KeyF43: "\x1b[18;6~", - KeyF44: "\x1b[19;6~", - KeyF45: "\x1b[20;6~", - KeyF46: "\x1b[21;6~", - KeyF47: "\x1b[23;6~", - KeyF48: "\x1b[24;6~", - KeyF49: "\x1bO3P", - KeyF50: "\x1bO3Q", - KeyF51: "\x1bO3R", - KeyF52: "\x1bO3S", - KeyF53: "\x1b[15;3~", - KeyF54: "\x1b[17;3~", - KeyF55: "\x1b[18;3~", - KeyF56: "\x1b[19;3~", - KeyF57: "\x1b[20;3~", - KeyF58: "\x1b[21;3~", - KeyF59: "\x1b[23;3~", - KeyF60: "\x1b[24;3~", - KeyF61: "\x1bO4P", - KeyF62: "\x1bO4Q", - KeyF63: "\x1bO4R", - KeyBacktab: "\x1b[Z", + Name: "konsole-256color", + Columns: 80, + Lines: 24, + Colors: 256, + Clear: "\x1b[H\x1b[2J", + EnterCA: "\x1b7\x1b[?47h", + ExitCA: "\x1b[2J\x1b[?47l\x1b8", + ShowCursor: "\x1b[?25h", + HideCursor: "\x1b[?25l", + AttrOff: "\x1b[0m\x0f", + Underline: "\x1b[4m", + Bold: "\x1b[1m", + Italic: "\x1b[3m", + Strikethrough: "\x1b[9m", + Dim: "\x1b[2m", + Blink: "\x1b[5m", + Reverse: "\x1b[7m", + EnterKeypad: "\x1b[?1h\x1b=", + ExitKeypad: "\x1b[?1l\x1b>", + SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", + SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", + SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m", + AltChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", + EnterAcs: "\x0e", + ExitAcs: "\x0f", + EnableAcs: "\x1b)0", + Mouse: "\x1b[M", + MouseMode: "%?%p1%{1}%=%t%'h'%Pa%e%'l'%Pa%;\x1b[?1000%ga%c\x1b[?1002%ga%c\x1b[?1003%ga%c\x1b[?1006%ga%c", + SetCursor: "\x1b[%i%p1%d;%p2%dH", + CursorBack1: "\b", + CursorUp1: "\x1b[A", + KeyUp: "\x1bOA", + KeyDown: "\x1bOB", + KeyRight: "\x1bOC", + KeyLeft: "\x1bOD", + KeyInsert: "\x1b[2~", + KeyDelete: "\x1b[3~", + KeyBackspace: "\xff", + KeyHome: "\x1bOH", + KeyEnd: "\x1bOF", + KeyPgUp: "\x1b[5~", + KeyPgDn: "\x1b[6~", + KeyF1: "\x1bOP", + KeyF2: "\x1bOQ", + KeyF3: "\x1bOR", + KeyF4: "\x1bOS", + KeyF5: "\x1b[15~", + KeyF6: "\x1b[17~", + KeyF7: "\x1b[18~", + KeyF8: "\x1b[19~", + KeyF9: "\x1b[20~", + KeyF10: "\x1b[21~", + KeyF11: "\x1b[23~", + KeyF12: "\x1b[24~", + KeyF13: "\x1bO2P", + KeyF14: "\x1bO2Q", + KeyF15: "\x1bO2R", + KeyF16: "\x1bO2S", + KeyF17: "\x1b[15;2~", + KeyF18: "\x1b[17;2~", + KeyF19: "\x1b[18;2~", + KeyF20: "\x1b[19;2~", + KeyF21: "\x1b[20;2~", + KeyF22: "\x1b[21;2~", + KeyF23: "\x1b[23;2~", + KeyF24: "\x1b[24;2~", + KeyF25: "\x1bO5P", + KeyF26: "\x1bO5Q", + KeyF27: "\x1bO5R", + KeyF28: "\x1bO5S", + KeyF29: "\x1b[15;5~", + KeyF30: "\x1b[17;5~", + KeyF31: "\x1b[18;5~", + KeyF32: "\x1b[19;5~", + KeyF33: "\x1b[20;5~", + KeyF34: "\x1b[21;5~", + KeyF35: "\x1b[23;5~", + KeyF36: "\x1b[24;5~", + KeyF37: "\x1bO6P", + KeyF38: "\x1bO6Q", + KeyF39: "\x1bO6R", + KeyF40: "\x1bO6S", + KeyF41: "\x1b[15;6~", + KeyF42: "\x1b[17;6~", + KeyF43: "\x1b[18;6~", + KeyF44: "\x1b[19;6~", + KeyF45: "\x1b[20;6~", + KeyF46: "\x1b[21;6~", + KeyF47: "\x1b[23;6~", + KeyF48: "\x1b[24;6~", + KeyF49: "\x1bO3P", + KeyF50: "\x1bO3Q", + KeyF51: "\x1bO3R", + KeyF52: "\x1bO3S", + KeyF53: "\x1b[15;3~", + KeyF54: "\x1b[17;3~", + KeyF55: "\x1b[18;3~", + KeyF56: "\x1b[19;3~", + KeyF57: "\x1b[20;3~", + KeyF58: "\x1b[21;3~", + KeyF59: "\x1b[23;3~", + KeyF60: "\x1b[24;3~", + KeyF61: "\x1bO4P", + KeyF62: "\x1bO4Q", + KeyF63: "\x1bO4R", + KeyBacktab: "\x1b[Z", + KeyShfLeft: "\x1b[1;2D", + KeyShfRight: "\x1b[1;2C", + KeyShfUp: "\x1b[1;2A", + KeyShfDown: "\x1b[1;2B", + KeyCtrlLeft: "\x1b[1;5D", + KeyCtrlRight: "\x1b[1;5C", + KeyCtrlUp: "\x1b[1;5A", + KeyCtrlDown: "\x1b[1;5B", + KeyMetaLeft: "\x1b[1;9D", + KeyMetaRight: "\x1b[1;9C", + KeyMetaUp: "\x1b[1;9A", + KeyMetaDown: "\x1b[1;9B", + KeyAltLeft: "\x1b[1;3D", + KeyAltRight: "\x1b[1;3C", + KeyAltUp: "\x1b[1;3A", + KeyAltDown: "\x1b[1;3B", + KeyAltShfLeft: "\x1b[1;4D", + KeyAltShfRight: "\x1b[1;4C", + KeyAltShfUp: "\x1b[1;4A", + KeyAltShfDown: "\x1b[1;4B", + KeyMetaShfLeft: "\x1b[1;10D", + KeyMetaShfRight: "\x1b[1;10C", + KeyMetaShfUp: "\x1b[1;10A", + KeyMetaShfDown: "\x1b[1;10B", + KeyCtrlShfLeft: "\x1b[1;6D", + KeyCtrlShfRight: "\x1b[1;6C", + KeyCtrlShfUp: "\x1b[1;6A", + KeyCtrlShfDown: "\x1b[1;6B", + KeyShfHome: "\x1b[1;2H", + KeyShfEnd: "\x1b[1;2F", + KeyCtrlHome: "\x1b[1;5H", + KeyCtrlEnd: "\x1b[1;5F", + KeyAltHome: "\x1b[1;9H", + KeyAltEnd: "\x1b[1;9F", + KeyCtrlShfHome: "\x1b[1;6H", + KeyCtrlShfEnd: "\x1b[1;6F", + KeyMetaShfHome: "\x1b[1;10H", + KeyMetaShfEnd: "\x1b[1;10F", + KeyAltShfHome: "\x1b[1;4H", + KeyAltShfEnd: "\x1b[1;4F", }) } diff --git a/vendor/maunium.net/go/tcell/terminfo/term_kterm.go b/vendor/maunium.net/go/tcell/terminfo/term_kterm.go index a1c6f3a..cb2c23d 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_kterm.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_kterm.go @@ -39,7 +39,7 @@ func init() { KeyLeft: "\x1bOD", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\b", + KeyBackspace: "\xff", KeyPgUp: "\x1b[5~", KeyPgDn: "\x1b[6~", KeyF1: "\x1b[11~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_linux.go b/vendor/maunium.net/go/tcell/terminfo/term_linux.go index 755e235..65b3842 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_linux.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_linux.go @@ -26,7 +26,7 @@ func init() { AltChars: "++,,--..00__``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}c~~", EnterAcs: "\x0e", ExitAcs: "\x0f", - EnableAcs: "\x1b(B\x1b)0", + EnableAcs: "\x1b)0", Mouse: "\x1b[M", MouseMode: "%?%p1%{1}%=%t%'h'%Pa%e%'l'%Pa%;\x1b[?1000%ga%c\x1b[?1002%ga%c\x1b[?1003%ga%c\x1b[?1006%ga%c", SetCursor: "\x1b[%i%p1%d;%p2%dH", @@ -38,7 +38,7 @@ func init() { KeyLeft: "\x1b[D", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1b[1~", KeyEnd: "\x1b[4~", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_rxvt.go b/vendor/maunium.net/go/tcell/terminfo/term_rxvt.go index 0a63bb2..1f33314 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_rxvt.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_rxvt.go @@ -43,7 +43,7 @@ func init() { KeyLeft: "\x1b[D", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1b[7~", KeyEnd: "\x1b[8~", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_rxvt_256color.go b/vendor/maunium.net/go/tcell/terminfo/term_rxvt_256color.go index 50a8b80..dd89a17 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_rxvt_256color.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_rxvt_256color.go @@ -43,7 +43,7 @@ func init() { KeyLeft: "\x1b[D", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1b[7~", KeyEnd: "\x1b[8~", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_rxvt_unicode.go b/vendor/maunium.net/go/tcell/terminfo/term_rxvt_unicode.go index ab65632..afc933a 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_rxvt_unicode.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_rxvt_unicode.go @@ -41,7 +41,7 @@ func init() { KeyLeft: "\x1b[D", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1b[7~", KeyEnd: "\x1b[8~", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_rxvt_unicode_256color.go b/vendor/maunium.net/go/tcell/terminfo/term_rxvt_unicode_256color.go index e019f6a..70ee364 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_rxvt_unicode_256color.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_rxvt_unicode_256color.go @@ -41,7 +41,7 @@ func init() { KeyLeft: "\x1b[D", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1b[7~", KeyEnd: "\x1b[8~", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_screen.go b/vendor/maunium.net/go/tcell/terminfo/term_screen.go index e7e6414..09ede53 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_screen.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_screen.go @@ -44,7 +44,7 @@ func init() { KeyLeft: "\x1bOD", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1b[1~", KeyEnd: "\x1b[4~", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_screen_256color.go b/vendor/maunium.net/go/tcell/terminfo/term_screen_256color.go index 9a8da8b..409bec5 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_screen_256color.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_screen_256color.go @@ -44,7 +44,7 @@ func init() { KeyLeft: "\x1bOD", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1b[1~", KeyEnd: "\x1b[4~", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_st.go b/vendor/maunium.net/go/tcell/terminfo/term_st.go index 67f557b..83e48e7 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_st.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_st.go @@ -3,7 +3,7 @@ package terminfo func init() { - // simpleterm 0.4.1 + // simpleterm AddTerminfo(&Terminfo{ Name: "st", Aliases: []string{"stterm"}, @@ -21,6 +21,7 @@ func init() { Bold: "\x1b[1m", Italic: "\x1b[3m", Strikethrough: "\x1b[9m", + Dim: "\x1b[2m", Blink: "\x1b[5m", Reverse: "\x1b[7m", EnterKeypad: "\x1b[?1h\x1b=", @@ -28,8 +29,7 @@ func init() { SetFg: "\x1b[3%p1%dm", SetBg: "\x1b[4%p1%dm", SetFgBg: "\x1b[3%p1%d;4%p2%dm", - PadChar: "\x00", - AltChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", + AltChars: "+C,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", EnterAcs: "\x1b(0", ExitAcs: "\x1b(B", EnableAcs: "\x1b)0", @@ -44,7 +44,7 @@ func init() { KeyLeft: "\x1bOD", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1b[1~", KeyEnd: "\x1b[4~", KeyPgUp: "\x1b[5~", @@ -113,7 +113,6 @@ func init() { KeyF62: "\x1b[1;4Q", KeyF63: "\x1b[1;4R", KeyClear: "\x1b[3;5~", - KeyBacktab: "\x1b[Z", KeyShfLeft: "\x1b[1;2D", KeyShfRight: "\x1b[1;2C", KeyShfUp: "\x1b[1;2A", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_st_256color.go b/vendor/maunium.net/go/tcell/terminfo/term_st_256color.go index 7eecbcb..8e3e8d6 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_st_256color.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_st_256color.go @@ -21,6 +21,7 @@ func init() { Bold: "\x1b[1m", Italic: "\x1b[3m", Strikethrough: "\x1b[9m", + Dim: "\x1b[2m", Blink: "\x1b[5m", Reverse: "\x1b[7m", EnterKeypad: "\x1b[?1h\x1b=", @@ -28,8 +29,7 @@ func init() { SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m", - PadChar: "\x00", - AltChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", + AltChars: "+C,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", EnterAcs: "\x1b(0", ExitAcs: "\x1b(B", EnableAcs: "\x1b)0", @@ -44,7 +44,7 @@ func init() { KeyLeft: "\x1bOD", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1b[1~", KeyEnd: "\x1b[4~", KeyPgUp: "\x1b[5~", @@ -113,7 +113,6 @@ func init() { KeyF62: "\x1b[1;4Q", KeyF63: "\x1b[1;4R", KeyClear: "\x1b[3;5~", - KeyBacktab: "\x1b[Z", KeyShfLeft: "\x1b[1;2D", KeyShfRight: "\x1b[1;2C", KeyShfUp: "\x1b[1;2A", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_sun.go b/vendor/maunium.net/go/tcell/terminfo/term_sun.go index 5b0235b..706c57e 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_sun.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_sun.go @@ -24,7 +24,7 @@ func init() { KeyRight: "\x1b[C", KeyLeft: "\x1b[D", KeyInsert: "\x1b[247z", - KeyDelete: "\u007f", + KeyDelete: "\xff", KeyBackspace: "\b", KeyHome: "\x1b[214z", KeyEnd: "\x1b[220z", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_sun_color.go b/vendor/maunium.net/go/tcell/terminfo/term_sun_color.go index 5d298b9..92c9375 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_sun_color.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_sun_color.go @@ -28,7 +28,7 @@ func init() { KeyRight: "\x1b[C", KeyLeft: "\x1b[D", KeyInsert: "\x1b[247z", - KeyDelete: "\u007f", + KeyDelete: "\xff", KeyBackspace: "\b", KeyHome: "\x1b[214z", KeyEnd: "\x1b[220z", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_vt320.go b/vendor/maunium.net/go/tcell/terminfo/term_vt320.go index 4541bf0..b09b29f 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_vt320.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_vt320.go @@ -35,7 +35,7 @@ func init() { KeyLeft: "\x1bOD", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1b[1~", KeyPgUp: "\x1b[5~", KeyPgDn: "\x1b[6~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_xfce.go b/vendor/maunium.net/go/tcell/terminfo/term_xfce.go index 1a83727..a3862a4 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_xfce.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_xfce.go @@ -42,7 +42,7 @@ func init() { KeyLeft: "\x1bOD", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1bOH", KeyEnd: "\x1bOF", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_xnuppc.go b/vendor/maunium.net/go/tcell/terminfo/term_xnuppc.go index e2c0861..595ae2f 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_xnuppc.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_xnuppc.go @@ -28,6 +28,6 @@ func init() { KeyDown: "\x1bOB", KeyRight: "\x1bOC", KeyLeft: "\x1bOD", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", }) } diff --git a/vendor/maunium.net/go/tcell/terminfo/term_xterm.go b/vendor/maunium.net/go/tcell/terminfo/term_xterm.go index aeb89ce..a2e42b2 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_xterm.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_xterm.go @@ -12,8 +12,8 @@ func init() { Colors: 8, Bell: "\a", Clear: "\x1b[H\x1b[2J", - EnterCA: "\x1b[?1049h", - ExitCA: "\x1b[?1049l", + EnterCA: "\x1b[?1049h\x1b[22;0;0t", + ExitCA: "\x1b[?1049l\x1b[23;0;0t", ShowCursor: "\x1b[?12l\x1b[?25h", HideCursor: "\x1b[?25l", AttrOff: "\x1b(B\x1b[m", @@ -43,7 +43,7 @@ func init() { KeyLeft: "\x1bOD", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1bOH", KeyEnd: "\x1bOF", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/term_xterm_256color.go b/vendor/maunium.net/go/tcell/terminfo/term_xterm_256color.go index b5b498d..47024c1 100644 --- a/vendor/maunium.net/go/tcell/terminfo/term_xterm_256color.go +++ b/vendor/maunium.net/go/tcell/terminfo/term_xterm_256color.go @@ -11,8 +11,8 @@ func init() { Colors: 256, Bell: "\a", Clear: "\x1b[H\x1b[2J", - EnterCA: "\x1b[?1049h", - ExitCA: "\x1b[?1049l", + EnterCA: "\x1b[?1049h\x1b[22;0;0t", + ExitCA: "\x1b[?1049l\x1b[23;0;0t", ShowCursor: "\x1b[?12l\x1b[?25h", HideCursor: "\x1b[?25l", AttrOff: "\x1b(B\x1b[m", @@ -42,7 +42,7 @@ func init() { KeyLeft: "\x1bOD", KeyInsert: "\x1b[2~", KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", + KeyBackspace: "\xff", KeyHome: "\x1bOH", KeyEnd: "\x1bOF", KeyPgUp: "\x1b[5~", diff --git a/vendor/maunium.net/go/tcell/terminfo/terminfo.go b/vendor/maunium.net/go/tcell/terminfo/terminfo.go index 013d312..aa1654d 100644 --- a/vendor/maunium.net/go/tcell/terminfo/terminfo.go +++ b/vendor/maunium.net/go/tcell/terminfo/terminfo.go @@ -1,4 +1,4 @@ -// Copyright 2017 The TCell Authors +// Copyright 2018 The TCell Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use file except in compliance with the License. @@ -17,12 +17,14 @@ package terminfo import ( "bytes" "compress/gzip" + "crypto/sha1" "encoding/json" "errors" "fmt" "io" "os" "path" + "path/filepath" "strconv" "strings" "sync" @@ -757,8 +759,16 @@ func loadFromFile(fname string, term string) (*Terminfo, error) { // LookupTerminfo attempts to find a definition for the named $TERM. // It first looks in the builtin database, which should cover just about // everyone. If it can't find one there, then it will attempt to read -// one from the JSON file located in either $TCELLDB, $HOME/.tcelldb -// or in this package's source directory as database.json). +// one from the JSON file located in either $TCELLDB, $HOME/.tcelldb, +// or as a database file. +// +// The database files are named by taking terminal name, hashing it through +// sha1, and then a subdirectory of the form database/hash[0:2]/hash[0:8] +// (with an optional .gz extension). +// +// For other local database files, we will look for the database file using +// the terminal name, so database/term[0:2]/term[0:8], again with optional +// .gz extension. func LookupTerminfo(name string) (*Terminfo, error) { if name == "" { // else on windows: index out of bounds @@ -776,38 +786,65 @@ func LookupTerminfo(name string) (*Terminfo, error) { letter := fmt.Sprintf("%02x", name[0]) gzfile := path.Join(letter, name+".gz") jsfile := path.Join(letter, name) + hash := fmt.Sprintf("%x", sha1.Sum([]byte(name))) + gzhfile := path.Join(hash[0:2], hash[0:8]+".gz") + jshfile := path.Join(hash[0:2], hash[0:8]) // Build up the search path. Old versions of tcell used a // single database file, whereas the new ones locate them // in JSON (optionally compressed) files. // - // The search path looks like: + // The search path for "xterm" (SHA1 sig e2e28a8e...) looks + // like this: // - // $TCELLDB/x/xterm.gz - // $TCELLDB/x/xterm + // $TCELLDB/78/xterm.gz + // $TCELLDB/78/xterm // $TCELLDB - // $HOME/.tcelldb/x/xterm.gz - // $HOME/.tcelldb/x/xterm + // $HOME/.tcelldb/e2/e2e28a8e.gz + // $HOME/.tcelldb/e2/e2e28a8e + // $HOME/.tcelldb/78/xterm.gz + // $HOME/.tcelldb/78/xterm // $HOME/.tcelldb - // $GOPATH/terminfo/database/x/xterm.gz - // $GOPATH/terminfo/database/x/xterm + // $GOPATH/terminfo/database/e2/e2e28a8e.gz + // $GOPATH/terminfo/database/e2/e2e28a8e + // $GOPATH/terminfo/database/78/xterm.gz + // $GOPATH/terminfo/database/78/xterm // + // Note that the legacy name lookups (78/xterm etc.) are + // provided for compatibility. We do not actually deliver + // any files with this style of naming, to avoid collisions + // on case insensitive filesystems. (*cough* mac *cough*). + + // If $GOPATH set, honor it, else assume $HOME/go just like + // modern golang does. + gopath := os.Getenv("GOPATH") + if gopath == "" { + gopath = path.Join(os.Getenv("HOME"), "go") + } if pth := os.Getenv("TCELLDB"); pth != "" { - files = append(files, path.Join(pth, gzfile)) - files = append(files, path.Join(pth, jsfile)) - files = append(files, pth) + files = append(files, + path.Join(pth, gzfile), + path.Join(pth, jsfile), + pth) } if pth := os.Getenv("HOME"); pth != "" { pth = path.Join(pth, ".tcelldb") - files = append(files, path.Join(pth, gzfile)) - files = append(files, path.Join(pth, jsfile)) - files = append(files, pth) + files = append(files, + path.Join(pth, gzhfile), + path.Join(pth, jshfile), + path.Join(pth, gzfile), + path.Join(pth, jsfile), + pth) } - for _, pth := range strings.Split(os.Getenv("GOPATH"), string(os.PathListSeparator)) { - pth = path.Join(pth, "src", "github.com", "gdamore", "tcell", "terminfo", "database") - files = append(files, path.Join(pth, gzfile)) - files = append(files, path.Join(pth, jsfile)) + for _, pth := range filepath.SplitList(gopath) { + pth = path.Join(pth, "src", "github.com", + "gdamore", "tcell", "terminfo", "database") + files = append(files, + path.Join(pth, gzhfile), + path.Join(pth, jshfile), + path.Join(pth, gzfile), + path.Join(pth, jsfile)) } for _, fname := range files { diff --git a/vendor/maunium.net/go/tcell/tscreen.go b/vendor/maunium.net/go/tcell/tscreen.go index dd49814..d8e62b2 100644 --- a/vendor/maunium.net/go/tcell/tscreen.go +++ b/vendor/maunium.net/go/tcell/tscreen.go @@ -444,8 +444,8 @@ func (t *tScreen) ResetTitle() { func (t *tScreen) Fini() { t.Lock() defer t.Unlock() - - ti := t.ti + + ti := t.ti t.cells.Resize(0, 0) t.TPuts(ti.ShowCursor) t.TPuts(ti.AttrOff) @@ -467,7 +467,7 @@ func (t *tScreen) Fini() { default: close(t.quit) } - + t.termioFini() } -- cgit v1.2.3