void ui_puts(uint8_t *str) { uint8_t *p = str; uint8_t c; while ((c = *p)) { if (c < 0x20) { abort(); } size_t clen = (size_t)mb_ptr2len(p); ui_call_put((String){ .data = (char *)p, .size = clen }); col++; if (mb_ptr2cells(p) > 1) { // double cell character, blank the next cell ui_call_put((String)STRING_INIT); col++; } if (utf_ambiguous_width(utf_ptr2char(p))) { pending_cursor_update = true; } if (col >= width) { ui_linefeed(); } p += clen; if (p_wd) { // 'writedelay': flush & delay each time. ui_flush(); uint64_t wd = (uint64_t)labs(p_wd); os_delay(wd, false); } }
static void parse_control_character(uint8_t c) { if (c == '\n') { ui_linefeed(); } else if (c == '\r') { ui_carriage_return(); } else if (c == '\b') { ui_cursor_left(); } else if (c == Ctrl_L) { ui_cursor_right(); } else if (c == Ctrl_G) { UI_CALL(bell); } }
static void send_output(uint8_t **ptr) { uint8_t *p = *ptr; while (*p >= 0x20) { size_t clen = (size_t)mb_ptr2len(p); UI_CALL(put, p, (size_t)clen); col++; if (mb_ptr2cells(p) > 1) { // double cell character, blank the next cell UI_CALL(put, NULL, 0); col++; } if (col >= width) { ui_linefeed(); } p += clen; } *ptr = p; }