-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.h
88 lines (62 loc) · 1.98 KB
/
list.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef LIST_H
#define LIST_H
#include <stdbool.h>
#include <dirent.h>
typedef struct list_ list_t;
struct list_
{
char *line;
size_t len_line, len_malloc;
list_t *next, *prev;
int flag;
};
list_t *list_new(list_t *prev);
list_t *list_new_file(FILE *, bool *eol);
list_t *list_from_dir(DIR *d);
int list_write_file(list_t *l, int n, FILE *f, bool eol);
list_t *list_copy_deep(const list_t *const l, list_t *prev);
list_t *list_append(list_t *accum, list_t *at, list_t *new);
list_t **list_seekp(list_t **pl, int y, bool creat);
list_t *list_seek(list_t *l, int y, bool creat);
void list_free(list_t *);
void list_inschar(list_t *, int *x, int *y, char ch, char gapchar);
void list_delchar(list_t *, int *x, int *y);
list_t *list_delregion(list_t **pl, const region_t *);
char *list_word_at(list_t *l, point_t const *);
char *list_fname_at(list_t *l, point_t const *);
/* *pl isn't changed - ABI compat with list_delregion */
void list_joinregion(list_t **pl, const region_t *, bool space);
int list_filter(
list_t **pl, const region_t *,
const char *cmd);
/* return false to stop */
typedef bool list_iter_f(char *, list_t *, int y, void *);
enum list_iter_flags
{
LIST_ITER_EVAL_NL = 1 << 0,
LIST_ITER_WHOLE_LINE = 1 << 1,
};
void list_iter_region(
list_t *, const region_t *,
enum list_iter_flags,
list_iter_f fn, void *ctx);
void list_insline(list_t **, int *x, int *y, int dir);
int list_evalnewlines1(list_t *l);
int list_count(const list_t *);
list_t *list_tail(list_t *);
#define isnewline(ch) ((ch) == '\n' || (ch) == '\r')
list_t *list_advance_y(
list_t *l, const int dir,
int *py, int *px)
__attribute__((nonnull(1, 3)));
list_t *list_advance_x(
list_t *l, const int dir,
int *py, int *px)
__attribute__((nonnull));
list_t *list_last(list_t *, int *py);
void list_clear_flag(list_t *);
struct range;
void list_flag_range(list_t *, const struct range *, int);
list_t *list_flagfind(list_t *, int flag, int *py);
list_t *list_contains(list_t *, const char *);
#endif