summaryrefslogtreecommitdiff
path: root/src/hist_view.h
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-12 17:49:34 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-12 17:49:34 +0300
commit4384435941b8c7658856b381d071aee2e0035e89 (patch)
tree5ece99c3dd1decb8ec3fd404c0ece2b5865a552a /src/hist_view.h
term: move the term core to subprojects/term
The core now builds, tests, and benchmarks alone, as a Meson subproject with no dependency on the main tree. - include/term/ holds term.h and the header-only unicode/. src/ holds the core and its private headers. The main tree gets only include/term through term_dep, so it cannot reach a private header. - The term tests, the term benchmarks, the Kitty parser suite, and tools/amalgamate.py and tools/generate_unicode.py move with it. The tests run as term:<name>. - The main build passes its -march (arch_flag) and b_ndebug to the subproject. A directory configured before this commit needs meson configure -Dterm:arch_flag=-march=... once. - The term tests compile with -UNDEBUG. They do work inside assert. - The subproject exports term_test_dep with term_api.h, for the main tree's render, thumbnail, color, and selection tests. - The Kitty bridge used struct vector2i and has not compiled since the public API redesign. It builds again. 2 of its 14 tests fail: REP after a tab, and a cursor report after a resize. - dirgraph.py drops the term and unicode layers. Its self-test uses pty. - The symbols test ignores the __odr_asan symbols that ASan adds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src/hist_view.h')
-rw-r--r--src/hist_view.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/hist_view.h b/src/hist_view.h
new file mode 100644
index 0000000..0214c0b
--- /dev/null
+++ b/src/hist_view.h
@@ -0,0 +1,60 @@
+#ifndef TERM_HIST_VIEW_H
+#define TERM_HIST_VIEW_H
+
+#include "hist.h"
+
+struct line_pos {
+ uint64_t id;
+ uint32_t seg;
+};
+
+struct view_anchor {
+ uint64_t line_id;
+ uint64_t cell;
+ uint64_t base_cell;
+ uint32_t seg;
+ bool active;
+};
+
+struct hist_view {
+ struct view_anchor anchor;
+
+ /* Line ids map to circular slots. Tree sums use physical slot order. */
+ uint64_t *fenwick;
+ uint32_t *counts;
+ uint64_t total_rows;
+ uint64_t first_id, end_id;
+ uint64_t epoch, head, tail, last_cells;
+ int cols;
+ uint32_t cap;
+ int index_cols;
+};
+
+void term_hist_view_init(struct hist_view *v);
+void term_hist_view_free(struct hist_view *v);
+void term_hist_view_clear(struct hist_view *v);
+
+/* Update the index during snapshot capture. Reads do not change it. */
+bool term_hist_view_sync(struct hist_view *v, const struct hist *h, int cols);
+void term_hist_view_refine(struct hist_view *v, struct hist *h, int cols, int rows);
+uint64_t term_hist_view_rows(const struct hist_view *v, const struct hist *h, int cols);
+bool term_hist_view_find_row(const struct hist_view *v, const struct hist *h, int row,
+ int cols, uint64_t *id, int *seg);
+
+/* Read the offset from the anchor at the current width. */
+int term_hist_view_scroll_offset(const struct hist_view *v, const struct hist *h, int cols);
+void term_hist_view_scroll(struct hist_view *v, const struct hist *h, int cols,
+ struct line_pos screen_top, int lines);
+void term_hist_view_scroll_to(struct hist_view *v, const struct hist *h, int cols,
+ struct line_pos screen_top, int offset);
+void term_hist_view_reset_bottom(struct hist_view *v);
+
+/* Clamp an evicted anchor. This does not update the index on the write path. */
+void term_hist_view_note_push(struct hist_view *v, const struct hist *h, int cols);
+void term_hist_view_rewrap(struct hist_view *v, const struct hist *h, int cols);
+
+bool term_hist_view_row_pos(const struct hist_view *v, const struct hist *h, int cols,
+ int screen_rows, struct line_pos screen_top, int y,
+ uint64_t *out_id, int *out_seg, int *out_screen_y);
+
+#endif