implemented numpad alt mode, fn keys alt mode and cursor alt mode

pull/111/merge
Ondřej Hruška 7 years ago
parent 8117229926
commit 9cac029e58
  1. 142
      html_orig/js/app.js
  2. 9
      html_orig/jssrc/keymaster.js
  3. 133
      html_orig/jssrc/term.js
  4. 5
      user/cgi_sockets.c
  5. 27
      user/cgi_term_cfg.c
  6. 25
      user/screen.c
  7. 17
      user/screen.h

@ -726,11 +726,16 @@
right: 39, down: 40, right: 39, down: 40,
del: 46, 'delete': 46, del: 46, 'delete': 46,
home: 36, end: 35, home: 36, end: 35,
pageup: 33, pagedown: 34, insert: 45, // added insert pageup: 33, pagedown: 34,
',': 188, '.': 190, '/': 191, ',': 188, '.': 190, '/': 191,
'`': 192, '-': 189, '=': 187, '`': 192, '-': 189, '=': 187,
';': 186, '\'': 222, ';': 186, '\'': 222,
'[': 219, ']': 221, '\\': 220 '[': 219, ']': 221, '\\': 220,
// added:
insert: 45,
np_0: 96, np_1: 97, np_2: 98, np_3: 99, np_4: 100, np_5: 101,
np_6: 102, np_7: 103, np_8: 104, np_9: 105, np_mul: 106,
np_add: 107, np_sub: 109, np_point: 110, np_div: 111, numlock: 144,
}, },
code = function(x){ code = function(x){
return _MAP[x] || x.toUpperCase().charCodeAt(0); return _MAP[x] || x.toUpperCase().charCodeAt(0);
@ -1761,6 +1766,12 @@ var Screen = (function () {
cursor.hanging = !!(num & 0x200); cursor.hanging = !!(num & 0x200);
// console.log("Attributes word ",num.toString(16)+'h'); // console.log("Attributes word ",num.toString(16)+'h');
Input.setAlts(
!!(num & 0x400), // cu
!!(num & 0x800), // np
!!(num & 0x1000) // fn
);
fg = cursor.fg; fg = cursor.fg;
bg = cursor.bg; bg = cursor.bg;
attrs = 0; attrs = 0;
@ -1875,6 +1886,7 @@ var Conn = (function() {
function doSend(message) { function doSend(message) {
console.log("TX: ", message); console.log("TX: ", message);
if (!ws) return; // for dry testing if (!ws) return; // for dry testing
if (ws.readyState != 1) { if (ws.readyState != 1) {
console.error("Socket not ready"); console.error("Socket not ready");
@ -1913,6 +1925,12 @@ var Conn = (function() {
/** User input */ /** User input */
var Input = (function() { var Input = (function() {
var opts = {
np_alt: false,
cu_alt: false,
fn_alt: false,
};
function sendStrMsg(str) { function sendStrMsg(str) {
Conn.send("STR:"+str); Conn.send("STR:"+str);
} }
@ -1925,73 +1943,110 @@ var Input = (function() {
Conn.send("BTN:"+n); Conn.send("BTN:"+n);
} }
function _initKeys() { function fa(alt, normal) {
// This takes care of text characters typed return opts.fn_alt ? alt : normal;
window.addEventListener('keypress', function(evt) { }
var str = '';
if (evt.key) str = evt.key; function ca(alt, normal) {
else if (evt.which) str = String.fromCodePoint(evt.which); return opts.cu_alt ? alt : normal;
if (str.length>0 && str.charCodeAt(0) >= 32) { }
// console.log("Typed ", str);
sendStrMsg(str); function na(alt, normal) {
return opts.np_alt ? alt : normal;
} }
});
function _bindFnKeys() {
var keymap = { var keymap = {
'tab': '\x09', 'tab': '\x09',
'backspace': '\x08', 'backspace': '\x08',
'enter': '\x0d', 'enter': '\x0d',
'ctrl+enter': '\x0a', 'ctrl+enter': '\x0a',
'esc': '\x1b', 'esc': '\x1b',
'up': '\x1b[A', 'up': ca('\x1bOA', '\x1b[A'),
'down': '\x1b[B', 'down': ca('\x1bOB', '\x1b[B'),
'right': '\x1b[C', 'right': ca('\x1bOC', '\x1b[C'),
'left': '\x1b[D', 'left': ca('\x1bOD', '\x1b[D'),
'home': '\x1b[1~', 'home': fa('\x1bOH', '\x1b[1~'),
'insert': '\x1b[2~', 'insert': '\x1b[2~',
'delete': '\x1b[3~', 'delete': '\x1b[3~',
'end': '\x1b[4~', 'end': fa('\x1bOF', '\x1b[4~'),
'pageup': '\x1b[5~', 'pageup': '\x1b[5~',
'pagedown': '\x1b[6~', 'pagedown': '\x1b[6~',
'f1': '\x1b[11~', 'f1': fa('\x1bOP', '\x1b[11~'),
'f2': '\x1b[12~', 'f2': fa('\x1bOQ', '\x1b[12~'),
'f3': '\x1b[13~', 'f3': fa('\x1bOR', '\x1b[13~'),
'f4': '\x1b[14~', 'f4': fa('\x1bOS', '\x1b[14~'),
'f5': '\x1b[15~', // disconnect 'f5': '\x1b[15~', // note the disconnect
'f6': '\x1b[17~', 'f6': '\x1b[17~',
'f7': '\x1b[18~', 'f7': '\x1b[18~',
'f8': '\x1b[19~', 'f8': '\x1b[19~',
'f9': '\x1b[20~', 'f9': '\x1b[20~',
'f10': '\x1b[21~', // disconnect 'f10': '\x1b[21~', // note the disconnect
'f11': '\x1b[23~', 'f11': '\x1b[23~',
'f12': '\x1b[24~', 'f12': '\x1b[24~',
'shift+f1': '\x1b[25~', 'shift+f1': fa('\x1bO1;2P', '\x1b[25~'),
'shift+f2': '\x1b[26~', // disconnect 'shift+f2': fa('\x1bO1;2Q', '\x1b[26~'), // note the disconnect
'shift+f3': '\x1b[28~', 'shift+f3': fa('\x1bO1;2R', '\x1b[28~'),
'shift+f4': '\x1b[29~', // disconnect 'shift+f4': fa('\x1bO1;2S', '\x1b[29~'), // note the disconnect
'shift+f5': '\x1b[31~', 'shift+f5': fa('\x1b[15;2~', '\x1b[31~'),
'shift+f6': '\x1b[32~', 'shift+f6': fa('\x1b[17;2~', '\x1b[32~'),
'shift+f7': '\x1b[33~', 'shift+f7': fa('\x1b[18;2~', '\x1b[33~'),
'shift+f8': '\x1b[34~', 'shift+f8': fa('\x1b[19;2~', '\x1b[34~'),
'shift+f9': fa('\x1b[20;2~', '\x1b[35~'), // 35-38 are not standard - but what is?
'shift+f10': fa('\x1b[21;2~', '\x1b[36~'),
'shift+f11': fa('\x1b[22;2~', '\x1b[37~'),
'shift+f12': fa('\x1b[23;2~', '\x1b[38~'),
'np_0': na('\x1bOp', '0'),
'np_1': na('\x1bOq', '1'),
'np_2': na('\x1bOr', '2'),
'np_3': na('\x1bOs', '3'),
'np_4': na('\x1bOt', '4'),
'np_5': na('\x1bOu', '5'),
'np_6': na('\x1bOv', '6'),
'np_7': na('\x1bOw', '7'),
'np_8': na('\x1bOx', '8'),
'np_9': na('\x1bOy', '9'),
'np_mul': na('\x1bOR', '*'),
'np_add': na('\x1bOl', '+'),
'np_sub': na('\x1bOS', '-'),
'np_point': na('\x1bOn', '.'),
'np_div': na('\x1bOQ', '/'),
// we don't implement numlock key (should change in numpad_alt mode, but it's even more useless than the rest)
}; };
for (var k in keymap) {
if (keymap.hasOwnProperty(k)) {
bind(k, keymap[k]);
}
}
}
function bind(combo, str) { function bind(combo, str) {
// mac fix - allow also cmd // mac fix - allow also cmd
if (combo.indexOf('ctrl+') !== -1) { if (combo.indexOf('ctrl+') !== -1) {
combo += ',' + combo.replace('ctrl', 'command'); combo += ',' + combo.replace('ctrl', 'command');
} }
// unbind possible old binding
key.unbind(combo);
key(combo, function (e) { key(combo, function (e) {
e.preventDefault(); e.preventDefault();
// console.log(combo);
sendStrMsg(str) sendStrMsg(str)
}); });
} }
for (var k in keymap) { function _initKeys() {
if (keymap.hasOwnProperty(k)) { // This takes care of text characters typed
bind(k, keymap[k]); window.addEventListener('keypress', function(evt) {
} var str = '';
if (evt.key) str = evt.key;
else if (evt.which) str = String.fromCodePoint(evt.which);
if (str.length>0 && str.charCodeAt(0) >= 32) {
// console.log("Typed ", str);
sendStrMsg(str);
} }
});
// ctrl-letter codes are sent as simple low ASCII codes // ctrl-letter codes are sent as simple low ASCII codes
for (var i = 1; i<=26;i++) { for (var i = 1; i<=26;i++) {
@ -2002,6 +2057,8 @@ var Input = (function() {
bind('ctrl+[', '\x1d'); bind('ctrl+[', '\x1d');
bind('ctrl+^', '\x1e'); bind('ctrl+^', '\x1e');
bind('ctrl+_', '\x1f'); bind('ctrl+_', '\x1f');
_bindFnKeys();
} }
function init() { function init() {
@ -2019,6 +2076,17 @@ var Input = (function() {
init: init, init: init,
onTap: sendPosMsg, onTap: sendPosMsg,
sendString: sendStrMsg, sendString: sendStrMsg,
setAlts: function(cu, np, fn) {
console.log("Set alts ", cu, np, fn);
if (opts.cu_alt != cu || opts.np_alt != np || opts.fn_alt != fn) {
opts.cu_alt = cu;
opts.np_alt = np;
opts.fn_alt = fn;
// rebind keys - codes have changed
_bindFnKeys();
}
},
}; };
})(); })();

@ -23,11 +23,16 @@
right: 39, down: 40, right: 39, down: 40,
del: 46, 'delete': 46, del: 46, 'delete': 46,
home: 36, end: 35, home: 36, end: 35,
pageup: 33, pagedown: 34, insert: 45, // added insert pageup: 33, pagedown: 34,
',': 188, '.': 190, '/': 191, ',': 188, '.': 190, '/': 191,
'`': 192, '-': 189, '=': 187, '`': 192, '-': 189, '=': 187,
';': 186, '\'': 222, ';': 186, '\'': 222,
'[': 219, ']': 221, '\\': 220 '[': 219, ']': 221, '\\': 220,
// added:
insert: 45,
np_0: 96, np_1: 97, np_2: 98, np_3: 99, np_4: 100, np_5: 101,
np_6: 102, np_7: 103, np_8: 104, np_9: 105, np_mul: 106,
np_add: 107, np_sub: 109, np_point: 110, np_div: 111, numlock: 144,
}, },
code = function(x){ code = function(x){
return _MAP[x] || x.toUpperCase().charCodeAt(0); return _MAP[x] || x.toUpperCase().charCodeAt(0);

@ -209,6 +209,12 @@ var Screen = (function () {
cursor.hanging = !!(num & 0x200); cursor.hanging = !!(num & 0x200);
// console.log("Attributes word ",num.toString(16)+'h'); // console.log("Attributes word ",num.toString(16)+'h');
Input.setAlts(
!!(num & 0x400), // cu
!!(num & 0x800), // np
!!(num & 0x1000) // fn
);
fg = cursor.fg; fg = cursor.fg;
bg = cursor.bg; bg = cursor.bg;
attrs = 0; attrs = 0;
@ -323,6 +329,7 @@ var Conn = (function() {
function doSend(message) { function doSend(message) {
console.log("TX: ", message); console.log("TX: ", message);
if (!ws) return; // for dry testing if (!ws) return; // for dry testing
if (ws.readyState != 1) { if (ws.readyState != 1) {
console.error("Socket not ready"); console.error("Socket not ready");
@ -361,6 +368,12 @@ var Conn = (function() {
/** User input */ /** User input */
var Input = (function() { var Input = (function() {
var opts = {
np_alt: false,
cu_alt: false,
fn_alt: false,
};
function sendStrMsg(str) { function sendStrMsg(str) {
Conn.send("STR:"+str); Conn.send("STR:"+str);
} }
@ -373,73 +386,110 @@ var Input = (function() {
Conn.send("BTN:"+n); Conn.send("BTN:"+n);
} }
function _initKeys() { function fa(alt, normal) {
// This takes care of text characters typed return opts.fn_alt ? alt : normal;
window.addEventListener('keypress', function(evt) {
var str = '';
if (evt.key) str = evt.key;
else if (evt.which) str = String.fromCodePoint(evt.which);
if (str.length>0 && str.charCodeAt(0) >= 32) {
// console.log("Typed ", str);
sendStrMsg(str);
} }
});
function ca(alt, normal) {
return opts.cu_alt ? alt : normal;
}
function na(alt, normal) {
return opts.np_alt ? alt : normal;
}
function _bindFnKeys() {
var keymap = { var keymap = {
'tab': '\x09', 'tab': '\x09',
'backspace': '\x08', 'backspace': '\x08',
'enter': '\x0d', 'enter': '\x0d',
'ctrl+enter': '\x0a', 'ctrl+enter': '\x0a',
'esc': '\x1b', 'esc': '\x1b',
'up': '\x1b[A', 'up': ca('\x1bOA', '\x1b[A'),
'down': '\x1b[B', 'down': ca('\x1bOB', '\x1b[B'),
'right': '\x1b[C', 'right': ca('\x1bOC', '\x1b[C'),
'left': '\x1b[D', 'left': ca('\x1bOD', '\x1b[D'),
'home': '\x1b[1~', 'home': fa('\x1bOH', '\x1b[1~'),
'insert': '\x1b[2~', 'insert': '\x1b[2~',
'delete': '\x1b[3~', 'delete': '\x1b[3~',
'end': '\x1b[4~', 'end': fa('\x1bOF', '\x1b[4~'),
'pageup': '\x1b[5~', 'pageup': '\x1b[5~',
'pagedown': '\x1b[6~', 'pagedown': '\x1b[6~',
'f1': '\x1b[11~', 'f1': fa('\x1bOP', '\x1b[11~'),
'f2': '\x1b[12~', 'f2': fa('\x1bOQ', '\x1b[12~'),
'f3': '\x1b[13~', 'f3': fa('\x1bOR', '\x1b[13~'),
'f4': '\x1b[14~', 'f4': fa('\x1bOS', '\x1b[14~'),
'f5': '\x1b[15~', // disconnect 'f5': '\x1b[15~', // note the disconnect
'f6': '\x1b[17~', 'f6': '\x1b[17~',
'f7': '\x1b[18~', 'f7': '\x1b[18~',
'f8': '\x1b[19~', 'f8': '\x1b[19~',
'f9': '\x1b[20~', 'f9': '\x1b[20~',
'f10': '\x1b[21~', // disconnect 'f10': '\x1b[21~', // note the disconnect
'f11': '\x1b[23~', 'f11': '\x1b[23~',
'f12': '\x1b[24~', 'f12': '\x1b[24~',
'shift+f1': '\x1b[25~', 'shift+f1': fa('\x1bO1;2P', '\x1b[25~'),
'shift+f2': '\x1b[26~', // disconnect 'shift+f2': fa('\x1bO1;2Q', '\x1b[26~'), // note the disconnect
'shift+f3': '\x1b[28~', 'shift+f3': fa('\x1bO1;2R', '\x1b[28~'),
'shift+f4': '\x1b[29~', // disconnect 'shift+f4': fa('\x1bO1;2S', '\x1b[29~'), // note the disconnect
'shift+f5': '\x1b[31~', 'shift+f5': fa('\x1b[15;2~', '\x1b[31~'),
'shift+f6': '\x1b[32~', 'shift+f6': fa('\x1b[17;2~', '\x1b[32~'),
'shift+f7': '\x1b[33~', 'shift+f7': fa('\x1b[18;2~', '\x1b[33~'),
'shift+f8': '\x1b[34~', 'shift+f8': fa('\x1b[19;2~', '\x1b[34~'),
'shift+f9': fa('\x1b[20;2~', '\x1b[35~'), // 35-38 are not standard - but what is?
'shift+f10': fa('\x1b[21;2~', '\x1b[36~'),
'shift+f11': fa('\x1b[22;2~', '\x1b[37~'),
'shift+f12': fa('\x1b[23;2~', '\x1b[38~'),
'np_0': na('\x1bOp', '0'),
'np_1': na('\x1bOq', '1'),
'np_2': na('\x1bOr', '2'),
'np_3': na('\x1bOs', '3'),
'np_4': na('\x1bOt', '4'),
'np_5': na('\x1bOu', '5'),
'np_6': na('\x1bOv', '6'),
'np_7': na('\x1bOw', '7'),
'np_8': na('\x1bOx', '8'),
'np_9': na('\x1bOy', '9'),
'np_mul': na('\x1bOR', '*'),
'np_add': na('\x1bOl', '+'),
'np_sub': na('\x1bOS', '-'),
'np_point': na('\x1bOn', '.'),
'np_div': na('\x1bOQ', '/'),
// we don't implement numlock key (should change in numpad_alt mode, but it's even more useless than the rest)
}; };
for (var k in keymap) {
if (keymap.hasOwnProperty(k)) {
bind(k, keymap[k]);
}
}
}
function bind(combo, str) { function bind(combo, str) {
// mac fix - allow also cmd // mac fix - allow also cmd
if (combo.indexOf('ctrl+') !== -1) { if (combo.indexOf('ctrl+') !== -1) {
combo += ',' + combo.replace('ctrl', 'command'); combo += ',' + combo.replace('ctrl', 'command');
} }
// unbind possible old binding
key.unbind(combo);
key(combo, function (e) { key(combo, function (e) {
e.preventDefault(); e.preventDefault();
// console.log(combo);
sendStrMsg(str) sendStrMsg(str)
}); });
} }
for (var k in keymap) { function _initKeys() {
if (keymap.hasOwnProperty(k)) { // This takes care of text characters typed
bind(k, keymap[k]); window.addEventListener('keypress', function(evt) {
} var str = '';
if (evt.key) str = evt.key;
else if (evt.which) str = String.fromCodePoint(evt.which);
if (str.length>0 && str.charCodeAt(0) >= 32) {
// console.log("Typed ", str);
sendStrMsg(str);
} }
});
// ctrl-letter codes are sent as simple low ASCII codes // ctrl-letter codes are sent as simple low ASCII codes
for (var i = 1; i<=26;i++) { for (var i = 1; i<=26;i++) {
@ -450,6 +500,8 @@ var Input = (function() {
bind('ctrl+[', '\x1d'); bind('ctrl+[', '\x1d');
bind('ctrl+^', '\x1e'); bind('ctrl+^', '\x1e');
bind('ctrl+_', '\x1f'); bind('ctrl+_', '\x1f');
_bindFnKeys();
} }
function init() { function init() {
@ -467,6 +519,17 @@ var Input = (function() {
init: init, init: init,
onTap: sendPosMsg, onTap: sendPosMsg,
sendString: sendStrMsg, sendString: sendStrMsg,
setAlts: function(cu, np, fn) {
console.log("Set alts ", cu, np, fn);
if (opts.cu_alt != cu || opts.np_alt != np || opts.fn_alt != fn) {
opts.cu_alt = cu;
opts.np_alt = np;
opts.fn_alt = fn;
// rebind keys - codes have changed
_bindFnKeys();
}
},
}; };
})(); })();

@ -74,18 +74,19 @@ void ICACHE_FLASH_ATTR screen_notifyChange(ScreenNotifyChangeTopic topic)
{ {
// this is not the most ideal/cleanest implementation // this is not the most ideal/cleanest implementation
// PRs are welcome for a nicer update "queue" solution // PRs are welcome for a nicer update "queue" solution
if (termconf->display_tout_ms == 0) termconf->display_tout_ms = SCR_DEF_DISPLAY_TOUT_MS;
if (topic == CHANGE_LABELS) { if (topic == CHANGE_LABELS) {
// separate timer from content change timer, to avoid losing that update // separate timer from content change timer, to avoid losing that update
os_timer_disarm(&notifyTim2); os_timer_disarm(&notifyTim2);
os_timer_setfn(&notifyTim2, notifyLabelsTimCb, NULL); os_timer_setfn(&notifyTim2, notifyLabelsTimCb, NULL);
os_timer_arm(&notifyTim2, SCREEN_NOTIFY_DELAY_MS, 0); os_timer_arm(&notifyTim2, termconf->display_tout_ms, 0);
} }
else if (topic == CHANGE_CONTENT) { else if (topic == CHANGE_CONTENT) {
// throttle delay // throttle delay
os_timer_disarm(&notifyTim); os_timer_disarm(&notifyTim);
os_timer_setfn(&notifyTim, notifyTimCb, NULL); os_timer_setfn(&notifyTim, notifyTimCb, NULL);
os_timer_arm(&notifyTim, SCREEN_NOTIFY_DELAY_MS, 0); os_timer_arm(&notifyTim, termconf->display_tout_ms, 0);
} }
} }

@ -20,7 +20,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
{ {
char buff[50]; char buff[50];
char redir_url_buf[100]; char redir_url_buf[100];
int n, w, h; int32 n, w, h;
bool shall_clear_screen = false; bool shall_clear_screen = false;
@ -85,13 +85,30 @@ cgiTermCfgSetParams(HttpdConnData *connData)
dbg("Parser timeout: %s ms", buff); dbg("Parser timeout: %s ms", buff);
n = atoi(buff); n = atoi(buff);
if (n >= 0) { if (n >= 0) {
termconf->parser_tout_ms = (u8) n; termconf->parser_tout_ms = n;
} else { } else {
warn("Bad timeout %s", buff); warn("Bad timeout %s", buff);
redir_url += sprintf(redir_url, "parser_tout_ms,"); redir_url += sprintf(redir_url, "parser_tout_ms,");
} }
} }
if (GET_ARG("display_tout_ms")) {
dbg("Display update idle timeout: %s ms", buff);
n = atoi(buff);
if (n >= 0) {
termconf->display_tout_ms = n;
} else {
warn("Bad timeout %s", buff);
redir_url += sprintf(redir_url, "display_tout_ms,");
}
}
if (GET_ARG("fn_alt_mode")) {
dbg("FN alt mode: %s", buff);
n = atoi(buff);
termconf->fn_alt_mode = (bool)n;
}
if (GET_ARG("default_fg")) { if (GET_ARG("default_fg")) {
dbg("Screen default FG: %s", buff); dbg("Screen default FG: %s", buff);
n = atoi(buff); n = atoi(buff);
@ -175,6 +192,12 @@ tplTermCfg(HttpdConnData *connData, char *token, void **arg)
else if (streq(token, "parser_tout_ms")) { else if (streq(token, "parser_tout_ms")) {
sprintf(buff, "%d", termconf->parser_tout_ms); sprintf(buff, "%d", termconf->parser_tout_ms);
} }
else if (streq(token, "display_tout_ms")) {
sprintf(buff, "%d", termconf->display_tout_ms);
}
else if (streq(token, "fn_alt_mode")) {
sprintf(buff, "%d", (int)termconf->fn_alt_mode);
}
else if (streq(token, "theme")) { else if (streq(token, "theme")) {
sprintf(buff, "%d", termconf->theme); sprintf(buff, "%d", termconf->theme);
} }

@ -102,10 +102,12 @@ void terminal_restore_defaults(void)
{ {
termconf->default_bg = 0; termconf->default_bg = 0;
termconf->default_fg = 7; termconf->default_fg = 7;
termconf->width = 26; termconf->width = SCR_DEF_WIDTH;
termconf->height = 10; termconf->height = SCR_DEF_HEIGHT;
termconf->parser_tout_ms = 10; termconf->parser_tout_ms = SCR_DEF_PARSER_TOUT_MS;
sprintf(termconf->title, "ESPTerm"); termconf->display_tout_ms = SCR_DEF_DISPLAY_TOUT_MS;
termconf->fn_alt_mode = SCR_DEF_FN_ALT_MODE;
sprintf(termconf->title, SCR_DEF_TITLE);
for(int i=1; i <= 5; i++) { for(int i=1; i <= 5; i++) {
sprintf(termconf->btn[i-1], "%d", i); sprintf(termconf->btn[i-1], "%d", i);
} }
@ -123,6 +125,8 @@ void terminal_apply_settings(void)
/** this is used when changing terminal settings that do not affect the screen size */ /** this is used when changing terminal settings that do not affect the screen size */
void terminal_apply_settings_noclear(void) void terminal_apply_settings_noclear(void)
{ {
if (termconf->display_tout_ms == 0) termconf->display_tout_ms = SCR_DEF_DISPLAY_TOUT_MS;
memcpy(&termconf_scratch, termconf, sizeof(TerminalConfigBundle)); memcpy(&termconf_scratch, termconf, sizeof(TerminalConfigBundle));
if (W*H >= MAX_SCREEN_SIZE) { if (W*H >= MAX_SCREEN_SIZE) {
error("BAD SCREEN SIZE: %d rows x %d cols", H, W); error("BAD SCREEN SIZE: %d rows x %d cols", H, W);
@ -685,13 +689,17 @@ screen_set_insert_mode(bool insert)
void ICACHE_FLASH_ATTR void ICACHE_FLASH_ATTR
screen_set_numpad_alt_mode(bool alt_mode) screen_set_numpad_alt_mode(bool alt_mode)
{ {
NOTIFY_LOCK();
scr.numpad_alt_mode = alt_mode; scr.numpad_alt_mode = alt_mode;
NOTIFY_DONE();
} }
void ICACHE_FLASH_ATTR void ICACHE_FLASH_ATTR
screen_set_cursors_alt_mode(bool alt_mode) screen_set_cursors_alt_mode(bool alt_mode)
{ {
NOTIFY_LOCK();
scr.cursors_alt_mode = alt_mode; scr.cursors_alt_mode = alt_mode;
NOTIFY_DONE();
} }
//endregion //endregion
@ -990,10 +998,11 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
encode2B((u16) ( encode2B((u16) (
cursor.fg | cursor.fg |
(cursor.bg<<4) | (cursor.bg<<4) |
(cursor.visible ? 1<<8 : 0) | (cursor.visible ? 0x100 : 0) |
(cursor.hanging ? 1<<9 : 0) | (cursor.hanging ? 0x200 : 0) |
(scr.cursors_alt_mode ? 1<<10 : 0) | (scr.cursors_alt_mode ? 0x400 : 0) |
(scr.numpad_alt_mode ? 1<<11 : 0) (scr.numpad_alt_mode ? 0x800 : 0) |
(termconf->fn_alt_mode ? 0x1000 : 0)
) )
, &w5); , &w5);

@ -34,7 +34,7 @@
* *
*/ */
// Size designed for the wifi config structure // Size designed for the terminal config structure
// Must be constant to avoid corrupting user config after upgrade // Must be constant to avoid corrupting user config after upgrade
#define TERMCONF_SIZE 200 #define TERMCONF_SIZE 200
@ -54,7 +54,16 @@ typedef enum {
#define ATTR_FRAKTUR (1<<5) #define ATTR_FRAKTUR (1<<5)
#define ATTR_STRIKE (1<<6) #define ATTR_STRIKE (1<<6)
#define SCREEN_NOTIFY_DELAY_MS 20 #define SCR_DEF_DISPLAY_TOUT_MS 20
#define SCR_DEF_PARSER_TOUT_MS 10
#define SCR_DEF_FN_ALT_MODE false
#define SCR_DEF_WIDTH 26
#define SCR_DEF_HEIGHT 10
#define SCR_DEF_TITLE "ESPTerm"
/** Maximum screen size (determines size of the static data array) */
#define MAX_SCREEN_SIZE (80*30)
typedef struct { typedef struct {
u32 width; u32 width;
@ -65,6 +74,8 @@ typedef struct {
char btn[5][TERM_BTN_LEN]; char btn[5][TERM_BTN_LEN];
u8 theme; u8 theme;
u32 parser_tout_ms; u32 parser_tout_ms;
u32 display_tout_ms;
bool fn_alt_mode; // xterm compatibility mode (alternate codes for some FN keys)
} TerminalConfigBundle; } TerminalConfigBundle;
// Live config // Live config
@ -80,8 +91,6 @@ void terminal_restore_defaults(void);
void terminal_apply_settings(void); void terminal_apply_settings(void);
void terminal_apply_settings_noclear(void); // the same, but with no screen reset / init void terminal_apply_settings_noclear(void); // the same, but with no screen reset / init
/** Maximum screen size (determines size of the static data array) */
#define MAX_SCREEN_SIZE (80*30)
typedef enum { typedef enum {
CLEAR_TO_CURSOR=0, CLEAR_FROM_CURSOR=1, CLEAR_ALL=2 CLEAR_TO_CURSOR=0, CLEAR_FROM_CURSOR=1, CLEAR_ALL=2

Loading…
Cancel
Save