two hundred and fifty six colors, ladies and gentlemen!!

http-comm
Ondřej Hruška 7 years ago
parent 65d177f149
commit ccbb1886af
  1. 2
      esphttpdconfig.mk
  2. 2
      front-end
  3. 17
      user/apars_csi.c
  4. 3
      user/apars_osc.c
  5. 70
      user/screen.c
  6. 6
      user/screen.h
  7. 2
      user/serial.c
  8. 20
      user/user_main.c

@ -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 \

@ -1 +1 @@
Subproject commit c07a6162f2d89802e68930e0665a9e5a85ac13a9
Subproject commit 810782a7f299272b9ebfe0ae3c5087bc0fe9c59d

@ -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;

@ -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--;

@ -30,8 +30,8 @@ static void utf8_remap(char* out, char g, char charset);
*/
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++) {

@ -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 ---

@ -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

@ -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);
//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;
//Main routine. Initialize stdout, the I/O, filesystem and the webserver and we're done.
void ICACHE_FLASH_ATTR user_init(void)
{
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

Loading…
Cancel
Save