aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gopkg.lock4
-rw-r--r--vendor/github.com/awesome-gocui/gocui/escape.go90
2 files changed, 62 insertions, 32 deletions
diff --git a/Gopkg.lock b/Gopkg.lock
index a63ecf89..8e2f5b81 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -50,11 +50,11 @@
[[projects]]
branch = "master"
- digest = "1:96d56c73765f6ba0dbccf953502342da2c4f0d4280a5aef4e4e3eea9e6674ba1"
+ digest = "1:1bd56b71a75f4df8aae1d65feb3aee6742ed1a2ff00fa9aaf74b40d9fadc4440"
name = "github.com/awesome-gocui/gocui"
packages = ["."]
pruneopts = "UT"
- revision = "c9d3c2bec453a8d648228640c79cc769bbc78df8"
+ revision = "a34ffb055986a3f9461735162c9a2d235b95b8cb"
[[projects]]
branch = "master"
diff --git a/vendor/github.com/awesome-gocui/gocui/escape.go b/vendor/github.com/awesome-gocui/gocui/escape.go
index c88309b0..64360802 100644
--- a/vendor/github.com/awesome-gocui/gocui/escape.go
+++ b/vendor/github.com/awesome-gocui/gocui/escape.go
@@ -5,8 +5,9 @@
package gocui
import (
- "github.com/go-errors/errors"
"strconv"
+
+ "github.com/go-errors/errors"
)
type escapeInterpreter struct {
@@ -17,13 +18,22 @@ type escapeInterpreter struct {
mode OutputMode
}
-type escapeState int
+type (
+ escapeState int
+ fontEffect int
+)
const (
stateNone escapeState = iota
stateEscape
stateCSI
stateParams
+
+ bold fontEffect = 1
+ underline fontEffect = 4
+ reverse fontEffect = 7
+ setForegroundColor fontEffect = 38
+ setBackgroundColor fontEffect = 48
)
var (
@@ -191,39 +201,59 @@ func (ei *escapeInterpreter) output256() error {
return ei.outputNormal()
}
- fgbg, err := strconv.Atoi(ei.csiParam[0])
- if err != nil {
- return errCSIParseError
- }
- color, err := strconv.Atoi(ei.csiParam[2])
- if err != nil {
- return errCSIParseError
- }
+ for _, param := range splitFgBg(ei.csiParam) {
+ fgbg, err := strconv.Atoi(param[0])
+ if err != nil {
+ return errCSIParseError
+ }
+ color, err := strconv.Atoi(param[2])
+ if err != nil {
+ return errCSIParseError
+ }
- switch fgbg {
- case 38:
- ei.curFgColor = Attribute(color + 1)
+ switch fontEffect(fgbg) {
+ case setForegroundColor:
+ ei.curFgColor = Attribute(color + 1)
- for _, param := range ei.csiParam[3:] {
- p, err := strconv.Atoi(param)
- if err != nil {
- return errCSIParseError
- }
+ for _, s := range param[3:] {
+ p, err := strconv.Atoi(s)
+ if err != nil {
+ return errCSIParseError
+ }
+
+ switch fontEffect(p) {
+ case bold:
+ ei.curFgColor |= AttrBold
+ case underline:
+ ei.curFgColor |= AttrUnderline
+ case reverse:
+ ei.curFgColor |= AttrReverse
- switch {
- case p == 1:
- ei.curFgColor |= AttrBold
- case p == 4:
- ei.curFgColor |= AttrUnderline
- case p == 7:
- ei.curFgColor |= AttrReverse
+ }
}
+ case setBackgroundColor:
+ ei.curBgColor = Attribute(color + 1)
+ default:
+ return errCSIParseError
}
- case 48:
- ei.curBgColor = Attribute(color + 1)
- default:
- return errCSIParseError
}
-
return nil
}
+
+func splitFgBg(params []string) [][]string {
+ var out [][]string
+ var current []string
+ for _, p := range params {
+ if len(current) == 3 && (p == "48" || p == "38") {
+ out = append(out, current)
+ current = []string{}
+ }
+ current = append(current, p)
+ }
+
+ if len(current) > 0 {
+ out = append(out, current)
+ }
+
+ return out
+}