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.
This commit is contained in:
parent
10e8940807
commit
49d411a3d1
15 changed files with 2454 additions and 746 deletions
67
16col/pcboard.coffee
Normal file
67
16col/pcboard.coffee
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
|
||||
class @ImageTextModePCBoard extends @ImageTextMode
|
||||
|
||||
constructor: ( options ) ->
|
||||
super
|
||||
@tabstop = 8
|
||||
@linewrap = 80
|
||||
@codes = { POFF: '', WAIT: '' }
|
||||
this[k] = v for own k, v of options
|
||||
|
||||
parse: ( content ) ->
|
||||
@screen = []
|
||||
@state = 0
|
||||
@x = 0
|
||||
@y = 0
|
||||
@attr = 7
|
||||
|
||||
for key, val of @codes
|
||||
code = new RegExp '@' + key + '@', 'g'
|
||||
content.replace code, val
|
||||
|
||||
content = content.split( '' )
|
||||
while ch = content.shift()
|
||||
if @state is 0
|
||||
switch ch
|
||||
when "\x1a" then @state = 2
|
||||
when '@' then @state = 1
|
||||
when "\n"
|
||||
@x = 0
|
||||
@y++
|
||||
when "\r" then break
|
||||
when "\t"
|
||||
i = ( @x + 1 ) % @tabstop
|
||||
@putpixel ' ' while i-- > 0
|
||||
else
|
||||
@putpixel ch
|
||||
else if @state is 1
|
||||
if ch is 'X'
|
||||
@attr = ( parseInt( content.shift(), 16 ) << 4 ) + parseInt( content.shift(), 16 )
|
||||
else if ch + content[ 0..2 ].join( '' ) is 'CLS@'
|
||||
content.shift() for [ 1 .. 3 ]
|
||||
@screen = []
|
||||
else if ch + content[ 0..2 ].join( '' ) is 'POS:'
|
||||
content.shift() for [ 1 .. 3 ]
|
||||
@x = content.shift()
|
||||
@x += content.shift() if content[ 0 ] isnt '@'
|
||||
@x--
|
||||
|
||||
content.shift()
|
||||
else
|
||||
@putpixel '@'
|
||||
@putpixel ch
|
||||
|
||||
@state = 0
|
||||
else if @state is 2
|
||||
break
|
||||
else
|
||||
@state = 0
|
||||
|
||||
putpixel: ( ch ) ->
|
||||
@screen[ @y ] = [] if !@screen[ @y ]?
|
||||
@screen[ @y ][ @x ] = { ch: ch, attr: @attr }
|
||||
|
||||
if ++@x >= @linewrap
|
||||
@x = 0
|
||||
@y++
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue