From e2ce23641d10edf94c876baeea70ba8d07af19ae Mon Sep 17 00:00:00 2001 From: mcmlxxix <> Date: Tue, 5 May 2020 04:23:21 +0000 Subject: [PATCH] added frame.getWord(x,y) method -- returns adjacent non-whitespace characters at position --- exec/load/frame.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/exec/load/frame.js b/exec/load/frame.js index 4bddb7af5f..f7c60bda1c 100644 --- a/exec/load/frame.js +++ b/exec/load/frame.js @@ -386,6 +386,25 @@ Frame.prototype.setData = function(x,y,ch,attr,use_offset) { if(this.__properties__.open) this.__properties__.display.updateChar(this,x,y); } +Frame.prototype.getWord = function(x,y) { + var word = [] + var nx = x-this.x; + var ny = y-this.y; + var cell = this.getData(nx,ny,false); + while(nx >= 0 && cell != undefined && cell.ch != undefined && cell.ch.match(/[0-9a-zA-Z]/)) { + word.unshift(cell.ch); + nx--; + cell = this.getData(nx,ny,false); + } + nx = x-this.x+1; + cell = this.getData(nx,ny,false); + while(nx < this.width && cell != undefined && cell.ch != undefined && cell.ch.match(/[0-9a-zA-Z]/)) { + word.push(cell.ch); + nx++; + cell = this.getData(nx,ny,false); + } + return word.join(""); +} Frame.prototype.clearData = function(x,y,use_offset) { var px = x; var py = y; -- GitLab