Handle cross-frame codes

This commit is contained in:
Marcin Kulik 2011-03-09 21:54:38 +01:00
parent f6fa3cf145
commit 88d6e50033
2 changed files with 21 additions and 19 deletions

View File

@ -163,23 +163,13 @@ SP.AnsiInterpreter.prototype = {
}
if (handler) {
handler.call(this, data, match);
data = data.slice(match[0].length)
} else {
var s = data.slice(0, 10);
var hex = '';
for (i=0; i<s.length; i++) {
hex += '0x' + s[i].charCodeAt(0).toString(16) + ',';
return data;
}
console.log("failed matching: '" + s + "' (" + hex + ")");
throw 'bummer';
return;
}
}
return '';
}
}

View File

@ -26,19 +26,31 @@ SP.Player.prototype = {
this.terminal.restartCursorBlink();
setTimeout(function() {
// console.log(this.dataIndex);
// console.log(this.currentData);
this.interpreter.feed(this.currentData);
var rest = this.interpreter.feed(this.currentData);
this.terminal.updateDirtyLines();
var n = timing[1];
console.log(timing[0]);
console.log(n);
this.currentData = this.data.slice(this.dataIndex, this.dataIndex + n);
if (rest.length > 0)
console.log('rest: ' + rest);
this.currentData = rest + this.data.slice(this.dataIndex, this.dataIndex + n);
this.dataIndex += n;
this.frame += 1;
if (rest.length > 20) {
var s = rest.slice(0, 10);
var hex = '';
for (i=0; i<s.length; i++) {
hex += '0x' + s[i].charCodeAt(0).toString(16) + ',';
}
console.log("failed matching: '" + s + "' (" + hex + ")");
return;
}
if (!window.stopped) {
this.nextFrame();
}
}.bind(this), timing[0] * 1000 * (1.0 / speed));
}
}