implemented numpad alt mode, fn keys alt mode and cursor alt mode

This commit is contained in:
2017-08-18 14:19:54 +02:00
parent 8117229926
commit 9cac029e58
7 changed files with 312 additions and 134 deletions
+3 -2
View File
@@ -74,18 +74,19 @@ void ICACHE_FLASH_ATTR screen_notifyChange(ScreenNotifyChangeTopic topic)
{
// this is not the most ideal/cleanest implementation
// PRs are welcome for a nicer update "queue" solution
if (termconf->display_tout_ms == 0) termconf->display_tout_ms = SCR_DEF_DISPLAY_TOUT_MS;
if (topic == CHANGE_LABELS) {
// separate timer from content change timer, to avoid losing that update
os_timer_disarm(&notifyTim2);
os_timer_setfn(&notifyTim2, notifyLabelsTimCb, NULL);
os_timer_arm(&notifyTim2, SCREEN_NOTIFY_DELAY_MS, 0);
os_timer_arm(&notifyTim2, termconf->display_tout_ms, 0);
}
else if (topic == CHANGE_CONTENT) {
// throttle delay
os_timer_disarm(&notifyTim);
os_timer_setfn(&notifyTim, notifyTimCb, NULL);
os_timer_arm(&notifyTim, SCREEN_NOTIFY_DELAY_MS, 0);
os_timer_arm(&notifyTim, termconf->display_tout_ms, 0);
}
}
+25 -2
View File
@@ -20,7 +20,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
{
char buff[50];
char redir_url_buf[100];
int n, w, h;
int32 n, w, h;
bool shall_clear_screen = false;
@@ -85,13 +85,30 @@ cgiTermCfgSetParams(HttpdConnData *connData)
dbg("Parser timeout: %s ms", buff);
n = atoi(buff);
if (n >= 0) {
termconf->parser_tout_ms = (u8) n;
termconf->parser_tout_ms = n;
} else {
warn("Bad timeout %s", buff);
redir_url += sprintf(redir_url, "parser_tout_ms,");
}
}
if (GET_ARG("display_tout_ms")) {
dbg("Display update idle timeout: %s ms", buff);
n = atoi(buff);
if (n >= 0) {
termconf->display_tout_ms = n;
} else {
warn("Bad timeout %s", buff);
redir_url += sprintf(redir_url, "display_tout_ms,");
}
}
if (GET_ARG("fn_alt_mode")) {
dbg("FN alt mode: %s", buff);
n = atoi(buff);
termconf->fn_alt_mode = (bool)n;
}
if (GET_ARG("default_fg")) {
dbg("Screen default FG: %s", buff);
n = atoi(buff);
@@ -175,6 +192,12 @@ tplTermCfg(HttpdConnData *connData, char *token, void **arg)
else if (streq(token, "parser_tout_ms")) {
sprintf(buff, "%d", termconf->parser_tout_ms);
}
else if (streq(token, "display_tout_ms")) {
sprintf(buff, "%d", termconf->display_tout_ms);
}
else if (streq(token, "fn_alt_mode")) {
sprintf(buff, "%d", (int)termconf->fn_alt_mode);
}
else if (streq(token, "theme")) {
sprintf(buff, "%d", termconf->theme);
}
+17 -8
View File
@@ -102,10 +102,12 @@ void terminal_restore_defaults(void)
{
termconf->default_bg = 0;
termconf->default_fg = 7;
termconf->width = 26;
termconf->height = 10;
termconf->parser_tout_ms = 10;
sprintf(termconf->title, "ESPTerm");
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;
sprintf(termconf->title, SCR_DEF_TITLE);
for(int i=1; i <= 5; i++) {
sprintf(termconf->btn[i-1], "%d", i);
}
@@ -123,6 +125,8 @@ void terminal_apply_settings(void)
/** this is used when changing terminal settings that do not affect the screen size */
void terminal_apply_settings_noclear(void)
{
if (termconf->display_tout_ms == 0) termconf->display_tout_ms = SCR_DEF_DISPLAY_TOUT_MS;
memcpy(&termconf_scratch, termconf, sizeof(TerminalConfigBundle));
if (W*H >= MAX_SCREEN_SIZE) {
error("BAD SCREEN SIZE: %d rows x %d cols", H, W);
@@ -685,13 +689,17 @@ screen_set_insert_mode(bool insert)
void ICACHE_FLASH_ATTR
screen_set_numpad_alt_mode(bool alt_mode)
{
NOTIFY_LOCK();
scr.numpad_alt_mode = alt_mode;
NOTIFY_DONE();
}
void ICACHE_FLASH_ATTR
screen_set_cursors_alt_mode(bool alt_mode)
{
NOTIFY_LOCK();
scr.cursors_alt_mode = alt_mode;
NOTIFY_DONE();
}
//endregion
@@ -990,10 +998,11 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
encode2B((u16) (
cursor.fg |
(cursor.bg<<4) |
(cursor.visible ? 1<<8 : 0) |
(cursor.hanging ? 1<<9 : 0) |
(scr.cursors_alt_mode ? 1<<10 : 0) |
(scr.numpad_alt_mode ? 1<<11 : 0)
(cursor.visible ? 0x100 : 0) |
(cursor.hanging ? 0x200 : 0) |
(scr.cursors_alt_mode ? 0x400 : 0) |
(scr.numpad_alt_mode ? 0x800 : 0) |
(termconf->fn_alt_mode ? 0x1000 : 0)
)
, &w5);
+13 -4
View File
@@ -34,7 +34,7 @@
*
*/
// Size designed for the wifi config structure
// Size designed for the terminal config structure
// Must be constant to avoid corrupting user config after upgrade
#define TERMCONF_SIZE 200
@@ -54,7 +54,16 @@ typedef enum {
#define ATTR_FRAKTUR (1<<5)
#define ATTR_STRIKE (1<<6)
#define SCREEN_NOTIFY_DELAY_MS 20
#define SCR_DEF_DISPLAY_TOUT_MS 20
#define SCR_DEF_PARSER_TOUT_MS 10
#define SCR_DEF_FN_ALT_MODE false
#define SCR_DEF_WIDTH 26
#define SCR_DEF_HEIGHT 10
#define SCR_DEF_TITLE "ESPTerm"
/** Maximum screen size (determines size of the static data array) */
#define MAX_SCREEN_SIZE (80*30)
typedef struct {
u32 width;
@@ -65,6 +74,8 @@ typedef struct {
char btn[5][TERM_BTN_LEN];
u8 theme;
u32 parser_tout_ms;
u32 display_tout_ms;
bool fn_alt_mode; // xterm compatibility mode (alternate codes for some FN keys)
} TerminalConfigBundle;
// Live config
@@ -80,8 +91,6 @@ void terminal_restore_defaults(void);
void terminal_apply_settings(void);
void terminal_apply_settings_noclear(void); // the same, but with no screen reset / init
/** Maximum screen size (determines size of the static data array) */
#define MAX_SCREEN_SIZE (80*30)
typedef enum {
CLEAR_TO_CURSOR=0, CLEAR_FROM_CURSOR=1, CLEAR_ALL=2