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