X-Git-Url: https://jasonwoof.com/gitweb/?p=watch-my-terminal.git;a=blobdiff_plain;f=terminal.coffee;h=0ba72f43bb28a8d1996ff6438640e258d6aeef0d;hp=d5830c5401e27aa73e159f3db5ee82f570ac92ac;hb=39e9d94e9556527642a06b39b1d14e35c0533d23;hpb=e5cb729bf87ae7e8a3473a4527af609e49d61321 diff --git a/terminal.coffee b/terminal.coffee index d5830c5..0ba72f4 100644 --- a/terminal.coffee +++ b/terminal.coffee @@ -100,7 +100,7 @@ class Terminal return set_attribute_bits: (mask, value) -> - @a = (@a & ~mask) | value + @a = ((@a & ~mask) | value) # we're supposed to ignore leeding zeros, and while we're at it, lets swap # in the default for blank or missing values @@ -221,36 +221,41 @@ class Terminal csi_m: -> args = [] for i in arguments - args.push @fix_esc_arg i, 0 + args.push @fix_esc_arg i, '0' while args.length > 0 - switch args.shift() - + arg = args.shift() + switch arg # remove all style/color when '0' - @set_attribute_bits 0xffffff, 0x000007 + @a = 0 # style attributes when '1' # bold - @set_attribute_bits 0x10000, 0x10000 + @set_attribute_bits 0x010000, 0x010000 + # FIXME add '3' for italic ('23' to turn it off) when '4' # underline - @set_attribute_bits 0x20000, 0x20000 + @set_attribute_bits 0x020000, 0x020000 when '5' # blink - @set_attribute_bits 0x40000, 0x40000 + @set_attribute_bits 0x040000, 0x040000 + when '7' # inverse + @set_attribute_bits 0x080000, 0x080000 when '8' # invisible - @set_attribute_bits 0x80000, 0x80000 + @set_attribute_bits 0x100000, 0x100000 # disable style attributes when '22' # not bold... according to a page - @set_attribute_bits 0x10000, 0 + @set_attribute_bits 0x010000, 0 when '21' # ... though this would make more sense for "not bold" - @set_attribute_bits 0x10000, 0 + @set_attribute_bits 0x010000, 0 when '24' # not underline - @set_attribute_bits 0x20000, 0 + @set_attribute_bits 0x020000, 0 when '25' # not blink - @set_attribute_bits 0x40000, 0 + @set_attribute_bits 0x040000, 0 + when '27' # not inverse + @set_attribute_bits 0x080000, 0 when '28' # not invisible - @set_attribute_bits 0x80000, 0 + @set_attribute_bits 0x100000, 0 when '100' # reset colors but not other attributes @set_attribute_bits 0xffff, 0x0007 @@ -343,10 +348,10 @@ class Terminal when '107' # bg bright white @set_attribute_bits 0xff, 0x0f - else # if we don't recognize the style, go back to default - @set_attribute_bits 0xffffff, 0 + console.log "unrecognized csi_m arg: \"#{arg}\"" + @a = 0 return # str is the whole escape sequence (minus the esc[ prefix)