From 655de768e39248237b0283682f4be6aa5beeeaf9 Mon Sep 17 00:00:00 2001 From: mcmlxxix <> Date: Mon, 14 Nov 2011 22:20:32 +0000 Subject: [PATCH] add screenShot( fileName [,append=false] ) method --- exec/load/frame.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/exec/load/frame.js b/exec/load/frame.js index f5f1c88abe..ad27e26f51 100644 --- a/exec/load/frame.js +++ b/exec/load/frame.js @@ -255,7 +255,34 @@ function Frame(x,y,width,height,attr,frame) { var yoff = frame.y - this.y; updateChar(xoff + x,yoff + y); } + this.screenShot = function(file,append) { + var f = new File(file); + if(append) + f.open('ab',true,4096); + else + f.open('wb',true,4096) ; + if(!f.is_open) + return false; + for(var y = 0;y<this.height;y++) { + for(var x = 0;x<this.width;x++) { + var c = getTopCanvas(x,y); + var d = getData(c,x,y); + if(d.ch) + f.write(d.ch); + else + f.write(" "); + if(d.attr) + f.writeBin(d.attr,1); + else + f.writeBin(0,1); + } + } + + f.close(); + return true; + } + /* private functions */ function updateChar(x,y) { if(!properties.update[y]) @@ -800,6 +827,9 @@ function Frame(x,y,width,height,attr,frame) { if(update) this.refresh(); } + this.screenShot = function(file,append) { + return properties.display.screenShot(file,append); + } /* console method emulation */ this.home = function() { -- GitLab