diff --git a/esphttpdconfig.mk b/esphttpdconfig.mk index 6672162..a46fa85 100644 --- a/esphttpdconfig.mk +++ b/esphttpdconfig.mk @@ -47,7 +47,7 @@ GLOBAL_CFLAGS = \ -DDEBUG_HTTP=0 \ -DDEBUG_ESPFS=0 \ -DDEBUG_PERSIST=0 \ - -DDEBUG_UTFCACHE=1 \ + -DDEBUG_UTFCACHE=0 \ -DDEBUG_CGI=0 \ -DDEBUG_WIFI=0 \ -DDEBUG_WS=0 \ diff --git a/front-end b/front-end index c07a616..810782a 160000 --- a/front-end +++ b/front-end @@ -1 +1 @@ -Subproject commit c07a6162f2d89802e68930e0665a9e5a85ac13a9 +Subproject commit 810782a7f299272b9ebfe0ae3c5087bc0fe9c59d diff --git a/user/apars_csi.c b/user/apars_csi.c index 4ed852d..a83e8ba 100644 --- a/user/apars_csi.c +++ b/user/apars_csi.c @@ -557,12 +557,12 @@ do_csi_sgr(CSI_Data *opts) else if (n == SGR_FG_256 || n == SGR_BG_256) { if (i < count-2) { if (opts->n[i + 1] == 5) { - u16 color = (u16) opts->n[i + 2]; + u8 color = (u8) opts->n[i + 2]; bool fg = n == SGR_FG_256; if (fg) { - screen_set_fg_ext(color); + screen_set_fg(color); } else { - screen_set_bg_ext(color); + screen_set_bg(color); } } else { @@ -664,7 +664,8 @@ do_csi_set_private_option(CSI_Data *opts) } else if (n == 3) { // DECCOLM 132 column mode - not implemented due to RAM demands - ansi_noimpl("132col"); + // XXX 132col + // ansi_noimpl("132col"); // DECCOLM side effects as per // https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/deccolm-cls.html @@ -688,7 +689,7 @@ do_csi_set_private_option(CSI_Data *opts) // Key auto-repeat // We don't implement this currently, but it could be added // - discard repeated keypress events between keydown and keyup. - ansi_noimpl("Auto-repeat toggle"); + // XXX auto repeat toggle } else if (n == 9 || (n >= 1000 && n <= 1006) || n == 1015) { // 9 - X10 tracking @@ -708,7 +709,7 @@ do_csi_set_private_option(CSI_Data *opts) else if (n == 1006) mouse_tracking.encoding = yn ? MTE_SGR : MTE_SIMPLE; else if (n == 1015) mouse_tracking.encoding = yn ? MTE_URXVT : MTE_SIMPLE; - dbg("Mouse mode=%d, enc=%d, foctr=%d", + ansi_dbg("Mouse mode=%d, enc=%d, foctr=%d", mouse_tracking.mode, mouse_tracking.encoding, mouse_tracking.focus_tracking); @@ -722,7 +723,7 @@ do_csi_set_private_option(CSI_Data *opts) else if (n == 40) { // allow/disallow 80->132 mode // not implemented because of RAM demands - ansi_noimpl("132col enable"); + // ansi_noimpl("132col enable"); } else if (n == 45) { // reverse wrap-around @@ -756,7 +757,7 @@ do_csi_set_private_option(CSI_Data *opts) } else if (n == 2004) { // Bracketed paste mode - ansi_noimpl("Bracketed paste"); + screen_set_bracketed_paste(yn); } else if (n == 800) { // ESPTerm: Toggle display of buttons termconf_live.show_buttons = yn; diff --git a/user/apars_osc.c b/user/apars_osc.c index 28c68b0..df68d07 100644 --- a/user/apars_osc.c +++ b/user/apars_osc.c @@ -40,6 +40,9 @@ apars_handle_osc(char *buffer) // Window title (or "icon name" in Xterm) screen_set_title(buffer); } + else if (n == 4) { + // XXX setting RGB color, ignore + } else if (n == 9) { // iTerm2-style "growl" notifications buffer--; diff --git a/user/screen.c b/user/screen.c index 9b3006c..49b611b 100644 --- a/user/screen.c +++ b/user/screen.c @@ -28,10 +28,10 @@ static void utf8_remap(char* out, char g, char charset); /** * Screen cell data type (16 bits) */ -typedef struct __attribute__((packed)){ +typedef struct __attribute__((packed)) { UnicodeCacheRef symbol : 8; - Color fg : 8; - Color bg : 8; + Color fg; + Color bg; u8 attrs; } Cell; @@ -68,8 +68,8 @@ static struct { #define R1 scr.vm1 #define RH (scr.vm1 - scr.vm0 + 1) // horizontal edges - will be useful if horizontal margin is implemented -#define C0 0 -#define C1 (W-1) +//#define C0 0 +//#define C1 (W-1) typedef struct { /* Cursor position */ @@ -1165,7 +1165,6 @@ screen_reverse_wrap_enable(bool enable) void ICACHE_FLASH_ATTR screen_set_fg(Color color) { - if (color > COLOR_MAX) color = COLOR_MAX; cursor.fg = color; } @@ -1175,28 +1174,9 @@ screen_set_fg(Color color) void ICACHE_FLASH_ATTR screen_set_bg(Color color) { - if (color > COLOR_MAX) color = COLOR_MAX; cursor.bg = color; } -/** - * Set cursor foreground color, extended - */ -void ICACHE_FLASH_ATTR -screen_set_fg_ext(u16 color) -{ - // TODO validate and set -} - -/** - * Set cursor background color, extended - */ -void ICACHE_FLASH_ATTR -screen_set_bg_ext(u16 color) -{ - // TODO validate and set -} - void ICACHE_FLASH_ATTR screen_set_sgr(u8 attrs, bool ena) { @@ -1264,6 +1244,14 @@ screen_set_reverse_video(bool reverse) NOTIFY_DONE(); } +void ICACHE_FLASH_ATTR +screen_set_bracketed_paste(bool ena) +{ + NOTIFY_LOCK(); + scr.bracketed_paste = ena; + NOTIFY_DONE(); +} + void ICACHE_FLASH_ATTR screen_set_newline_mode(bool nlm) { @@ -1562,6 +1550,7 @@ struct ScreenSerializeState { void ICACHE_FLASH_ATTR screenSerializeLabelsToBuffer(char *buffer, size_t buf_len) { + (void)buf_len; // let's just assume it's long enough - called with the huge websocket buffer sprintf(buffer, "T%s\x01%s\x01%s\x01%s\x01%s\x01%s", // use 0x01 as separator termconf_live.title, @@ -1658,10 +1647,17 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data) (termconf_live.show_buttons << 7) | (termconf_live.show_config_links << 8) | ((termconf_live.cursor_shape&0x07) << 9) | // 9,10,11 - cursor shape based on DECSCUSR - (termconf_live.crlf_mode << 12) + (termconf_live.crlf_mode << 12) | + (scr.bracketed_paste << 13) ); } +#define SEQ_TAG_REPEAT '\x02' +#define SEQ_TAG_COLORS '\x03' +#define SEQ_TAG_ATTRS '\x04' +#define SEQ_TAG_FG '\x05' +#define SEQ_TAG_BG '\x06' + int i = ss->index; while(i < W*H && remain > 12) { cell = cell0 = &screen[i]; @@ -1681,7 +1677,9 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data) if (repCnt == 0) { // No repeat bool changeAttrs = cell0->attrs != ss->lastAttrs; - bool changeColors = (cell0->fg != ss->lastFg || cell0->bg != ss->lastBg); + bool changeFg = cell0->fg != ss->lastFg; + bool changeBg = cell0->bg != ss->lastBg; + bool changeColors = changeFg && changeBg; Color fg, bg; // Reverse fg and bg if we're in global reverse mode @@ -1694,16 +1692,18 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data) bg = cell0->fg; } - if (!changeAttrs && changeColors) { - bufput_t2B('\x03', fg | (bg<<4)); + if (changeColors) { + bufput_t3B(SEQ_TAG_COLORS, bg<<8 | fg); } - else if (changeAttrs && !changeColors) { - // attrs only - bufput_t2B('\x04', cell0->attrs); + else if (changeFg) { + bufput_t2B(SEQ_TAG_FG, fg); } - else if (changeAttrs && changeColors) { - // colors and attrs - bufput_t3B('\x01', (u32) (fg | (bg<<4) | (cell0->attrs<<8))); + else if (changeBg) { + bufput_t2B(SEQ_TAG_BG, bg); + } + + if (changeAttrs) { + bufput_t2B(SEQ_TAG_ATTRS, cell0->attrs); } // copy the symbol, until first 0 or reached 4 bytes @@ -1728,7 +1728,7 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data) int savings = ss->lastCharLen*repCnt; if (savings > 3) { // Repeat count - bufput_t2B('\x02', repCnt); + bufput_t2B(SEQ_TAG_REPEAT, repCnt); } else { // repeat it manually for(int k = 0; k < repCnt; k++) { diff --git a/user/screen.h b/user/screen.h index e5918ea..3ae7f04 100644 --- a/user/screen.h +++ b/user/screen.h @@ -238,10 +238,6 @@ typedef uint8_t Color; // 0-16 void screen_set_fg(Color color); /** Set cursor background coloor */ void screen_set_bg(Color color); -/** Set cursor foreground color, extended */ -void screen_set_fg_ext(u16 color); -/** Set cursor background coloor, extended */ -void screen_set_bg_ext(u16 color); /** Enable/disable attrs by bitmask */ void screen_set_sgr(u8 attrs, bool ena); /** Set the inverse attribute */ @@ -265,6 +261,8 @@ void screen_set_reverse_video(bool reverse); void screen_save_private_opt(int n); /** Restore DECOPT */ void screen_restore_private_opt(int n); +/** Set bracketed paste */ +void screen_set_bracketed_paste(bool ena); // --- Charset --- diff --git a/user/serial.c b/user/serial.c index f2dcae3..4ecb128 100644 --- a/user/serial.c +++ b/user/serial.c @@ -31,7 +31,7 @@ buf_pop(void *unused) lb_ls++; if (lb_ls >= LOGBUF_SIZE) lb_ls = 0; - if (OK == UART_WriteCharCRLF(UART1, logbuf[lb_ls], 1000)) { + if (OK == UART_WriteCharCRLF(UART1, logbuf[lb_ls], 5)) { quantity--; } else { // try another time diff --git a/user/user_main.c b/user/user_main.c index 86bf9c1..5cdb3e0 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -64,12 +64,12 @@ static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg) if (diff == 0) { if (cnt == 5) { // only every 5 secs if no change - dbg("Free heap: %d bytes", heap); + dbg("FH: %d", heap); cnt = 0; } } else { // report change - dbg("Free heap: %d bytes (%s%d)", heap, cc, diff); + dbg("FH: %d (%s%d)", heap, cc, diff); cnt = 0; } @@ -79,13 +79,14 @@ static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg) // Deferred init static void user_start(void *unused); +static void user_start2(void *unused); + +static ETSTimer userStartTimer; +static ETSTimer prHeapTimer; //Main routine. Initialize stdout, the I/O, filesystem and the webserver and we're done. void ICACHE_FLASH_ATTR user_init(void) { - static ETSTimer userStartTimer; - static ETSTimer prHeapTimer; - serialInitBase(); // Prevent WiFi starting and connecting by default @@ -113,17 +114,14 @@ void ICACHE_FLASH_ATTR user_init(void) #if DEBUG_HEAP // Heap use timer & blink - os_timer_disarm(&prHeapTimer); - os_timer_setfn(&prHeapTimer, prHeapTimerCb, NULL); - os_timer_arm(&prHeapTimer, 1000, 1); + TIMER_START(&prHeapTimer, prHeapTimerCb, 1000, 1); #endif // do later (some functions do not work if called from user_init) - os_timer_disarm(&userStartTimer); - os_timer_setfn(&userStartTimer, user_start, NULL); - os_timer_arm(&userStartTimer, 10, 0); + TIMER_START(&userStartTimer, user_start, 10, 0); } + static void ICACHE_FLASH_ATTR user_start(void *unused) { // Load and apply stored settings, or defaults if stored settings are invalid