diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-01-21 22:52:54 +0100 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-01-21 22:52:54 +0100 |
| commit | dcacc00e3750300617ba6e16eb346713f91a783a (patch) | |
| tree | 38e2d4fb5ed9d119711d4295c6eda4b014af73fd /examples/dte/view.h | |
| parent | 58dac10aeb8f5a041c46bddbeaf4c7966a99b998 (diff) | |
| download | crep-dcacc00e3750300617ba6e16eb346713f91a783a.tar.gz | |
Remove testing data
Diffstat (limited to 'examples/dte/view.h')
| -rw-r--r-- | examples/dte/view.h | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/examples/dte/view.h b/examples/dte/view.h deleted file mode 100644 index c7bb254..0000000 --- a/examples/dte/view.h +++ /dev/null | |||
| @@ -1,62 +0,0 @@ | |||
| 1 | #ifndef VIEW_H | ||
| 2 | #define VIEW_H | ||
| 3 | |||
| 4 | #include <limits.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include <sys/types.h> | ||
| 7 | #include "block-iter.h" | ||
| 8 | #include "util/macros.h" | ||
| 9 | #include "util/string-view.h" | ||
| 10 | |||
| 11 | typedef enum { | ||
| 12 | SELECT_NONE, | ||
| 13 | SELECT_CHARS, | ||
| 14 | SELECT_LINES, | ||
| 15 | } SelectionType; | ||
| 16 | |||
| 17 | // A view into a Buffer, with its own cursor position and selection. | ||
| 18 | // Visually speaking, each tab in a Window corresponds to a View. | ||
| 19 | typedef struct View { | ||
| 20 | struct Buffer *buffer; | ||
| 21 | struct Window *window; | ||
| 22 | BlockIter cursor; | ||
| 23 | long cx, cy; // Cursor position | ||
| 24 | long cx_display; // Visual cursor x (char widths: wide 2, tab 1-8, control 2, invalid char 4) | ||
| 25 | long cx_char; // Cursor x in characters (invalid UTF-8 character (byte) is 1 char) | ||
| 26 | long vx, vy; // Top left corner | ||
| 27 | long preferred_x; // Preferred cursor x (preferred value for cx_display) | ||
| 28 | int tt_width; // Tab title width | ||
| 29 | int tt_truncated_width; | ||
| 30 | bool center_on_scroll; // Center view to cursor if scrolled | ||
| 31 | bool force_center; // Force centering view to cursor | ||
| 32 | |||
| 33 | SelectionType selection; | ||
| 34 | SelectionType select_mode; | ||
| 35 | ssize_t sel_so; // Cursor offset when selection was started | ||
| 36 | ssize_t sel_eo; // See `SEL_EO_RECALC` below | ||
| 37 | |||
| 38 | // Used to save cursor state when multiple views share same buffer | ||
| 39 | bool restore_cursor; | ||
| 40 | size_t saved_cursor_offset; | ||
| 41 | } View; | ||
| 42 | |||
| 43 | // If View::sel_eo is set to this value it means the offset must | ||
| 44 | // be calculated from the cursor iterator. Otherwise the offset | ||
| 45 | // is precalculated and may not be the same as the cursor position | ||
| 46 | // (see search/replace code). | ||
| 47 | #define SEL_EO_RECALC SSIZE_MAX | ||
| 48 | |||
| 49 | static inline void view_reset_preferred_x(View *view) | ||
| 50 | { | ||
| 51 | view->preferred_x = -1; | ||
| 52 | } | ||
| 53 | |||
| 54 | void view_update_cursor_y(View *view) NONNULL_ARGS; | ||
| 55 | void view_update_cursor_x(View *view) NONNULL_ARGS; | ||
| 56 | void view_update(View *view, unsigned int scroll_margin) NONNULL_ARGS; | ||
| 57 | long view_get_preferred_x(View *view) NONNULL_ARGS; | ||
| 58 | bool view_can_close(const View *view) NONNULL_ARGS; | ||
| 59 | StringView view_do_get_word_under_cursor(const View *view, size_t *offset_in_line) NONNULL_ARGS; | ||
| 60 | StringView view_get_word_under_cursor(const View *view) NONNULL_ARGS; | ||
| 61 | |||
| 62 | #endif | ||
