Sahli/16col/bin.js
2014-08-05 10:49:34 +03:00

51 lines
1.5 KiB
JavaScript

// Generated by CoffeeScript 1.7.1
(function() {
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
this.ImageTextModeBin = (function(_super) {
__extends(ImageTextModeBin, _super);
function ImageTextModeBin(options) {
var k, v;
ImageTextModeBin.__super__.constructor.apply(this, arguments);
this.linewrap = 160;
for (k in options) {
if (!__hasProp.call(options, k)) continue;
v = options[k];
this[k] = v;
}
}
ImageTextModeBin.prototype.parse = function(content) {
var attr, ch, i, x, y, _i, _ref;
x = 0;
y = 0;
this.screen[y] = [];
for (i = _i = 0, _ref = content.length - 2; _i <= _ref; i = _i += 2) {
ch = content.substr(i, 1);
if (ch === "\x1a") {
break;
}
attr = this.getByteAt(content, i + 1);
this.screen[y][x] = {
'ch': ch,
'attr': attr
};
x++;
if (x === this.linewrap) {
x = 0;
y++;
this.screen[y] = [];
}
}
if (this.screen[y].length === 0) {
return this.screen.pop();
}
};
return ImageTextModeBin;
})(this.ImageTextMode);
}).call(this);