summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-13 12:50:54 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-13 12:50:54 +0300
commita0fefd3856a4f03be0abbc51f7a9a0416db69eb5 (patch)
treea06737c8fcea5ee6d7d20223e9c36272e66b9e26 /src
parent71f0b19476adb170c24d6a8de4ab3133701b1aeb (diff)
Make term standalone library and export Meson dependencies
Diffstat (limited to 'src')
-rw-r--r--src/kernels.h2
-rw-r--r--src/meson.build5
-rw-r--r--src/text.c84
3 files changed, 46 insertions, 45 deletions
diff --git a/src/kernels.h b/src/kernels.h
index 48088b5..45d25b7 100644
--- a/src/kernels.h
+++ b/src/kernels.h
@@ -88,7 +88,7 @@ static inline size_t scan_printable_span(const char *buf, size_t len,
return scan_printable_span_avx512(buf, len, hi);
#endif
#if defined(TERM_KERNEL_AVX2)
- if (len >= 64 && term_use_avx2())
+ if (len >= 32 && term_use_avx2())
return scan_printable_span_avx2(buf, len, hi);
#endif
size_t i = 0;
diff --git a/src/meson.build b/src/meson.build
index 6eaf0d4..694ee0e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -2,7 +2,7 @@ subdir('osc')
# The x86-64 SIMD kernels pick their level at run time (see simd.h), so the
# library needs no ISA flags. -march in c_args sets the lowest level.
-term_headless_lib = both_libraries('term_headless',
+term_lib = both_libraries('term',
'core.c',
'escape.c',
'fastcsi.c',
@@ -23,5 +23,6 @@ term_headless_lib = both_libraries('term_headless',
include_directories: term_private_inc,
dependencies: [m_dep],
gnu_symbol_visibility: 'hidden',
- install: false
+ install: true
)
+
diff --git a/src/text.c b/src/text.c
index 9f73bd3..ad3e7f2 100644
--- a/src/text.c
+++ b/src/text.c
@@ -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;