diff --git a/app/assets/javascripts/player/vt.js.coffee b/app/assets/javascripts/player/vt.js.coffee index e99ec46..799806a 100644 --- a/app/assets/javascripts/player/vt.js.coffee +++ b/app/assets/javascripts/player/vt.js.coffee @@ -1,6 +1,7 @@ class AsciiIo.VT constructor: (cols, lines, @renderer) -> + @data = '' @sb = new AsciiIo.ScreenBuffer(cols, lines) @fg = @bg = undefined @@ -260,16 +261,18 @@ class AsciiIo.VT @COMPILED_PATTERNS = ([new RegExp("^" + re), f] for re, f of @PATTERNS) feed: (data) -> - while data.length > 0 + @data += data + + while @data.length > 0 match = null for pattern in @COMPILED_PATTERNS - match = pattern[0].exec(data) + match = pattern[0].exec(@data) if match handler = pattern[1] - handler.call(this, data, match) - data = data.slice(match[0].length) + handler.call(this, @data, match) + @data = @data.slice(match[0].length) break break unless match @@ -278,4 +281,4 @@ class AsciiIo.VT @renderer.render(changes, @sb.cursorX, @sb.cursorY) @sb.clearChanges() - data.length is 0 + @data.length is 0 diff --git a/spec/javascripts/player/vt_spec.js.coffee b/spec/javascripts/player/vt_spec.js.coffee index 599f2f4..fcae67a 100644 --- a/spec/javascripts/player/vt_spec.js.coffee +++ b/spec/javascripts/player/vt_spec.js.coffee @@ -196,10 +196,6 @@ describe 'AsciiIo.VT', -> describe ']', -> # Operating system command - # beforeEach -> - # vt = new AsciiIo.VT(cols, lines, renderer) - # vt.sb = {} # will throw 'undefined is not a function' - describe '0;...BELL', -> beforeEach -> data += ']0;foobar\x07' @@ -240,11 +236,11 @@ describe 'AsciiIo.VT', -> data += '[' describe 'buffering', -> - # it 'allows parsing in chunks', -> - # spyOn vt, 'handleSGR' - # vt.feed(data) - # vt.feed('m') - # expect(vt.handleSGR).toHaveBeenCalled() + it 'allows parsing in chunks', -> + spyOn vt, 'handleSGR' + vt.feed(data) + vt.feed('m') + expect(vt.handleSGR).toHaveBeenCalled() describe '@', -> it 'calls reserveCharacters', ->