Minor fixes in escapeInterpreter

This commit is contained in:
Roi Martin 2016-11-14 21:50:15 +01:00
parent aacdc2698f
commit 1ad1e27a52
1 changed files with 15 additions and 12 deletions

View File

@ -150,15 +150,19 @@ func (ei *escapeInterpreter) outputNormal() error {
switch { switch {
case p >= 30 && p <= 37: case p >= 30 && p <= 37:
ei.curFgColor = Attribute(p - 30 + 1) ei.curFgColor = Attribute(p - 30 + 1)
case p == 39:
ei.curFgColor = ColorDefault
case p >= 40 && p <= 47: case p >= 40 && p <= 47:
ei.curBgColor = Attribute(p - 40 + 1) ei.curBgColor = Attribute(p - 40 + 1)
case p == 49:
ei.curBgColor = ColorDefault
case p == 1: case p == 1:
ei.curFgColor |= AttrBold ei.curFgColor |= AttrBold
case p == 4: case p == 4:
ei.curFgColor |= AttrUnderline ei.curFgColor |= AttrUnderline
case p == 7: case p == 7:
ei.curFgColor |= AttrReverse ei.curFgColor |= AttrReverse
case p == 0 || p == 39: case p == 0:
ei.curFgColor = ColorDefault ei.curFgColor = ColorDefault
ei.curBgColor = ColorDefault ei.curBgColor = ColorDefault
} }
@ -177,27 +181,26 @@ func (ei *escapeInterpreter) output256() error {
return ei.outputNormal() return ei.outputNormal()
} }
fgbgParam, err := strconv.Atoi(ei.csiParam[0]) mode, err := strconv.Atoi(ei.csiParam[1])
if err != nil { if err != nil {
return errCSIParseError return errCSIParseError
} }
if mode != 5 {
fgbgType, err := strconv.Atoi(ei.csiParam[1])
if err != nil {
return errCSIParseError
}
if fgbgType != 5 {
return ei.outputNormal() return ei.outputNormal()
} }
fgbgColor, err := strconv.Atoi(ei.csiParam[2]) fgbg, err := strconv.Atoi(ei.csiParam[0])
if err != nil {
return errCSIParseError
}
color, err := strconv.Atoi(ei.csiParam[2])
if err != nil { if err != nil {
return errCSIParseError return errCSIParseError
} }
switch fgbgParam { switch fgbg {
case 38: case 38:
ei.curFgColor = Attribute(fgbgColor + 1) ei.curFgColor = Attribute(color + 1)
for _, param := range ei.csiParam[3:] { for _, param := range ei.csiParam[3:] {
p, err := strconv.Atoi(param) p, err := strconv.Atoi(param)
@ -215,7 +218,7 @@ func (ei *escapeInterpreter) output256() error {
} }
} }
case 48: case 48:
ei.curBgColor = Attribute(fgbgColor + 1) ei.curBgColor = Attribute(color + 1)
default: default:
return errCSIParseError return errCSIParseError
} }