diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 12:50:54 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 12:50:54 +0300 |
| commit | a0fefd3856a4f03be0abbc51f7a9a0416db69eb5 (patch) | |
| tree | a06737c8fcea5ee6d7d20223e9c36272e66b9e26 /src/text.c | |
| parent | 71f0b19476adb170c24d6a8de4ab3133701b1aeb (diff) | |
Make term standalone library and export Meson dependencies
Diffstat (limited to 'src/text.c')
| -rw-r--r-- | src/text.c | 84 |
1 files changed, 42 insertions, 42 deletions
@@ -216,48 +216,6 @@ static void term_feed_inner(struct term *t, const char *buf, size_t len, unsigne } unsigned char ch = (unsigned char)buf[i]; - if ((ch < 0x20 || ch == 0x7f) && t->state == ST_GROUND) - term_text_utf8_interrupt(t); - - if (TERM_EXPECT(ch < 0x20 && t->state == ST_GROUND && - ch != 0x1b && ch != '\n' && ch != '\r' && ch != '\b' && ch != '\t' && - ch != 0x0e && ch != 0x0f && ch != 0x07 && ch != 0x0b && - ch != 0x0c, 0)) { - continue; - } - - if (TERM_EXPECT(ch == 0x1b && t->state == ST_GROUND && - t->utf8_state == UTF8_ACCEPT && i + 1 < len && - buf[i + 1] == '[' && !t->insert_mode && - !t->lr_margin_mode && !t->graphics, 0)) { - int fast = term_try_fast_csi(t, buf + i + 2, len - i - 2); - if (fast > 0) { - i += 1 + (size_t)fast; - continue; - } - t->state = ST_CSI; - csi_parser_reset(&t->csi_parser); - i += 1 + term_escape_csi(t, buf + i + 2, len - i - 2); - continue; - } - - if (TERM_EXPECT(t->state == ST_GROUND && ch == '\n', 0)) { - size_t end = i + 1 + scan_byte_run(buf + i + 1, len - i - 1, '\n'); - if (term_lnm(t)) sc_cr(t); - sc_linefeed(t, end - i); - i = end - 1; - continue; - } - - if (TERM_EXPECT(t->state == ST_GROUND && ch == '\r' && - i + 1 < len && buf[i + 1] == '\n', 0)) { - size_t end = i + 2 + scan_crlf_pairs(buf + i + 2, len - i - 2); - sc_cr(t); - sc_linefeed(t, (end - i) / 2); - i = end - 1; - continue; - } - if (TERM_EXPECT(ch >= 0x20 && ch < 0x7f && !t->insert_mode && !t->lr_margin_mode && t->state == ST_GROUND && !t->graphics && t->utf8_state == UTF8_ACCEPT, 1)) { @@ -307,6 +265,48 @@ static void term_feed_inner(struct term *t, const char *buf, size_t len, unsigne continue; } + if ((ch < 0x20 || ch == 0x7f) && t->state == ST_GROUND) + term_text_utf8_interrupt(t); + + if (TERM_EXPECT(ch < 0x20 && t->state == ST_GROUND && + ch != 0x1b && ch != '\n' && ch != '\r' && ch != '\b' && ch != '\t' && + ch != 0x0e && ch != 0x0f && ch != 0x07 && ch != 0x0b && + ch != 0x0c, 0)) { + continue; + } + + if (TERM_EXPECT(ch == 0x1b && t->state == ST_GROUND && + t->utf8_state == UTF8_ACCEPT && i + 1 < len && + buf[i + 1] == '[' && !t->insert_mode && + !t->lr_margin_mode && !t->graphics, 0)) { + int fast = term_try_fast_csi(t, buf + i + 2, len - i - 2); + if (fast > 0) { + i += 1 + (size_t)fast; + continue; + } + t->state = ST_CSI; + csi_parser_reset(&t->csi_parser); + i += 1 + term_escape_csi(t, buf + i + 2, len - i - 2); + continue; + } + + if (TERM_EXPECT(t->state == ST_GROUND && ch == '\n', 0)) { + size_t end = i + 1 + scan_byte_run(buf + i + 1, len - i - 1, '\n'); + if (term_lnm(t)) sc_cr(t); + sc_linefeed(t, end - i); + i = end - 1; + continue; + } + + if (TERM_EXPECT(t->state == ST_GROUND && ch == '\r' && + i + 1 < len && buf[i + 1] == '\n', 0)) { + size_t end = i + 2 + scan_crlf_pairs(buf + i + 2, len - i - 2); + sc_cr(t); + sc_linefeed(t, (end - i) / 2); + i = end - 1; + continue; + } + if (TERM_EXPECT(ch == '\r' && t->state == ST_GROUND, 0)) { sc_cr(t); continue; |
