-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgap_buffer.h
38 lines (32 loc) · 1.15 KB
/
gap_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
#ifndef _GAP_BUFFER_MV_H_
#define _GAP_BUFFER_MV_H_
#define MIN_SIZE_GAP_BUFFER 32
#define MIN_SIZE_GAP_BUFFER_HALF 16 // MIN_SIZE_GAP_BUFFER / 2
typedef struct gap_buffer {
// unsigned int ID;
char* left;
char* right;
unsigned int left_index;
unsigned int right_index;
unsigned int length;
unsigned int cursor_pos;
} gap_buffer_t;
// TODO: all the functions should take a pointer to a gap buffer as a parameter
// TODO: init function should return a pointer to a gap buffer structure
void init_gap_buffer(gap_buffer_t* ptr);
void free_gap_buffer(gap_buffer_t* ptr);
void reset_gap_buffer(gap_buffer_t* ptr);
//void insert(char ch);
// void resize(void);
void insert_char(gap_buffer_t* ptr, char ch);
void insert_string(const char* ch); //TODO
// void set_cursor_at(gap_buffer_t* ptr, unsigned int index);
const char* get_left_message(gap_buffer_t* ptr);
const char* get_right_message(gap_buffer_t* ptr);
void update_gap_buffer(gap_buffer_t* ptr);
void delete_char(gap_buffer_t* ptr);
void delete_range(unsigned int from, unsigned int to); //TODO
void print_stats(gap_buffer_t* ptr);
void dump(char buf[], int length);
void dump_gap_buffer(gap_buffer_t* ptr);
#endif