dte test coverage


Directory: ./
File: src/bookmark.h
Date: 2025-09-07 23:01:39
Exec Total Coverage
Lines: 4 4 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 #ifndef BOOKMARK_H
2 #define BOOKMARK_H
3
4 #include <stdbool.h>
5 #include <stddef.h>
6 #include "util/macros.h"
7 #include "util/ptr-array.h"
8 #include "util/xmalloc.h"
9 #include "view.h"
10 #include "window.h"
11
12 typedef struct {
13 char *filename; // Needed after buffer is closed
14 unsigned long buffer_id; // Needed if buffer doesn't have a filename
15 char *pattern; // Regex from tag file (if set, line and column are 0)
16 unsigned long line, column; // File position (if non-zero, pattern is NULL)
17 } FileLocation;
18
19 303 static inline FileLocation *new_file_location (
20 char *filename, // NOLINT(readability-non-const-parameter): false positive
21 unsigned long buffer_id,
22 unsigned long line,
23 unsigned long column
24 ) {
25 303 FileLocation *loc = xmalloc(sizeof(*loc));
26 303 *loc = (FileLocation) {
27 .filename = filename,
28 .buffer_id = buffer_id,
29 .line = line,
30 .column = column
31 };
32 303 return loc;
33 }
34
35 FileLocation *get_current_file_location(const View *view) NONNULL_ARGS_AND_RETURN;
36 bool file_location_go(Window *window, const FileLocation *loc) NONNULL_ARGS WARN_UNUSED_RESULT;
37 void file_location_free(FileLocation *loc) NONNULL_ARGS;
38
39 size_t bookmark_push(PointerArray *bookmarks, FileLocation *loc) NONNULL_ARGS;
40 size_t bookmark_pop(PointerArray *bookmarks, Window *window) NONNULL_ARGS;
41
42 #endif
43