diff --git a/exec/dorkit/screen.js b/exec/dorkit/screen.js index b4f452603df638316e3e3bfdd23b8e15aa088f79..830723b56e0598b14b1d0e4d99e7afdbeed291a8 100644 --- a/exec/dorkit/screen.js +++ b/exec/dorkit/screen.js @@ -19,6 +19,8 @@ function Screen(w, h, attr, fill) this.pos = {x:0, y:0}; this.saved_pos = {x:0, y:0}; this.attr = new Attribute(7); + this.new_lines = 0; + this.touched = false; } Screen.ANSIRe = /^(.*?)\x1b\[([<-\?]{0,1})([0-;]*)([ -\/]*)([@-~])([\x00-\xff]*)$/; Screen.ANSIFragRe = /^(.*?)(\x1b(\[([<-\?]{0,1})([0-;]*)([ -\/]*)([@-~])?)?)$/; @@ -76,23 +78,27 @@ Screen.prototype.print=function(str) { break; case '\x0a': // Linefeed scr.pos.y++; + scr.new_lines++; check_scrollup(scr); break; case '\x0c': // Form feed (clear screen and home) scr.graphic.clear(); scr.pos.x=0; scr.pos.y=0; + scr.new_lines=0; break; case '\x0d': // Carriage return scr.pos.x = 0; break; default: + scr.touched=true; scr.graphic.data[scr.pos.x][scr.pos.y].ch = ch; scr.graphic.data[scr.pos.x][scr.pos.y].attr.value = scr.attr.value; scr.pos.x++; if (scr.pos.x >= scr.graphic.width) { scr.pos.x = 0; scr.pos.y++; + scr.new_lines++; check_scrollup(scr); } break; @@ -154,12 +160,16 @@ Screen.prototype.print=function(str) { this.pos.y -= p[0]; if (this.pos.y < 0) this.pos.y = 0; + if (this.touched) + this.new_lines = this.pos.y+1; break; case 'B': // Cursor Down param_defaults(p, [1]); this.pos.y += p[0]; if (this.pos.y >= this.graphic.height) this.pos.y = this.graphic.height-1; + if (this.touched) + this.new_lines = this.pos.y+1; break; case 'C': // Cursor Right param_defaults(p, [1]); @@ -179,6 +189,8 @@ Screen.prototype.print=function(str) { 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; + if (this.touched) + this.new_lines = p[0]; } break; case 'J': // Erase in screen @@ -195,6 +207,7 @@ Screen.prototype.print=function(str) { this.graphic.data[x][y].attr = this.attr.value; } } + this.touched = true; break; case 1: // Erase to beginning of screen... for (y = 0; y < this.pos.y; y++) { @@ -207,13 +220,17 @@ Screen.prototype.print=function(str) { this.graphic.data[x][this.pos.y].ch = this.graphic.ch; this.graphic.data[x][this.pos.y].attr = this.attr.value; } + this.touched = true; break; case 2: // Erase entire screen (Most BBS terminals also move to 1/1) this.graphic.clear(); + this.new_lines = 0; + this.touched = false; break; } break; case 'K': // Erase in line + scr.touched=true; param_defaults(p, [0]); switch(p[0]) { case 0: // Erase to eol @@ -239,6 +256,7 @@ Screen.prototype.print=function(str) { } break; case 'P': // Delete character + scr.touched=true; param_defaults(p, [1]); if (p[1] > this.graphic.width - this.pos.x) p[1] = this.graphic.width - this.pos.x; @@ -250,6 +268,7 @@ Screen.prototype.print=function(str) { } break; case 'X': // Erase character + scr.touched=true; param_defaults(p, [1]); if (p[1] > this.graphic.width - this.pos.x) p[1] = this.graphic.width - this.pos.x; @@ -345,6 +364,8 @@ Screen.prototype.print=function(str) { case 'u': this.pos.x = this.saved_pos.x; this.pos.y = this.saved_pos.y; + if (this.touched) + this.new_lines = this.pos.y; break; // Still TODO... case 'n': // Device status report... no action from this object. diff --git a/exec/load/dorkit.js b/exec/load/dorkit.js index 86e083177c7ae7bd6f5986dd9caf229c156a1241..e8ee34f551b3f1633a100d1959ef966330e93180 100644 --- a/exec/load/dorkit.js +++ b/exec/load/dorkit.js @@ -54,6 +54,8 @@ if (!String.prototype.repeat) { var dk = { console:{ + auto_pause:true, + _auto_pause:{lines_since:0}, last_pos:{x:1, y:1}, key:{ CTRL_A:'\x01', @@ -303,6 +305,11 @@ var dk = { * sets the current attribute to 7 */ clear:function() { + if (this.remote_screen !== undefined && this.auto_pause && (this.remote_screen.new_lines || this.remote_screen.touched)) { + this.auto_pause = false; + this.pause(); + this.auto_pause = true; + } this.attr=7; if (this.local) this.local_io.clear(); @@ -370,6 +377,11 @@ var dk = { } if (this.remote) { if (this.remote_screen !== undefined) { + if (this.remote_screen.new_lines >= this.rows && this.auto_pause) { + this.auto_pause = false; + this.pause(); + this.auto_pause = true; + } this.remote_screen.print(string); this.attr.value = this.remote_screen.attr.value; } @@ -457,6 +469,11 @@ var dk = { this.attr.value = attr; while(!this.waitkey(10000)); this.getkey(); + this.print("\b".repeat(11)+" ".repeat(11)+"\b".repeat(11)); + if (this.remote_screen !== undefined) { + this.remote_screen.new_lines = 0; + this.remote_screen.touched = false; + } }, /* @@ -561,12 +578,18 @@ var dk = { } else pos = str.length; + + if (this.auto_pause && this.remote_screen !== undefined) + this.remote_screen.new_lines = 0; + while(1) { if (!this.waitkey(opt.timeout === undefined ? 1000 : opt.timeout)) { if (opt.timeout !== undefined) return str; } key = this.getkey(); + if (key !== undefined && opt.upper_case) + key = key.toUpperCase(); if (opt.hotkeys !== undefined && str.length === 0 && opt.hotkeys.indexOf(key) !== -1) { if (ascii(key) >= 32) { if (opt.password) @@ -688,8 +711,6 @@ var dk = { break; if (opt.integer && (key < '0' || key > '9')) // Invalid integer... ignore TODO: Beep? break; - if (opt.upper_case) - key = key.toUpperCase(); if ((!opt.exascii) && key.charCodeAt(0) > 127) // Invalid EXASCII... ignore TODO: Beep? break; if (key.charCodeAt(0) < 32) // Control char... ignore TODO: Beep?