diff --git a/html_orig/jssrc/term_conn.js b/html_orig/jssrc/term_conn.js
index d9bbd57..7d32fa3 100644
--- a/html_orig/jssrc/term_conn.js
+++ b/html_orig/jssrc/term_conn.js
@@ -11,6 +11,7 @@ var Conn = (function () {
function onOpen(evt) {
console.log("CONNECTED");
+ heartbeat();
doSend("i");
}
diff --git a/html_orig/jssrc/term_screen.js b/html_orig/jssrc/term_screen.js
index 264a802..153ce31 100644
--- a/html_orig/jssrc/term_screen.js
+++ b/html_orig/jssrc/term_screen.js
@@ -160,9 +160,9 @@ class TermScreen {
let getTouchPositionOffset = touch => {
let rect = this.canvas.getBoundingClientRect();
return [touch.clientX - rect.left, touch.clientY - rect.top];
- }
+ };
this.canvas.addEventListener('touchstart', e => {
- touchPosition = getTouchPositionOffset(e.touches[0])
+ touchPosition = getTouchPositionOffset(e.touches[0]);
touchDidMove = false;
touchDownTime = Date.now();
});
@@ -651,7 +651,7 @@ class TermScreen {
let bg = 0;
let attrs = 0;
let cell = 0; // cell index
- let text = ' ';
+ let lastChar = ' ';
let screenLength = this.window.width * this.window.height;
this.screen = new Array(screenLength).fill(' ');
@@ -659,47 +659,56 @@ class TermScreen {
this.screenBG = new Array(screenLength).fill(' ');
this.screenAttrs = new Array(screenLength).fill(' ');
- while (i < str.length && cell < screenLength) {
- let character = str[i++];
- let charCode = character.charCodeAt(0);
+ let strArr = (typeof Array.from !== 'undefined' ? Array.from(str) : str.split(''));
+ while (i < strArr.length && cell < screenLength) {
+ let character = strArr[i++];
+ let charCode = character.codePointAt(0);
+
+ let data, count;
+ switch (charCode) {
+ case SEQ_SET_COLOR_ATTR:
+ data = parse3B(strArr[i]+strArr[i+1]+strArr[i+2]);
+ i += 3;
+ fg = data & 0xF;
+ bg = data >> 4 & 0xF;
+ attrs = data >> 8 & 0xFF;
+ break;
- if (charCode === SEQ_SET_COLOR_ATTR) {
- let data = parse3B(str, i);
- i += 3;
- fg = data & 0xF;
- bg = data >> 4 & 0xF;
- attrs = data >> 8 & 0xFF
- }
- else if (charCode == SEQ_SET_COLOR) {
- let data = parse2B(str, i);
- i += 2;
- fg = data & 0xF;
- bg = data >> 4 & 0xF
- }
- else if (charCode === SEQ_SET_ATTR) {
- let data = parse2B(str, i);
- i += 2;
- attrs = data & 0xFF
- }
- else if (charCode === SEQ_REPEAT) {
- let count = parse2B(str, i);
- i += 2;
- for (let j = 0; j < count; j++) {
- this.screen[cell] = text;
+ case SEQ_SET_COLOR:
+ data = parse2B(strArr[i]+strArr[i+1]);
+ i += 2;
+ fg = data & 0xF;
+ bg = data >> 4 & 0xF;
+ break;
+
+ case SEQ_SET_ATTR:
+ data = parse2B(strArr[i]+strArr[i+1]);
+ i += 2;
+ attrs = data & 0xFF;
+ break;
+
+ case SEQ_REPEAT:
+ count = parse2B(strArr[i]+strArr[i+1]);
+ i += 2;
+ for (let j = 0; j < count; j++) {
+ this.screen[cell] = lastChar;
+ this.screenFG[cell] = fg;
+ this.screenBG[cell] = bg;
+ this.screenAttrs[cell] = attrs;
+
+ if (++cell > screenLength) break;
+ }
+ break;
+
+ default:
+ // safety replacement
+ if (charCode < 32) character = '\ufffd';
+ // unique cell character
+ this.screen[cell] = lastChar = character;
this.screenFG[cell] = fg;
this.screenBG[cell] = bg;
this.screenAttrs[cell] = attrs;
-
- if (++cell > screenLength) break
- }
- }
- else {
- // unique cell character
- this.screen[cell] = text = character;
- this.screenFG[cell] = fg;
- this.screenBG[cell] = bg;
- this.screenAttrs[cell] = attrs;
- cell++
+ cell++;
}
}
diff --git a/html_orig/jssrc/utils.js b/html_orig/jssrc/utils.js
index d95c86c..3bb5574 100755
--- a/html_orig/jssrc/utils.js
+++ b/html_orig/jssrc/utils.js
@@ -128,12 +128,12 @@ function Chr(n) {
}
/** Decode number from 2B encoding */
-function parse2B(s, i) {
+function parse2B(s, i=0) {
return (s.charCodeAt(i++) - 1) + (s.charCodeAt(i) - 1) * 127;
}
/** Decode number from 3B encoding */
-function parse3B(s, i) {
+function parse3B(s, i=0) {
return (s.charCodeAt(i) - 1) + (s.charCodeAt(i+1) - 1) * 127 + (s.charCodeAt(i+2) - 1) * 127 * 127;
}
diff --git a/html_orig/sass/pages/_term.scss b/html_orig/sass/pages/_term.scss
index 6c257ab..c53298f 100755
--- a/html_orig/sass/pages/_term.scss
+++ b/html_orig/sass/pages/_term.scss
@@ -43,7 +43,12 @@ body.term {
background: none;
border: none;
resize: none;
- // visible for debugging. do opacity 0 later on
+ overflow: hidden;
+ opacity: 0;
+ outline: 0 none !important;
+ caret-color: transparent;
+ color: transparent;
+ @include click-through;
}
#touch-select-menu {
diff --git a/user/screen.c b/user/screen.c
index 45763e2..f5811bc 100644
--- a/user/screen.c
+++ b/user/screen.c
@@ -1396,10 +1396,10 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
// copy the symbol, until first 0 or reached 4 bytes
char c;
- int j = 0;
- while ((c = cell->c[j]) != 0 && j < 4) {
+ for(int j=0; j<4; j++) {
+ c = cell->c[j];
+ if(!c) break;
bufput_c(c);
- j++;
}
ss->lastFg = cell0->fg;