allow zero redraw delay

http-comm
Ondřej Hruška 7 years ago
parent 062b0e6188
commit b6c5648690
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 2
      front-end
  2. 7
      user/apars_utf8.c
  3. 13
      user/cgi_sockets.c
  4. 2
      user/cgi_term_cfg.c
  5. 22
      user/screen.c
  6. 7
      user/utf8.c
  7. 3
      user/utf8.h

@ -1 +1 @@
Subproject commit a5a157ad561879fdb801b81d37a3490d05fd89e3
Subproject commit cee23ca951bd1c07b9c1d1d1334f18c0894cc028

@ -87,12 +87,15 @@ apars_handle_plainchar(char c)
else {
bytes[utf_j++] = c;
if (utf_j >= utf_len) {
// check for bad sequences
// check for bad sequences - overlong or some other problem
if (bytes[0] == 0xF4 && bytes[1] > 0x8F) goto fail;
if (bytes[0] == 0xF0 && bytes[1] < 0x90) goto fail;
if (bytes[0] == 0xED && bytes[1] > 0x9F) goto fail;
if (bytes[0] == 0xE0 && bytes[1] < 0xA0) goto fail;
// trap for surrogates - those break javascript
if (bytes[0] == 0xED && bytes[1] >= 0xA0 && bytes[1] <= 0xBF) goto fail;
screen_putchar((const char *) bytes);
apars_reset_utf8buffer();
}
@ -113,5 +116,5 @@ fail:
apars_show_context();
apars_reset_utf8buffer();
ansi_dbg("Temporarily inhibiting parser...");
TIMER_START(&timerResumeRx, resumeRxCb, 1000, 0);
TIMER_START(&timerResumeRx, resumeRxCb, 500, 0);
}

@ -21,6 +21,7 @@ volatile ScreenNotifyTopics pendingBroadcastTopics = 0;
// flags for screen update timeouts
volatile bool notify_available = true;
volatile bool notify_cooldown = false;
volatile bool notify_scheduled = false;
/** True if we sent XOFF to browser to stop uploading,
* and we have to tell it we're ready again */
@ -109,6 +110,7 @@ updateNotifyCb(void *arg)
updateNotify_do(arg, 0);
notify_scheduled = false;
notify_cooldown = true;
TIMER_START(&notifyCooldownTim, notifyCooldownTimCb, termconf->display_cooldown_ms, 0);
@ -146,17 +148,16 @@ void ICACHE_FLASH_ATTR screen_notifyChange(ScreenNotifyTopics topics)
{
if (term_active_clients == 0) return;
// this is probably not needed here - ensure timeout is not 0
if (termconf->display_tout_ms == 0) {
termconf->display_tout_ms = SCR_DEF_DISPLAY_TOUT_MS;
}
inp_dbg("Notify +%02Xh", topics);
pendingBroadcastTopics |= topics;
int time = termconf->display_tout_ms;
if (time == 0 && notify_scheduled) return; // do not reset the timer if already scheduled
notify_scheduled = true;
// NOTE: the timer is restarted if already running
TIMER_START(&updateNotifyTim, updateNotifyCb, termconf->display_tout_ms, 0); // note - this adds latency to beep
TIMER_START(&updateNotifyTim, updateNotifyCb, time, 0); // note - this adds latency to beep
}
/**

@ -148,7 +148,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
if (GET_ARG("display_tout_ms")) {
cgi_dbg("Display update idle timeout: %s ms", buff);
n = atoi(buff);
if (n > 0) {
if (n >= 0) {
termconf->display_tout_ms = n;
} else {
cgi_warn("Bad update timeout %s", buff);

@ -239,12 +239,8 @@ terminal_apply_settings_noclear(void)
termconf->config_version = TERMCONF_VERSION;
// Validation...
if (termconf->display_tout_ms == 0) {
termconf->display_tout_ms = SCR_DEF_DISPLAY_TOUT_MS;
changed = 1;
}
if (termconf->display_cooldown_ms == 0) {
termconf->display_cooldown_ms = SCR_DEF_DISPLAY_COOLDOWN_MS;
termconf->display_cooldown_ms = 1;
changed = 1;
}
@ -1781,7 +1777,7 @@ utf8_remap(char *out, char g, char charset)
break;
}
utf8_encode(out, utf);
utf8_encode(out, utf, false);
}
//endregion
@ -1841,7 +1837,7 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, ScreenNotifyTopics topics,
} while(0)
#define bufput_utf8(num) do { \
nbytes = utf8_encode(bb, (num)+1); \
nbytes = utf8_encode(bb, (num)+1, true); \
bb += nbytes; \
remain -= nbytes; \
} while(0)
@ -1957,11 +1953,15 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, ScreenNotifyTopics topics,
bufput_utf8(W);
bufput_utf8(termconf_live.theme);
bufput_utf8(termconf_live.default_fg & 0xFFF);
bufput_utf8((u32)(termconf_live.default_fg >> 16) & 0xFFFF);
bufput_utf8(termconf_live.default_fg & 0xFFFF);
bufput_utf8((termconf_live.default_fg >> 16) & 0xFFFF);
dbg("Fg %04X,%04X", termconf_live.default_fg & 0xFFFF, (termconf_live.default_fg >> 16) & 0xFFFF);
bufput_utf8(termconf_live.default_bg & 0xFFFF);
bufput_utf8((termconf_live.default_bg >> 16) & 0xFFFF);
bufput_utf8(termconf_live.default_bg & 0xFFF);
bufput_utf8((u32)(termconf_live.default_bg >> 16) & 0xFFFF);
dbg("Bg %04X,%04X", termconf_live.default_bg & 0xFFFF, (termconf_live.default_bg >> 16) & 0xFFFF);
bufput_utf8(
(scr.cursor_visible << 0) |

@ -160,8 +160,13 @@ unicode_cache_remove(UnicodeCacheRef ref)
* @return number of bytes on success, 0 on failure (also produces U+FFFD, which uses 3 bytes)
*/
int ICACHE_FLASH_ATTR
utf8_encode(char *out, uint32_t utf)
utf8_encode(char *out, uint32_t utf, bool surrogateFix)
{
// Skip the surrogate block (wtf, unicode???)
if (surrogateFix && utf >= 0xD800) {
utf += 0x800;
}
if (utf <= 0x7F) {
// Plain ASCII
out[0] = (char) utf;

@ -63,9 +63,10 @@ bool unicode_cache_remove(UnicodeCacheRef ref);
*
* @param out - output buffer (min 4 characters), will be 0-terminated if shorten than 4
* @param utf - code point 0-0x10FFFF
* @param surrogateFix - add 0x800 to 0xD800-0xDFFF to avoid invalid code points
* @return number of bytes on success, 0 on failure (also produces U+FFFD, which uses 3 bytes)
*/
int utf8_encode(char *out, uint32_t utf);
int utf8_encode(char *out, uint32_t utf, bool surrogateFix);
#if DEBUG_UTFCACHE
#define utfc_warn warn

Loading…
Cancel
Save