Merge branch 'offscale-bg' into work
This commit is contained in:
+17
-21
@@ -551,31 +551,27 @@ do_csi_sgr(CSI_Data *opts)
|
|||||||
else if (n >= SGR_FG_BRT_START && n <= SGR_FG_BRT_END) screen_set_fg((Color) ((n - SGR_FG_BRT_START) + 8)); // AIX bright fg
|
else if (n >= SGR_FG_BRT_START && n <= SGR_FG_BRT_END) screen_set_fg((Color) ((n - SGR_FG_BRT_START) + 8)); // AIX bright fg
|
||||||
else if (n >= SGR_BG_BRT_START && n <= SGR_BG_BRT_END) screen_set_bg((Color) ((n - SGR_BG_BRT_START) + 8)); // AIX bright bg
|
else if (n >= SGR_BG_BRT_START && n <= SGR_BG_BRT_END) screen_set_bg((Color) ((n - SGR_BG_BRT_START) + 8)); // AIX bright bg
|
||||||
// reset color
|
// reset color
|
||||||
else if (n == SGR_FG_DEFAULT) screen_set_fg(termconf_live.default_fg); // default fg
|
else if (n == SGR_FG_DEFAULT) screen_set_default_fg();
|
||||||
else if (n == SGR_BG_DEFAULT) screen_set_bg(termconf_live.default_bg); // default bg
|
else if (n == SGR_BG_DEFAULT) screen_set_default_bg();
|
||||||
// 256 colors
|
// 256 colors
|
||||||
else if (n == SGR_FG_256 || n == SGR_BG_256) {
|
else if (n == SGR_FG_256 || n == SGR_BG_256) {
|
||||||
if (i < count-2) {
|
if (i >= count-2) {
|
||||||
if (opts->n[i + 1] == 5) {
|
|
||||||
u8 color = (u8) opts->n[i + 2];
|
|
||||||
bool fg = n == SGR_FG_256;
|
|
||||||
if (fg) {
|
|
||||||
screen_set_fg(color);
|
|
||||||
} else {
|
|
||||||
screen_set_bg(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ansi_warn("SGR syntax err");
|
|
||||||
apars_show_context();
|
|
||||||
break; // abandon further
|
|
||||||
}
|
|
||||||
i += 2;
|
|
||||||
} else {
|
|
||||||
ansi_warn("SGR syntax err");
|
ansi_warn("SGR syntax err");
|
||||||
apars_show_context();
|
apars_show_context();
|
||||||
break; // abandon further
|
break; // abandon further
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->n[i + 1] != 5) {
|
||||||
|
ansi_warn("SGR syntax err");
|
||||||
|
apars_show_context();
|
||||||
|
break; // abandon further
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 color = (u8) opts->n[i + 2];
|
||||||
|
bool fg = n == SGR_FG_256;
|
||||||
|
if (fg) screen_set_fg(color);
|
||||||
|
else screen_set_bg(color);
|
||||||
|
i += 2;
|
||||||
}
|
}
|
||||||
// -- set attr --
|
// -- set attr --
|
||||||
else if (n == SGR_BOLD) screen_set_sgr(ATTR_BOLD, 1);
|
else if (n == SGR_BOLD) screen_set_sgr(ATTR_BOLD, 1);
|
||||||
@@ -585,7 +581,7 @@ do_csi_sgr(CSI_Data *opts)
|
|||||||
else if (n == SGR_BLINK || n == SGR_BLINK_FAST) screen_set_sgr(ATTR_BLINK, 1); // 6 - rapid blink, not supported
|
else if (n == SGR_BLINK || n == SGR_BLINK_FAST) screen_set_sgr(ATTR_BLINK, 1); // 6 - rapid blink, not supported
|
||||||
else if (n == SGR_STRIKE) screen_set_sgr(ATTR_STRIKE, 1);
|
else if (n == SGR_STRIKE) screen_set_sgr(ATTR_STRIKE, 1);
|
||||||
else if (n == SGR_FRAKTUR) screen_set_sgr(ATTR_FRAKTUR, 1);
|
else if (n == SGR_FRAKTUR) screen_set_sgr(ATTR_FRAKTUR, 1);
|
||||||
else if (n == SGR_INVERSE) screen_set_sgr_inverse(1);
|
else if (n == SGR_INVERSE) screen_set_sgr(ATTR_INVERSE, 1);
|
||||||
else if (n == SGR_CONCEAL) screen_set_sgr_conceal(1);
|
else if (n == SGR_CONCEAL) screen_set_sgr_conceal(1);
|
||||||
else if (n == SGR_OVERLINE) screen_set_sgr(ATTR_OVERLINE, 1);
|
else if (n == SGR_OVERLINE) screen_set_sgr(ATTR_OVERLINE, 1);
|
||||||
// -- clear attr --
|
// -- clear attr --
|
||||||
@@ -595,7 +591,7 @@ do_csi_sgr(CSI_Data *opts)
|
|||||||
else if (n == SGR_NO_UNDERLINE) screen_set_sgr(ATTR_UNDERLINE, 0);
|
else if (n == SGR_NO_UNDERLINE) screen_set_sgr(ATTR_UNDERLINE, 0);
|
||||||
else if (n == SGR_NO_BLINK) screen_set_sgr(ATTR_BLINK, 0);
|
else if (n == SGR_NO_BLINK) screen_set_sgr(ATTR_BLINK, 0);
|
||||||
else if (n == SGR_NO_STRIKE) screen_set_sgr(ATTR_STRIKE, 0);
|
else if (n == SGR_NO_STRIKE) screen_set_sgr(ATTR_STRIKE, 0);
|
||||||
else if (n == SGR_NO_INVERSE) screen_set_sgr_inverse(0);
|
else if (n == SGR_NO_INVERSE) screen_set_sgr(ATTR_INVERSE, 0);
|
||||||
else if (n == SGR_NO_CONCEAL) screen_set_sgr_conceal(0);
|
else if (n == SGR_NO_CONCEAL) screen_set_sgr_conceal(0);
|
||||||
else if (n == SGR_NO_OVERLINE) screen_set_sgr(ATTR_OVERLINE, 0);
|
else if (n == SGR_NO_OVERLINE) screen_set_sgr(ATTR_OVERLINE, 0);
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -37,6 +37,14 @@ httpd_cgi_state ICACHE_FLASH_ATTR tplScreen(HttpdConnData *connData, char *token
|
|||||||
sprintf(buff, "%d", termconf->want_all_fn);
|
sprintf(buff, "%d", termconf->want_all_fn);
|
||||||
tplSend(connData, buff, -1);
|
tplSend(connData, buff, -1);
|
||||||
}
|
}
|
||||||
|
else if (streq(token, "default_fg")) {
|
||||||
|
sprintf(buff, "%d", termconf->default_fg);
|
||||||
|
tplSend(connData, buff, -1);
|
||||||
|
}
|
||||||
|
else if (streq(token, "default_bg")) {
|
||||||
|
sprintf(buff, "%d", termconf->default_bg);
|
||||||
|
tplSend(connData, buff, -1);
|
||||||
|
}
|
||||||
|
|
||||||
return HTTPD_CGI_DONE;
|
return HTTPD_CGI_DONE;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -86,7 +86,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
|||||||
n = atoi(buff);
|
n = atoi(buff);
|
||||||
if (n >= 0 && n < 16) {
|
if (n >= 0 && n < 16) {
|
||||||
if (termconf->default_bg != n) {
|
if (termconf->default_bg != n) {
|
||||||
termconf->default_bg = (u8) n;
|
termconf->default_bg = n;
|
||||||
shall_clear_screen = true;
|
shall_clear_screen = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -100,7 +100,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
|||||||
n = atoi(buff);
|
n = atoi(buff);
|
||||||
if (n >= 0 && n < 16) {
|
if (n >= 0 && n < 16) {
|
||||||
if (termconf->default_fg != n) {
|
if (termconf->default_fg != n) {
|
||||||
termconf->default_fg = (u8) n;
|
termconf->default_fg = n;
|
||||||
shall_clear_screen = true;
|
shall_clear_screen = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ typedef struct { // the entire block should be 1024 bytes long (for compatibilit
|
|||||||
uint32_t checksum; // computed before write and tested on load. If it doesn't match, values are reset to hard defaults.
|
uint32_t checksum; // computed before write and tested on load. If it doesn't match, values are reset to hard defaults.
|
||||||
} AppConfigBundle;
|
} AppConfigBundle;
|
||||||
|
|
||||||
#define ADMINCONF_VERSION 1
|
#define ADMINCONF_VERSION 0
|
||||||
#define ADMINCONF_SIZE 256
|
#define ADMINCONF_SIZE 256
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
+92
-139
@@ -8,6 +8,7 @@
|
|||||||
#include "jstring.h"
|
#include "jstring.h"
|
||||||
#include "character_sets.h"
|
#include "character_sets.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
|
#include "uart_buffer.h"
|
||||||
|
|
||||||
TerminalConfigBundle * const termconf = &persist.current.termconf;
|
TerminalConfigBundle * const termconf = &persist.current.termconf;
|
||||||
TerminalConfigBundle termconf_live;
|
TerminalConfigBundle termconf_live;
|
||||||
@@ -20,11 +21,6 @@ static void utf8_remap(char* out, char g, char charset);
|
|||||||
#define W termconf_live.width
|
#define W termconf_live.width
|
||||||
#define H termconf_live.height
|
#define H termconf_live.height
|
||||||
|
|
||||||
/**
|
|
||||||
* Highest permissible value of the color attribute
|
|
||||||
*/
|
|
||||||
#define COLOR_MAX 15
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Screen cell data type (16 bits)
|
* Screen cell data type (16 bits)
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +28,7 @@ typedef struct __attribute__((packed)) {
|
|||||||
UnicodeCacheRef symbol : 8;
|
UnicodeCacheRef symbol : 8;
|
||||||
Color fg;
|
Color fg;
|
||||||
Color bg;
|
Color bg;
|
||||||
u8 attrs;
|
CellAttrs attrs;
|
||||||
} Cell;
|
} Cell;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,9 +74,9 @@ typedef struct {
|
|||||||
bool hanging; //!< xenl state - cursor half-wrapped
|
bool hanging; //!< xenl state - cursor half-wrapped
|
||||||
|
|
||||||
/* SGR */
|
/* SGR */
|
||||||
bool inverse; //!< not in attrs bc it's applied server-side (not sent to browser)
|
bool inverse; //!< not in attrs bc it's applied immediately when writing the cell
|
||||||
bool conceal; //!< similar to inverse, causes all to be replaced by SP
|
bool conceal; //!< similar to inverse, causes all to be replaced by SP
|
||||||
u8 attrs;
|
u16 attrs;
|
||||||
Color fg; //!< Foreground color for writing
|
Color fg; //!< Foreground color for writing
|
||||||
Color bg; //!< Background color for writing
|
Color bg; //!< Background color for writing
|
||||||
|
|
||||||
@@ -207,45 +203,12 @@ terminal_apply_settings_noclear(void)
|
|||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
// Migrate to v1
|
// // Migrate to v1
|
||||||
if (termconf->config_version < 1) {
|
// if (termconf->config_version < 1) {
|
||||||
persist_dbg("termconf: Updating to version 1");
|
// persist_dbg("termconf: Updating to version %d", 1);
|
||||||
termconf->display_cooldown_ms = SCR_DEF_DISPLAY_COOLDOWN_MS;
|
// termconf->display_cooldown_ms = SCR_DEF_DISPLAY_COOLDOWN_MS;
|
||||||
changed = 1;
|
// changed = 1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Migrate to v2
|
|
||||||
if (termconf->config_version < 2) {
|
|
||||||
persist_dbg("termconf: Updating to version 2");
|
|
||||||
termconf->loopback = 0;
|
|
||||||
termconf->show_config_links = 1;
|
|
||||||
termconf->show_buttons = 1;
|
|
||||||
changed = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Migrate to v3
|
|
||||||
if (termconf->config_version < 3) {
|
|
||||||
persist_dbg("termconf: Updating to version 3");
|
|
||||||
for(int i=1; i <= TERM_BTN_COUNT; i++) {
|
|
||||||
sprintf(termconf->btn_msg[i-1], "%c", i);
|
|
||||||
}
|
|
||||||
changed = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Migrate to v4
|
|
||||||
if (termconf->config_version < 4) {
|
|
||||||
persist_dbg("termconf: Updating to version 4");
|
|
||||||
termconf->cursor_shape = CURSOR_BLOCK_BL;
|
|
||||||
termconf->crlf_mode = false;
|
|
||||||
changed = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Migrate to v5
|
|
||||||
if (termconf->config_version < 4) {
|
|
||||||
persist_dbg("termconf: Updating to version 5");
|
|
||||||
termconf->want_all_fn = 0;
|
|
||||||
changed = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
termconf->config_version = TERMCONF_VERSION;
|
termconf->config_version = TERMCONF_VERSION;
|
||||||
|
|
||||||
@@ -288,9 +251,9 @@ screen_init(void)
|
|||||||
NOTIFY_LOCK();
|
NOTIFY_LOCK();
|
||||||
Cell sample;
|
Cell sample;
|
||||||
sample.symbol = ' ';
|
sample.symbol = ' ';
|
||||||
sample.fg = termconf->default_fg;
|
sample.fg = 0;
|
||||||
sample.bg = termconf->default_bg;
|
sample.bg = 0;
|
||||||
sample.attrs = 0;
|
sample.attrs = 0; // use default colors
|
||||||
for (unsigned int i = 0; i < MAX_SCREEN_SIZE; i++) {
|
for (unsigned int i = 0; i < MAX_SCREEN_SIZE; i++) {
|
||||||
memcpy(&screen[i], &sample, sizeof(Cell));
|
memcpy(&screen[i], &sample, sizeof(Cell));
|
||||||
}
|
}
|
||||||
@@ -345,10 +308,9 @@ screen_reset_on_resize(void)
|
|||||||
void ICACHE_FLASH_ATTR
|
void ICACHE_FLASH_ATTR
|
||||||
screen_reset_sgr(void)
|
screen_reset_sgr(void)
|
||||||
{
|
{
|
||||||
cursor.fg = termconf->default_fg;
|
cursor.fg = 0;
|
||||||
cursor.bg = termconf->default_bg;
|
cursor.bg = 0;
|
||||||
cursor.attrs = 0;
|
cursor.attrs = 0;
|
||||||
cursor.inverse = false;
|
|
||||||
cursor.conceal = false;
|
cursor.conceal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,14 +550,13 @@ static void ICACHE_FLASH_ATTR
|
|||||||
clear_range(unsigned int from, unsigned int to)
|
clear_range(unsigned int from, unsigned int to)
|
||||||
{
|
{
|
||||||
if (to >= W*H) to = W*H-1;
|
if (to >= W*H) to = W*H-1;
|
||||||
Color fg = (cursor.inverse) ? cursor.bg : cursor.fg;
|
|
||||||
Color bg = (cursor.inverse) ? cursor.fg : cursor.bg;
|
|
||||||
|
|
||||||
Cell sample;
|
Cell sample;
|
||||||
sample.symbol = ' ';
|
sample.symbol = ' ';
|
||||||
sample.fg = fg;
|
sample.fg = cursor.fg;
|
||||||
sample.bg = bg;
|
sample.bg = cursor.bg;
|
||||||
sample.attrs = 0;
|
// we discard all attributes except color-set flags
|
||||||
|
sample.attrs = (CellAttrs) (cursor.attrs & (ATTR_FG | ATTR_BG));
|
||||||
|
|
||||||
for (unsigned int i = from; i <= to; i++) {
|
for (unsigned int i = from; i <= to; i++) {
|
||||||
UnicodeCacheRef symbol = screen[i].symbol;
|
UnicodeCacheRef symbol = screen[i].symbol;
|
||||||
@@ -771,8 +732,8 @@ screen_fill_with_E(void)
|
|||||||
|
|
||||||
Cell sample;
|
Cell sample;
|
||||||
sample.symbol = 'E';
|
sample.symbol = 'E';
|
||||||
sample.fg = termconf->default_fg;
|
sample.fg = 0;
|
||||||
sample.bg = termconf->default_bg;
|
sample.bg = 0;
|
||||||
sample.attrs = 0;
|
sample.attrs = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i <= W*H-1; i++) {
|
for (unsigned int i = 0; i <= W*H-1; i++) {
|
||||||
@@ -1174,6 +1135,7 @@ void ICACHE_FLASH_ATTR
|
|||||||
screen_set_fg(Color color)
|
screen_set_fg(Color color)
|
||||||
{
|
{
|
||||||
cursor.fg = color;
|
cursor.fg = color;
|
||||||
|
cursor.attrs |= ATTR_FG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1183,10 +1145,31 @@ void ICACHE_FLASH_ATTR
|
|||||||
screen_set_bg(Color color)
|
screen_set_bg(Color color)
|
||||||
{
|
{
|
||||||
cursor.bg = color;
|
cursor.bg = color;
|
||||||
|
cursor.attrs |= ATTR_BG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set cursor foreground color to default
|
||||||
|
*/
|
||||||
|
void ICACHE_FLASH_ATTR
|
||||||
|
screen_set_default_fg(void)
|
||||||
|
{
|
||||||
|
cursor.fg = 0;
|
||||||
|
cursor.attrs &= ~ATTR_FG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set cursor background color to default
|
||||||
|
*/
|
||||||
|
void ICACHE_FLASH_ATTR
|
||||||
|
screen_set_default_bg(void)
|
||||||
|
{
|
||||||
|
cursor.bg = 0;
|
||||||
|
cursor.attrs &= ~ATTR_BG;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR
|
void ICACHE_FLASH_ATTR
|
||||||
screen_set_sgr(u8 attrs, bool ena)
|
screen_set_sgr(CellAttrs attrs, bool ena)
|
||||||
{
|
{
|
||||||
if (ena) {
|
if (ena) {
|
||||||
cursor.attrs |= attrs;
|
cursor.attrs |= attrs;
|
||||||
@@ -1196,12 +1179,6 @@ screen_set_sgr(u8 attrs, bool ena)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR
|
|
||||||
screen_set_sgr_inverse(bool ena)
|
|
||||||
{
|
|
||||||
cursor.inverse = ena;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR
|
void ICACHE_FLASH_ATTR
|
||||||
screen_set_sgr_conceal(bool ena)
|
screen_set_sgr_conceal(bool ena)
|
||||||
{
|
{
|
||||||
@@ -1359,9 +1336,11 @@ screen_report_sgr(char *buffer)
|
|||||||
if (cursor.attrs & ATTR_BLINK) buffer += sprintf(buffer, ";%d", SGR_BLINK);
|
if (cursor.attrs & ATTR_BLINK) buffer += sprintf(buffer, ";%d", SGR_BLINK);
|
||||||
if (cursor.attrs & ATTR_FRAKTUR) buffer += sprintf(buffer, ";%d", SGR_FRAKTUR);
|
if (cursor.attrs & ATTR_FRAKTUR) buffer += sprintf(buffer, ";%d", SGR_FRAKTUR);
|
||||||
if (cursor.attrs & ATTR_STRIKE) buffer += sprintf(buffer, ";%d", SGR_STRIKE);
|
if (cursor.attrs & ATTR_STRIKE) buffer += sprintf(buffer, ";%d", SGR_STRIKE);
|
||||||
if (cursor.inverse) buffer += sprintf(buffer, ";%d", SGR_INVERSE);
|
if (cursor.attrs & ATTR_INVERSE) buffer += sprintf(buffer, ";%d", SGR_INVERSE);
|
||||||
if (cursor.fg != termconf->default_fg) buffer += sprintf(buffer, ";%d", ((cursor.fg > 7) ? SGR_FG_BRT_START : SGR_FG_START) + (cursor.fg&7));
|
if (cursor.attrs & ATTR_FG)
|
||||||
if (cursor.bg != termconf->default_bg) buffer += sprintf(buffer, ";%d", ((cursor.bg > 7) ? SGR_BG_BRT_START : SGR_BG_START) + (cursor.bg&7));
|
buffer += sprintf(buffer, ";%d", ((cursor.fg > 7) ? SGR_FG_BRT_START : SGR_FG_START) + (cursor.fg&7));
|
||||||
|
if (cursor.attrs & ATTR_BG)
|
||||||
|
buffer += sprintf(buffer, ";%d", ((cursor.bg > 7) ? SGR_BG_BRT_START : SGR_BG_START) + (cursor.bg&7));
|
||||||
(void)buffer;
|
(void)buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1403,14 +1382,8 @@ putchar_graphic(const char *ch)
|
|||||||
}
|
}
|
||||||
unicode_cache_remove(c->symbol);
|
unicode_cache_remove(c->symbol);
|
||||||
c->symbol = unicode_cache_add((const u8 *)ch);
|
c->symbol = unicode_cache_add((const u8 *)ch);
|
||||||
|
c->fg = cursor.fg;
|
||||||
if (cursor.inverse) {
|
c->bg = cursor.bg;
|
||||||
c->fg = cursor.bg;
|
|
||||||
c->bg = cursor.fg;
|
|
||||||
} else {
|
|
||||||
c->fg = cursor.fg;
|
|
||||||
c->bg = cursor.bg;
|
|
||||||
}
|
|
||||||
c->attrs = cursor.attrs;
|
c->attrs = cursor.attrs;
|
||||||
|
|
||||||
cursor.x++;
|
cursor.x++;
|
||||||
@@ -1543,7 +1516,7 @@ utf8_remap(char *out, char g, char charset)
|
|||||||
struct ScreenSerializeState {
|
struct ScreenSerializeState {
|
||||||
Color lastFg;
|
Color lastFg;
|
||||||
Color lastBg;
|
Color lastBg;
|
||||||
bool lastAttrs;
|
CellAttrs lastAttrs;
|
||||||
UnicodeCacheRef lastSymbol;
|
UnicodeCacheRef lastSymbol;
|
||||||
char lastChar[4];
|
char lastChar[4];
|
||||||
u8 lastCharLen;
|
u8 lastCharLen;
|
||||||
@@ -1593,58 +1566,46 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Cell *cell, *cell0;
|
Cell *cell, *cell0;
|
||||||
WordB2 w1;
|
|
||||||
WordB3 lw1;
|
|
||||||
|
|
||||||
|
u8 nbytes;
|
||||||
size_t remain = buf_len;
|
size_t remain = buf_len;
|
||||||
char *bb = buffer;
|
char *bb = buffer;
|
||||||
|
|
||||||
#define bufput_c(c) do { \
|
#define bufput_c(c) do { \
|
||||||
*bb = (char)c; bb++; \
|
*bb = (char)(c); \
|
||||||
|
bb++; \
|
||||||
remain--; \
|
remain--; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define bufput_2B(n) do { \
|
#define bufput_utf8(num) do { \
|
||||||
encode2B((u16) n, &w1); \
|
nbytes = utf8_encode(bb, (num)+1); \
|
||||||
bufput_c(w1.lsb); \
|
bb += nbytes; \
|
||||||
bufput_c(w1.msb); \
|
remain -= nbytes; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define bufput_3B(n) do { \
|
#define bufput_t_utf8(t, num) do { \
|
||||||
encode3B((u32) n, &lw1); \
|
bufput_c((t)); \
|
||||||
bufput_c(lw1.lsb); \
|
bufput_utf8((num)); \
|
||||||
bufput_c(lw1.msb); \
|
} while(0)
|
||||||
bufput_c(lw1.xsb); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#define bufput_t2B(t, n) do { \
|
|
||||||
bufput_c(t); \
|
|
||||||
bufput_2B(n); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#define bufput_t3B(t, n) do { \
|
|
||||||
bufput_c(t); \
|
|
||||||
bufput_3B(n); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
if (ss == NULL) {
|
if (ss == NULL) {
|
||||||
*data = ss = malloc(sizeof(struct ScreenSerializeState));
|
*data = ss = malloc(sizeof(struct ScreenSerializeState));
|
||||||
ss->index = 0;
|
ss->index = 0;
|
||||||
ss->lastBg = 0;
|
ss->lastBg = 0xFF;
|
||||||
ss->lastFg = 0;
|
ss->lastFg = 0xFF;
|
||||||
ss->lastAttrs = 0;
|
ss->lastAttrs = 0xFFFF;
|
||||||
ss->lastCharLen = 0;
|
ss->lastCharLen = 0;
|
||||||
ss->lastSymbol = 32;
|
ss->lastSymbol = 0;
|
||||||
strncpy(ss->lastChar, " ", 4);
|
strncpy(ss->lastChar, " ", 4);
|
||||||
|
|
||||||
bufput_c('S');
|
bufput_c('S');
|
||||||
// H W X Y Attribs
|
// H W X Y Attribs
|
||||||
bufput_2B(H);
|
bufput_utf8(H);
|
||||||
bufput_2B(W);
|
bufput_utf8(W);
|
||||||
bufput_2B(cursor.y);
|
bufput_utf8(cursor.y);
|
||||||
bufput_2B(cursor.x);
|
bufput_utf8(cursor.x);
|
||||||
// 3B has 18 free bits
|
// 3B has 18 free bits
|
||||||
bufput_3B(
|
bufput_utf8(
|
||||||
(scr.cursor_visible << 0) |
|
(scr.cursor_visible << 0) |
|
||||||
(cursor.hanging << 1) |
|
(cursor.hanging << 1) |
|
||||||
(scr.cursors_alt_mode << 2) |
|
(scr.cursors_alt_mode << 2) |
|
||||||
@@ -1656,7 +1617,8 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
|
|||||||
(termconf_live.show_config_links << 8) |
|
(termconf_live.show_config_links << 8) |
|
||||||
((termconf_live.cursor_shape&0x07) << 9) | // 9,10,11 - cursor shape based on DECSCUSR
|
((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)
|
(scr.bracketed_paste << 13) |
|
||||||
|
(scr.reverse_video << 14)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1683,7 +1645,7 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (repCnt == 0) {
|
if (repCnt == 0) {
|
||||||
// No repeat
|
// No repeat - first occurrence
|
||||||
bool changeAttrs = cell0->attrs != ss->lastAttrs;
|
bool changeAttrs = cell0->attrs != ss->lastAttrs;
|
||||||
bool changeFg = cell0->fg != ss->lastFg;
|
bool changeFg = cell0->fg != ss->lastFg;
|
||||||
bool changeBg = cell0->bg != ss->lastBg;
|
bool changeBg = cell0->bg != ss->lastBg;
|
||||||
@@ -1691,27 +1653,21 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
|
|||||||
Color fg, bg;
|
Color fg, bg;
|
||||||
|
|
||||||
// Reverse fg and bg if we're in global reverse mode
|
// Reverse fg and bg if we're in global reverse mode
|
||||||
if (! scr.reverse_video) {
|
fg = cell0->fg;
|
||||||
fg = cell0->fg;
|
bg = cell0->bg;
|
||||||
bg = cell0->bg;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fg = cell0->bg;
|
|
||||||
bg = cell0->fg;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changeColors) {
|
if (changeColors) {
|
||||||
bufput_t3B(SEQ_TAG_COLORS, bg<<8 | fg);
|
bufput_t_utf8(SEQ_TAG_COLORS, bg<<8 | fg);
|
||||||
}
|
}
|
||||||
else if (changeFg) {
|
else if (changeFg) {
|
||||||
bufput_t2B(SEQ_TAG_FG, fg);
|
bufput_t_utf8(SEQ_TAG_FG, fg);
|
||||||
}
|
}
|
||||||
else if (changeBg) {
|
else if (changeBg) {
|
||||||
bufput_t2B(SEQ_TAG_BG, bg);
|
bufput_t_utf8(SEQ_TAG_BG, bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changeAttrs) {
|
if (changeAttrs) {
|
||||||
bufput_t2B(SEQ_TAG_ATTRS, cell0->attrs);
|
bufput_t_utf8(SEQ_TAG_ATTRS, cell0->attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy the symbol, until first 0 or reached 4 bytes
|
// copy the symbol, until first 0 or reached 4 bytes
|
||||||
@@ -1733,24 +1689,21 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
|
|||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
// last character was repeated repCnt times
|
// last character was repeated repCnt times
|
||||||
int savings = ss->lastCharLen*repCnt;
|
bufput_t_utf8(SEQ_TAG_REPEAT, repCnt);
|
||||||
if (savings > 3) {
|
|
||||||
// Repeat count
|
|
||||||
bufput_t2B(SEQ_TAG_REPEAT, repCnt);
|
|
||||||
} else {
|
|
||||||
// repeat it manually
|
|
||||||
for(int k = 0; k < repCnt; k++) {
|
|
||||||
for (int j = 0; j < ss->lastCharLen; j++) {
|
|
||||||
bufput_c(ss->lastChar[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ss->index = i;
|
ss->index = i;
|
||||||
bufput_c('\0'); // terminate the string
|
bufput_c('\0'); // terminate the string
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
printf("MSG: ");
|
||||||
|
for (int j=0;j<bb-buffer;j++) {
|
||||||
|
printf("%02X ", buffer[j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (i < W*H-1) {
|
if (i < W*H-1) {
|
||||||
return HTTPD_CGI_MORE;
|
return HTTPD_CGI_MORE;
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-15
@@ -37,7 +37,7 @@
|
|||||||
// Size designed for the terminal config structure
|
// Size designed for the terminal config structure
|
||||||
// Must be constant to avoid corrupting user config after upgrade
|
// Must be constant to avoid corrupting user config after upgrade
|
||||||
#define TERMCONF_SIZE 300
|
#define TERMCONF_SIZE 300
|
||||||
#define TERMCONF_VERSION 5
|
#define TERMCONF_VERSION 0
|
||||||
|
|
||||||
#define TERM_BTN_LEN 10
|
#define TERM_BTN_LEN 10
|
||||||
#define TERM_BTN_MSG_LEN 10
|
#define TERM_BTN_MSG_LEN 10
|
||||||
@@ -77,8 +77,8 @@ enum CursorShape {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
u32 width;
|
u32 width;
|
||||||
u32 height;
|
u32 height;
|
||||||
u8 default_bg; // should be the Color typedef, but this way the size is more explicit
|
u32 default_bg; // 00-FFh - ANSI colors, (00:00:00-FF:FF:FF)+256 - True Color
|
||||||
u8 default_fg;
|
u32 default_fg;
|
||||||
char title[TERM_TITLE_LEN];
|
char title[TERM_TITLE_LEN];
|
||||||
char btn[TERM_BTN_COUNT][TERM_BTN_LEN];
|
char btn[TERM_BTN_COUNT][TERM_BTN_LEN];
|
||||||
u8 theme;
|
u8 theme;
|
||||||
@@ -228,25 +228,32 @@ void screen_set_origin_mode(bool region_origin);
|
|||||||
|
|
||||||
// --- Graphic rendition setting ---
|
// --- Graphic rendition setting ---
|
||||||
|
|
||||||
typedef uint8_t Color; // 0-16
|
typedef uint8_t Color;
|
||||||
|
typedef uint16_t CellAttrs;
|
||||||
|
|
||||||
#define ATTR_BOLD (1<<0)
|
// TODO sort by the expected frequency of being set - so when we switch to utf-8 encoding for data fields, it uses fewer bytes
|
||||||
#define ATTR_FAINT (1<<1)
|
#define ATTR_BOLD (1<<0) //!< Bold font
|
||||||
#define ATTR_ITALIC (1<<2)
|
#define ATTR_FAINT (1<<1) //!< Faint foreground color (reduced alpha)
|
||||||
#define ATTR_UNDERLINE (1<<3)
|
#define ATTR_ITALIC (1<<2) //!< Italic font
|
||||||
#define ATTR_BLINK (1<<4)
|
#define ATTR_UNDERLINE (1<<3) //!< Underline decoration
|
||||||
#define ATTR_FRAKTUR (1<<5)
|
#define ATTR_BLINK (1<<4) //!< Blinking
|
||||||
#define ATTR_STRIKE (1<<6)
|
#define ATTR_FRAKTUR (1<<5) //!< Fraktur font (unicode substitution)
|
||||||
#define ATTR_OVERLINE (1<<7)
|
#define ATTR_STRIKE (1<<6) //!< Strike-through decoration
|
||||||
|
#define ATTR_OVERLINE (1<<7) //!< Over-line decoration
|
||||||
|
#define ATTR_FG (1<<8) //!< 1 if not using default background color (ignore cell bg) - color extension bit
|
||||||
|
#define ATTR_BG (1<<9) //!< 1 if not using default foreground color (ignore cell fg) - color extension bit
|
||||||
|
#define ATTR_INVERSE (1<<10) //!< Invert colors - this is useful so we can clear then with SGR manipulation commands
|
||||||
|
|
||||||
/** Set cursor foreground color */
|
/** Set cursor foreground color */
|
||||||
void screen_set_fg(Color color);
|
void screen_set_fg(Color color);
|
||||||
/** Set cursor background coloor */
|
/** Set cursor background coloor */
|
||||||
void screen_set_bg(Color color);
|
void screen_set_bg(Color color);
|
||||||
|
/** Set cursor foreground color to default */
|
||||||
|
void screen_set_default_fg(void);
|
||||||
|
/** Set cursor background color to default */
|
||||||
|
void screen_set_default_bg(void);
|
||||||
/** Enable/disable attrs by bitmask */
|
/** Enable/disable attrs by bitmask */
|
||||||
void screen_set_sgr(u8 attrs, bool ena);
|
void screen_set_sgr(CellAttrs attrs, bool ena);
|
||||||
/** Set the inverse attribute */
|
|
||||||
void screen_set_sgr_inverse(bool ena);
|
|
||||||
/** Conceal style */
|
/** Conceal style */
|
||||||
void screen_set_sgr_conceal(bool ena);
|
void screen_set_sgr_conceal(bool ena);
|
||||||
/** Reset cursor attribs */
|
/** Reset cursor attribs */
|
||||||
|
|||||||
+6
-13
@@ -13,19 +13,10 @@ void ICACHE_FLASH_ATTR
|
|||||||
sysconf_apply_settings(void)
|
sysconf_apply_settings(void)
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (sysconf->config_version < 1) {
|
// if (sysconf->config_version < 1) {
|
||||||
dbg("Upgrading syscfg to v 1");
|
// dbg("Upgrading syscfg to v 1");
|
||||||
sysconf->access_pw[0] = 0;
|
// changed = true;
|
||||||
sysconf->pwlock = PWLOCK_NONE;
|
// }
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sysconf->config_version < 2) {
|
|
||||||
dbg("Upgrading syscfg to v 2");
|
|
||||||
strcpy(sysconf->access_pw, DEF_ACCESS_PW);
|
|
||||||
strcpy(sysconf->access_name, DEF_ACCESS_NAME);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sysconf->config_version = SYSCONF_VERSION;
|
sysconf->config_version = SYSCONF_VERSION;
|
||||||
|
|
||||||
@@ -45,4 +36,6 @@ sysconf_restore_defaults(void)
|
|||||||
sysconf->config_version = SYSCONF_VERSION;
|
sysconf->config_version = SYSCONF_VERSION;
|
||||||
sysconf->access_pw[0] = 0;
|
sysconf->access_pw[0] = 0;
|
||||||
sysconf->pwlock = PWLOCK_NONE;
|
sysconf->pwlock = PWLOCK_NONE;
|
||||||
|
strcpy(sysconf->access_pw, DEF_ACCESS_PW);
|
||||||
|
strcpy(sysconf->access_name, DEF_ACCESS_NAME);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
// Size designed for the wifi config structure
|
// Size designed for the wifi config structure
|
||||||
// Must be constant to avoid corrupting user config after upgrade
|
// Must be constant to avoid corrupting user config after upgrade
|
||||||
#define SYSCONF_SIZE 300
|
#define SYSCONF_SIZE 300
|
||||||
#define SYSCONF_VERSION 2
|
#define SYSCONF_VERSION 0
|
||||||
|
|
||||||
#define DEF_ACCESS_PW "1234"
|
#define DEF_ACCESS_PW "1234"
|
||||||
#define DEF_ACCESS_NAME "espterm"
|
#define DEF_ACCESS_NAME "espterm"
|
||||||
|
|||||||
Reference in New Issue
Block a user