dte test coverage


Directory: ./
File: src/selection.h
Date: 2025-12-11 10:43:49
Coverage Exec Excl Total
Lines: 100.0% 10 0 10
Functions: 100.0% 2 0 2
Branches: 100.0% 4 0 4

Line Branch Exec Source
1 #ifndef SELECTION_H
2 #define SELECTION_H
3
4 #include <stdbool.h>
5 #include <stddef.h>
6 #include "block-iter.h"
7 #include "buffer.h"
8 #include "util/debug.h"
9 #include "util/macros.h"
10 #include "util/string-view.h"
11 #include "view.h"
12
13 typedef struct {
14 BlockIter si;
15 size_t so;
16 size_t eo;
17 bool swapped;
18 } SelectionInfo;
19
20 void view_do_set_selection_type(View *view, SelectionType sel) NOINLINE;
21
22 134 static inline void view_set_selection_type(View *view, SelectionType sel)
23 {
24
2/2
✓ Branch 2 → 3 taken 118 times.
✓ Branch 2 → 6 taken 16 times.
134 if (likely(sel == view->selection)) {
25 // If `sel` is SELECT_NONE here, it's always equal to select_mode
26 118 BUG_ON(!sel && view->select_mode);
27 return;
28 }
29
30 16 view_do_set_selection_type(view, sel);
31 }
32
33 144 static inline bool unselect(View *view)
34 {
35
2/2
✓ Branch 2 → 3 taken 13 times.
✓ Branch 2 → 4 taken 131 times.
144 if (view->selection) {
36 13 view->selection = SELECT_NONE;
37 13 view->select_mode = SELECT_NONE;
38 13 mark_all_lines_changed(view->buffer);
39 }
40 144 return true; // To allow tail-calling from command handlers
41 }
42
43 SelectionInfo init_selection(const View *view) NONNULL_ARGS WARN_UNUSED_RESULT;
44 size_t prepare_selection(View *view) NONNULL_ARGS WARN_UNUSED_RESULT;
45 size_t get_nr_selected_lines(const SelectionInfo *info) NONNULL_ARGS WARN_UNUSED_RESULT;
46 size_t get_nr_selected_chars(const SelectionInfo *info) NONNULL_ARGS WARN_UNUSED_RESULT;
47
48 void select_block(View *view) NONNULL_ARGS;
49 bool line_has_opening_brace(StringView line) WARN_UNUSED_RESULT;
50 bool line_has_closing_brace(StringView line) WARN_UNUSED_RESULT;
51
52 #endif
53