help page improvements, opt to hide botnav and buttons, DECOPT for those: 800 and 801, charset tables added to help page, terminal css overhaul to avoid Black Lines

This commit is contained in:
2017-09-06 14:21:38 +02:00
parent d2b2b89593
commit ba9c757cdc
42 changed files with 1801 additions and 1345 deletions
+8
View File
@@ -531,6 +531,14 @@ static void ICACHE_FLASH_ATTR do_csi_privattr(CSI_Data *opts)
else if (n == 25) {
screen_set_cursor_visible(yn);
}
else if (n == 800) { // ESPTerm: Toggle display of buttons
termconf_scratch.show_buttons = yn;
screen_notifyChange(CHANGE_CONTENT); // this info is included in the screen preamble
}
else if (n == 801) { // ESPTerm: Toggle display of config links
termconf_scratch.show_config_links = yn;
screen_notifyChange(CHANGE_CONTENT); // this info is included in the screen preamble
}
else {
ansi_noimpl("CSI ? %d %c", n, opts->key);
}
+1 -1
View File
@@ -39,7 +39,7 @@ apars_handle_osc(const char *buffer)
if (n == 0 || n == 2) {
screen_set_title(buffer);
}
else if (n >= 81 && n <= 85) { // numbers chosen to not collide with any xterm supported codes
else if (n >= 81 && n <= 85) { // ESPTerm: action button label
screen_set_button_text(n - 80, buffer);
}
else {
+18
View File
@@ -120,6 +120,18 @@ cgiTermCfgSetParams(HttpdConnData *connData)
termconf->fn_alt_mode = (bool)n;
}
if (GET_ARG("show_buttons")) {
dbg("Show buttons: %s", buff);
n = atoi(buff);
termconf->show_buttons = (bool)n;
}
if (GET_ARG("show_config_links")) {
dbg("Show config links: %s", buff);
n = atoi(buff);
termconf->show_config_links = (bool)n;
}
if (GET_ARG("default_fg")) {
dbg("Screen default FG: %s", buff);
n = atoi(buff);
@@ -212,6 +224,12 @@ tplTermCfg(HttpdConnData *connData, char *token, void **arg)
else if (streq(token, "fn_alt_mode")) {
sprintf(buff, "%d", (int)termconf->fn_alt_mode);
}
else if (streq(token, "show_buttons")) {
sprintf(buff, "%d", (int)termconf->show_buttons);
}
else if (streq(token, "show_config_links")) {
sprintf(buff, "%d", (int)termconf->show_config_links);
}
else if (streq(token, "theme")) {
sprintf(buff, "%d", termconf->theme);
}
+169
View File
@@ -0,0 +1,169 @@
//
// Created by MightyPork on 2017/09/06.
//
#ifndef ESPTERM_CHARACTER_SETS_H_H
#define ESPTERM_CHARACTER_SETS_H_H
#include <c_types.h>
// Tables must be contiguous!
#define CODEPAGE_A_BEGIN 35
#define CODEPAGE_A_END 35
static const u16 codepage_A[] =
{// Unicode ASCII SYM
// %%BEGIN:A%%
0x20a4, // 35 # £
// %%END:A%%
};
#define CODEPAGE_0_BEGIN 96
#define CODEPAGE_0_END 126
/**
* translates VT100 ACS escape codes to Unicode values.
* Based on rxvt-unicode screen.C table.
*/
static const u16 codepage_0[] =
{// Unicode ASCII SYM
// %%BEGIN:0%%
0x2666, // 96 ` ♦
0x2592, // 97 a ▒
0x2409, // 98 b HT
0x240c, // 99 c FF
0x240d, // 100 d CR
0x240a, // 101 e LF
0x00b0, // 102 f °
0x00b1, // 103 g ±
0x2424, // 104 h NL
0x240b, // 105 i VT
0x2518, // 106 j ┘
0x2510, // 107 k ┐
0x250c, // 108 l ┌
0x2514, // 109 m └
0x253c, // 110 n ┼
0x23ba, // 111 o ⎺
0x23bb, // 112 p ⎻
0x2500, // 113 q ─
0x23bc, // 114 r ⎼
0x23bd, // 115 s ⎽
0x251c, // 116 t ├
0x2524, // 117 u ┤
0x2534, // 118 v ┴
0x252c, // 119 w ┬
0x2502, // 120 x │
0x2264, // 121 y ≤
0x2265, // 122 z ≥
0x03c0, // 123 { π
0x2260, // 124 | ≠
0x20a4, // 125 } £
0x00b7, // 126 ~ ·
// %%END:0%%
};
#define CODEPAGE_1_BEGIN 33
#define CODEPAGE_1_END 126
static const u16 codepage_1[] =
{// Unicode ASCII SYM DOS
// %%BEGIN:1%%
0x263A, // 33 ! ☺ (1) - low ASCII symbols from DOS, moved to +32
0x263B, // 34 " ☻ (2)
0x2665, // 35 # ♥ (3)
0x2666, // 36 $ ♦ (4)
0x2663, // 37 % ♣ (5)
0x2660, // 38 & ♠ (6)
0x2022, // 39 ' • (7) - inverse dot and circle left out, can be done with SGR
0x231B, // 40 ( ⌛ - hourglass (timer icon)
0x25CB, // 41 ) ○ (9)
0x21AF, // 42 * ↯ - electricity (lightning monitor...)
0x266A, // 43 + ♪ (13)
0x266B, // 44 , ♫ (14)
0x263C, // 45 - ☼ (15)
0x2302, // 46 . ⌂ (127)
0x2622, // 47 / ☢ - radioactivity (geiger counter...)
0x2591, // 48 0 ░ (176) - this block is kept aligned and ordered from DOS, moved -128
0x2592, // 49 1 ▒ (177)
0x2593, // 50 2 ▓ (178)
0x2502, // 51 3 │ (179)
0x2524, // 52 4 ┤ (180)
0x2561, // 53 5 ╡ (181)
0x2562, // 54 6 ╢ (182)
0x2556, // 55 7 ╖ (183)
0x2555, // 56 8 ╕ (184)
0x2563, // 57 9 ╣ (185)
0x2551, // 58 : ║ (186)
0x2557, // 59 ; ╗ (187)
0x255D, // 60 < ╝ (188)
0x255C, // 61 = ╜ (189)
0x255B, // 62 > ╛ (190)
0x2510, // 63 ? ┐ (191)
0x2514, // 64 @ └ (192)
0x2534, // 65 A ┴ (193)
0x252C, // 66 B ┬ (194)
0x251C, // 67 C ├ (195)
0x2500, // 68 D ─ (196)
0x253C, // 69 E ┼ (197)
0x255E, // 70 F ╞ (198)
0x255F, // 71 G ╟ (199)
0x255A, // 72 H ╚ (200)
0x2554, // 73 I ╔ (201)
0x2569, // 74 J ╩ (202)
0x2566, // 75 K ╦ (203)
0x2560, // 76 L ╠ (204)
0x2550, // 77 M ═ (205)
0x256C, // 78 N ╬ (206)
0x2567, // 79 O ╧ (207)
0x2568, // 80 P ╨ (208)
0x2564, // 81 Q ╤ (209)
0x2565, // 82 R ╥ (210)
0x2559, // 83 S ╙ (211)
0x2558, // 84 T ╘ (212)
0x2552, // 85 U ╒ (213)
0x2553, // 86 V ╓ (214)
0x256B, // 87 W ╫ (215)
0x256A, // 88 X ╪ (216)
0x2518, // 89 Y ┘ (217)
0x250C, // 90 Z ┌ (218)
0x2588, // 91 [ █ (219)
0x2584, // 92 \ ▄ (220)
0x258C, // 93 ] ▌ (221)
0x2590, // 94 ^ ▐ (222)
0x2580, // 95 _ ▀ (223)
0x2195, // 96 ` ↕ (18) - moved from low DOS ASCII
0x2191, // 97 a ↑ (24)
0x2193, // 98 b ↓ (25)
0x2192, // 99 c → (26)
0x2190, // 100 d ← (27)
0x2194, // 101 e ↔ (29)
0x25B2, // 102 f ▲ (30)
0x25BC, // 103 g ▼ (31)
0x25BA, // 104 h ► (16)
0x25C4, // 105 i ◄ (17)
0x25E2, // 106 j ◢ - added for slanted corners
0x25E3, // 107 k ◣
0x25E4, // 108 l ◤
0x25E5, // 109 m ◥
0x256D, // 110 n ╭ - rounded corners
0x256E, // 111 o ╮
0x256F, // 112 p ╯
0x2570, // 113 q ╰
0x0, // 114 r - free positions for future expansion
0x0, // 115 s
0x0, // 116 t
0x0, // 117 u
0x0, // 118 v
0x0, // 119 w
0x0, // 120 x
0x0, // 121 y
0x0, // 122 z
0x0, // 123 {
0x0, // 124 |
0x2714, // 125 } ✔ - checkboxes or checklist items
0x2718, // 126 ~ ✘
// %%END:1%%
};
#endif //ESPTERM_CHARACTER_SETS_H_H
+44 -158
View File
@@ -6,6 +6,7 @@
#include "ascii.h"
#include "apars_logging.h"
#include "jstring.h"
#include "character_sets.h"
TerminalConfigBundle * const termconf = &persist.current.termconf;
TerminalConfigBundle termconf_scratch;
@@ -129,17 +130,23 @@ static volatile int notifyLock = 0;
void ICACHE_FLASH_ATTR
terminal_restore_defaults(void)
{
termconf->default_bg = 0;
termconf->default_fg = 7;
termconf->width = SCR_DEF_WIDTH;
termconf->height = SCR_DEF_HEIGHT;
termconf->parser_tout_ms = SCR_DEF_PARSER_TOUT_MS;
termconf->display_tout_ms = SCR_DEF_DISPLAY_TOUT_MS;
termconf->fn_alt_mode = SCR_DEF_FN_ALT_MODE;
termconf->default_bg = 0;
termconf->default_fg = 7;
sprintf(termconf->title, SCR_DEF_TITLE);
for(int i=1; i <= 5; i++) {
sprintf(termconf->btn[i-1], "%d", i);
}
termconf->theme = 0;
termconf->parser_tout_ms = SCR_DEF_PARSER_TOUT_MS;
termconf->display_tout_ms = SCR_DEF_DISPLAY_TOUT_MS;
termconf->fn_alt_mode = SCR_DEF_FN_ALT_MODE;
termconf->config_version = TERMCONF_VERSION;
termconf->display_cooldown_ms = SCR_DEF_DISPLAY_COOLDOWN_MS;
termconf->loopback = 0;
termconf->show_buttons = 1;
termconf->show_config_links = 1;
}
/**
@@ -165,6 +172,15 @@ terminal_apply_settings_noclear(void)
changed = 1;
}
// Migrate to v2
if (termconf->config_version < 2) {
dbg("termconf: Updating to version 2");
termconf->loopback = 0;
termconf->show_config_links = 1;
termconf->show_buttons = 1;
changed = 1;
}
termconf->config_version = TERMCONF_VERSION;
// Validation...
@@ -223,8 +239,8 @@ cursor_reset(void)
cursor.origin_mode = false;
cursor.charsetN = 0;
cursor.charset0 = CS_USASCII;
cursor.charset1 = CS_DEC_SUPPLEMENTAL;
cursor.charset0 = CS_B_USASCII;
cursor.charset1 = CS_0_DEC_SUPPLEMENTAL;
cursor.wraparound = true;
screen_reset_sgr();
@@ -1119,143 +1135,6 @@ screen_putchar(const char *ch)
NOTIFY_DONE();
}
/**
* translates VT100 ACS escape codes to Unicode values.
* Based on rxvt-unicode screen.C table.
*/
static const u16 codepage_0[] =
{// Unicode ASCII SYM
0x2666, // 96 ` ♦
0x2592, // 97 a ▒
0x2409, // 98 b HT
0x240c, // 99 c FF
0x240d, // 100 d CR
0x240a, // 101 e LF
0x00b0, // 102 f °
0x00b1, // 103 g ±
0x2424, // 104 h NL
0x240b, // 105 i VT
0x2518, // 106 j ┘
0x2510, // 107 k ┐
0x250c, // 108 l ┌
0x2514, // 109 m └
0x253c, // 110 n ┼
0x23ba, // 111 o ⎺
0x23bb, // 112 p ⎻
0x2500, // 113 q ─
0x23bc, // 114 r ⎼
0x23bd, // 115 s ⎽
0x251c, // 116 t ├
0x2524, // 117 u ┤
0x2534, // 118 v ┴
0x252c, // 119 w ┬
0x2502, // 120 x │
0x2264, // 121 y ≤
0x2265, // 122 z ≥
0x03c0, // 123 { π
0x2260, // 124 | ≠
0x20a4, // 125 } £
0x00b7, // 126 ~ ·
};
static const u16 codepage_1[] =
{// Unicode ASCII SYM DOS
0x263A, // 33 ! ☺ (1) - low ASCII symbols from DOS, moved to +32
0x263B, // 34 " ☻ (2)
0x2665, // 35 # ♥ (3)
0x2666, // 36 $ ♦ (4)
0x2663, // 37 % ♣ (5)
0x2660, // 38 & ♠ (6)
0x2022, // 39 ' • (7) - inverse dot and circle left out, can be done with SGR
0x0,//0x231B, // 40 ( ⌛ - hourglass (timer icon)
0x25CB, // 41 ) ○ (9)
0x21AF, // 42 * ↯ - electricity (lightning monitor...)
0x266A, // 43 + ♪ (13)
0x266B, // 44 , ♫ (14)
0x263C, // 45 - ☼ (15)
0x2302, // 46 . ⌂ (127)
0x0,//0x2622, // 47 / ☢ - radioactivity (geiger counter...)
0x2591, // 48 0 ░ (176) - this block is kept aligned and ordered from DOS, moved -128
0x2592, // 49 1 ▒ (177)
0x2593, // 50 2 ▓ (178)
0x2502, // 51 3 │ (179)
0x2524, // 52 4 ┤ (180)
0x2561, // 53 5 ╡ (181)
0x2562, // 54 6 ╢ (182)
0x2556, // 55 7 ╖ (183)
0x2555, // 56 8 ╕ (184)
0x2563, // 57 9 ╣ (185)
0x2551, // 58 : ║ (186)
0x2557, // 59 ; ╗ (187)
0x255D, // 60 < ╝ (188)
0x255C, // 61 = ╜ (189)
0x255B, // 62 > ╛ (190)
0x2510, // 63 ? ┐ (191)
0x2514, // 64 @ └ (192)
0x2534, // 65 A ┴ (193)
0x252C, // 66 B ┬ (194)
0x251C, // 67 C ├ (195)
0x2500, // 68 D ─ (196)
0x253C, // 69 E ┼ (197)
0x255E, // 70 F ╞ (198)
0x255F, // 71 G ╟ (199)
0x255A, // 72 H ╚ (200)
0x2554, // 73 I ╔ (201)
0x2569, // 74 J ╩ (202)
0x2566, // 75 K ╦ (203)
0x2560, // 76 L ╠ (204)
0x2550, // 77 M ═ (205)
0x256C, // 78 N ╬ (206)
0x2567, // 79 O ╧ (207)
0x2568, // 80 P ╨ (208)
0x2564, // 81 Q ╤ (209)
0x2565, // 82 R ╥ (210)
0x2559, // 83 S ╙ (211)
0x2558, // 84 T ╘ (212)
0x2552, // 85 U ╒ (213)
0x2553, // 86 V ╓ (214)
0x256B, // 87 W ╫ (215)
0x256A, // 88 X ╪ (216)
0x2518, // 89 Y ┘ (217)
0x250C, // 90 Z ┌ (218)
0x2588, // 91 [ █ (219)
0x2584, // 92 \ ▄ (220)
0x258C, // 93 ] ▌ (221)
0x2590, // 94 ^ ▐ (222)
0x2580, // 95 _ ▀ (223)
0x2195, // 96 ` ↕ (18) - moved from low DOS ASCII
0x2191, // 97 a ↑ (24)
0x2193, // 98 b ↓ (25)
0x2192, // 99 c → (26)
0x2190, // 100 d ← (27)
0x2194, // 101 e ↔ (29)
0x25B2, // 102 f ▲ (30)
0x25BC, // 103 g ▼ (31)
0x25BA, // 104 h ► (16)
0x25C4, // 105 i ◄ (17)
0x0,//0x25E2, // 106 j ◢ - added for slanted corners
0x0,//0x25E3, // 107 k ◣
0x0,//0x25E4, // 108 l ◤
0x0,//0x25E5, // 109 m ◥
0x256D, // 110 n ╭ - rounded corners
0x256E, // 111 o ╮
0x256F, // 112 p ╯
0x2570, // 113 q ╰
0x0, // 114 r - free positions for future expansion
0x0, // 115 s
0x0, // 116 t
0x0, // 117 u
0x0, // 118 v
0x0, // 119 w
0x0, // 120 x
0x0, // 121 y
0x0, // 122 z
0x0, // 123 {
0x0, // 124 |
0x0,//0x2714, // 125 } ✔ - checkboxes or checklist items
0x0,//0x2718, // 126 ~ ✘
};
/**
* UTF remap
* @param out - output char[4]
@@ -1269,26 +1148,29 @@ utf8_remap(char *out, char g, char charset)
u16 utf = (unsigned char)g;
switch (charset) {
case CS_DEC_SUPPLEMENTAL: /* DEC Special Character & Line Drawing Set */
if ((g >= 96) && (g < 0x7F)) {
n = codepage_0[g - 96];
case CS_0_DEC_SUPPLEMENTAL: /* DEC Special Character & Line Drawing Set */
if ((g >= CODEPAGE_0_BEGIN) && (g <= CODEPAGE_0_END)) {
n = codepage_0[g - CODEPAGE_0_BEGIN];
if (n) utf = n;
}
break;
case CS_DOS_437: /* ESPTerm Character Rom 1 */
if ((g >= 33) && (g < 0x7F)) {
n = codepage_1[g - 33];
case CS_1_DOS_437: /* ESPTerm Character Rom 1 */
if ((g >= CODEPAGE_1_BEGIN) && (g <= CODEPAGE_1_END)) {
n = codepage_1[g - CODEPAGE_1_END];
if (n) utf = n;
}
break;
case CS_UKASCII: /* UK, replaces # with GBP */
if (g == '#') utf = 0x20a4;
case CS_A_UKASCII: /* UK, replaces # with GBP */
if ((g >= CODEPAGE_A_BEGIN) && (g <= CODEPAGE_A_END)) {
n = codepage_A[g - CODEPAGE_A_BEGIN];
if (n) utf = n;
}
break;
default:
case CS_USASCII:
case CS_B_USASCII:
// No change
break;
}
@@ -1395,11 +1277,15 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
encode2B((u16) cursor.y, &w3);
encode2B((u16) cursor.x, &w4);
encode2B((u16) (
(cursor.visible ? 0x01 : 0) |
(cursor.hanging ? 0x02 : 0) |
(scr.cursors_alt_mode ? 0x04 : 0) |
(scr.numpad_alt_mode ? 0x08 : 0) |
(termconf->fn_alt_mode ? 0x10 : 0)
(cursor.visible ? 1<<0 : 0) |
(cursor.hanging ? 1<<1 : 0) |
(scr.cursors_alt_mode ? 1<<2 : 0) |
(scr.numpad_alt_mode ? 1<<3 : 0) |
(termconf->fn_alt_mode ? 1<<4 : 0) |
(mouse_tracking.mode!=MTM_NONE ? 1<<5 : 0) |
(mouse_tracking.mode>=MTM_BUTTON_MOTION ? 1<<6 : 0) |
(termconf_scratch.show_buttons ? 1<<7 : 0) |
(termconf_scratch.show_config_links ? 1<<8 : 0)
)
, &w5);
+10 -7
View File
@@ -44,7 +44,7 @@
#define SCR_DEF_DISPLAY_TOUT_MS 10
#define SCR_DEF_DISPLAY_COOLDOWN_MS 30
#define SCR_DEF_PARSER_TOUT_MS 10
#define SCR_DEF_FN_ALT_MODE false
#define SCR_DEF_FN_ALT_MODE true // true - SS3 codes, easier to parse & for xterm compatibility
#define SCR_DEF_WIDTH 26
#define SCR_DEF_HEIGHT 10
#define SCR_DEF_TITLE "ESPTerm"
@@ -52,7 +52,7 @@
/** Maximum screen size (determines size of the static data array) */
#define MAX_SCREEN_SIZE (80*25)
#define TERMCONF_VERSION 1
#define TERMCONF_VERSION 2
// --- Persistent Settings ---
@@ -69,6 +69,9 @@ typedef struct {
bool fn_alt_mode; // xterm compatibility mode (alternate codes for some FN keys)
u8 config_version;
u32 display_cooldown_ms;
bool loopback;
bool show_buttons;
bool show_config_links;
} TerminalConfigBundle;
// Live config
@@ -84,7 +87,7 @@ enum MTM {
MTM_NONE = 0,
MTM_X10 = 1,
MTM_NORMAL = 2,
MTM_BUTTON_MOTION = 3,
MTM_BUTTON_MOTION = 3, // any higher mode tracks motion
MTM_ANY_MOTION = 4,
};
@@ -121,10 +124,10 @@ void screen_set_button_text(int num, const char *text);
// --- Encoding ---
typedef enum {
CS_USASCII = 'B',
CS_UKASCII = 'A',
CS_DEC_SUPPLEMENTAL = '0',
CS_DOS_437 = '1',
CS_B_USASCII = 'B',
CS_A_UKASCII = 'A',
CS_0_DEC_SUPPLEMENTAL = '0',
CS_1_DOS_437 = '1',
} CHARSET;
httpd_cgi_state screenSerializeToBuffer(char *buffer, size_t buf_len, void **data);
+2 -2
View File
@@ -5,8 +5,8 @@
#ifndef ESP_VT100_FIRMWARE_VERSION_H
#define ESP_VT100_FIRMWARE_VERSION_H
#define FW_V_MAJOR 0
#define FW_V_MINOR 7
#define FW_V_MAJOR 8
#define FW_V_MINOR 0
#define FW_V_PATCH 1
#define FIRMWARE_VERSION STR(FW_V_MAJOR) "." STR(FW_V_MINOR) "." STR(FW_V_PATCH) "+" GIT_HASH