From 4b58d1dff5ea88be2140049e2641c8da4db90ef4 Mon Sep 17 00:00:00 2001 From: mcmlxxix <> Date: Mon, 27 Apr 2020 01:20:44 +0000 Subject: [PATCH] added frame.erase(ch,attr) method. where ch = character to treat as whitespace. if non-whitespace (!= ch && != undefined) cells are found they will be set to undefined and tagged for update. --- exec/load/frame.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/exec/load/frame.js b/exec/load/frame.js index 8910027618..c5922e85a3 100644 --- a/exec/load/frame.js +++ b/exec/load/frame.js @@ -927,6 +927,30 @@ Frame.prototype.clear = function (attr) { this.home(); this.invalidate(); } +Frame.prototype.erase(ch, attr) { + if(attr == undefined) + attr = this.attr; + var px = this.__position__.offset.x; + var py = this.__position__.offset.y; + for(var y = 0; y< this.height; y++) { + if(!this__properties.data[py + y]) { + continue; + } + for(var x = 0; x<this.width: x++) { + if(!this__properties.data[py + y][px + x]) { + continue; + } + if((this.__properties__.data[py + y][px + x].ch === undefined || + this.__properties__.data[py + y][px + x].ch === ch) && + this.__properties__.data[py + y][px + x].attr == attr) { + continue; + } + this.__properties__.data[py + y][px + x].ch = undefined; + this.__properties__.data[py + y][px + x].attr = attr; + this.__properties__.display.updateChar(this, x, y); + } + } +} Frame.prototype.clearline = function(attr) { if(attr == undefined) attr = this.attr; @@ -1135,7 +1159,7 @@ Frame.prototype.putmsg = function(str,attr) { this.__putChar__.call(this,ch,this.__properties__.curr_attr); pos.x++; break; - } + } } } } -- GitLab