This source file includes following definitions.
- edit_buffer_get_current_byte
- edit_buffer_get_previous_byte
- edit_buffer_get_current_bol
- edit_buffer_get_current_eol
1
2
3
4
5 #ifndef MC__EDIT_BUFFER_H
6 #define MC__EDIT_BUFFER_H
7
8
9
10
11
12
13
14 typedef struct edit_buffer_struct
15 {
16 off_t curs1;
17 off_t curs2;
18 GPtrArray *b1;
19 GPtrArray *b2;
20 off_t size;
21 long lines;
22 long curs_line;
23 } edit_buffer_t;
24
25 typedef struct edit_buffer_read_file_status_msg_struct
26 {
27 simple_status_msg_t status_msg;
28
29 gboolean first;
30 edit_buffer_t *buf;
31 off_t loaded;
32 } edit_buffer_read_file_status_msg_t;
33
34
35
36
37
38 void edit_buffer_init (edit_buffer_t *buf, off_t size);
39 void edit_buffer_clean (edit_buffer_t *buf);
40
41 int edit_buffer_get_byte (const edit_buffer_t *buf, off_t byte_index);
42 int edit_buffer_get_utf (const edit_buffer_t *buf, off_t byte_index, int *char_length);
43 int edit_buffer_get_prev_utf (const edit_buffer_t *buf, off_t byte_index, int *char_length);
44 long edit_buffer_count_lines (const edit_buffer_t *buf, off_t first, off_t last);
45 off_t edit_buffer_get_bol (const edit_buffer_t *buf, off_t current);
46 off_t edit_buffer_get_eol (const edit_buffer_t *buf, off_t current);
47 GString *edit_buffer_get_word_from_pos (const edit_buffer_t *buf, off_t start_pos, off_t *start,
48 gsize *cut);
49 gboolean edit_buffer_find_word_start (const edit_buffer_t *buf, off_t *word_start, gsize *word_len);
50
51 void edit_buffer_insert (edit_buffer_t *buf, int c);
52 void edit_buffer_insert_ahead (edit_buffer_t *buf, int c);
53 int edit_buffer_delete (edit_buffer_t *buf);
54 int edit_buffer_backspace (edit_buffer_t *buf);
55
56 off_t edit_buffer_get_forward_offset (const edit_buffer_t *buf, off_t current, long lines,
57 off_t upto);
58 off_t edit_buffer_get_backward_offset (const edit_buffer_t *buf, off_t current, long lines);
59
60 off_t edit_buffer_read_file (edit_buffer_t *buf, int fd, off_t size,
61 edit_buffer_read_file_status_msg_t *sm, gboolean *aborted);
62 off_t edit_buffer_write_file (edit_buffer_t *buf, int fd);
63
64 int edit_buffer_calc_percent (const edit_buffer_t *buf, off_t offset);
65
66
67
68 static inline int
69 edit_buffer_get_current_byte (const edit_buffer_t *buf)
70 {
71 return edit_buffer_get_byte (buf, buf->curs1);
72 }
73
74
75
76 static inline int
77 edit_buffer_get_previous_byte (const edit_buffer_t *buf)
78 {
79 return edit_buffer_get_byte (buf, buf->curs1 - 1);
80 }
81
82
83
84
85
86
87
88
89
90
91 static inline off_t
92 edit_buffer_get_current_bol (const edit_buffer_t *buf)
93 {
94 return edit_buffer_get_bol (buf, buf->curs1);
95 }
96
97
98
99
100
101
102
103
104
105
106 static inline off_t
107 edit_buffer_get_current_eol (const edit_buffer_t *buf)
108 {
109 return edit_buffer_get_eol (buf, buf->curs1);
110 }
111
112
113
114 #endif