Bring back color support
parent
1185e3a4d9
commit
b87649aec2
@ -1,64 +1,47 @@
|
|||||||
class AsciiIo.SgrInterpreter
|
class AsciiIo.SgrInterpreter
|
||||||
|
|
||||||
reset: ->
|
parse: (numbers) ->
|
||||||
@attrs =
|
changes = {}
|
||||||
fg : undefined
|
|
||||||
bg : undefined
|
|
||||||
blink : false
|
|
||||||
bright : false
|
|
||||||
italic : false
|
|
||||||
underline: false
|
|
||||||
|
|
||||||
buildBrush: (oldBrush, numbers) ->
|
|
||||||
@attrs =
|
|
||||||
fg : oldBrush.fg
|
|
||||||
bg : oldBrush.bg
|
|
||||||
blink : oldBrush.blink
|
|
||||||
bright : oldBrush.bright
|
|
||||||
italic : oldBrush.italic
|
|
||||||
underline: oldBrush.underline
|
|
||||||
|
|
||||||
numbers = [0] if numbers.length is 0
|
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while i < numbers.length
|
while i < numbers.length
|
||||||
n = numbers[i]
|
n = numbers[i]
|
||||||
|
|
||||||
if n is 0
|
if n is 0
|
||||||
@reset()
|
_(changes).extend AsciiIo.Brush.defaultAttrs
|
||||||
else if n is 1
|
else if n is 1
|
||||||
@attrs.bright = true
|
changes.bright = true
|
||||||
else if n is 3
|
else if n is 3
|
||||||
@attrs.italic = true
|
changes.italic = true
|
||||||
else if n is 4
|
else if n is 4
|
||||||
@attrs.underline = true
|
changes.underline = true
|
||||||
else if n is 5
|
else if n is 5
|
||||||
@attrs.blink = true
|
changes.blink = true
|
||||||
else if n is 23
|
else if n is 23
|
||||||
@attrs.italic = false
|
changes.italic = false
|
||||||
else if n is 24
|
else if n is 24
|
||||||
@attrs.underline = false
|
changes.underline = false
|
||||||
else if n is 25
|
else if n is 25
|
||||||
@attrs.blink = false
|
changes.blink = false
|
||||||
else if n >= 30 and n <= 37
|
else if n >= 30 and n <= 37
|
||||||
@attrs.fg = n - 30
|
changes.fg = n - 30
|
||||||
else if n is 38
|
else if n is 38
|
||||||
@attrs.fg = numbers[i + 2]
|
changes.fg = numbers[i + 2]
|
||||||
i += 2
|
i += 2
|
||||||
else if n is 39
|
else if n is 39
|
||||||
@attrs.fg = undefined
|
changes.fg = undefined
|
||||||
else if n >= 40 and n <= 47
|
else if n >= 40 and n <= 47
|
||||||
@attrs.bg = n - 40
|
changes.bg = n - 40
|
||||||
else if n is 48
|
else if n is 48
|
||||||
@attrs.bg = numbers[i + 2]
|
changes.bg = numbers[i + 2]
|
||||||
i += 2
|
i += 2
|
||||||
else if n is 49
|
else if n is 49
|
||||||
@attrs.bg = undefined
|
changes.bg = undefined
|
||||||
else if n >= 90 and n <= 97
|
else if n >= 90 and n <= 97
|
||||||
@attrs.fg = n - 90
|
changes.fg = n - 90
|
||||||
else if n >= 100 and n <= 107
|
else if n >= 100 and n <= 107
|
||||||
@attrs.bg = n - 100
|
changes.bg = n - 100
|
||||||
|
|
||||||
i++
|
i++
|
||||||
|
|
||||||
AsciiIo.Brush.create @attrs
|
changes
|
||||||
|
Loading…
Reference in New Issue