-
Notifications
You must be signed in to change notification settings - Fork 0
/
buffer.h
117 lines (82 loc) · 2.15 KB
/
buffer.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef BUFFER_H
#define BUFFER_H
#include <stdbool.h>
#include <time.h> /* time_t */
#include "bufmode.h"
#include "yank.h"
#include "retain.h"
typedef struct buffer buffer_t;
enum case_tog
{
CASE_TOGGLE,
CASE_UPPER,
CASE_LOWER,
};
struct buffer
{
/* must be first */
struct retain retains;
list_t *head;
/* used for `gv' */
struct
{
point_t npos, vpos;
enum buf_mode mode;
} prev_visual;
point_t prev_insert;
char *fname;
bool eol;
bool modified;
time_t mtime;
unsigned col_insert_height;
};
buffer_t *buffer_new(void);
void buffer_new_fname(
buffer_t **, const char *fname,
const char **const err);
void buffer_replace_fname(
buffer_t *, const char *fname,
const char **const err);
void buffer_replace_list(buffer_t *, list_t *);
buffer_t *buffer_new_file_nofind(FILE *f);
int buffer_opencount(const buffer_t *);
void buffer_free(buffer_t *);
int buffer_write_file(buffer_t *, int n, FILE *, bool eol);
void buffer_set_fname(buffer_t *, const char *);
const char *buffer_fname(const buffer_t *);
void buffer_inscolchar(
buffer_t *buf, char ch, unsigned ncols,
point_t *const ui_pos);
void buffer_inschar_at(buffer_t *, char ch, int *x, int *y);
/* TODO: remove arg 2 and 3 */
void buffer_delchar(buffer_t *, int *x, int *y);
typedef void buffer_action_f(
buffer_t *, const region_t *, point_t *out);
struct buffer_action
{
buffer_action_f *fn;
bool always_linewise;
};
extern struct buffer_action
buffer_delregion,
buffer_joinregion_space, buffer_joinregion_nospace,
buffer_yankregion,
buffer_indent, buffer_unindent;
void buffer_smartindent(buffer_t *, int *x, int y);
void buffer_insyank(
buffer_t *, const yank *,
point_t *ui_pos,
bool prepend, bool modify);
int buffer_filter(
buffer_t *,
const region_t *,
const char *cmd);
void buffer_insline(buffer_t *, int dir, point_t *ui_pos);
unsigned buffer_nlines(const buffer_t *);
void buffer_caseregion(
buffer_t *, enum case_tog,
const region_t *region);
const char *buffer_shortfname(const char *); /* internal fname buffer */
bool buffer_findat(const buffer_t *, const char *, point_t *, int dir);
#define buffer_release(b) release((b), buffer_free)
#endif