Sahli/16col/bin.coffee
Howland Owl 49d411a3d1 split classes into files for better understanding
- also for excluding some things in the build, as I may not need
 to support PCBoard at revision. Actually, I don't. Later I can
 add that support, but for now, I need the Revision bits working.
2014-04-05 13:30:28 +03:00

25 lines
650 B
CoffeeScript

class @ImageTextModeBin extends @ImageTextMode
constructor: ( options ) ->
super
@linewrap = 160
this[k] = v for own k, v of options
parse: ( content ) ->
x = 0
y = 0
@screen[ y ] = []
for i in [ 0 .. content.length - 2 ] by 2
ch = content.substr( i, 1 )
break if ch == "\x1a"
attr = @getByteAt( content, i + 1 )
@screen[ y ][ x ] = { 'ch': ch, 'attr': attr }
x++
if x == @linewrap
x = 0
y++
@screen[ y ] = []
@screen.pop() if @screen[ y ].length == 0