Compare commits

...
3 Commits
5 changed files with 62 additions and 32 deletions
+9 -3
View File
@@ -424,8 +424,14 @@ static void ICACHE_FLASH_ATTR do_csi_privattr(CSI_Data *opts)
screen_set_charset(1, 'B');
}
else if (n == 3) {
// 132 column mode - not implemented due to RAM demands
ansi_noimpl("80->132");
// DECCOLM 132 column mode - not implemented due to RAM demands
ansi_noimpl("132col");
// DECCOLM side effects as per
// https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/deccolm-cls.html
screen_clear(CLEAR_ALL);
screen_set_scrolling_region(0, 0);
screen_cursor_set(0, 0);
}
else if (n == 4) {
// Smooth scroll - not implemented
@@ -463,7 +469,7 @@ static void ICACHE_FLASH_ATTR do_csi_privattr(CSI_Data *opts)
else if (n == 40) {
// allow/disallow 80->132 mode
// not implemented because of RAM demands
ansi_noimpl("80->132 enable");
ansi_noimpl("132col enable");
}
else if (n == 45) {
// reverse wrap-around
+8 -4
View File
@@ -8,6 +8,8 @@
#include "uart_buffer.h"
#include "ansi_parser.h"
#define LOOPBACK 0
#define SOCK_BUF_LEN 1024
static char sock_buff[SOCK_BUF_LEN];
@@ -128,11 +130,13 @@ void ICACHE_FLASH_ATTR updateSockRx(Websock *ws, char *data, int len, int flags)
if (strstarts(data, "STR:")) {
// pass string verbatim
#if LOOPBACK
for(int i=4;i<strlen(data); i++) {
ansi_parser(data[i]);
}
#else
UART_SendAsync(data+4, -1);
// debug loopback
// for(int i=4;i<strlen(data); i++) {
// ansi_parser(data[i]);
// }
#endif
}
else if (strstarts(data, "BTN:")) {
// send button as low ASCII value 1-9
+37 -24
View File
@@ -4,12 +4,13 @@
#include "persist.h"
#include "sgr.h"
#include "ascii.h"
#include "apars_logging.h"
TerminalConfigBundle * const termconf = &persist.current.termconf;
TerminalConfigBundle termconf_scratch;
// forward declare
static void utf8_remap(char* out, char g, char table);
static void utf8_remap(char* out, char g, char charset);
#define W termconf_scratch.width
#define H termconf_scratch.height
@@ -54,9 +55,6 @@ static struct {
// Vertical margin bounds (inclusive start/end of scrolling region)
int vm0;
int vm1;
char charset0;
char charset1;
} scr;
#define R0 scr.vm0
@@ -76,6 +74,8 @@ typedef struct {
// Other attribs
int charsetN;
char charset0;
char charset1;
bool wraparound; //!< Wrapping when EOL
bool origin_mode; // DECOM - absolute positioning is relative to vertical margins
bool selective_erase; // TODO implement
@@ -94,6 +94,7 @@ static CursorTypeDef cursor;
* Saved cursor position, used with the SCP RCP commands
*/
static CursorTypeDef cursor_sav;
bool cursor_saved = false;
/**
* This is used to prevent premature change notifications
@@ -214,6 +215,8 @@ cursor_reset(void)
cursor.origin_mode = false;
cursor.charsetN = 0;
cursor.charset0 = CS_USASCII;
cursor.charset1 = CS_DEC_SUPPLEMENTAL;
cursor.wraparound = true;
screen_reset_sgr();
@@ -246,9 +249,6 @@ screen_reset(void)
scr.newline_mode = false;
scr.reverse = false;
scr.charset0 = 'B';
scr.charset1 = '0';
scr.vm0 = 0;
scr.vm1 = H-1;
@@ -646,7 +646,7 @@ screen_scroll_up(unsigned int lines)
memcpy(screen + y * W, screen + (y + lines) * W, W * sizeof(Cell));
}
clear_range(R0 * W+y * W, (R1+1)*W-1);
clear_range(y * W, (R1+1)*W-1);
done:
NOTIFY_DONE();
@@ -683,7 +683,7 @@ screen_scroll_down(unsigned int lines)
void ICACHE_FLASH_ATTR
screen_set_scrolling_region(int from, int to)
{
if (from == 0 && to == 0) {
if (from <= 0 && to <= 0) {
scr.vm0 = 0;
scr.vm1 = H-1;
} else if (from >= 0 && from < H-1 && to > from) {
@@ -691,6 +691,7 @@ screen_set_scrolling_region(int from, int to)
scr.vm1 = to;
} else {
// Bad range, do nothing
ansi_warn("Bad SR bounds %d, %d", from, to);
}
// Always move cursor home (may be translated due to DECOM)
@@ -832,6 +833,7 @@ screen_cursor_save(bool withAttrs)
{
// always save with attribs
memcpy(&cursor_sav, &cursor, sizeof(CursorTypeDef));
cursor_saved = true;
}
/**
@@ -842,12 +844,18 @@ screen_cursor_restore(bool withAttrs)
{
NOTIFY_LOCK();
if (withAttrs) {
memcpy(&cursor_sav, &cursor, sizeof(CursorTypeDef));
} else {
cursor.x = cursor_sav.x;
cursor.y = cursor_sav.y;
cursor.hanging = cursor_sav.hanging;
if (!cursor_saved) {
cursor_reset();
}
else {
if (withAttrs) {
memcpy(&cursor, &cursor_sav, sizeof(CursorTypeDef));
}
else {
cursor.x = cursor_sav.x;
cursor.y = cursor_sav.y;
cursor.hanging = cursor_sav.hanging;
}
}
NOTIFY_DONE();
@@ -936,8 +944,8 @@ screen_set_charset_n(int Gx)
void ICACHE_FLASH_ATTR
screen_set_charset(int Gx, char charset)
{
if (Gx == 0) scr.charset0 = charset;
else if (Gx == 1) scr.charset1 = charset;
if (Gx == 0) cursor.charset0 = charset;
else if (Gx == 1) cursor.charset1 = charset;
}
void ICACHE_FLASH_ATTR
@@ -1071,7 +1079,7 @@ screen_putchar(const char *ch)
if (ch[1] == 0 && ch[0] <= 0x7f) {
// we have len=1 and ASCII
utf8_remap(c->c, ch[0], (cursor.charsetN == 0) ? scr.charset0 : scr.charset1);
utf8_remap(c->c, ch[0], (cursor.charsetN == 0) ? cursor.charset0 : cursor.charset1);
}
else {
// copy unicode char
@@ -1239,32 +1247,37 @@ static const u16 codepage_1[] =
* UTF remap
* @param out - output char[4]
* @param g - ASCII char
* @param table - table name (0, A, B)
* @param charset - table name (0, A, B)
*/
static void ICACHE_FLASH_ATTR
utf8_remap(char *out, char g, char table)
utf8_remap(char *out, char g, char charset)
{
u16 n;
u16 utf = (unsigned char)g;
switch (table) {
case '0': /* DEC Special Character & Line Drawing Set */
switch (charset) {
case CS_DEC_SUPPLEMENTAL: /* DEC Special Character & Line Drawing Set */
if ((g >= 96) && (g < 0x7F)) {
n = codepage_0[g - 96];
if (n) utf = n;
}
break;
case '1': /* ESPTerm Character Rom 1 */
case CS_DOS_437: /* ESPTerm Character Rom 1 */
if ((g >= 33) && (g < 0x7F)) {
n = codepage_1[g - 33];
if (n) utf = n;
}
break;
case 'A': /* UK, replaces # with GBP */
case CS_UKASCII: /* UK, replaces # with GBP */
if (g == '#') utf = 0x20a4;
break;
default:
case CS_USASCII:
// No change
break;
}
// Encode to UTF-8
+7
View File
@@ -108,6 +108,13 @@ typedef struct {
u8 xsb;
} WordB3;
typedef enum {
CS_USASCII = 'B',
CS_UKASCII = 'A',
CS_DEC_SUPPLEMENTAL = '0',
CS_DOS_437 = '1',
} CHARSET;
/** Encode number to two nice ASCII bytes */
void encode2B(u16 number, WordB2 *stru);
+1 -1
View File
@@ -7,7 +7,7 @@
#define FW_V_MAJOR 0
#define FW_V_MINOR 6
#define FW_V_PATCH 8
#define FW_V_PATCH 9
#define FIRMWARE_VERSION STR(FW_V_MAJOR) "." STR(FW_V_MINOR) "." STR(FW_V_PATCH) "+" GIT_HASH
#define FIRMWARE_VERSION_NUM (FW_V_MAJOR*10000 + FW_V_MINOR*100 + FW_V_PATCH) // this is used in ID queries