Add xterm-256color as a valid terminal.
[eco.git] / buffer.h
blob9e0dffc8ce6051e80a477d5278600aa9cf427956
1 /*
2 * Copyright (C) 2008 Diego Hernan Borghetti.
3 * Eco
4 */
6 #ifndef _ECO_BUFFER_H
7 #define _ECO_BUFFER_H
9 struct E_File_Path;
11 typedef struct _E_Line {
12 struct _E_Line *next;
13 struct _E_Line *prev;
15 /* line flags. */
16 char flag;
18 /* chunk of text. */
19 char *text;
21 /* chunk size. */
22 int size;
24 /* memory used. */
25 int used;
26 } E_Line;
28 typedef struct _E_Buffer {
29 struct _E_Buffer *next;
31 /* file paths. */
32 struct E_File_Path *paths;
34 /* file name or untitled */
35 char *name;
37 /* line list. */
38 E_Line *lines;
40 /* "top-level" line. */
41 E_Line *first;
43 /* current "edit" line. */
44 E_Line *line;
46 /* cursor position in the "current line" */
47 short dot;
49 /* real pad for big lines. */
50 short dot_pad;
52 /* buffer flags. */
53 char flag;
55 /* number of lines in this buffer. */
56 int nlines;
58 /* current line number. */
59 int nl;
60 } E_Buffer;
62 /* buffer->flag */
63 #define BUFFER_FLUSH (1<<0)
64 #define BUFFER_CMODE (1<<1)
65 #define BUFFER_UP (1<<2)
66 #define BUFFER_DOWN (1<<3)
67 #define BUFFER_NOIDENT (1<<4)
69 /* buffer search mode. */
70 #define BUFFER_SEARCH_FORWARD 0
71 #define BUFFER_SEARCH_BACKWARD 1
73 /* set/unset buffer flags */
74 #define BUFFER_SET(b, f) \
75 if (!(b->flag & f)) \
76 b->flag|= (f)
78 #define BUFFER_UNSET(b, f) \
79 if (b->flag & f) \
80 b->flag&= ~(f)
82 E_Buffer *e_buffer_new(char *file);
83 void e_buffer_free(E_Buffer *bf);
85 void e_buffer_newline(E_Buffer *bf);
86 void e_buffer_newline_first(E_Buffer *bf);
87 void e_buffer_joinline(E_Buffer *bf);
88 void e_buffer_splitline(E_Buffer *bf);
89 void e_buffer_cleanline(E_Buffer *bf);
90 void e_buffer_insert(E_Buffer *bf, int c, int repeat);
91 void e_buffer_insert_str(E_Buffer *bf, char *str, int len);
92 void e_buffer_backspace(E_Buffer *bf);
93 void e_buffer_del(E_Buffer *bf);
94 void e_buffer_killline(E_Buffer *bf, int cut);
96 void e_buffer_up(E_Buffer *bf);
97 void e_buffer_down(E_Buffer *bf);
98 void e_buffer_left(E_Buffer *bf);
99 void e_buffer_right(E_Buffer *bf);
101 void e_buffer_goto(E_Buffer *bf, int line);
102 void e_buffer_goto_begin(E_Buffer *bf);
103 void e_buffer_goto_end(E_Buffer *bf);
104 void e_buffer_bol(E_Buffer *bf);
105 void e_buffer_eol(E_Buffer *bf);
106 void e_buffer_scroll(E_Buffer *bf, int nline, int dir);
108 void e_buffer_search(E_Buffer *bf, char *pattern, int dir);
109 int e_buffer_replace(E_Buffer *bf, char *pattern, char *replace);
111 void e_buffer_rem_empty_lines(E_Buffer *bf);
113 #endif /* _ECO_BUFFER_H */