From 9152dd3803f97112d260462860550cc6f538a0de Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Thu, 12 Nov 2015 08:35:24 +0000
Subject: [PATCH] Fix some bugs, don't use FF to clear screen, start using an
 origin of 0,0.

---
 exec/dorkit/graphic.js        | 4 ++--
 exec/dorkit/jsexec_console.js | 4 ++--
 exec/dorkit/screen.js         | 8 ++++----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/exec/dorkit/graphic.js b/exec/dorkit/graphic.js
index 1cafa52519..01e1a57fc9 100644
--- a/exec/dorkit/graphic.js
+++ b/exec/dorkit/graphic.js
@@ -471,9 +471,9 @@ Graphic.prototype.draw = function(xpos,ypos,width,height,xoff,yoff)
 	var ch;
 
 	if(xpos==undefined)
-		xpos=1;
+		xpos=0;
 	if(ypos==undefined)
-		ypos=1;
+		ypos=0;
 	if(width==undefined)
 		width=this.width;
 	if(height==undefined)
diff --git a/exec/dorkit/jsexec_console.js b/exec/dorkit/jsexec_console.js
index 728567e67c..b1df0f3aed 100644
--- a/exec/dorkit/jsexec_console.js
+++ b/exec/dorkit/jsexec_console.js
@@ -1,10 +1,10 @@
 /*
- * Clears the current screen to black and moves to location 1,1
+ * Clears the current screen and moves to location 1,1
  */
 
 dk.console.remote_io = {
 	clear:function() {
-		this.print("\x0c");
+		this.print("\x1b[2J\x1b[1;1H");
 	},
 
 	/*
diff --git a/exec/dorkit/screen.js b/exec/dorkit/screen.js
index 5199ae1e46..3beeb3dc80 100644
--- a/exec/dorkit/screen.js
+++ b/exec/dorkit/screen.js
@@ -17,7 +17,7 @@ function Screen(w, h, attr, fill)
 	this.graphic = new Graphic(w, h, attr, fill);
 	this.escbuf = '';
 	this.pos = {x:0, y:0};
-	this.stored_pos = {x:0, y:0};
+	this.saved_pos = {x:0, y:0};
 	this.attr = new Attribute(7);
 }
 Screen.ANSIRe = /^(.*?)\x1b\[([<-\?]{0,1})([0-;]*)([ -\/]*)([@-~])([\x00-\xff]*)$/;
@@ -176,9 +176,9 @@ Screen.prototype.print=function(str) {
 			case 'H':	// Cursor position
 			case 'f':
 				param_defaults(p, [1,1]);
-				if (p[0] >= 0 && p[0] < this.graphic.height && p[1] >= 0 && p[1] <= this.graphic.width) {
-					this.pos.x = p[1];
-					this.pos.y = p[0];
+				if (p[0] >= 1 && p[0] < this.graphic.height && p[1] >= 1 && p[1] <= this.graphic.width) {
+					this.pos.x = p[1]-1;
+					this.pos.y = p[0]-1;
 				}
 				break;
 			case 'J':	// Erase in screen
-- 
GitLab