Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca410736f7 | ||
|
|
2ca8bf1483 | ||
|
|
35393827a9 | ||
|
|
ea84d1889d | ||
|
|
bc41a21f23 | ||
|
|
e48180ac10 |
@@ -145,6 +145,7 @@ add_definitions(
|
||||
-DFLAG_GZIP=2
|
||||
-DADMIN_PASSWORD="asdf"
|
||||
-DGIT_HASH="blabla"
|
||||
-DDEBUG_ANSI=1
|
||||
-DESPFS_HEATSHRINK)
|
||||
|
||||
add_executable(esp_vt100_firmware ${SOURCE_FILES})
|
||||
|
||||
@@ -65,8 +65,15 @@ LIBS += esphttpd
|
||||
# compiler flags using during compilation of source files
|
||||
CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \
|
||||
-nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \
|
||||
-Wno-address -Wno-unused -DHTTPD_MAX_BACKLOG_SIZE=8192 -DADMIN_PASSWORD=$(ADMIN_PASSWORD) \
|
||||
-DGIT_HASH='"$(shell git rev-parse --short HEAD)"'
|
||||
-Wno-address -Wno-unused
|
||||
|
||||
CFLAGS += -DHTTPD_MAX_BACKLOG_SIZE=10240
|
||||
CFLAGS += -DGIT_HASH='"$(shell git rev-parse --short HEAD)"'
|
||||
CFLAGS += -DADMIN_PASSWORD=$(ADMIN_PASSWORD)
|
||||
|
||||
# Debug logging
|
||||
CFLAGS += -DDEBUG_ANSI=1
|
||||
CFLAGS += -DDEBUG_INPUT=0
|
||||
|
||||
# linker flags used to generate the main object file
|
||||
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
|
||||
|
||||
+18
-3
@@ -1152,9 +1152,6 @@ body.term #botnav {
|
||||
position: absolute;
|
||||
top: -9999px; }
|
||||
|
||||
.nb {
|
||||
font-weight: normal !important; }
|
||||
|
||||
.theme-0 .fg0 {
|
||||
color: #111213; }
|
||||
.theme-0 .bg0 {
|
||||
@@ -1548,6 +1545,24 @@ body.term #botnav {
|
||||
.bold {
|
||||
font-weight: bold !important; }
|
||||
|
||||
.faint span {
|
||||
opacity: 0.6; }
|
||||
|
||||
.italic {
|
||||
font-style: italic; }
|
||||
|
||||
.under {
|
||||
text-decoration: underline; }
|
||||
|
||||
.strike {
|
||||
text-decoration: line-through; }
|
||||
|
||||
.underline.strike {
|
||||
text-decoration: underline line-through; }
|
||||
|
||||
.blink-hide .blink {
|
||||
color: transparent; }
|
||||
|
||||
.Row.color-preview {
|
||||
font-family: monospace;
|
||||
font-size: 16pt;
|
||||
|
||||
+521
-63
@@ -701,6 +701,302 @@
|
||||
// Set Chibi's global namespace here ($)
|
||||
w.$ = chibi;
|
||||
}());
|
||||
// keymaster.js
|
||||
// (c) 2011-2013 Thomas Fuchs
|
||||
// keymaster.js may be freely distributed under the MIT license.
|
||||
|
||||
;(function(global){
|
||||
var k,
|
||||
_handlers = {},
|
||||
_mods = { 16: false, 18: false, 17: false, 91: false },
|
||||
_scope = 'all',
|
||||
// modifier keys
|
||||
_MODIFIERS = {
|
||||
'⇧': 16, shift: 16,
|
||||
'⌥': 18, alt: 18, option: 18,
|
||||
'⌃': 17, ctrl: 17, control: 17,
|
||||
'⌘': 91, command: 91
|
||||
},
|
||||
// special keys
|
||||
_MAP = {
|
||||
backspace: 8, tab: 9, clear: 12,
|
||||
enter: 13, 'return': 13,
|
||||
esc: 27, escape: 27, space: 32,
|
||||
left: 37, up: 38,
|
||||
right: 39, down: 40,
|
||||
del: 46, 'delete': 46,
|
||||
home: 36, end: 35,
|
||||
pageup: 33, pagedown: 34, insert: 45, // added insert
|
||||
',': 188, '.': 190, '/': 191,
|
||||
'`': 192, '-': 189, '=': 187,
|
||||
';': 186, '\'': 222,
|
||||
'[': 219, ']': 221, '\\': 220
|
||||
},
|
||||
code = function(x){
|
||||
return _MAP[x] || x.toUpperCase().charCodeAt(0);
|
||||
},
|
||||
_downKeys = [];
|
||||
|
||||
for(k=1;k<20;k++) _MAP['f'+k] = 111+k;
|
||||
|
||||
// IE doesn't support Array#indexOf, so have a simple replacement
|
||||
function index(array, item){
|
||||
var i = array.length;
|
||||
while(i--) if(array[i]===item) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// for comparing mods before unassignment
|
||||
function compareArray(a1, a2) {
|
||||
if (a1.length != a2.length) return false;
|
||||
for (var i = 0; i < a1.length; i++) {
|
||||
if (a1[i] !== a2[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
var modifierMap = {
|
||||
16:'shiftKey',
|
||||
18:'altKey',
|
||||
17:'ctrlKey',
|
||||
91:'metaKey'
|
||||
};
|
||||
function updateModifierKey(event) {
|
||||
for(k in _mods) _mods[k] = event[modifierMap[k]];
|
||||
};
|
||||
|
||||
// handle keydown event
|
||||
function dispatch(event) {
|
||||
var key, handler, k, i, modifiersMatch, scope;
|
||||
key = event.keyCode;
|
||||
|
||||
if (index(_downKeys, key) == -1) {
|
||||
_downKeys.push(key);
|
||||
}
|
||||
|
||||
// if a modifier key, set the key.<modifierkeyname> property to true and return
|
||||
if(key == 93 || key == 224) key = 91; // right command on webkit, command on Gecko
|
||||
if(key in _mods) {
|
||||
_mods[key] = true;
|
||||
// 'assignKey' from inside this closure is exported to window.key
|
||||
for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = true;
|
||||
return;
|
||||
}
|
||||
updateModifierKey(event);
|
||||
|
||||
// see if we need to ignore the keypress (filter() can can be overridden)
|
||||
// by default ignore key presses if a select, textarea, or input is focused
|
||||
if(!assignKey.filter.call(this, event)) return;
|
||||
|
||||
// abort if no potentially matching shortcuts found
|
||||
if (!(key in _handlers)) return;
|
||||
|
||||
scope = getScope();
|
||||
|
||||
// for each potential shortcut
|
||||
for (i = 0; i < _handlers[key].length; i++) {
|
||||
handler = _handlers[key][i];
|
||||
|
||||
// see if it's in the current scope
|
||||
if(handler.scope == scope || handler.scope == 'all'){
|
||||
// check if modifiers match if any
|
||||
modifiersMatch = handler.mods.length > 0;
|
||||
for(k in _mods)
|
||||
if((!_mods[k] && index(handler.mods, +k) > -1) ||
|
||||
(_mods[k] && index(handler.mods, +k) == -1)) modifiersMatch = false;
|
||||
// call the handler and stop the event if neccessary
|
||||
if((handler.mods.length == 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch){
|
||||
if(handler.method(event, handler)===false){
|
||||
if(event.preventDefault) event.preventDefault();
|
||||
else event.returnValue = false;
|
||||
if(event.stopPropagation) event.stopPropagation();
|
||||
if(event.cancelBubble) event.cancelBubble = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// unset modifier keys on keyup
|
||||
function clearModifier(event){
|
||||
var key = event.keyCode, k,
|
||||
i = index(_downKeys, key);
|
||||
|
||||
// remove key from _downKeys
|
||||
if (i >= 0) {
|
||||
_downKeys.splice(i, 1);
|
||||
}
|
||||
|
||||
if(key == 93 || key == 224) key = 91;
|
||||
if(key in _mods) {
|
||||
_mods[key] = false;
|
||||
for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = false;
|
||||
}
|
||||
};
|
||||
|
||||
function resetModifiers() {
|
||||
for(k in _mods) _mods[k] = false;
|
||||
for(k in _MODIFIERS) assignKey[k] = false;
|
||||
};
|
||||
|
||||
// parse and assign shortcut
|
||||
function assignKey(key, scope, method){
|
||||
var keys, mods;
|
||||
keys = getKeys(key);
|
||||
if (method === undefined) {
|
||||
method = scope;
|
||||
scope = 'all';
|
||||
}
|
||||
|
||||
// for each shortcut
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
// set modifier keys if any
|
||||
mods = [];
|
||||
key = keys[i].split('+');
|
||||
if (key.length > 1){
|
||||
mods = getMods(key);
|
||||
key = [key[key.length-1]];
|
||||
}
|
||||
// convert to keycode and...
|
||||
key = key[0]
|
||||
key = code(key);
|
||||
// ...store handler
|
||||
if (!(key in _handlers)) _handlers[key] = [];
|
||||
_handlers[key].push({ shortcut: keys[i], scope: scope, method: method, key: keys[i], mods: mods });
|
||||
}
|
||||
};
|
||||
|
||||
// unbind all handlers for given key in current scope
|
||||
function unbindKey(key, scope) {
|
||||
var multipleKeys, keys,
|
||||
mods = [],
|
||||
i, j, obj;
|
||||
|
||||
multipleKeys = getKeys(key);
|
||||
|
||||
for (j = 0; j < multipleKeys.length; j++) {
|
||||
keys = multipleKeys[j].split('+');
|
||||
|
||||
if (keys.length > 1) {
|
||||
mods = getMods(keys);
|
||||
}
|
||||
|
||||
key = keys[keys.length - 1];
|
||||
key = code(key);
|
||||
|
||||
if (scope === undefined) {
|
||||
scope = getScope();
|
||||
}
|
||||
if (!_handlers[key]) {
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < _handlers[key].length; i++) {
|
||||
obj = _handlers[key][i];
|
||||
// only clear handlers if correct scope and mods match
|
||||
if (obj.scope === scope && compareArray(obj.mods, mods)) {
|
||||
_handlers[key][i] = {};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Returns true if the key with code 'keyCode' is currently down
|
||||
// Converts strings into key codes.
|
||||
function isPressed(keyCode) {
|
||||
if (typeof(keyCode)=='string') {
|
||||
keyCode = code(keyCode);
|
||||
}
|
||||
return index(_downKeys, keyCode) != -1;
|
||||
}
|
||||
|
||||
function getPressedKeyCodes() {
|
||||
return _downKeys.slice(0);
|
||||
}
|
||||
|
||||
function filter(event){
|
||||
var tagName = (event.target || event.srcElement).tagName;
|
||||
// ignore keypressed in any elements that support keyboard data input
|
||||
return !(tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA');
|
||||
}
|
||||
|
||||
// initialize key.<modifier> to false
|
||||
for(k in _MODIFIERS) assignKey[k] = false;
|
||||
|
||||
// set current scope (default 'all')
|
||||
function setScope(scope){ _scope = scope || 'all' };
|
||||
function getScope(){ return _scope || 'all' };
|
||||
|
||||
// delete all handlers for a given scope
|
||||
function deleteScope(scope){
|
||||
var key, handlers, i;
|
||||
|
||||
for (key in _handlers) {
|
||||
handlers = _handlers[key];
|
||||
for (i = 0; i < handlers.length; ) {
|
||||
if (handlers[i].scope === scope) handlers.splice(i, 1);
|
||||
else i++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// abstract key logic for assign and unassign
|
||||
function getKeys(key) {
|
||||
var keys;
|
||||
key = key.replace(/\s/g, '');
|
||||
keys = key.split(',');
|
||||
if ((keys[keys.length - 1]) == '') {
|
||||
keys[keys.length - 2] += ',';
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
// abstract mods logic for assign and unassign
|
||||
function getMods(key) {
|
||||
var mods = key.slice(0, key.length - 1);
|
||||
for (var mi = 0; mi < mods.length; mi++)
|
||||
mods[mi] = _MODIFIERS[mods[mi]];
|
||||
return mods;
|
||||
}
|
||||
|
||||
// cross-browser events
|
||||
function addEvent(object, event, method) {
|
||||
if (object.addEventListener)
|
||||
object.addEventListener(event, method, false);
|
||||
else if(object.attachEvent)
|
||||
object.attachEvent('on'+event, function(){ method(window.event) });
|
||||
};
|
||||
|
||||
// set the handlers globally on document
|
||||
addEvent(document, 'keydown', function(event) { dispatch(event) }); // Passing _scope to a callback to ensure it remains the same by execution. Fixes #48
|
||||
addEvent(document, 'keyup', clearModifier);
|
||||
|
||||
// reset modifiers to false whenever the window is (re)focused.
|
||||
addEvent(window, 'focus', resetModifiers);
|
||||
|
||||
// store previously defined key
|
||||
var previousKey = global.key;
|
||||
|
||||
// restore previously defined key and return reference to our key object
|
||||
function noConflict() {
|
||||
var k = global.key;
|
||||
global.key = previousKey;
|
||||
return k;
|
||||
}
|
||||
|
||||
// set window.key and window.key.set/get/deleteScope, and the default filter
|
||||
global.key = assignKey;
|
||||
global.key.setScope = setScope;
|
||||
global.key.getScope = getScope;
|
||||
global.key.deleteScope = deleteScope;
|
||||
global.key.filter = filter;
|
||||
global.key.isPressed = isPressed;
|
||||
global.key.getPressedKeyCodes = getPressedKeyCodes;
|
||||
global.key.noConflict = noConflict;
|
||||
global.key.unbind = unbindKey;
|
||||
|
||||
if(typeof module !== 'undefined') module.exports = assignKey;
|
||||
|
||||
})(this);
|
||||
/** Make a node */
|
||||
function mk(e) {return document.createElement(e)}
|
||||
|
||||
@@ -1022,6 +1318,70 @@ $.ready(function() {
|
||||
}, 1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
|
||||
if (!String.fromCodePoint) {
|
||||
(function() {
|
||||
var defineProperty = (function() {
|
||||
// IE 8 only supports `Object.defineProperty` on DOM elements
|
||||
try {
|
||||
var object = {};
|
||||
var $defineProperty = Object.defineProperty;
|
||||
var result = $defineProperty(object, object, object) && $defineProperty;
|
||||
} catch(error) {}
|
||||
return result;
|
||||
}());
|
||||
var stringFromCharCode = String.fromCharCode;
|
||||
var floor = Math.floor;
|
||||
var fromCodePoint = function() {
|
||||
var MAX_SIZE = 0x4000;
|
||||
var codeUnits = [];
|
||||
var highSurrogate;
|
||||
var lowSurrogate;
|
||||
var index = -1;
|
||||
var length = arguments.length;
|
||||
if (!length) {
|
||||
return '';
|
||||
}
|
||||
var result = '';
|
||||
while (++index < length) {
|
||||
var codePoint = Number(arguments[index]);
|
||||
if (
|
||||
!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
|
||||
codePoint < 0 || // not a valid Unicode code point
|
||||
codePoint > 0x10FFFF || // not a valid Unicode code point
|
||||
floor(codePoint) != codePoint // not an integer
|
||||
) {
|
||||
throw RangeError('Invalid code point: ' + codePoint);
|
||||
}
|
||||
if (codePoint <= 0xFFFF) { // BMP code point
|
||||
codeUnits.push(codePoint);
|
||||
} else { // Astral code point; split in surrogate halves
|
||||
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
||||
codePoint -= 0x10000;
|
||||
highSurrogate = (codePoint >> 10) + 0xD800;
|
||||
lowSurrogate = (codePoint % 0x400) + 0xDC00;
|
||||
codeUnits.push(highSurrogate, lowSurrogate);
|
||||
}
|
||||
if (index + 1 == length || codeUnits.length > MAX_SIZE) {
|
||||
result += stringFromCharCode.apply(null, codeUnits);
|
||||
codeUnits.length = 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
if (defineProperty) {
|
||||
defineProperty(String, 'fromCodePoint', {
|
||||
'value': fromCodePoint,
|
||||
'configurable': true,
|
||||
'writable': true
|
||||
});
|
||||
} else {
|
||||
String.fromCodePoint = fromCodePoint;
|
||||
}
|
||||
}());
|
||||
}
|
||||
// Generated from PHP locale file
|
||||
var _tr = {
|
||||
"wifi.connected_ip_is": "Connected, IP is ",
|
||||
@@ -1200,7 +1560,7 @@ var Screen = (function () {
|
||||
y: 0,
|
||||
fg: 7, // colors 0-15
|
||||
bg: 0,
|
||||
bold: false,
|
||||
attrs: 0,
|
||||
suppress: false, // do not turn on in blink interval (for safe moving)
|
||||
hidden: false // do not show
|
||||
};
|
||||
@@ -1208,35 +1568,19 @@ var Screen = (function () {
|
||||
var screen = [];
|
||||
var blinkIval;
|
||||
|
||||
/** Clear screen */
|
||||
function _clear() {
|
||||
for (var i = W*H-1; i>=0; i--) {
|
||||
var cell = screen[i];
|
||||
cell.t = ' ';
|
||||
cell.bg = cursor.bg;
|
||||
cell.fg = cursor.fg;
|
||||
cell.bold = false;
|
||||
_draw(cell);
|
||||
}
|
||||
}
|
||||
|
||||
/** Set text and color at XY */
|
||||
function _cellAt(y, x) {
|
||||
return screen[y*W+x];
|
||||
}
|
||||
var frakturExceptions = {
|
||||
'C': '\u212d',
|
||||
'H': '\u210c',
|
||||
'I': '\u2111',
|
||||
'R': '\u211c',
|
||||
'Z': '\u2128',
|
||||
};
|
||||
|
||||
/** Get cell under cursor */
|
||||
function _curCell() {
|
||||
return screen[cursor.y*W + cursor.x];
|
||||
}
|
||||
|
||||
/** Enable or disable cursor visibility */
|
||||
function _cursorEnable(enable) {
|
||||
cursor.hidden = !enable;
|
||||
cursor.a &= enable;
|
||||
_draw(_curCell());
|
||||
}
|
||||
|
||||
/** Safely move cursor */
|
||||
function cursorSet(y, x) {
|
||||
// Hide and prevent from showing up during the move
|
||||
@@ -1255,13 +1599,44 @@ var Screen = (function () {
|
||||
inv = cursor.a && cursor.x == cell.x && cursor.y == cell.y;
|
||||
}
|
||||
|
||||
var e = cell.e, fg, bg;
|
||||
var elem = cell.e, fg, bg, cn, t;
|
||||
// Colors
|
||||
fg = inv ? cell.bg : cell.fg;
|
||||
bg = inv ? cell.fg : cell.bg;
|
||||
// Update
|
||||
e.innerText = (cell.t + ' ')[0];
|
||||
e.className = 'fg' + fg + ' bg' + bg + (cell.bold ? ' bold' : '');
|
||||
elem.textContent = t = (cell.t + ' ')[0];
|
||||
|
||||
cn = 'fg' + fg + ' bg' + bg;
|
||||
if (cell.attrs & (1<<0)) cn += ' bold';
|
||||
if (cell.attrs & (1<<2)) cn += ' italic';
|
||||
if (cell.attrs & (1<<3)) cn += ' under';
|
||||
if (cell.attrs & (1<<4)) cn += ' blink';
|
||||
if (cell.attrs & (1<<5)) {
|
||||
cn += ' fraktur';
|
||||
// perform substitution
|
||||
if (t >= 'a' && t <= 'z') {
|
||||
t = String.fromCodePoint(0x1d51e - 97 + t.charCodeAt(0));
|
||||
}
|
||||
else if (t >= 'A' && t <= 'Z') {
|
||||
// this set is incomplete, some exceptions are needed
|
||||
if (frakturExceptions.hasOwnProperty(t)) {
|
||||
t = frakturExceptions[t];
|
||||
} else {
|
||||
t = String.fromCodePoint(0x1d504 - 65 + t.charCodeAt(0));
|
||||
}
|
||||
}
|
||||
elem.textContent = t;
|
||||
}
|
||||
if (cell.attrs & (1<<6)) cn += ' strike';
|
||||
|
||||
if (cell.attrs & (1<<1)) {
|
||||
cn += ' faint';
|
||||
// faint requires special html - otherwise it would also dim the background.
|
||||
// we use opacity on the text...
|
||||
elem.innerHTML = '<span>' + e(elem.textContent) + '</span>';
|
||||
}
|
||||
|
||||
elem.className = cn;
|
||||
}
|
||||
|
||||
/** Show entire screen */
|
||||
@@ -1305,6 +1680,7 @@ var Screen = (function () {
|
||||
t: ' ',
|
||||
fg: cursor.fg,
|
||||
bg: cursor.bg,
|
||||
attrs: 0,
|
||||
e: e,
|
||||
x: i % W,
|
||||
y: Math.floor(i / W),
|
||||
@@ -1328,6 +1704,15 @@ var Screen = (function () {
|
||||
_draw(_curCell(), cursor.a);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
// blink attribute
|
||||
setInterval(function () {
|
||||
$('#screen').removeClass('blink-hide');
|
||||
setTimeout(function() {
|
||||
$('#screen').addClass('blink-hide');
|
||||
}, 800); // 200 ms ON
|
||||
}, 1000);
|
||||
|
||||
inited = true;
|
||||
}
|
||||
|
||||
@@ -1336,11 +1721,18 @@ var Screen = (function () {
|
||||
return (s.charCodeAt(i++) - 1) + (s.charCodeAt(i) - 1) * 127;
|
||||
}
|
||||
|
||||
var SEQ_SET_COLOR = 1;
|
||||
/** Decode three-byte number */
|
||||
function parse3B(s, i) {
|
||||
return (s.charCodeAt(i) - 1) + (s.charCodeAt(i+1) - 1) * 127 + (s.charCodeAt(i+2) - 1) * 127 * 127;
|
||||
}
|
||||
|
||||
var SEQ_SET_COLOR_ATTR = 1;
|
||||
var SEQ_REPEAT = 2;
|
||||
var SEQ_SET_COLOR = 3;
|
||||
var SEQ_SET_ATTR = 4;
|
||||
|
||||
function _load_content(str) {
|
||||
var i = 0, ci = 0, j, jc, num, num2, t = ' ', fg, bg, bold, cell;
|
||||
var i = 0, ci = 0, j, jc, num, num2, t = ' ', fg, bg, attrs, cell;
|
||||
|
||||
if (!inited) _init();
|
||||
|
||||
@@ -1362,25 +1754,31 @@ var Screen = (function () {
|
||||
num = parse2B(str, i); i += 2; // fg bg bold hidden
|
||||
cursor.fg = num & 0x0F;
|
||||
cursor.bg = (num & 0xF0) >> 4;
|
||||
cursor.bold = !!(num & 0x100);
|
||||
cursor.hidden = !(num & 0x200);
|
||||
// console.log("FG ",cursor.fg, ", BG ", cursor.bg,", BOLD ", cursor.bold, ", HIDE ", cursor.hidden);
|
||||
cursor.hidden = !(num & 0x100);
|
||||
|
||||
fg = cursor.fg;
|
||||
bg = cursor.bg;
|
||||
bold = cursor.bold;
|
||||
attrs = 0;
|
||||
|
||||
// Here come the content
|
||||
while(i < str.length && ci<W*H) {
|
||||
|
||||
j = str[i++];
|
||||
jc = j.charCodeAt(0);
|
||||
if (jc == SEQ_SET_COLOR) {
|
||||
if (jc == SEQ_SET_COLOR_ATTR) {
|
||||
num = parse3B(str, i); i += 3;
|
||||
fg = num & 0x0F;
|
||||
bg = (num & 0xF0) >> 4;
|
||||
attrs = (num & 0xFF00)>>8;
|
||||
}
|
||||
else if (jc == SEQ_SET_COLOR) {
|
||||
num = parse2B(str, i); i += 2;
|
||||
fg = num & 0x0F;
|
||||
bg = (num & 0xF0) >> 4;
|
||||
bold = !!(num & 0x100);
|
||||
// console.log("Switch to ",fg,bg,bold);
|
||||
}
|
||||
else if (jc == SEQ_SET_ATTR) {
|
||||
num = parse2B(str, i); i += 2;
|
||||
attrs = num & 0xFF;
|
||||
}
|
||||
else if (jc == SEQ_REPEAT) {
|
||||
num = parse2B(str, i); i += 2;
|
||||
@@ -1390,7 +1788,7 @@ var Screen = (function () {
|
||||
cell.fg = fg;
|
||||
cell.bg = bg;
|
||||
cell.t = t;
|
||||
cell.bold = bold;
|
||||
cell.attrs = attrs;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1399,7 +1797,7 @@ var Screen = (function () {
|
||||
t = cell.t = j;
|
||||
cell.fg = fg;
|
||||
cell.bg = bg;
|
||||
cell.bold = bold;
|
||||
cell.attrs = attrs;
|
||||
// console.log("Symbol ", j);
|
||||
}
|
||||
}
|
||||
@@ -1450,12 +1848,14 @@ var Conn = (function() {
|
||||
console.warn("SOCKET CLOSED, code "+evt.code+". Reconnecting...");
|
||||
setTimeout(function() {
|
||||
init();
|
||||
}, 1000);
|
||||
}, 200);
|
||||
// this happens when the buffer gets fucked up via invalid unicode.
|
||||
// we basically use polling instead of socket then
|
||||
}
|
||||
|
||||
function onMessage(evt) {
|
||||
try {
|
||||
console.log("RX: ", evt.data);
|
||||
//console.log("RX: ", evt.data);
|
||||
// Assume all our messages are screen updates
|
||||
Screen.load(evt.data);
|
||||
} catch(e) {
|
||||
@@ -1515,31 +1915,89 @@ var Input = (function() {
|
||||
Conn.send("BTN:"+n);
|
||||
}
|
||||
|
||||
function _initKeys() {
|
||||
// This takes care of text characters typed
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
var keymap = {
|
||||
'tab': '\x09',
|
||||
'backspace': '\x08',
|
||||
'enter': '\x0d',
|
||||
'ctrl+enter': '\x0a',
|
||||
'esc': '\x1b',
|
||||
'up': '\x1b[A',
|
||||
'down': '\x1b[B',
|
||||
'right': '\x1b[C',
|
||||
'left': '\x1b[D',
|
||||
'home': '\x1b[1~',
|
||||
'insert': '\x1b[2~',
|
||||
'delete': '\x1b[3~',
|
||||
'end': '\x1b[4~',
|
||||
'pageup': '\x1b[5~',
|
||||
'pagedown': '\x1b[6~',
|
||||
'f1': '\x1b[11~',
|
||||
'f2': '\x1b[12~',
|
||||
'f3': '\x1b[13~',
|
||||
'f4': '\x1b[14~',
|
||||
'f5': '\x1b[15~', // disconnect
|
||||
'f6': '\x1b[17~',
|
||||
'f7': '\x1b[18~',
|
||||
'f8': '\x1b[19~',
|
||||
'f9': '\x1b[20~',
|
||||
'f10': '\x1b[21~', // disconnect
|
||||
'f11': '\x1b[23~',
|
||||
'f12': '\x1b[24~',
|
||||
'shift+f1': '\x1b[25~',
|
||||
'shift+f2': '\x1b[26~', // disconnect
|
||||
'shift+f3': '\x1b[28~',
|
||||
'shift+f4': '\x1b[29~', // disconnect
|
||||
'shift+f5': '\x1b[31~',
|
||||
'shift+f6': '\x1b[32~',
|
||||
'shift+f7': '\x1b[33~',
|
||||
'shift+f8': '\x1b[34~',
|
||||
};
|
||||
|
||||
function bind(combo, str) {
|
||||
// mac fix - allow also cmd
|
||||
if (combo.indexOf('ctrl+') !== -1) {
|
||||
combo += ',' + combo.replace('ctrl', 'command');
|
||||
}
|
||||
key(combo, function (e) {
|
||||
e.preventDefault();
|
||||
// console.log(combo);
|
||||
sendStrMsg(str)
|
||||
});
|
||||
}
|
||||
|
||||
for (var k in keymap) {
|
||||
if (keymap.hasOwnProperty(k)) {
|
||||
bind(k, keymap[k]);
|
||||
}
|
||||
}
|
||||
|
||||
// ctrl-letter codes are sent as simple low ASCII codes
|
||||
for (var i = 1; i<=26;i++) {
|
||||
bind('ctrl+' + String.fromCharCode(96+i), String.fromCharCode(i));
|
||||
}
|
||||
bind('ctrl+]', '\x1b'); // alternate way to enter ESC
|
||||
bind('ctrl+\\', '\x1c');
|
||||
bind('ctrl+[', '\x1d');
|
||||
bind('ctrl+^', '\x1e');
|
||||
bind('ctrl+_', '\x1f');
|
||||
}
|
||||
|
||||
function init() {
|
||||
window.addEventListener('keypress', function(e) {
|
||||
var code = +e.which;
|
||||
if (code >= 32 && code < 127) {
|
||||
var ch = String.fromCharCode(code);
|
||||
//console.log("Typed ", ch, "code", code, e);
|
||||
sendStrMsg(ch);
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('keydown', function(e) {
|
||||
var code = e.keyCode;
|
||||
//console.log("Down ", code, e);
|
||||
switch(code) {
|
||||
case 8: sendStrMsg('\x08'); break;
|
||||
case 10:
|
||||
case 13: sendStrMsg('\x0d\x0a'); break;
|
||||
case 27: sendStrMsg('\x1b'); break; // this allows to directly enter control sequences
|
||||
case 37: sendStrMsg('\x1b[D'); break;
|
||||
case 38: sendStrMsg('\x1b[A'); break;
|
||||
case 39: sendStrMsg('\x1b[C'); break;
|
||||
case 40: sendStrMsg('\x1b[B'); break;
|
||||
}
|
||||
});
|
||||
_initKeys();
|
||||
|
||||
// Button presses
|
||||
qsa('#buttons button').forEach(function(s) {
|
||||
s.addEventListener('click', function() {
|
||||
sendBtnMsg(+this.dataset['n']);
|
||||
|
||||
@@ -123,3 +123,67 @@ $.ready(function() {
|
||||
}, 1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
|
||||
if (!String.fromCodePoint) {
|
||||
(function() {
|
||||
var defineProperty = (function() {
|
||||
// IE 8 only supports `Object.defineProperty` on DOM elements
|
||||
try {
|
||||
var object = {};
|
||||
var $defineProperty = Object.defineProperty;
|
||||
var result = $defineProperty(object, object, object) && $defineProperty;
|
||||
} catch(error) {}
|
||||
return result;
|
||||
}());
|
||||
var stringFromCharCode = String.fromCharCode;
|
||||
var floor = Math.floor;
|
||||
var fromCodePoint = function() {
|
||||
var MAX_SIZE = 0x4000;
|
||||
var codeUnits = [];
|
||||
var highSurrogate;
|
||||
var lowSurrogate;
|
||||
var index = -1;
|
||||
var length = arguments.length;
|
||||
if (!length) {
|
||||
return '';
|
||||
}
|
||||
var result = '';
|
||||
while (++index < length) {
|
||||
var codePoint = Number(arguments[index]);
|
||||
if (
|
||||
!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
|
||||
codePoint < 0 || // not a valid Unicode code point
|
||||
codePoint > 0x10FFFF || // not a valid Unicode code point
|
||||
floor(codePoint) != codePoint // not an integer
|
||||
) {
|
||||
throw RangeError('Invalid code point: ' + codePoint);
|
||||
}
|
||||
if (codePoint <= 0xFFFF) { // BMP code point
|
||||
codeUnits.push(codePoint);
|
||||
} else { // Astral code point; split in surrogate halves
|
||||
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
||||
codePoint -= 0x10000;
|
||||
highSurrogate = (codePoint >> 10) + 0xD800;
|
||||
lowSurrogate = (codePoint % 0x400) + 0xDC00;
|
||||
codeUnits.push(highSurrogate, lowSurrogate);
|
||||
}
|
||||
if (index + 1 == length || codeUnits.length > MAX_SIZE) {
|
||||
result += stringFromCharCode.apply(null, codeUnits);
|
||||
codeUnits.length = 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
if (defineProperty) {
|
||||
defineProperty(String, 'fromCodePoint', {
|
||||
'value': fromCodePoint,
|
||||
'configurable': true,
|
||||
'writable': true
|
||||
});
|
||||
} else {
|
||||
String.fromCodePoint = fromCodePoint;
|
||||
}
|
||||
}());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,296 @@
|
||||
// keymaster.js
|
||||
// (c) 2011-2013 Thomas Fuchs
|
||||
// keymaster.js may be freely distributed under the MIT license.
|
||||
|
||||
;(function(global){
|
||||
var k,
|
||||
_handlers = {},
|
||||
_mods = { 16: false, 18: false, 17: false, 91: false },
|
||||
_scope = 'all',
|
||||
// modifier keys
|
||||
_MODIFIERS = {
|
||||
'⇧': 16, shift: 16,
|
||||
'⌥': 18, alt: 18, option: 18,
|
||||
'⌃': 17, ctrl: 17, control: 17,
|
||||
'⌘': 91, command: 91
|
||||
},
|
||||
// special keys
|
||||
_MAP = {
|
||||
backspace: 8, tab: 9, clear: 12,
|
||||
enter: 13, 'return': 13,
|
||||
esc: 27, escape: 27, space: 32,
|
||||
left: 37, up: 38,
|
||||
right: 39, down: 40,
|
||||
del: 46, 'delete': 46,
|
||||
home: 36, end: 35,
|
||||
pageup: 33, pagedown: 34, insert: 45, // added insert
|
||||
',': 188, '.': 190, '/': 191,
|
||||
'`': 192, '-': 189, '=': 187,
|
||||
';': 186, '\'': 222,
|
||||
'[': 219, ']': 221, '\\': 220
|
||||
},
|
||||
code = function(x){
|
||||
return _MAP[x] || x.toUpperCase().charCodeAt(0);
|
||||
},
|
||||
_downKeys = [];
|
||||
|
||||
for(k=1;k<20;k++) _MAP['f'+k] = 111+k;
|
||||
|
||||
// IE doesn't support Array#indexOf, so have a simple replacement
|
||||
function index(array, item){
|
||||
var i = array.length;
|
||||
while(i--) if(array[i]===item) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// for comparing mods before unassignment
|
||||
function compareArray(a1, a2) {
|
||||
if (a1.length != a2.length) return false;
|
||||
for (var i = 0; i < a1.length; i++) {
|
||||
if (a1[i] !== a2[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
var modifierMap = {
|
||||
16:'shiftKey',
|
||||
18:'altKey',
|
||||
17:'ctrlKey',
|
||||
91:'metaKey'
|
||||
};
|
||||
function updateModifierKey(event) {
|
||||
for(k in _mods) _mods[k] = event[modifierMap[k]];
|
||||
};
|
||||
|
||||
// handle keydown event
|
||||
function dispatch(event) {
|
||||
var key, handler, k, i, modifiersMatch, scope;
|
||||
key = event.keyCode;
|
||||
|
||||
if (index(_downKeys, key) == -1) {
|
||||
_downKeys.push(key);
|
||||
}
|
||||
|
||||
// if a modifier key, set the key.<modifierkeyname> property to true and return
|
||||
if(key == 93 || key == 224) key = 91; // right command on webkit, command on Gecko
|
||||
if(key in _mods) {
|
||||
_mods[key] = true;
|
||||
// 'assignKey' from inside this closure is exported to window.key
|
||||
for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = true;
|
||||
return;
|
||||
}
|
||||
updateModifierKey(event);
|
||||
|
||||
// see if we need to ignore the keypress (filter() can can be overridden)
|
||||
// by default ignore key presses if a select, textarea, or input is focused
|
||||
if(!assignKey.filter.call(this, event)) return;
|
||||
|
||||
// abort if no potentially matching shortcuts found
|
||||
if (!(key in _handlers)) return;
|
||||
|
||||
scope = getScope();
|
||||
|
||||
// for each potential shortcut
|
||||
for (i = 0; i < _handlers[key].length; i++) {
|
||||
handler = _handlers[key][i];
|
||||
|
||||
// see if it's in the current scope
|
||||
if(handler.scope == scope || handler.scope == 'all'){
|
||||
// check if modifiers match if any
|
||||
modifiersMatch = handler.mods.length > 0;
|
||||
for(k in _mods)
|
||||
if((!_mods[k] && index(handler.mods, +k) > -1) ||
|
||||
(_mods[k] && index(handler.mods, +k) == -1)) modifiersMatch = false;
|
||||
// call the handler and stop the event if neccessary
|
||||
if((handler.mods.length == 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch){
|
||||
if(handler.method(event, handler)===false){
|
||||
if(event.preventDefault) event.preventDefault();
|
||||
else event.returnValue = false;
|
||||
if(event.stopPropagation) event.stopPropagation();
|
||||
if(event.cancelBubble) event.cancelBubble = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// unset modifier keys on keyup
|
||||
function clearModifier(event){
|
||||
var key = event.keyCode, k,
|
||||
i = index(_downKeys, key);
|
||||
|
||||
// remove key from _downKeys
|
||||
if (i >= 0) {
|
||||
_downKeys.splice(i, 1);
|
||||
}
|
||||
|
||||
if(key == 93 || key == 224) key = 91;
|
||||
if(key in _mods) {
|
||||
_mods[key] = false;
|
||||
for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = false;
|
||||
}
|
||||
};
|
||||
|
||||
function resetModifiers() {
|
||||
for(k in _mods) _mods[k] = false;
|
||||
for(k in _MODIFIERS) assignKey[k] = false;
|
||||
};
|
||||
|
||||
// parse and assign shortcut
|
||||
function assignKey(key, scope, method){
|
||||
var keys, mods;
|
||||
keys = getKeys(key);
|
||||
if (method === undefined) {
|
||||
method = scope;
|
||||
scope = 'all';
|
||||
}
|
||||
|
||||
// for each shortcut
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
// set modifier keys if any
|
||||
mods = [];
|
||||
key = keys[i].split('+');
|
||||
if (key.length > 1){
|
||||
mods = getMods(key);
|
||||
key = [key[key.length-1]];
|
||||
}
|
||||
// convert to keycode and...
|
||||
key = key[0]
|
||||
key = code(key);
|
||||
// ...store handler
|
||||
if (!(key in _handlers)) _handlers[key] = [];
|
||||
_handlers[key].push({ shortcut: keys[i], scope: scope, method: method, key: keys[i], mods: mods });
|
||||
}
|
||||
};
|
||||
|
||||
// unbind all handlers for given key in current scope
|
||||
function unbindKey(key, scope) {
|
||||
var multipleKeys, keys,
|
||||
mods = [],
|
||||
i, j, obj;
|
||||
|
||||
multipleKeys = getKeys(key);
|
||||
|
||||
for (j = 0; j < multipleKeys.length; j++) {
|
||||
keys = multipleKeys[j].split('+');
|
||||
|
||||
if (keys.length > 1) {
|
||||
mods = getMods(keys);
|
||||
}
|
||||
|
||||
key = keys[keys.length - 1];
|
||||
key = code(key);
|
||||
|
||||
if (scope === undefined) {
|
||||
scope = getScope();
|
||||
}
|
||||
if (!_handlers[key]) {
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < _handlers[key].length; i++) {
|
||||
obj = _handlers[key][i];
|
||||
// only clear handlers if correct scope and mods match
|
||||
if (obj.scope === scope && compareArray(obj.mods, mods)) {
|
||||
_handlers[key][i] = {};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Returns true if the key with code 'keyCode' is currently down
|
||||
// Converts strings into key codes.
|
||||
function isPressed(keyCode) {
|
||||
if (typeof(keyCode)=='string') {
|
||||
keyCode = code(keyCode);
|
||||
}
|
||||
return index(_downKeys, keyCode) != -1;
|
||||
}
|
||||
|
||||
function getPressedKeyCodes() {
|
||||
return _downKeys.slice(0);
|
||||
}
|
||||
|
||||
function filter(event){
|
||||
var tagName = (event.target || event.srcElement).tagName;
|
||||
// ignore keypressed in any elements that support keyboard data input
|
||||
return !(tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA');
|
||||
}
|
||||
|
||||
// initialize key.<modifier> to false
|
||||
for(k in _MODIFIERS) assignKey[k] = false;
|
||||
|
||||
// set current scope (default 'all')
|
||||
function setScope(scope){ _scope = scope || 'all' };
|
||||
function getScope(){ return _scope || 'all' };
|
||||
|
||||
// delete all handlers for a given scope
|
||||
function deleteScope(scope){
|
||||
var key, handlers, i;
|
||||
|
||||
for (key in _handlers) {
|
||||
handlers = _handlers[key];
|
||||
for (i = 0; i < handlers.length; ) {
|
||||
if (handlers[i].scope === scope) handlers.splice(i, 1);
|
||||
else i++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// abstract key logic for assign and unassign
|
||||
function getKeys(key) {
|
||||
var keys;
|
||||
key = key.replace(/\s/g, '');
|
||||
keys = key.split(',');
|
||||
if ((keys[keys.length - 1]) == '') {
|
||||
keys[keys.length - 2] += ',';
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
// abstract mods logic for assign and unassign
|
||||
function getMods(key) {
|
||||
var mods = key.slice(0, key.length - 1);
|
||||
for (var mi = 0; mi < mods.length; mi++)
|
||||
mods[mi] = _MODIFIERS[mods[mi]];
|
||||
return mods;
|
||||
}
|
||||
|
||||
// cross-browser events
|
||||
function addEvent(object, event, method) {
|
||||
if (object.addEventListener)
|
||||
object.addEventListener(event, method, false);
|
||||
else if(object.attachEvent)
|
||||
object.attachEvent('on'+event, function(){ method(window.event) });
|
||||
};
|
||||
|
||||
// set the handlers globally on document
|
||||
addEvent(document, 'keydown', function(event) { dispatch(event) }); // Passing _scope to a callback to ensure it remains the same by execution. Fixes #48
|
||||
addEvent(document, 'keyup', clearModifier);
|
||||
|
||||
// reset modifiers to false whenever the window is (re)focused.
|
||||
addEvent(window, 'focus', resetModifiers);
|
||||
|
||||
// store previously defined key
|
||||
var previousKey = global.key;
|
||||
|
||||
// restore previously defined key and return reference to our key object
|
||||
function noConflict() {
|
||||
var k = global.key;
|
||||
global.key = previousKey;
|
||||
return k;
|
||||
}
|
||||
|
||||
// set window.key and window.key.set/get/deleteScope, and the default filter
|
||||
global.key = assignKey;
|
||||
global.key.setScope = setScope;
|
||||
global.key.getScope = getScope;
|
||||
global.key.deleteScope = deleteScope;
|
||||
global.key.filter = filter;
|
||||
global.key.isPressed = isPressed;
|
||||
global.key.getPressedKeyCodes = getPressedKeyCodes;
|
||||
global.key.noConflict = noConflict;
|
||||
global.key.unbind = unbindKey;
|
||||
|
||||
if(typeof module !== 'undefined') module.exports = assignKey;
|
||||
|
||||
})(this);
|
||||
+161
-63
@@ -8,7 +8,7 @@ var Screen = (function () {
|
||||
y: 0,
|
||||
fg: 7, // colors 0-15
|
||||
bg: 0,
|
||||
bold: false,
|
||||
attrs: 0,
|
||||
suppress: false, // do not turn on in blink interval (for safe moving)
|
||||
hidden: false // do not show
|
||||
};
|
||||
@@ -16,35 +16,19 @@ var Screen = (function () {
|
||||
var screen = [];
|
||||
var blinkIval;
|
||||
|
||||
/** Clear screen */
|
||||
function _clear() {
|
||||
for (var i = W*H-1; i>=0; i--) {
|
||||
var cell = screen[i];
|
||||
cell.t = ' ';
|
||||
cell.bg = cursor.bg;
|
||||
cell.fg = cursor.fg;
|
||||
cell.bold = false;
|
||||
_draw(cell);
|
||||
}
|
||||
}
|
||||
|
||||
/** Set text and color at XY */
|
||||
function _cellAt(y, x) {
|
||||
return screen[y*W+x];
|
||||
}
|
||||
var frakturExceptions = {
|
||||
'C': '\u212d',
|
||||
'H': '\u210c',
|
||||
'I': '\u2111',
|
||||
'R': '\u211c',
|
||||
'Z': '\u2128',
|
||||
};
|
||||
|
||||
/** Get cell under cursor */
|
||||
function _curCell() {
|
||||
return screen[cursor.y*W + cursor.x];
|
||||
}
|
||||
|
||||
/** Enable or disable cursor visibility */
|
||||
function _cursorEnable(enable) {
|
||||
cursor.hidden = !enable;
|
||||
cursor.a &= enable;
|
||||
_draw(_curCell());
|
||||
}
|
||||
|
||||
/** Safely move cursor */
|
||||
function cursorSet(y, x) {
|
||||
// Hide and prevent from showing up during the move
|
||||
@@ -63,13 +47,44 @@ var Screen = (function () {
|
||||
inv = cursor.a && cursor.x == cell.x && cursor.y == cell.y;
|
||||
}
|
||||
|
||||
var e = cell.e, fg, bg;
|
||||
var elem = cell.e, fg, bg, cn, t;
|
||||
// Colors
|
||||
fg = inv ? cell.bg : cell.fg;
|
||||
bg = inv ? cell.fg : cell.bg;
|
||||
// Update
|
||||
e.innerText = (cell.t + ' ')[0];
|
||||
e.className = 'fg' + fg + ' bg' + bg + (cell.bold ? ' bold' : '');
|
||||
elem.textContent = t = (cell.t + ' ')[0];
|
||||
|
||||
cn = 'fg' + fg + ' bg' + bg;
|
||||
if (cell.attrs & (1<<0)) cn += ' bold';
|
||||
if (cell.attrs & (1<<2)) cn += ' italic';
|
||||
if (cell.attrs & (1<<3)) cn += ' under';
|
||||
if (cell.attrs & (1<<4)) cn += ' blink';
|
||||
if (cell.attrs & (1<<5)) {
|
||||
cn += ' fraktur';
|
||||
// perform substitution
|
||||
if (t >= 'a' && t <= 'z') {
|
||||
t = String.fromCodePoint(0x1d51e - 97 + t.charCodeAt(0));
|
||||
}
|
||||
else if (t >= 'A' && t <= 'Z') {
|
||||
// this set is incomplete, some exceptions are needed
|
||||
if (frakturExceptions.hasOwnProperty(t)) {
|
||||
t = frakturExceptions[t];
|
||||
} else {
|
||||
t = String.fromCodePoint(0x1d504 - 65 + t.charCodeAt(0));
|
||||
}
|
||||
}
|
||||
elem.textContent = t;
|
||||
}
|
||||
if (cell.attrs & (1<<6)) cn += ' strike';
|
||||
|
||||
if (cell.attrs & (1<<1)) {
|
||||
cn += ' faint';
|
||||
// faint requires special html - otherwise it would also dim the background.
|
||||
// we use opacity on the text...
|
||||
elem.innerHTML = '<span>' + e(elem.textContent) + '</span>';
|
||||
}
|
||||
|
||||
elem.className = cn;
|
||||
}
|
||||
|
||||
/** Show entire screen */
|
||||
@@ -113,6 +128,7 @@ var Screen = (function () {
|
||||
t: ' ',
|
||||
fg: cursor.fg,
|
||||
bg: cursor.bg,
|
||||
attrs: 0,
|
||||
e: e,
|
||||
x: i % W,
|
||||
y: Math.floor(i / W),
|
||||
@@ -136,6 +152,15 @@ var Screen = (function () {
|
||||
_draw(_curCell(), cursor.a);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
// blink attribute
|
||||
setInterval(function () {
|
||||
$('#screen').removeClass('blink-hide');
|
||||
setTimeout(function() {
|
||||
$('#screen').addClass('blink-hide');
|
||||
}, 800); // 200 ms ON
|
||||
}, 1000);
|
||||
|
||||
inited = true;
|
||||
}
|
||||
|
||||
@@ -144,11 +169,18 @@ var Screen = (function () {
|
||||
return (s.charCodeAt(i++) - 1) + (s.charCodeAt(i) - 1) * 127;
|
||||
}
|
||||
|
||||
var SEQ_SET_COLOR = 1;
|
||||
/** Decode three-byte number */
|
||||
function parse3B(s, i) {
|
||||
return (s.charCodeAt(i) - 1) + (s.charCodeAt(i+1) - 1) * 127 + (s.charCodeAt(i+2) - 1) * 127 * 127;
|
||||
}
|
||||
|
||||
var SEQ_SET_COLOR_ATTR = 1;
|
||||
var SEQ_REPEAT = 2;
|
||||
var SEQ_SET_COLOR = 3;
|
||||
var SEQ_SET_ATTR = 4;
|
||||
|
||||
function _load_content(str) {
|
||||
var i = 0, ci = 0, j, jc, num, num2, t = ' ', fg, bg, bold, cell;
|
||||
var i = 0, ci = 0, j, jc, num, num2, t = ' ', fg, bg, attrs, cell;
|
||||
|
||||
if (!inited) _init();
|
||||
|
||||
@@ -170,25 +202,31 @@ var Screen = (function () {
|
||||
num = parse2B(str, i); i += 2; // fg bg bold hidden
|
||||
cursor.fg = num & 0x0F;
|
||||
cursor.bg = (num & 0xF0) >> 4;
|
||||
cursor.bold = !!(num & 0x100);
|
||||
cursor.hidden = !(num & 0x200);
|
||||
// console.log("FG ",cursor.fg, ", BG ", cursor.bg,", BOLD ", cursor.bold, ", HIDE ", cursor.hidden);
|
||||
cursor.hidden = !(num & 0x100);
|
||||
|
||||
fg = cursor.fg;
|
||||
bg = cursor.bg;
|
||||
bold = cursor.bold;
|
||||
attrs = 0;
|
||||
|
||||
// Here come the content
|
||||
while(i < str.length && ci<W*H) {
|
||||
|
||||
j = str[i++];
|
||||
jc = j.charCodeAt(0);
|
||||
if (jc == SEQ_SET_COLOR) {
|
||||
if (jc == SEQ_SET_COLOR_ATTR) {
|
||||
num = parse3B(str, i); i += 3;
|
||||
fg = num & 0x0F;
|
||||
bg = (num & 0xF0) >> 4;
|
||||
attrs = (num & 0xFF00)>>8;
|
||||
}
|
||||
else if (jc == SEQ_SET_COLOR) {
|
||||
num = parse2B(str, i); i += 2;
|
||||
fg = num & 0x0F;
|
||||
bg = (num & 0xF0) >> 4;
|
||||
bold = !!(num & 0x100);
|
||||
// console.log("Switch to ",fg,bg,bold);
|
||||
}
|
||||
else if (jc == SEQ_SET_ATTR) {
|
||||
num = parse2B(str, i); i += 2;
|
||||
attrs = num & 0xFF;
|
||||
}
|
||||
else if (jc == SEQ_REPEAT) {
|
||||
num = parse2B(str, i); i += 2;
|
||||
@@ -198,7 +236,7 @@ var Screen = (function () {
|
||||
cell.fg = fg;
|
||||
cell.bg = bg;
|
||||
cell.t = t;
|
||||
cell.bold = bold;
|
||||
cell.attrs = attrs;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -207,7 +245,7 @@ var Screen = (function () {
|
||||
t = cell.t = j;
|
||||
cell.fg = fg;
|
||||
cell.bg = bg;
|
||||
cell.bold = bold;
|
||||
cell.attrs = attrs;
|
||||
// console.log("Symbol ", j);
|
||||
}
|
||||
}
|
||||
@@ -258,12 +296,14 @@ var Conn = (function() {
|
||||
console.warn("SOCKET CLOSED, code "+evt.code+". Reconnecting...");
|
||||
setTimeout(function() {
|
||||
init();
|
||||
}, 1000);
|
||||
}, 200);
|
||||
// this happens when the buffer gets fucked up via invalid unicode.
|
||||
// we basically use polling instead of socket then
|
||||
}
|
||||
|
||||
function onMessage(evt) {
|
||||
try {
|
||||
console.log("RX: ", evt.data);
|
||||
//console.log("RX: ", evt.data);
|
||||
// Assume all our messages are screen updates
|
||||
Screen.load(evt.data);
|
||||
} catch(e) {
|
||||
@@ -323,31 +363,89 @@ var Input = (function() {
|
||||
Conn.send("BTN:"+n);
|
||||
}
|
||||
|
||||
function _initKeys() {
|
||||
// This takes care of text characters typed
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
var keymap = {
|
||||
'tab': '\x09',
|
||||
'backspace': '\x08',
|
||||
'enter': '\x0d',
|
||||
'ctrl+enter': '\x0a',
|
||||
'esc': '\x1b',
|
||||
'up': '\x1b[A',
|
||||
'down': '\x1b[B',
|
||||
'right': '\x1b[C',
|
||||
'left': '\x1b[D',
|
||||
'home': '\x1b[1~',
|
||||
'insert': '\x1b[2~',
|
||||
'delete': '\x1b[3~',
|
||||
'end': '\x1b[4~',
|
||||
'pageup': '\x1b[5~',
|
||||
'pagedown': '\x1b[6~',
|
||||
'f1': '\x1b[11~',
|
||||
'f2': '\x1b[12~',
|
||||
'f3': '\x1b[13~',
|
||||
'f4': '\x1b[14~',
|
||||
'f5': '\x1b[15~', // disconnect
|
||||
'f6': '\x1b[17~',
|
||||
'f7': '\x1b[18~',
|
||||
'f8': '\x1b[19~',
|
||||
'f9': '\x1b[20~',
|
||||
'f10': '\x1b[21~', // disconnect
|
||||
'f11': '\x1b[23~',
|
||||
'f12': '\x1b[24~',
|
||||
'shift+f1': '\x1b[25~',
|
||||
'shift+f2': '\x1b[26~', // disconnect
|
||||
'shift+f3': '\x1b[28~',
|
||||
'shift+f4': '\x1b[29~', // disconnect
|
||||
'shift+f5': '\x1b[31~',
|
||||
'shift+f6': '\x1b[32~',
|
||||
'shift+f7': '\x1b[33~',
|
||||
'shift+f8': '\x1b[34~',
|
||||
};
|
||||
|
||||
function bind(combo, str) {
|
||||
// mac fix - allow also cmd
|
||||
if (combo.indexOf('ctrl+') !== -1) {
|
||||
combo += ',' + combo.replace('ctrl', 'command');
|
||||
}
|
||||
key(combo, function (e) {
|
||||
e.preventDefault();
|
||||
// console.log(combo);
|
||||
sendStrMsg(str)
|
||||
});
|
||||
}
|
||||
|
||||
for (var k in keymap) {
|
||||
if (keymap.hasOwnProperty(k)) {
|
||||
bind(k, keymap[k]);
|
||||
}
|
||||
}
|
||||
|
||||
// ctrl-letter codes are sent as simple low ASCII codes
|
||||
for (var i = 1; i<=26;i++) {
|
||||
bind('ctrl+' + String.fromCharCode(96+i), String.fromCharCode(i));
|
||||
}
|
||||
bind('ctrl+]', '\x1b'); // alternate way to enter ESC
|
||||
bind('ctrl+\\', '\x1c');
|
||||
bind('ctrl+[', '\x1d');
|
||||
bind('ctrl+^', '\x1e');
|
||||
bind('ctrl+_', '\x1f');
|
||||
}
|
||||
|
||||
function init() {
|
||||
window.addEventListener('keypress', function(e) {
|
||||
var code = +e.which;
|
||||
if (code >= 32 && code < 127) {
|
||||
var ch = String.fromCharCode(code);
|
||||
//console.log("Typed ", ch, "code", code, e);
|
||||
sendStrMsg(ch);
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('keydown', function(e) {
|
||||
var code = e.keyCode;
|
||||
//console.log("Down ", code, e);
|
||||
switch(code) {
|
||||
case 8: sendStrMsg('\x08'); break;
|
||||
case 10:
|
||||
case 13: sendStrMsg('\x0d\x0a'); break;
|
||||
case 27: sendStrMsg('\x1b'); break; // this allows to directly enter control sequences
|
||||
case 37: sendStrMsg('\x1b[D'); break;
|
||||
case 38: sendStrMsg('\x1b[A'); break;
|
||||
case 39: sendStrMsg('\x1b[C'); break;
|
||||
case 40: sendStrMsg('\x1b[B'); break;
|
||||
}
|
||||
});
|
||||
_initKeys();
|
||||
|
||||
// Button presses
|
||||
qsa('#buttons button').forEach(function(s) {
|
||||
s.addEventListener('click', function() {
|
||||
sendBtnMsg(+this.dataset['n']);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
echo "Packing js..."
|
||||
|
||||
cat jssrc/chibi.js \
|
||||
jssrc/keymaster.js \
|
||||
jssrc/utils.js \
|
||||
jssrc/modal.js \
|
||||
jssrc/notif.js \
|
||||
|
||||
@@ -86,11 +86,6 @@ body.term {
|
||||
top: -9999px;
|
||||
}
|
||||
|
||||
// "non-bold"
|
||||
.nb {
|
||||
font-weight: normal !important;
|
||||
}
|
||||
|
||||
// Tango
|
||||
.theme-0 {
|
||||
$term-colors:
|
||||
@@ -163,10 +158,36 @@ body.term {
|
||||
}
|
||||
}
|
||||
|
||||
// Attributes
|
||||
.bold {
|
||||
font-weight: bold !important;
|
||||
}
|
||||
|
||||
.faint span { // content of faint is wrapped in span
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.under {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.strike {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.underline.strike {
|
||||
text-decoration: underline line-through;
|
||||
}
|
||||
|
||||
.blink-hide .blink {
|
||||
color: transparent;
|
||||
}
|
||||
//
|
||||
|
||||
.Row.color-preview {
|
||||
font-family: monospace;
|
||||
font-size: 16pt;
|
||||
|
||||
+343
-256
@@ -11,26 +11,27 @@ static const char _ansi_actions[] = {
|
||||
0, 1, 0, 1, 1, 1, 2, 1,
|
||||
3, 1, 4, 1, 5, 1, 6, 1,
|
||||
7, 1, 8, 1, 9, 1, 10, 1,
|
||||
11, 1, 12, 1, 13, 1, 14, 2,
|
||||
2, 5, 2, 10, 11, 2, 10, 12
|
||||
|
||||
11, 1, 12, 1, 13, 1, 14, 1,
|
||||
15, 1, 16, 1, 17, 2, 2, 5,
|
||||
2, 10, 11, 2, 10, 12
|
||||
};
|
||||
|
||||
static const char _ansi_eof_actions[] = {
|
||||
0, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 0, 0, 0, 0,
|
||||
0, 0, 0, 0
|
||||
13, 13, 13, 13, 13, 13, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const int ansi_start = 1;
|
||||
static const int ansi_first_final = 28;
|
||||
static const int ansi_first_final = 30;
|
||||
static const int ansi_error = 0;
|
||||
|
||||
static const int ansi_en_CSI_body = 4;
|
||||
static const int ansi_en_OSC_body = 6;
|
||||
static const int ansi_en_TITLE_body = 26;
|
||||
static const int ansi_en_CSI_body = 5;
|
||||
static const int ansi_en_OSC_body = 7;
|
||||
static const int ansi_en_TITLE_body = 27;
|
||||
static const int ansi_en_charsetcmd_body = 29;
|
||||
static const int ansi_en_main = 1;
|
||||
|
||||
|
||||
@@ -39,16 +40,45 @@ static const int ansi_en_main = 1;
|
||||
|
||||
static volatile int cs = -1;
|
||||
|
||||
static ETSTimer resetTim;
|
||||
volatile u32 ansi_parser_char_cnt = 0;
|
||||
|
||||
static void ICACHE_FLASH_ATTR
|
||||
resetParserCb(void *arg) {
|
||||
void ICACHE_FLASH_ATTR
|
||||
ansi_parser_reset(void) {
|
||||
if (cs != ansi_start) {
|
||||
cs = ansi_start;
|
||||
warn("Parser timeout, state reset");
|
||||
apars_reset_utf8buffer();
|
||||
ansi_warn("Parser timeout, state reset");
|
||||
}
|
||||
}
|
||||
|
||||
#define HISTORY_LEN 16
|
||||
|
||||
#if DEBUG_ANSI
|
||||
static char history[HISTORY_LEN + 1];
|
||||
#endif
|
||||
|
||||
void ICACHE_FLASH_ATTR
|
||||
apars_handle_badseq(void)
|
||||
{
|
||||
#if DEBUG_ANSI
|
||||
char buf1[HISTORY_LEN*3+2];
|
||||
char buf2[HISTORY_LEN*3+2];
|
||||
char *b1 = buf1;
|
||||
char *b2 = buf2;
|
||||
char c;
|
||||
|
||||
for(int i=0;i<HISTORY_LEN;i++) {
|
||||
c = history[i];
|
||||
b1 += sprintf(b1, "%2X ", c);
|
||||
if (c < 32 || c > 127) c = '.';
|
||||
b2 += sprintf(b2, "%c ", c);
|
||||
}
|
||||
|
||||
ansi_dbg("Context: %s", buf2);
|
||||
ansi_dbg(" %s", buf1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Linear ANSI chars stream parser
|
||||
*
|
||||
@@ -68,11 +98,14 @@ ansi_parser(const char *newdata, size_t len)
|
||||
// The CSI code is built here
|
||||
static char csi_leading; //!< Leading char, 0 if none
|
||||
static int csi_ni; //!< Number of the active digit
|
||||
static int csi_cnt; //!< Digit count
|
||||
static int csi_n[CSI_N_MAX]; //!< Param digits
|
||||
static char csi_char; //!< CSI action char (end)
|
||||
static char osc_buffer[OSC_CHAR_MAX];
|
||||
static int osc_bi;
|
||||
|
||||
ansi_parser_char_cnt++;
|
||||
|
||||
if (len == 0) len = strlen(newdata);
|
||||
|
||||
// Load new data to Ragel vars
|
||||
@@ -83,24 +116,28 @@ ansi_parser(const char *newdata, size_t len)
|
||||
// Init Ragel on the first run
|
||||
if (cs == -1) {
|
||||
|
||||
/* #line 87 "user/ansi_parser.c" */
|
||||
/* #line 120 "user/ansi_parser.c" */
|
||||
{
|
||||
cs = ansi_start;
|
||||
}
|
||||
|
||||
/* #line 57 "user/ansi_parser.rl" */
|
||||
/* #line 89 "user/ansi_parser.rl" */
|
||||
|
||||
#if DEBUG_ANSI
|
||||
memset(history, 0, sizeof(history));
|
||||
#endif
|
||||
}
|
||||
|
||||
// schedule state reset
|
||||
if (termconf->parser_tout_ms > 0) {
|
||||
os_timer_disarm(&resetTim);
|
||||
os_timer_setfn(&resetTim, resetParserCb, NULL);
|
||||
os_timer_arm(&resetTim, termconf->parser_tout_ms, 0);
|
||||
#if DEBUG_ANSI
|
||||
for(int i=len; i<HISTORY_LEN; i++) {
|
||||
history[i-len] = history[i];
|
||||
}
|
||||
strcpy(&history[HISTORY_LEN-len], newdata);
|
||||
#endif
|
||||
|
||||
// The parser
|
||||
|
||||
/* #line 104 "user/ansi_parser.c" */
|
||||
/* #line 141 "user/ansi_parser.c" */
|
||||
{
|
||||
const char *_acts;
|
||||
unsigned int _nacts;
|
||||
@@ -117,201 +154,216 @@ case 1:
|
||||
goto tr0;
|
||||
case 2:
|
||||
switch( (*p) ) {
|
||||
case 35: goto tr3;
|
||||
case 91: goto tr5;
|
||||
case 93: goto tr6;
|
||||
case 107: goto tr7;
|
||||
}
|
||||
if ( (*p) < 65 ) {
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr4;
|
||||
} else if ( (*p) > 90 ) {
|
||||
if ( 97 <= (*p) && (*p) <= 122 )
|
||||
goto tr4;
|
||||
} else
|
||||
goto tr4;
|
||||
goto tr2;
|
||||
case 0:
|
||||
goto _out;
|
||||
case 3:
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr8;
|
||||
goto tr2;
|
||||
case 28:
|
||||
if ( (*p) == 27 )
|
||||
goto tr1;
|
||||
goto tr0;
|
||||
case 4:
|
||||
switch( (*p) ) {
|
||||
case 59: goto tr11;
|
||||
case 64: goto tr12;
|
||||
case 32: goto tr3;
|
||||
case 35: goto tr4;
|
||||
case 91: goto tr7;
|
||||
case 93: goto tr8;
|
||||
case 107: goto tr9;
|
||||
}
|
||||
if ( (*p) < 60 ) {
|
||||
if ( (*p) > 47 ) {
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr10;
|
||||
goto tr6;
|
||||
} else if ( (*p) >= 40 )
|
||||
goto tr5;
|
||||
} else if ( (*p) > 62 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 97 <= (*p) && (*p) <= 122 )
|
||||
goto tr6;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto tr6;
|
||||
} else
|
||||
goto tr6;
|
||||
goto tr2;
|
||||
case 0:
|
||||
goto _out;
|
||||
case 3:
|
||||
if ( 70 <= (*p) && (*p) <= 71 )
|
||||
goto tr10;
|
||||
goto tr2;
|
||||
case 30:
|
||||
if ( (*p) == 27 )
|
||||
goto tr1;
|
||||
goto tr0;
|
||||
case 4:
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr11;
|
||||
goto tr2;
|
||||
case 5:
|
||||
switch( (*p) ) {
|
||||
case 59: goto tr14;
|
||||
case 64: goto tr15;
|
||||
}
|
||||
if ( (*p) < 60 ) {
|
||||
if ( (*p) > 47 ) {
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr13;
|
||||
} else if ( (*p) >= 32 )
|
||||
goto tr9;
|
||||
goto tr12;
|
||||
} else if ( (*p) > 63 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 96 <= (*p) && (*p) <= 122 )
|
||||
goto tr13;
|
||||
goto tr16;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto tr13;
|
||||
goto tr16;
|
||||
} else
|
||||
goto tr9;
|
||||
goto tr2;
|
||||
case 5:
|
||||
if ( (*p) == 59 )
|
||||
goto tr11;
|
||||
if ( (*p) < 64 ) {
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr10;
|
||||
} else if ( (*p) > 90 ) {
|
||||
if ( 96 <= (*p) && (*p) <= 122 )
|
||||
goto tr13;
|
||||
} else
|
||||
goto tr13;
|
||||
goto tr2;
|
||||
case 29:
|
||||
goto tr2;
|
||||
case 30:
|
||||
if ( (*p) == 59 )
|
||||
goto tr11;
|
||||
if ( (*p) < 64 ) {
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr10;
|
||||
} else if ( (*p) > 90 ) {
|
||||
if ( 96 <= (*p) && (*p) <= 122 )
|
||||
goto tr13;
|
||||
} else
|
||||
goto tr13;
|
||||
goto tr12;
|
||||
goto tr2;
|
||||
case 6:
|
||||
switch( (*p) ) {
|
||||
case 48: goto tr14;
|
||||
case 66: goto tr15;
|
||||
case 84: goto tr16;
|
||||
case 87: goto tr17;
|
||||
}
|
||||
goto tr2;
|
||||
case 7:
|
||||
if ( (*p) == 59 )
|
||||
goto tr18;
|
||||
goto tr14;
|
||||
if ( (*p) < 64 ) {
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr13;
|
||||
} else if ( (*p) > 90 ) {
|
||||
if ( 96 <= (*p) && (*p) <= 122 )
|
||||
goto tr16;
|
||||
} else
|
||||
goto tr16;
|
||||
goto tr2;
|
||||
case 8:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr20;
|
||||
case 27: goto tr21;
|
||||
}
|
||||
goto tr19;
|
||||
case 31:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr20;
|
||||
case 27: goto tr21;
|
||||
}
|
||||
goto tr19;
|
||||
case 9:
|
||||
if ( (*p) == 92 )
|
||||
goto tr22;
|
||||
goto tr2;
|
||||
case 32:
|
||||
if ( (*p) == 59 )
|
||||
goto tr14;
|
||||
if ( (*p) < 64 ) {
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr13;
|
||||
} else if ( (*p) > 90 ) {
|
||||
if ( 96 <= (*p) && (*p) <= 122 )
|
||||
goto tr16;
|
||||
} else
|
||||
goto tr16;
|
||||
goto tr2;
|
||||
case 10:
|
||||
if ( (*p) == 84 )
|
||||
goto tr23;
|
||||
goto tr2;
|
||||
case 11:
|
||||
if ( (*p) == 78 )
|
||||
goto tr24;
|
||||
goto tr2;
|
||||
case 12:
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr25;
|
||||
goto tr2;
|
||||
case 13:
|
||||
if ( (*p) == 61 )
|
||||
goto tr26;
|
||||
goto tr2;
|
||||
case 14:
|
||||
case 7:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr28;
|
||||
case 27: goto tr29;
|
||||
case 48: goto tr17;
|
||||
case 66: goto tr18;
|
||||
case 84: goto tr19;
|
||||
case 87: goto tr20;
|
||||
}
|
||||
goto tr27;
|
||||
goto tr2;
|
||||
case 8:
|
||||
if ( (*p) == 59 )
|
||||
goto tr21;
|
||||
goto tr2;
|
||||
case 9:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr23;
|
||||
case 27: goto tr24;
|
||||
}
|
||||
goto tr22;
|
||||
case 33:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr28;
|
||||
case 27: goto tr29;
|
||||
case 7: goto tr23;
|
||||
case 27: goto tr24;
|
||||
}
|
||||
goto tr27;
|
||||
case 15:
|
||||
goto tr22;
|
||||
case 10:
|
||||
if ( (*p) == 92 )
|
||||
goto tr30;
|
||||
goto tr25;
|
||||
goto tr2;
|
||||
case 16:
|
||||
if ( (*p) == 73 )
|
||||
goto tr31;
|
||||
case 34:
|
||||
goto tr2;
|
||||
case 17:
|
||||
case 11:
|
||||
if ( (*p) == 84 )
|
||||
goto tr32;
|
||||
goto tr26;
|
||||
goto tr2;
|
||||
case 18:
|
||||
if ( (*p) == 76 )
|
||||
case 12:
|
||||
if ( (*p) == 78 )
|
||||
goto tr27;
|
||||
goto tr2;
|
||||
case 13:
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr28;
|
||||
goto tr2;
|
||||
case 14:
|
||||
if ( (*p) == 61 )
|
||||
goto tr29;
|
||||
goto tr2;
|
||||
case 15:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr31;
|
||||
case 27: goto tr32;
|
||||
}
|
||||
goto tr30;
|
||||
case 35:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr31;
|
||||
case 27: goto tr32;
|
||||
}
|
||||
goto tr30;
|
||||
case 16:
|
||||
if ( (*p) == 92 )
|
||||
goto tr33;
|
||||
goto tr2;
|
||||
case 19:
|
||||
if ( (*p) == 69 )
|
||||
case 17:
|
||||
if ( (*p) == 73 )
|
||||
goto tr34;
|
||||
goto tr2;
|
||||
case 20:
|
||||
if ( (*p) == 61 )
|
||||
case 18:
|
||||
if ( (*p) == 84 )
|
||||
goto tr35;
|
||||
goto tr2;
|
||||
case 21:
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
case 19:
|
||||
if ( (*p) == 76 )
|
||||
goto tr36;
|
||||
goto tr2;
|
||||
case 20:
|
||||
if ( (*p) == 69 )
|
||||
goto tr37;
|
||||
goto tr2;
|
||||
case 21:
|
||||
if ( (*p) == 61 )
|
||||
goto tr38;
|
||||
goto tr2;
|
||||
case 22:
|
||||
if ( (*p) == 59 )
|
||||
goto tr37;
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr36;
|
||||
goto tr2;
|
||||
case 23:
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr38;
|
||||
goto tr2;
|
||||
case 24:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr39;
|
||||
case 27: goto tr40;
|
||||
}
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr38;
|
||||
goto tr2;
|
||||
case 25:
|
||||
if ( (*p) == 92 )
|
||||
goto tr39;
|
||||
goto tr2;
|
||||
case 26:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr42;
|
||||
case 27: goto tr43;
|
||||
}
|
||||
goto tr41;
|
||||
case 34:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr42;
|
||||
case 27: goto tr43;
|
||||
}
|
||||
goto tr41;
|
||||
case 27:
|
||||
if ( (*p) == 92 )
|
||||
goto tr44;
|
||||
case 23:
|
||||
if ( (*p) == 59 )
|
||||
goto tr40;
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr39;
|
||||
goto tr2;
|
||||
case 35:
|
||||
case 24:
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr41;
|
||||
goto tr2;
|
||||
case 25:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr42;
|
||||
case 27: goto tr43;
|
||||
}
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr41;
|
||||
goto tr2;
|
||||
case 26:
|
||||
if ( (*p) == 92 )
|
||||
goto tr42;
|
||||
goto tr2;
|
||||
case 27:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr45;
|
||||
case 27: goto tr46;
|
||||
}
|
||||
goto tr44;
|
||||
case 36:
|
||||
switch( (*p) ) {
|
||||
case 7: goto tr45;
|
||||
case 27: goto tr46;
|
||||
}
|
||||
goto tr44;
|
||||
case 28:
|
||||
if ( (*p) == 92 )
|
||||
goto tr47;
|
||||
goto tr2;
|
||||
case 37:
|
||||
goto tr2;
|
||||
case 29:
|
||||
goto tr48;
|
||||
case 38:
|
||||
goto tr2;
|
||||
}
|
||||
|
||||
@@ -319,101 +371,112 @@ case 35:
|
||||
tr0: cs = 1; goto f1;
|
||||
tr1: cs = 2; goto _again;
|
||||
tr3: cs = 3; goto _again;
|
||||
tr9: cs = 5; goto f7;
|
||||
tr10: cs = 5; goto f8;
|
||||
tr11: cs = 5; goto f9;
|
||||
tr14: cs = 7; goto _again;
|
||||
tr18: cs = 8; goto _again;
|
||||
tr19: cs = 8; goto f12;
|
||||
tr4: cs = 4; goto _again;
|
||||
tr12: cs = 6; goto f9;
|
||||
tr13: cs = 6; goto f10;
|
||||
tr14: cs = 6; goto f11;
|
||||
tr17: cs = 8; goto _again;
|
||||
tr21: cs = 9; goto _again;
|
||||
tr15: cs = 10; goto _again;
|
||||
tr23: cs = 11; goto _again;
|
||||
tr24: cs = 12; goto _again;
|
||||
tr25: cs = 13; goto f8;
|
||||
tr26: cs = 14; goto _again;
|
||||
tr27: cs = 14; goto f12;
|
||||
tr22: cs = 9; goto f14;
|
||||
tr24: cs = 10; goto _again;
|
||||
tr18: cs = 11; goto _again;
|
||||
tr26: cs = 12; goto _again;
|
||||
tr27: cs = 13; goto _again;
|
||||
tr28: cs = 14; goto f10;
|
||||
tr29: cs = 15; goto _again;
|
||||
tr16: cs = 16; goto _again;
|
||||
tr31: cs = 17; goto _again;
|
||||
tr32: cs = 18; goto _again;
|
||||
tr33: cs = 19; goto _again;
|
||||
tr34: cs = 20; goto _again;
|
||||
tr17: cs = 21; goto _again;
|
||||
tr36: cs = 22; goto f8;
|
||||
tr37: cs = 23; goto f9;
|
||||
tr38: cs = 24; goto f8;
|
||||
tr40: cs = 25; goto _again;
|
||||
tr41: cs = 26; goto f12;
|
||||
tr43: cs = 27; goto _again;
|
||||
tr4: cs = 28; goto f2;
|
||||
tr5: cs = 28; goto f3;
|
||||
tr6: cs = 28; goto f4;
|
||||
tr7: cs = 28; goto f5;
|
||||
tr8: cs = 28; goto f6;
|
||||
tr13: cs = 29; goto f11;
|
||||
tr12: cs = 30; goto f10;
|
||||
tr20: cs = 31; goto f13;
|
||||
tr35: cs = 32; goto f5;
|
||||
tr22: cs = 32; goto f14;
|
||||
tr30: cs = 32; goto f16;
|
||||
tr39: cs = 32; goto f17;
|
||||
tr28: cs = 33; goto f15;
|
||||
tr42: cs = 34; goto f13;
|
||||
tr44: cs = 35; goto f14;
|
||||
tr30: cs = 15; goto f14;
|
||||
tr32: cs = 16; goto _again;
|
||||
tr19: cs = 17; goto _again;
|
||||
tr34: cs = 18; goto _again;
|
||||
tr35: cs = 19; goto _again;
|
||||
tr36: cs = 20; goto _again;
|
||||
tr37: cs = 21; goto _again;
|
||||
tr20: cs = 22; goto _again;
|
||||
tr39: cs = 23; goto f10;
|
||||
tr40: cs = 24; goto f11;
|
||||
tr41: cs = 25; goto f10;
|
||||
tr43: cs = 26; goto _again;
|
||||
tr44: cs = 27; goto f14;
|
||||
tr46: cs = 28; goto _again;
|
||||
tr5: cs = 30; goto f2;
|
||||
tr6: cs = 30; goto f3;
|
||||
tr7: cs = 30; goto f4;
|
||||
tr8: cs = 30; goto f5;
|
||||
tr9: cs = 30; goto f6;
|
||||
tr10: cs = 30; goto f7;
|
||||
tr11: cs = 30; goto f8;
|
||||
tr16: cs = 31; goto f13;
|
||||
tr15: cs = 32; goto f12;
|
||||
tr23: cs = 33; goto f15;
|
||||
tr38: cs = 34; goto f6;
|
||||
tr25: cs = 34; goto f16;
|
||||
tr33: cs = 34; goto f18;
|
||||
tr42: cs = 34; goto f19;
|
||||
tr31: cs = 35; goto f17;
|
||||
tr45: cs = 36; goto f15;
|
||||
tr47: cs = 37; goto f16;
|
||||
tr48: cs = 38; goto f20;
|
||||
|
||||
f1: _acts = _ansi_actions + 1; goto execFuncs;
|
||||
f3: _acts = _ansi_actions + 3; goto execFuncs;
|
||||
f7: _acts = _ansi_actions + 5; goto execFuncs;
|
||||
f8: _acts = _ansi_actions + 7; goto execFuncs;
|
||||
f9: _acts = _ansi_actions + 9; goto execFuncs;
|
||||
f11: _acts = _ansi_actions + 11; goto execFuncs;
|
||||
f4: _acts = _ansi_actions + 3; goto execFuncs;
|
||||
f9: _acts = _ansi_actions + 5; goto execFuncs;
|
||||
f10: _acts = _ansi_actions + 7; goto execFuncs;
|
||||
f11: _acts = _ansi_actions + 9; goto execFuncs;
|
||||
f13: _acts = _ansi_actions + 11; goto execFuncs;
|
||||
f0: _acts = _ansi_actions + 13; goto execFuncs;
|
||||
f4: _acts = _ansi_actions + 15; goto execFuncs;
|
||||
f5: _acts = _ansi_actions + 17; goto execFuncs;
|
||||
f17: _acts = _ansi_actions + 19; goto execFuncs;
|
||||
f12: _acts = _ansi_actions + 21; goto execFuncs;
|
||||
f14: _acts = _ansi_actions + 23; goto execFuncs;
|
||||
f16: _acts = _ansi_actions + 25; goto execFuncs;
|
||||
f6: _acts = _ansi_actions + 27; goto execFuncs;
|
||||
f2: _acts = _ansi_actions + 29; goto execFuncs;
|
||||
f10: _acts = _ansi_actions + 31; goto execFuncs;
|
||||
f13: _acts = _ansi_actions + 34; goto execFuncs;
|
||||
f15: _acts = _ansi_actions + 37; goto execFuncs;
|
||||
f5: _acts = _ansi_actions + 15; goto execFuncs;
|
||||
f6: _acts = _ansi_actions + 17; goto execFuncs;
|
||||
f19: _acts = _ansi_actions + 19; goto execFuncs;
|
||||
f14: _acts = _ansi_actions + 21; goto execFuncs;
|
||||
f16: _acts = _ansi_actions + 23; goto execFuncs;
|
||||
f18: _acts = _ansi_actions + 25; goto execFuncs;
|
||||
f8: _acts = _ansi_actions + 27; goto execFuncs;
|
||||
f3: _acts = _ansi_actions + 29; goto execFuncs;
|
||||
f7: _acts = _ansi_actions + 31; goto execFuncs;
|
||||
f2: _acts = _ansi_actions + 33; goto execFuncs;
|
||||
f20: _acts = _ansi_actions + 35; goto execFuncs;
|
||||
f12: _acts = _ansi_actions + 37; goto execFuncs;
|
||||
f15: _acts = _ansi_actions + 40; goto execFuncs;
|
||||
f17: _acts = _ansi_actions + 43; goto execFuncs;
|
||||
|
||||
execFuncs:
|
||||
_nacts = *_acts++;
|
||||
while ( _nacts-- > 0 ) {
|
||||
switch ( *_acts++ ) {
|
||||
case 0:
|
||||
/* #line 76 "user/ansi_parser.rl" */
|
||||
/* #line 112 "user/ansi_parser.rl" */
|
||||
{
|
||||
apars_handle_plainchar((*p));
|
||||
if ((*p) != 0) {
|
||||
apars_handle_plainchar((*p));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* #line 83 "user/ansi_parser.rl" */
|
||||
/* #line 121 "user/ansi_parser.rl" */
|
||||
{
|
||||
// Reset the CSI builder
|
||||
csi_leading = csi_char = 0;
|
||||
csi_ni = 0;
|
||||
csi_cnt = 0;
|
||||
|
||||
// Zero out digits
|
||||
for(int i = 0; i < CSI_N_MAX; i++) {
|
||||
csi_n[i] = 0;
|
||||
}
|
||||
|
||||
{cs = 4;goto _again;}
|
||||
{cs = 5;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
/* #line 96 "user/ansi_parser.rl" */
|
||||
/* #line 135 "user/ansi_parser.rl" */
|
||||
{
|
||||
csi_leading = (*p);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
/* #line 100 "user/ansi_parser.rl" */
|
||||
/* #line 139 "user/ansi_parser.rl" */
|
||||
{
|
||||
if (csi_cnt == 0) csi_cnt = 1;
|
||||
// x10 + digit
|
||||
if (csi_ni < CSI_N_MAX) {
|
||||
csi_n[csi_ni] = csi_n[csi_ni]*10 + ((*p) - '0');
|
||||
@@ -421,30 +484,31 @@ execFuncs:
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
/* #line 107 "user/ansi_parser.rl" */
|
||||
/* #line 147 "user/ansi_parser.rl" */
|
||||
{
|
||||
if (csi_cnt == 0) csi_cnt = 1; // handle case when first arg is empty
|
||||
csi_cnt++;
|
||||
csi_ni++;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
/* #line 111 "user/ansi_parser.rl" */
|
||||
/* #line 153 "user/ansi_parser.rl" */
|
||||
{
|
||||
csi_char = (*p);
|
||||
|
||||
apars_handle_CSI(csi_leading, csi_n, csi_char);
|
||||
|
||||
apars_handle_CSI(csi_leading, csi_n, csi_cnt, csi_char);
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
/* #line 119 "user/ansi_parser.rl" */
|
||||
/* #line 159 "user/ansi_parser.rl" */
|
||||
{
|
||||
ansi_warn("Invalid escape sequence discarded.");
|
||||
apars_handle_badseq();
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
/* #line 136 "user/ansi_parser.rl" */
|
||||
/* #line 177 "user/ansi_parser.rl" */
|
||||
{
|
||||
csi_ni = 0;
|
||||
|
||||
@@ -456,32 +520,32 @@ execFuncs:
|
||||
osc_bi = 0;
|
||||
osc_buffer[0] = '\0';
|
||||
|
||||
{cs = 6;goto _again;}
|
||||
{cs = 7;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
/* #line 151 "user/ansi_parser.rl" */
|
||||
/* #line 192 "user/ansi_parser.rl" */
|
||||
{
|
||||
osc_bi = 0;
|
||||
osc_buffer[0] = '\0';
|
||||
{cs = 26;goto _again;}
|
||||
{cs = 27;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
/* #line 157 "user/ansi_parser.rl" */
|
||||
/* #line 198 "user/ansi_parser.rl" */
|
||||
{
|
||||
apars_handle_OSC_SetScreenSize(csi_n[0], csi_n[1]);
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
/* #line 162 "user/ansi_parser.rl" */
|
||||
/* #line 203 "user/ansi_parser.rl" */
|
||||
{
|
||||
osc_buffer[osc_bi++] = (*p);
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
/* #line 166 "user/ansi_parser.rl" */
|
||||
/* #line 207 "user/ansi_parser.rl" */
|
||||
{
|
||||
osc_buffer[osc_bi++] = '\0';
|
||||
apars_handle_OSC_SetTitle(osc_buffer);
|
||||
@@ -489,7 +553,7 @@ execFuncs:
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
/* #line 172 "user/ansi_parser.rl" */
|
||||
/* #line 213 "user/ansi_parser.rl" */
|
||||
{
|
||||
osc_buffer[osc_bi++] = '\0';
|
||||
apars_handle_OSC_SetButton(csi_n[0], osc_buffer);
|
||||
@@ -497,20 +561,42 @@ execFuncs:
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
/* #line 204 "user/ansi_parser.rl" */
|
||||
/* #line 245 "user/ansi_parser.rl" */
|
||||
{
|
||||
apars_handle_hashCode((*p));
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
/* #line 209 "user/ansi_parser.rl" */
|
||||
/* #line 250 "user/ansi_parser.rl" */
|
||||
{
|
||||
apars_handle_shortCode((*p));
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
/* #line 514 "user/ansi_parser.c" */
|
||||
case 15:
|
||||
/* #line 255 "user/ansi_parser.rl" */
|
||||
{
|
||||
apars_handle_setXCtrls((*p));
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
/* #line 260 "user/ansi_parser.rl" */
|
||||
{
|
||||
// abuse the buffer for storing the leading char
|
||||
osc_buffer[0] = (*p);
|
||||
{cs = 29;goto _again;}
|
||||
}
|
||||
break;
|
||||
case 17:
|
||||
/* #line 266 "user/ansi_parser.rl" */
|
||||
{
|
||||
apars_handle_characterSet(osc_buffer[0], (*p));
|
||||
{cs = 1;goto _again;}
|
||||
}
|
||||
break;
|
||||
/* #line 600 "user/ansi_parser.c" */
|
||||
}
|
||||
}
|
||||
goto _again;
|
||||
@@ -528,15 +614,16 @@ _again:
|
||||
while ( __nacts-- > 0 ) {
|
||||
switch ( *__acts++ ) {
|
||||
case 6:
|
||||
/* #line 119 "user/ansi_parser.rl" */
|
||||
/* #line 159 "user/ansi_parser.rl" */
|
||||
{
|
||||
ansi_warn("Invalid escape sequence discarded.");
|
||||
apars_handle_badseq();
|
||||
{cs = 1; if ( p == pe )
|
||||
goto _test_eof;
|
||||
goto _again;}
|
||||
}
|
||||
break;
|
||||
/* #line 540 "user/ansi_parser.c" */
|
||||
/* #line 627 "user/ansi_parser.c" */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -544,7 +631,7 @@ goto _again;}
|
||||
_out: {}
|
||||
}
|
||||
|
||||
/* #line 229 "user/ansi_parser.rl" */
|
||||
/* #line 290 "user/ansi_parser.rl" */
|
||||
|
||||
}
|
||||
|
||||
|
||||
+22
-3
@@ -5,17 +5,33 @@
|
||||
#include <screen.h>
|
||||
|
||||
// Max nr of CSI parameters
|
||||
#define CSI_N_MAX 3
|
||||
#define CSI_N_MAX 10
|
||||
#define OSC_CHAR_MAX TERM_TITLE_LEN
|
||||
|
||||
extern void apars_handle_badseq(void);
|
||||
extern void apars_handle_plainchar(char c);
|
||||
extern void apars_handle_CSI(char leadchar, int *params, char keychar);
|
||||
extern void apars_handle_CSI(char leadchar, int *params, int count, char keychar);
|
||||
extern void apars_handle_OSC_SetScreenSize(int rows, int cols);
|
||||
extern void apars_handle_OSC_SetButton(int num, const char *buffer);
|
||||
extern void apars_handle_OSC_SetTitle(const char *buffer);
|
||||
extern void apars_handle_shortCode(char c);
|
||||
extern void apars_handle_hashCode(char c);
|
||||
extern void apars_handle_characterSet(char leadchar, char c);
|
||||
extern void apars_handle_setXCtrls(char c);
|
||||
extern void apars_reset_utf8buffer(void);
|
||||
|
||||
void ansi_parser_reset(void);
|
||||
|
||||
extern volatile u32 ansi_parser_char_cnt;
|
||||
|
||||
// defined in the makefile
|
||||
#if DEBUG_ANSI
|
||||
#define ansi_warn warn
|
||||
#define ansi_dbg dbg
|
||||
#else
|
||||
#define ansi_warn(...)
|
||||
#define ansi_dbg(...)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Linear ANSI chars stream parser
|
||||
@@ -32,4 +48,7 @@ extern void apars_handle_hashCode(char c);
|
||||
*/
|
||||
void ansi_parser(const char *newdata, size_t len);
|
||||
|
||||
/** This shows a short error message and prints the history (if any) */
|
||||
void apars_handle_badseq(void);
|
||||
|
||||
#endif // ANSI_PARSER_H
|
||||
|
||||
+75
-14
@@ -10,16 +10,45 @@
|
||||
|
||||
static volatile int cs = -1;
|
||||
|
||||
static ETSTimer resetTim;
|
||||
volatile u32 ansi_parser_char_cnt = 0;
|
||||
|
||||
static void ICACHE_FLASH_ATTR
|
||||
resetParserCb(void *arg) {
|
||||
void ICACHE_FLASH_ATTR
|
||||
ansi_parser_reset(void) {
|
||||
if (cs != ansi_start) {
|
||||
cs = ansi_start;
|
||||
warn("Parser timeout, state reset");
|
||||
apars_reset_utf8buffer();
|
||||
ansi_warn("Parser timeout, state reset");
|
||||
}
|
||||
}
|
||||
|
||||
#define HISTORY_LEN 16
|
||||
|
||||
#if DEBUG_ANSI
|
||||
static char history[HISTORY_LEN + 1];
|
||||
#endif
|
||||
|
||||
void ICACHE_FLASH_ATTR
|
||||
apars_handle_badseq(void)
|
||||
{
|
||||
#if DEBUG_ANSI
|
||||
char buf1[HISTORY_LEN*3+2];
|
||||
char buf2[HISTORY_LEN*3+2];
|
||||
char *b1 = buf1;
|
||||
char *b2 = buf2;
|
||||
char c;
|
||||
|
||||
for(int i=0;i<HISTORY_LEN;i++) {
|
||||
c = history[i];
|
||||
b1 += sprintf(b1, "%2X ", c);
|
||||
if (c < 32 || c > 127) c = '.';
|
||||
b2 += sprintf(b2, "%c ", c);
|
||||
}
|
||||
|
||||
ansi_dbg("Context: %s", buf2);
|
||||
ansi_dbg(" %s", buf1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Linear ANSI chars stream parser
|
||||
*
|
||||
@@ -39,11 +68,14 @@ ansi_parser(const char *newdata, size_t len)
|
||||
// The CSI code is built here
|
||||
static char csi_leading; //!< Leading char, 0 if none
|
||||
static int csi_ni; //!< Number of the active digit
|
||||
static int csi_cnt; //!< Digit count
|
||||
static int csi_n[CSI_N_MAX]; //!< Param digits
|
||||
static char csi_char; //!< CSI action char (end)
|
||||
static char osc_buffer[OSC_CHAR_MAX];
|
||||
static int osc_bi;
|
||||
|
||||
ansi_parser_char_cnt++;
|
||||
|
||||
if (len == 0) len = strlen(newdata);
|
||||
|
||||
// Load new data to Ragel vars
|
||||
@@ -54,14 +86,18 @@ ansi_parser(const char *newdata, size_t len)
|
||||
// Init Ragel on the first run
|
||||
if (cs == -1) {
|
||||
%% write init;
|
||||
|
||||
#if DEBUG_ANSI
|
||||
memset(history, 0, sizeof(history));
|
||||
#endif
|
||||
}
|
||||
|
||||
// schedule state reset
|
||||
if (termconf->parser_tout_ms > 0) {
|
||||
os_timer_disarm(&resetTim);
|
||||
os_timer_setfn(&resetTim, resetParserCb, NULL);
|
||||
os_timer_arm(&resetTim, termconf->parser_tout_ms, 0);
|
||||
#if DEBUG_ANSI
|
||||
for(int i=len; i<HISTORY_LEN; i++) {
|
||||
history[i-len] = history[i];
|
||||
}
|
||||
strcpy(&history[HISTORY_LEN-len], newdata);
|
||||
#endif
|
||||
|
||||
// The parser
|
||||
%%{
|
||||
@@ -74,7 +110,9 @@ ansi_parser(const char *newdata, size_t len)
|
||||
# --- Regular characters to be printed ---
|
||||
|
||||
action plain_char {
|
||||
apars_handle_plainchar(fc);
|
||||
if (fc != 0) {
|
||||
apars_handle_plainchar(fc);
|
||||
}
|
||||
}
|
||||
|
||||
# --- CSI CSI commands (Select Graphic Rendition) ---
|
||||
@@ -84,6 +122,7 @@ ansi_parser(const char *newdata, size_t len)
|
||||
// Reset the CSI builder
|
||||
csi_leading = csi_char = 0;
|
||||
csi_ni = 0;
|
||||
csi_cnt = 0;
|
||||
|
||||
// Zero out digits
|
||||
for(int i = 0; i < CSI_N_MAX; i++) {
|
||||
@@ -98,6 +137,7 @@ ansi_parser(const char *newdata, size_t len)
|
||||
}
|
||||
|
||||
action CSI_digit {
|
||||
if (csi_cnt == 0) csi_cnt = 1;
|
||||
// x10 + digit
|
||||
if (csi_ni < CSI_N_MAX) {
|
||||
csi_n[csi_ni] = csi_n[csi_ni]*10 + (fc - '0');
|
||||
@@ -105,18 +145,19 @@ ansi_parser(const char *newdata, size_t len)
|
||||
}
|
||||
|
||||
action CSI_semi {
|
||||
if (csi_cnt == 0) csi_cnt = 1; // handle case when first arg is empty
|
||||
csi_cnt++;
|
||||
csi_ni++;
|
||||
}
|
||||
|
||||
action CSI_end {
|
||||
csi_char = fc;
|
||||
|
||||
apars_handle_CSI(csi_leading, csi_n, csi_char);
|
||||
|
||||
apars_handle_CSI(csi_leading, csi_n, csi_cnt, csi_char);
|
||||
fgoto main;
|
||||
}
|
||||
|
||||
action errBadSeq {
|
||||
ansi_warn("Invalid escape sequence discarded.");
|
||||
apars_handle_badseq();
|
||||
fgoto main;
|
||||
}
|
||||
@@ -211,6 +252,24 @@ ansi_parser(const char *newdata, size_t len)
|
||||
fgoto main;
|
||||
}
|
||||
|
||||
action SetXCtrls {
|
||||
apars_handle_setXCtrls(fc);
|
||||
fgoto main;
|
||||
}
|
||||
|
||||
action CharsetCmd_start {
|
||||
// abuse the buffer for storing the leading char
|
||||
osc_buffer[0] = fc;
|
||||
fgoto charsetcmd_body;
|
||||
}
|
||||
|
||||
action CharsetCmd_end {
|
||||
apars_handle_characterSet(osc_buffer[0], fc);
|
||||
fgoto main;
|
||||
}
|
||||
|
||||
charsetcmd_body := (any @CharsetCmd_end) $!errBadSeq;
|
||||
|
||||
# --- Main parser loop ---
|
||||
|
||||
main :=
|
||||
@@ -220,7 +279,9 @@ ansi_parser(const char *newdata, size_t len)
|
||||
(']' @OSC_start) |
|
||||
('#' digit @HASH_code) |
|
||||
('k' @SetTitle_start) |
|
||||
([a-jl-zA-Z0-9] @SHORT_code)
|
||||
([a-jl-zA-Z0-9=<>] @SHORT_code) |
|
||||
([()*+-./] @CharsetCmd_start) |
|
||||
(' ' [FG] @SetXCtrls)
|
||||
)
|
||||
)+ $!errBadSeq;
|
||||
|
||||
|
||||
+203
-56
@@ -22,9 +22,17 @@ static int utf_j = 0;
|
||||
void ICACHE_FLASH_ATTR
|
||||
apars_handle_plainchar(char c)
|
||||
{
|
||||
if (c == 7) return; // BELL - beep (TODO play beep in browser)
|
||||
|
||||
// collecting unicode glyphs...
|
||||
if (c & 0x80) {
|
||||
if (utf_i == 0) {
|
||||
// start
|
||||
if (c == 192 || c == 193 || c >= 245) {
|
||||
// forbidden codes
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((c & 0xE0) == 0xC0) {
|
||||
utf_i = 2;
|
||||
}
|
||||
@@ -34,33 +42,68 @@ apars_handle_plainchar(char c)
|
||||
else if ((c & 0xF8) == 0xF0) {
|
||||
utf_i = 4;
|
||||
}
|
||||
else {
|
||||
// chars over 127 that don't start unicode sequences
|
||||
goto fail;
|
||||
}
|
||||
|
||||
utf_collect[0] = c;
|
||||
utf_j = 1;
|
||||
}
|
||||
else {
|
||||
utf_collect[utf_j++] = c;
|
||||
if (utf_j >= utf_i) {
|
||||
screen_putchar(utf_collect);
|
||||
utf_i = 0;
|
||||
utf_j = 0;
|
||||
memset(utf_collect, 0, 4);
|
||||
if ((c & 0xC0) != 0x80) {
|
||||
goto fail;
|
||||
}
|
||||
else {
|
||||
utf_collect[utf_j++] = c;
|
||||
if (utf_j >= utf_i) {
|
||||
screen_putchar(utf_collect);
|
||||
apars_reset_utf8buffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (c == 14) {
|
||||
screen_set_charset_n(1);
|
||||
return;
|
||||
}
|
||||
if (c == 15) {
|
||||
screen_set_charset_n(0);
|
||||
return;
|
||||
}
|
||||
|
||||
utf_collect[0] = c;
|
||||
utf_collect[1] = 0; // just to make sure it's closed...
|
||||
screen_putchar(utf_collect);
|
||||
}
|
||||
|
||||
return;
|
||||
fail:
|
||||
ansi_warn("Bad UTF-8");
|
||||
apars_reset_utf8buffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bad sequence received, show warning
|
||||
*/
|
||||
void apars_handle_badseq(void)
|
||||
void ICACHE_FLASH_ATTR
|
||||
apars_reset_utf8buffer(void)
|
||||
{
|
||||
warn("Invalid escape sequence discarded.");
|
||||
utf_i = 0;
|
||||
utf_j = 0;
|
||||
memset(utf_collect, 0, 4);
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR
|
||||
apars_handle_characterSet(char leadchar, char c)
|
||||
{
|
||||
if (leadchar == '(') screen_set_charset(0, c);
|
||||
else if (leadchar == ')') screen_set_charset(1, c);
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR
|
||||
apars_handle_setXCtrls(char c)
|
||||
{
|
||||
// this does not seem to do anything, sent by some unix programs
|
||||
// ansi_warn("NOIMPL Select %cbit ctrls", c=='F'? '7':'8');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,37 +113,12 @@ void apars_handle_badseq(void)
|
||||
* \param keychar - the char terminating the sequence
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR
|
||||
apars_handle_CSI(char leadchar, int *params, char keychar)
|
||||
apars_handle_CSI(char leadchar, int *params, int count, char keychar)
|
||||
{
|
||||
/*
|
||||
Implemented codes (from Wikipedia)
|
||||
|
||||
CSI n A CUU – Cursor Up
|
||||
CSI n B CUD – Cursor Down
|
||||
CSI n C CUF – Cursor Forward
|
||||
CSI n D CUB – Cursor Back
|
||||
CSI n E CNL – Cursor Next Line
|
||||
CSI n F CPL – Cursor Previous Line
|
||||
CSI n G CHA – Cursor Horizontal Absolute
|
||||
CSI n ; m H CUP – Cursor Position
|
||||
CSI n J ED – Erase Display
|
||||
CSI n K EL – Erase in Line
|
||||
CSI n S SU – Scroll Up
|
||||
CSI n T SD – Scroll Down
|
||||
CSI n ; m f HVP – Horizontal and Vertical Position
|
||||
CSI n m SGR – Select Graphic Rendition (Implemented only some)
|
||||
CSI 6n DSR – Device Status Report
|
||||
CSI s SCP – Save Cursor Position
|
||||
CSI u RCP – Restore Cursor Position
|
||||
CSI ?25l DECTCEM Hides the cursor
|
||||
CSI ?25h DECTCEM Shows the cursor
|
||||
|
||||
and some others
|
||||
*/
|
||||
|
||||
int n1 = params[0];
|
||||
int n2 = params[1];
|
||||
// int n3 = params[2];
|
||||
int n3 = params[2];
|
||||
static char buf[20];
|
||||
|
||||
// defaults
|
||||
switch (keychar) {
|
||||
@@ -216,54 +234,118 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
||||
// Query device status - reply "Device is OK"
|
||||
UART_WriteString(UART0, "\033[0n", UART_TIMEOUT_US);
|
||||
}
|
||||
else {
|
||||
ansi_warn("NOIMPL query %d", n1);
|
||||
}
|
||||
break;
|
||||
|
||||
// DECTCEM feature enable / disable
|
||||
|
||||
case 'h': // feature enable
|
||||
if (leadchar == '?') {
|
||||
if (n1 == 25) {
|
||||
screen_cursor_enable(1);
|
||||
} else if (n1 == 7) {
|
||||
screen_wrap_enable(1);
|
||||
if (n1 == 25) screen_cursor_enable(1);
|
||||
else if (n1 == 7) screen_wrap_enable(1);
|
||||
else if (n1 == 1) {
|
||||
// TODO something with arrow keys??
|
||||
}
|
||||
else {
|
||||
ansi_warn("NOIMPL DEC opt %d", n1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (n1 == 4) {
|
||||
// TODO insert mode, i think this is to suppress user input
|
||||
}
|
||||
else {
|
||||
ansi_warn("NOIMPL flag %d", n1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'l': // feature disable
|
||||
if (leadchar == '?') {
|
||||
if (n1 == 25) {
|
||||
screen_cursor_enable(0);
|
||||
} else if (n1 == 7) {
|
||||
screen_wrap_enable(0);
|
||||
if (n1 == 25) screen_cursor_enable(0);
|
||||
else if (n1 == 7) screen_wrap_enable(0);
|
||||
else if (n1 == 1) {
|
||||
// TODO see above
|
||||
}
|
||||
else {
|
||||
ansi_warn("NOIMPL DEC opt %d", n1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (n1 == 4) {
|
||||
// TODO see above
|
||||
}
|
||||
else {
|
||||
ansi_warn("NOIMPL flag %d", n1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'm': // SGR - graphics rendition aka attributes
|
||||
if (count == 0) {
|
||||
count = 1; // this makes it work as 0 (reset)
|
||||
}
|
||||
|
||||
// iterate arguments
|
||||
for (int i = 0; i < CSI_N_MAX; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
int n = params[i];
|
||||
|
||||
if (i == 0 && n == 0) { // reset SGR
|
||||
if (n == 0) { // reset SGR
|
||||
screen_reset_cursor(); // resets colors, inverse and bold.
|
||||
break; // cannot combine reset with others - discard
|
||||
}
|
||||
else if (n >= 30 && n <= 37) screen_set_fg((Color) (n - 30)); // ANSI normal fg
|
||||
else if (n >= 40 && n <= 47) screen_set_bg((Color) (n - 40)); // ANSI normal bg
|
||||
else if (n == 39) screen_set_fg(termconf_scratch.default_fg); // default fg
|
||||
else if (n == 49) screen_set_bg(termconf_scratch.default_bg); // default bg
|
||||
else if (n == 7) screen_inverse(true); // inverse
|
||||
else if (n == 27) screen_inverse(false); // positive
|
||||
else if (n == 1) screen_set_bold(true); // bold
|
||||
else if (n == 21 || n == 22) screen_set_bold(false); // bold off
|
||||
|
||||
else if (n == 1) screen_attr_enable(ATTR_BOLD);
|
||||
else if (n == 2) screen_attr_enable(ATTR_FAINT);
|
||||
else if (n == 3) screen_attr_enable(ATTR_ITALIC);
|
||||
else if (n == 4) screen_attr_enable(ATTR_UNDERLINE);
|
||||
else if (n == 5 || n == 6) screen_attr_enable(ATTR_BLINK); // 6 - rapid blink, not supported
|
||||
else if (n == 7) screen_inverse_enable(true);
|
||||
else if (n == 9) screen_attr_enable(ATTR_STRIKE);
|
||||
|
||||
else if (n == 20) screen_attr_enable(ATTR_FRAKTUR);
|
||||
else if (n == 21) screen_attr_disable(ATTR_BOLD);
|
||||
else if (n == 22) screen_attr_disable(ATTR_FAINT);
|
||||
else if (n == 23) screen_attr_disable(ATTR_ITALIC|ATTR_FRAKTUR);
|
||||
else if (n == 24) screen_attr_disable(ATTR_UNDERLINE);
|
||||
else if (n == 25) screen_attr_disable(ATTR_BLINK);
|
||||
else if (n == 27) screen_inverse_enable(false);
|
||||
else if (n == 29) screen_attr_disable(ATTR_STRIKE);
|
||||
|
||||
else if (n >= 90 && n <= 97) screen_set_fg((Color) (n - 90 + 8)); // AIX bright fg
|
||||
else if (n >= 100 && n <= 107) screen_set_bg((Color) (n - 100 + 8)); // AIX bright bg
|
||||
else {
|
||||
ansi_warn("NOIMPL SGR attr %d", n);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 't': // SunView code to set screen size (from GNU Screen)
|
||||
screen_resize(n1, n2);
|
||||
case 't': // xterm hacks
|
||||
switch(n1) {
|
||||
case 8: // set size
|
||||
screen_resize(n2, n3);
|
||||
break;
|
||||
case 18: // report size
|
||||
printf(buf, "\033[8;%d;%dt", termconf_scratch.height, termconf_scratch.width);
|
||||
UART_WriteString(UART0, buf, UART_TIMEOUT_US);
|
||||
break;
|
||||
case 11: // Report iconified -> is not iconified
|
||||
UART_WriteString(UART0, "\033[1t", UART_TIMEOUT_US);
|
||||
break;
|
||||
case 21: // Report title
|
||||
UART_WriteString(UART0, "\033]L", UART_TIMEOUT_US);
|
||||
UART_WriteString(UART0, termconf_scratch.title, UART_TIMEOUT_US);
|
||||
UART_WriteString(UART0, "\033\\", UART_TIMEOUT_US);
|
||||
break;
|
||||
case 24: // Set Height only
|
||||
screen_resize(n2, termconf_scratch.width);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
@@ -281,6 +363,42 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
||||
case 'P':
|
||||
screen_delete_characters(n1);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
// TODO scrolling region
|
||||
// ansi_warn("NOIMPL scrolling region");
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
// TODO clear tab
|
||||
ansi_warn("NOIMPL clear tab");
|
||||
break;
|
||||
|
||||
case 'Z':
|
||||
// TODO back tab
|
||||
ansi_warn("NOIMPL cursor back tab");
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
// TODO setmode (??)
|
||||
ansi_warn("NOIMPL CSI setmode %d", n1);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
if (leadchar == '!') {
|
||||
info("SOFT RESET!");
|
||||
system_restart();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
// report capabilities (pretend we're vt4xx)
|
||||
UART_WriteString(UART0, "\033[?64;22;c", UART_TIMEOUT_US);
|
||||
break;
|
||||
|
||||
default:
|
||||
ansi_warn("Unknown CSI: %c", keychar);
|
||||
apars_handle_badseq();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,6 +409,9 @@ void ICACHE_FLASH_ATTR apars_handle_hashCode(char c)
|
||||
case '8':
|
||||
screen_fill_with_E();
|
||||
break;
|
||||
|
||||
default:
|
||||
ansi_warn("Unknown # sequence: %c", c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,22 +422,48 @@ void ICACHE_FLASH_ATTR apars_handle_shortCode(char c)
|
||||
case 'c': // screen reset
|
||||
screen_reset();
|
||||
break;
|
||||
|
||||
case '7': // save cursor + attrs
|
||||
screen_cursor_save(true);
|
||||
break;
|
||||
|
||||
case '8': // restore cursor + attrs
|
||||
screen_cursor_restore(true);
|
||||
break;
|
||||
|
||||
case 'E': // same as CR LF
|
||||
screen_cursor_move(1, 0, false);
|
||||
screen_cursor_set_x(0);
|
||||
break;
|
||||
|
||||
case 'D': // move cursor down, scroll screen up if needed
|
||||
screen_cursor_move(1, 0, true);
|
||||
break;
|
||||
|
||||
case 'M': // move cursor up, scroll screen down if needed
|
||||
screen_cursor_move(-1, 0, true);
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
// TODO set tab
|
||||
// ansi_warn("NOIMPL set tab");
|
||||
break;
|
||||
|
||||
// TODO those don't seem to do anything
|
||||
case '>':
|
||||
// ansi_warn("NOIMPL NUMKP");
|
||||
break;
|
||||
|
||||
case '<':
|
||||
// ansi_warn("NOIMPL SETANSI");
|
||||
break;
|
||||
|
||||
case '=':
|
||||
// ansi_warn("NOIMPL ALTKP");
|
||||
break;
|
||||
|
||||
default:
|
||||
ansi_warn("Unknown 1-char seq %c", c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#ifndef ANSI_PARSER_CALLBACKS_H
|
||||
#define ANSI_PARSER_CALLBACKS_H
|
||||
|
||||
void apars_handle_badseq(void);
|
||||
void apars_handle_plainchar(char c);
|
||||
void apars_handle_CSI(char leadchar, int *params, char keychar);
|
||||
void apars_handle_CSI(char leadchar, int *params, int count, char keychar);
|
||||
void apars_handle_OSC_SetScreenSize(int rows, int cols);
|
||||
void apars_handle_OSC_SetButton(int num, const char *buffer);
|
||||
void apars_handle_OSC_SetTitle(const char *buffer);
|
||||
void apars_handle_shortCode(char c);
|
||||
void apars_handle_hashCode(char c);
|
||||
void apars_handle_characterSet(char leadchar, char c);
|
||||
void apars_handle_setXCtrls(char c);
|
||||
void apars_reset_utf8buffer(void);
|
||||
|
||||
#endif //ESP_VT100_FIRMWARE_ANSI_PARSER_CALLBACKS_H
|
||||
|
||||
+5
-5
@@ -98,7 +98,7 @@ void ICACHE_FLASH_ATTR updateSockRx(Websock *ws, char *data, int len, int flags)
|
||||
|
||||
// TODO re-implement those, use single byte markers and B2 encoding
|
||||
|
||||
dbg("Sock RX str: %s, len %d", data, len);
|
||||
ws_dbg("Sock RX str: %s, len %d", data, len);
|
||||
|
||||
if (strstarts(data, "STR:")) {
|
||||
// pass string verbatim
|
||||
@@ -134,24 +134,24 @@ void ICACHE_FLASH_ATTR updateSockRx(Websock *ws, char *data, int len, int flags)
|
||||
}
|
||||
|
||||
if (!screen_isCoordValid(y, x)) {
|
||||
warn("Mouse input at invalid coordinates");
|
||||
ws_warn("Mouse input at invalid coordinates");
|
||||
return;
|
||||
}
|
||||
|
||||
dbg("Screen clicked at row %d, col %d", y+1, x+1);
|
||||
ws_dbg("Screen clicked at row %d, col %d", y+1, x+1);
|
||||
|
||||
// Send as 1-based to user
|
||||
sprintf(buf, "\033[%d;%dM", y+1, x+1);
|
||||
UART_WriteString(UART0, buf, UART_TIMEOUT_US);
|
||||
}
|
||||
else {
|
||||
warn("Bad command.");
|
||||
ws_warn("Bad command.");
|
||||
}
|
||||
}
|
||||
|
||||
/** Socket connected for updates */
|
||||
void ICACHE_FLASH_ATTR updateSockConnect(Websock *ws)
|
||||
{
|
||||
info("Socket connected to "URL_WS_UPDATE);
|
||||
ws_info("Socket connected to "URL_WS_UPDATE);
|
||||
ws->recvCb = updateSockRx;
|
||||
}
|
||||
|
||||
@@ -9,4 +9,15 @@
|
||||
void updateSockConnect(Websock *ws);
|
||||
void screen_notifyChange(ScreenNotifyChangeTopic topic);
|
||||
|
||||
// defined in the makefile
|
||||
#if DEBUG_INPUT
|
||||
#define ws_warn warn
|
||||
#define ws_dbg dbg
|
||||
#define ws_info info
|
||||
#else
|
||||
#define ws_warn(...)
|
||||
#define ws_dbg(...)
|
||||
#define ws_info(...)
|
||||
#endif
|
||||
|
||||
#endif //CGI_SOCKETS_H
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "ansi_parser_callbacks.h"
|
||||
#include "wifimgr.h"
|
||||
#include "persist.h"
|
||||
#include "screen.h"
|
||||
#include "ansi_parser.h"
|
||||
|
||||
#define BTNGPIO 0
|
||||
|
||||
@@ -21,6 +23,28 @@ static bool enable_ap_button = false;
|
||||
|
||||
static ETSTimer resetBtntimer;
|
||||
static ETSTimer blinkyTimer;
|
||||
static ETSTimer ansiParserResetTimer;
|
||||
|
||||
static void ICACHE_FLASH_ATTR ansiParserResetTimerCb(void *arg) {
|
||||
static u32 last_charcnt = 0;
|
||||
static int same_charcnt = -1;
|
||||
if (termconf->parser_tout_ms == 0) return;
|
||||
|
||||
if (last_charcnt != ansi_parser_char_cnt) {
|
||||
last_charcnt = ansi_parser_char_cnt;
|
||||
same_charcnt = 0;
|
||||
}
|
||||
else {
|
||||
if (same_charcnt != -1) {
|
||||
same_charcnt++;
|
||||
if (same_charcnt > termconf->parser_tout_ms) {
|
||||
ansi_parser_reset();
|
||||
same_charcnt = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Holding BOOT pin triggers AP reset, then Factory Reset.
|
||||
// Indicate that by blinking the on-board LED.
|
||||
@@ -102,6 +126,10 @@ void ICACHE_FLASH_ATTR ioInit() {
|
||||
os_timer_setfn(&resetBtntimer, resetBtnTimerCb, NULL);
|
||||
os_timer_arm(&resetBtntimer, 500, 1);
|
||||
|
||||
os_timer_disarm(&ansiParserResetTimer);
|
||||
os_timer_setfn(&ansiParserResetTimer, ansiParserResetTimerCb, NULL);
|
||||
os_timer_arm(&ansiParserResetTimer, 1, 1);
|
||||
|
||||
// One way to enter AP mode - hold GPIO0 low.
|
||||
if (GPIO_INPUT_GET(BTNGPIO) == 0) {
|
||||
// starting "in BOOT mode" - do not install the AP reset timer
|
||||
|
||||
+179
-72
@@ -8,6 +8,9 @@
|
||||
TerminalConfigBundle * const termconf = &persist.current.termconf;
|
||||
TerminalConfigBundle termconf_scratch;
|
||||
|
||||
// forward declare
|
||||
static void utf8_remap(char* out, char g, char table);
|
||||
|
||||
#define W termconf_scratch.width
|
||||
#define H termconf_scratch.height
|
||||
|
||||
@@ -61,7 +64,7 @@ typedef struct __attribute__((packed)){
|
||||
char c[4]; // space for a full unicode character
|
||||
Color fg : 4;
|
||||
Color bg : 4;
|
||||
bool bold : 1;
|
||||
u8 attrs;
|
||||
} Cell;
|
||||
|
||||
/**
|
||||
@@ -75,10 +78,15 @@ static Cell screen[MAX_SCREEN_SIZE];
|
||||
static struct {
|
||||
int x; //!< X coordinate
|
||||
int y; //!< Y coordinate
|
||||
bool visible; //!< Visible
|
||||
bool inverse; //!< Inverse colors
|
||||
bool autowrap; //!< Wrapping when EOL
|
||||
bool bold; //!< Bold style
|
||||
bool visible; //!< Visible (not attribute, DEC special)
|
||||
bool inverse;
|
||||
u8 attrs;
|
||||
|
||||
char charset0;
|
||||
char charset1;
|
||||
int charsetN;
|
||||
|
||||
Color fg; //!< Foreground color for writing
|
||||
Color bg; //!< Background color for writing
|
||||
} cursor;
|
||||
@@ -89,10 +97,10 @@ static struct {
|
||||
static struct {
|
||||
int x;
|
||||
int y;
|
||||
|
||||
// optionally saved attrs
|
||||
// mark that attrs are saved
|
||||
bool withAttrs;
|
||||
bool inverse;
|
||||
u8 attrs;
|
||||
bool inverse; // attribute that's not in the bitfield
|
||||
Color fg;
|
||||
Color bg;
|
||||
} cursor_sav;
|
||||
@@ -120,8 +128,8 @@ static inline void
|
||||
clear_range(unsigned int from, unsigned int to)
|
||||
{
|
||||
if (to >= W*H) to = W*H-1;
|
||||
Color fg = cursor.inverse ? cursor.bg : cursor.fg;
|
||||
Color bg = cursor.inverse ? cursor.fg : cursor.bg;
|
||||
Color fg = (cursor.inverse) ? cursor.bg : cursor.fg;
|
||||
Color bg = (cursor.inverse) ? cursor.fg : cursor.bg;
|
||||
|
||||
Cell sample;
|
||||
sample.c[0] = ' ';
|
||||
@@ -130,7 +138,7 @@ clear_range(unsigned int from, unsigned int to)
|
||||
sample.c[3] = 0;
|
||||
sample.fg = fg;
|
||||
sample.bg = bg;
|
||||
sample.bold = false;
|
||||
sample.attrs = 0;
|
||||
|
||||
for (unsigned int i = from; i <= to; i++) {
|
||||
memcpy(&screen[i], &sample, sizeof(Cell));
|
||||
@@ -148,9 +156,12 @@ cursor_reset(void)
|
||||
cursor.fg = termconf_scratch.default_fg;
|
||||
cursor.bg = termconf_scratch.default_bg;
|
||||
cursor.visible = 1;
|
||||
cursor.inverse = 0;
|
||||
cursor.autowrap = 1;
|
||||
cursor.bold = 0;
|
||||
cursor.attrs = 0;
|
||||
|
||||
cursor.charset0 = 'B';
|
||||
cursor.charset1 = '0';
|
||||
cursor.charsetN = 0;
|
||||
}
|
||||
|
||||
//endregion
|
||||
@@ -186,12 +197,10 @@ screen_reset(void)
|
||||
void ICACHE_FLASH_ATTR
|
||||
screen_reset_cursor(void)
|
||||
{
|
||||
NOTIFY_LOCK();
|
||||
cursor.fg = termconf_scratch.default_fg;
|
||||
cursor.bg = termconf_scratch.default_bg;
|
||||
cursor.inverse = 0;
|
||||
cursor.bold = 0;
|
||||
NOTIFY_DONE();
|
||||
cursor.attrs = 0;
|
||||
cursor.inverse = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,7 +273,7 @@ screen_fill_with_E(void)
|
||||
sample.c[3] = 0;
|
||||
sample.fg = termconf_scratch.default_fg;
|
||||
sample.bg = termconf_scratch.default_bg;
|
||||
sample.bold = false;
|
||||
sample.attrs = 0;
|
||||
|
||||
for (unsigned int i = 0; i <= W*H-1; i++) {
|
||||
memcpy(&screen[i], &sample, sizeof(Cell));
|
||||
@@ -533,11 +542,11 @@ screen_cursor_save(bool withAttrs)
|
||||
if (withAttrs) {
|
||||
cursor_sav.fg = cursor.fg;
|
||||
cursor_sav.bg = cursor.bg;
|
||||
cursor_sav.inverse = cursor.inverse;
|
||||
cursor_sav.attrs = cursor.attrs;
|
||||
} else {
|
||||
cursor_sav.fg = termconf_scratch.default_fg;
|
||||
cursor_sav.bg = termconf_scratch.default_bg;
|
||||
cursor_sav.inverse = 0;
|
||||
cursor_sav.attrs = 0; // avoid leftovers if the wrong restore is used
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,7 +563,7 @@ screen_cursor_restore(bool withAttrs)
|
||||
if (withAttrs) {
|
||||
cursor.fg = cursor_sav.fg;
|
||||
cursor.bg = cursor_sav.bg;
|
||||
cursor.inverse = cursor_sav.inverse;
|
||||
cursor.attrs = cursor_sav.attrs;
|
||||
}
|
||||
|
||||
NOTIFY_DONE();
|
||||
@@ -606,43 +615,19 @@ screen_set_bg(Color color)
|
||||
cursor.bg = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cursor foreground and background color
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR
|
||||
screen_set_colors(Color fg, Color bg)
|
||||
void screen_attr_enable(u8 attrs)
|
||||
{
|
||||
screen_set_fg(fg);
|
||||
screen_set_bg(bg);
|
||||
cursor.attrs |= attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invert colors
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR
|
||||
screen_inverse(bool inverse)
|
||||
void screen_attr_disable(u8 attrs)
|
||||
{
|
||||
cursor.inverse = inverse;
|
||||
cursor.attrs &= ~attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make foreground bright.
|
||||
*
|
||||
* This relates to the '1' SGR command which originally means
|
||||
* "bold font". We interpret that as "Bright", similar to other
|
||||
* terminal emulators.
|
||||
*
|
||||
* Note that the bright colors can be used without bold using the 90+ codes
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR
|
||||
screen_set_bold(bool bold)
|
||||
void screen_inverse_enable(bool ena)
|
||||
{
|
||||
if (!bold) {
|
||||
cursor.fg = (Color) (cursor.fg % 8);
|
||||
} else {
|
||||
cursor.fg = (Color) ((cursor.fg % 8) + 8); // change anything to the bright colors
|
||||
}
|
||||
cursor.bold = bold;
|
||||
cursor.inverse = ena;
|
||||
}
|
||||
|
||||
//endregion
|
||||
@@ -659,12 +644,26 @@ bool ICACHE_FLASH_ATTR screen_isCoordValid(int y, int x)
|
||||
return x >= 0 && y >= 0 && x < W && y < H;
|
||||
}
|
||||
|
||||
|
||||
void ICACHE_FLASH_ATTR screen_set_charset_n(int Gx)
|
||||
{
|
||||
if (Gx < 0 || Gx > 1) return; // bad n
|
||||
cursor.charsetN = Gx;
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR screen_set_charset(int Gx, char charset)
|
||||
{
|
||||
if (Gx == 0) cursor.charset0 = charset;
|
||||
if (Gx == 1) cursor.charset1 = charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a character in the cursor color, move to right with wrap.
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR
|
||||
screen_putchar(const char *ch)
|
||||
{
|
||||
char buf[4];
|
||||
NOTIFY_LOCK();
|
||||
|
||||
Cell *c = &screen[cursor.x + cursor.y * W];
|
||||
@@ -689,15 +688,11 @@ screen_putchar(const char *ch)
|
||||
cursor.y--;
|
||||
}
|
||||
}
|
||||
// erase target cell
|
||||
c = &screen[cursor.x + cursor.y * W];
|
||||
c->c[0] = ' ';
|
||||
c->c[1] = 0;
|
||||
c->c[2] = 0;
|
||||
c->c[3] = 0;
|
||||
// apparently backspace should not clear the cell
|
||||
goto done;
|
||||
|
||||
case 9: // TAB
|
||||
// TODO change if tab setting is ever implemented
|
||||
if (cursor.x<((W-1)-(W-1)%4)) {
|
||||
c->c[0] = ' ';
|
||||
c->c[1] = 0;
|
||||
@@ -712,13 +707,19 @@ screen_putchar(const char *ch)
|
||||
default:
|
||||
if (ch[0] < ' ') {
|
||||
// Discard
|
||||
warn("Ignoring control char %d", (int)ch);
|
||||
warn("Ignoring control char %d", (int)ch[0]);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
// copy unicode char
|
||||
strncpy(c->c, ch, 4);
|
||||
if (ch[1] == 0 && ch[0] <= 0x7f) {
|
||||
// we have len=1 and ASCII
|
||||
utf8_remap(c->c, ch[0], (cursor.charsetN == 0) ? cursor.charset0 : cursor.charset1);
|
||||
}
|
||||
else {
|
||||
// copy unicode char
|
||||
strncpy(c->c, ch, 4);
|
||||
}
|
||||
|
||||
if (cursor.inverse) {
|
||||
c->fg = cursor.bg;
|
||||
@@ -727,7 +728,7 @@ screen_putchar(const char *ch)
|
||||
c->fg = cursor.fg;
|
||||
c->bg = cursor.bg;
|
||||
}
|
||||
c->bold = cursor.bold;
|
||||
c->attrs = cursor.attrs;
|
||||
|
||||
cursor.x++;
|
||||
// X wrap
|
||||
@@ -750,6 +751,84 @@ done:
|
||||
NOTIFY_DONE();
|
||||
}
|
||||
|
||||
/**
|
||||
* translates VT100 ACS escape codes to Unicode values.
|
||||
* Based on rxvt-unicode screen.C table.
|
||||
*/
|
||||
static const u16 vt100_to_unicode[62] =
|
||||
{
|
||||
// ? ? ? ? ? ? ?
|
||||
// A=UPARR B=DNARR C=RTARR D=LFARR E=FLBLK F=3/4BL G=SNOMN
|
||||
0x2191, 0x2193, 0x2192, 0x2190, 0x2588, 0x259a, 0x2603,
|
||||
// H= I= J= K= L= M= N=
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
// O= P= Q= R= S= T= U=
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
// V= W= X= Y= Z= [= \=
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
// ? ? v->0 v->1 v->2 v->3 v->4
|
||||
// ]= ^= _=SPC `=DIAMN a=HSMED b=HT c=FF
|
||||
0, 0, 0x0020, 0x25c6, 0x2592, 0x2409, 0x240c,
|
||||
// v->5 v->6 v->7 v->8 v->9 v->a v->b
|
||||
// d=CR e=LF f=DEGRE g=PLSMN h=NL i=VT j=SL-BR
|
||||
0x240d, 0x240a, 0x00b0, 0x00b1, 0x2424, 0x240b, 0x2518,
|
||||
// v->c v->d v->e v->f v->10 v->11 v->12
|
||||
// k=SL-TR l=SL-TL m=SL-BL n=SL-+ o=SL-T1 p=SL-T2 q=SL-HZ
|
||||
0x2510, 0x250c, 0x2514, 0x253c, 0x23ba, 0x23bb, 0x2500,
|
||||
// v->13 v->14 v->15 v->16 v->17 v->18 v->19
|
||||
// r=SL-T4 s=SL-T5 t=SL-VR u=SL-VL v=SL-HU w=Sl-HD x=SL-VT
|
||||
0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, 0x252c, 0x2502,
|
||||
// v->1a v->1b b->1c v->1d v->1e/a3 v->1f
|
||||
// y=LT-EQ z=GT-EQ {=PI |=NOTEQ }=POUND ~=DOT
|
||||
0x2264, 0x2265, 0x03c0, 0x2260, 0x20a4, 0x00b7
|
||||
};
|
||||
|
||||
/**
|
||||
* UTF remap
|
||||
* @param out - output char[4]
|
||||
* @param g - ASCII char
|
||||
* @param table - table name (0, A, B)
|
||||
*/
|
||||
static void ICACHE_FLASH_ATTR
|
||||
utf8_remap(char *out, char g, char table)
|
||||
{
|
||||
u16 utf = 0;
|
||||
|
||||
switch (table)
|
||||
{
|
||||
case '0': /* DEC Special Character & Line Drawing Set */
|
||||
if ((g >= 0x41) && (g <= 0x7e) && (vt100_to_unicode[g - 0x41])) {
|
||||
utf = vt100_to_unicode[g - 0x41];
|
||||
}
|
||||
break;
|
||||
case 'A': /* UK, replaces # with GBP */
|
||||
if (g == '#') utf = 0x20a4;
|
||||
break;
|
||||
}
|
||||
|
||||
if (utf > 0x7F) {
|
||||
// formulas taken from: https://gist.github.com/yamamushi/5823402
|
||||
if ((utf >= 0x80) && (utf <= 0x07FF)) {
|
||||
out[0] = (char) ((utf >> 0x06) ^ 0xC0);
|
||||
out[1] = (char) (((utf ^ 0xFFC0) | 0x80) & ~0x40);
|
||||
out[2]=0;
|
||||
}
|
||||
else if ((utf >= 0x0800) && (utf <= 0xFFFF)) {
|
||||
out[0] = (char) (((utf ^ 0xFC0FFF) >> 0x0C) | 0xE0);
|
||||
out[1] = (char) ((((utf ^ 0xFFF03F) >> 0x06) | 0x80) & ~0x40);
|
||||
out[2] = (char) (((utf ^ 0xFFFC0) | 0x80) & ~0x40);
|
||||
out[3]=0;
|
||||
} else {
|
||||
out[0] = g;
|
||||
out[1] = 0;
|
||||
}
|
||||
} else {
|
||||
out[0] = g;
|
||||
out[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//region Serialization
|
||||
|
||||
@@ -791,7 +870,7 @@ void screen_dd(void)
|
||||
struct ScreenSerializeState {
|
||||
Color lastFg;
|
||||
Color lastBg;
|
||||
bool lastBold;
|
||||
bool lastAttrs;
|
||||
char lastChar[4];
|
||||
int index;
|
||||
};
|
||||
@@ -800,8 +879,24 @@ void ICACHE_FLASH_ATTR
|
||||
encode2B(u16 number, WordB2 *stru)
|
||||
{
|
||||
stru->lsb = (u8) (number % 127);
|
||||
stru->msb = (u8) ((number - stru->lsb) / 127 + 1);
|
||||
number = (u16) ((number - stru->lsb) / 127);
|
||||
stru->lsb += 1;
|
||||
|
||||
stru->msb = (u8) (number + 1);
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR
|
||||
encode3B(u32 number, WordB3 *stru)
|
||||
{
|
||||
stru->lsb = (u8) (number % 127);
|
||||
number = (number - stru->lsb) / 127;
|
||||
stru->lsb += 1;
|
||||
|
||||
stru->msb = (u8) (number % 127);
|
||||
number = (number - stru->msb) / 127;
|
||||
stru->msb += 1;
|
||||
|
||||
stru->xsb = (u8) (number + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -847,6 +942,7 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
|
||||
|
||||
Cell *cell, *cell0;
|
||||
WordB2 w1, w2, w3, w4, w5;
|
||||
WordB3 lw1;
|
||||
|
||||
size_t remain = buf_len; int used = 0;
|
||||
char *bb = buffer;
|
||||
@@ -862,7 +958,7 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
|
||||
ss->index = 0;
|
||||
ss->lastBg = 0;
|
||||
ss->lastFg = 0;
|
||||
ss->lastBold = false;
|
||||
ss->lastAttrs = 0;
|
||||
memset(ss->lastChar, 0, 4); // this ensures the first char is never "repeat"
|
||||
|
||||
encode2B((u16) H, &w1);
|
||||
@@ -872,8 +968,7 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
|
||||
encode2B((u16) (
|
||||
cursor.fg |
|
||||
(cursor.bg<<4) |
|
||||
(cursor.bold?0x100:0) |
|
||||
(cursor.visible?0x200:0))
|
||||
(cursor.visible ? 1<<8 : 0))
|
||||
, &w5);
|
||||
|
||||
// H W X Y Attribs
|
||||
@@ -889,7 +984,7 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
|
||||
while (i < W*H
|
||||
&& cell->fg == ss->lastFg
|
||||
&& cell->bg == ss->lastBg
|
||||
&& cell->bold == ss->lastBold
|
||||
&& cell->attrs == ss->lastAttrs
|
||||
&& strneq(cell->c, ss->lastChar, 4)) {
|
||||
// Repeat
|
||||
repCnt++;
|
||||
@@ -898,13 +993,25 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
|
||||
|
||||
if (repCnt == 0) {
|
||||
// No repeat
|
||||
if (cell0->bold != ss->lastBold || cell0->fg != ss->lastFg || cell0->bg != ss->lastBg) {
|
||||
encode2B((u16) (
|
||||
bool changeAttrs = cell0->attrs != ss->lastAttrs;
|
||||
bool changeColors = (cell0->fg != ss->lastFg || cell0->bg != ss->lastBg);
|
||||
if (!changeAttrs && changeColors) {
|
||||
encode2B(cell0->fg | (cell0->bg<<4), &w1);
|
||||
bufprint("\x03%c%c", w1.lsb, w1.msb);
|
||||
}
|
||||
else if (changeAttrs && !changeColors) {
|
||||
// attrs only
|
||||
encode2B(cell0->attrs, &w1);
|
||||
bufprint("\x04%c%c", w1.lsb, w1.msb);
|
||||
}
|
||||
else if (changeAttrs && changeColors) {
|
||||
// colors and attrs
|
||||
encode3B((u32) (
|
||||
cell0->fg |
|
||||
(cell0->bg<<4) |
|
||||
(cell0->bold?0x100:0))
|
||||
, &w1);
|
||||
bufprint("\x01%c%c", w1.lsb, w1.msb);
|
||||
(cell0->attrs<<8))
|
||||
, &lw1);
|
||||
bufprint("\x01%c%c%c", lw1.lsb, lw1.msb, lw1.xsb);
|
||||
}
|
||||
|
||||
// copy the symbol, until first 0 or reached 4 bytes
|
||||
@@ -916,7 +1023,7 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
|
||||
|
||||
ss->lastFg = cell0->fg;
|
||||
ss->lastBg = cell0->bg;
|
||||
ss->lastBold = cell0->bold;
|
||||
ss->lastAttrs = cell0->attrs;
|
||||
memcpy(ss->lastChar, cell0->c, 4);
|
||||
|
||||
i++;
|
||||
|
||||
+23
-7
@@ -46,6 +46,14 @@ typedef enum {
|
||||
CHANGE_LABELS,
|
||||
} ScreenNotifyChangeTopic;
|
||||
|
||||
#define ATTR_BOLD (1<<0)
|
||||
#define ATTR_FAINT (1<<1)
|
||||
#define ATTR_ITALIC (1<<2)
|
||||
#define ATTR_UNDERLINE (1<<3)
|
||||
#define ATTR_BLINK (1<<4)
|
||||
#define ATTR_FRAKTUR (1<<5)
|
||||
#define ATTR_STRIKE (1<<6)
|
||||
|
||||
#define SCREEN_NOTIFY_DELAY_MS 20
|
||||
|
||||
typedef struct {
|
||||
@@ -95,6 +103,12 @@ typedef struct {
|
||||
u8 msb;
|
||||
} WordB2;
|
||||
|
||||
typedef struct {
|
||||
u8 lsb;
|
||||
u8 msb;
|
||||
u8 xsb;
|
||||
} WordB3;
|
||||
|
||||
/** Encode number to two nice ASCII bytes */
|
||||
void encode2B(u16 number, WordB2 *stru);
|
||||
|
||||
@@ -119,7 +133,7 @@ void screen_clear_in_line(unsigned int count);
|
||||
void screen_scroll_up(unsigned int lines);
|
||||
/** Shift screen downwards */
|
||||
void screen_scroll_down(unsigned int lines);
|
||||
/** esc # 8 - fill entire screen with E of default colors */
|
||||
/** esc # 8 - fill entire screen with E of default colors (DEC alignment display) */
|
||||
void screen_fill_with_E(void);
|
||||
|
||||
// --- insert / delete ---
|
||||
@@ -157,12 +171,14 @@ void screen_wrap_enable(bool enable);
|
||||
void screen_set_fg(Color color);
|
||||
/** Set cursor background coloor */
|
||||
void screen_set_bg(Color color);
|
||||
/** make foreground bright */
|
||||
void screen_set_bold(bool bold);
|
||||
/** Set cursor foreground and background color */
|
||||
void screen_set_colors(Color fg, Color bg);
|
||||
/** Invert colors */
|
||||
void screen_inverse(bool inverse);
|
||||
|
||||
// enable or disable attrs by bitmask
|
||||
void screen_attr_enable(u8 attrs);
|
||||
void screen_attr_disable(u8 attrs);
|
||||
void screen_inverse_enable(bool ena);
|
||||
|
||||
void screen_set_charset_n(int Gx);
|
||||
void screen_set_charset(int Gx, char charset);
|
||||
|
||||
/**
|
||||
* Set a character in the cursor color, move to right with wrap.
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef USER_MAIN_H_H
|
||||
#define USER_MAIN_H_H
|
||||
|
||||
#define FIRMWARE_VERSION "0.6.5+" GIT_HASH
|
||||
#define FIRMWARE_VERSION "0.6.7+" GIT_HASH
|
||||
#define TERMINAL_GITHUB_REPO "https://github.com/MightyPork/esp-vt100-firmware"
|
||||
|
||||
#endif //USER_MAIN_H_H
|
||||
|
||||
Reference in New Issue
Block a user