Screen don't get update after search & replace.
[eco.git] / buffer.h
blobf732919063f668ad14641c18efaf1ca664bd941a
1 /*
2 * Copyright (C) 2008 Diego Hernan Borghetti.
3 * Eco
4 */
6 #ifndef _ECO_BUFFER_H
7 #define _ECO_BUFFER_H
9 typedef struct _E_Line {
10 struct _E_Line *next;
11 struct _E_Line *prev;
13 /* line flags. */
14 char flag;
16 /* chunk of text. */
17 char *text;
19 /* chunk size. */
20 int size;
22 /* memory used. */
23 int used;
24 } E_Line;
26 typedef struct _E_Buffer {
27 struct _E_Buffer *next;
29 /* buffer file. */
30 char *file;
32 /* buffer name a shortcut for show in the status line. */
33 char *name;
35 /* line list. */
36 E_Line *lines;
38 /* "top-level" line. */
39 E_Line *first;
41 /* current "edit" line. */
42 E_Line *line;
44 /* cursor position in the "current line" */
45 short dot;
47 /* real pad for big lines. */
48 short dot_pad;
50 /* buffer flags. */
51 char flag;
53 /* number of lines in this buffer. */
54 int nlines;
56 /* current line number. */
57 int nl;
58 } E_Buffer;
60 /* buffer->flag */
61 #define BUFFER_FLUSH (1<<0)
62 #define BUFFER_CMODE (1<<1)
64 /* buffer search mode. */
65 #define BUFFER_SEARCH_FORWARD 0
66 #define BUFFER_SEARCH_BACKWARD 1
68 /* set/unset buffer flags */
69 #define BUFFER_SET(b, f) \
70 if (!(b->flag & f)) \
71 b->flag|= (f)
73 #define BUFFER_UNSET(b, f) \
74 if (b->flag & f) \
75 b->flag&= ~(f)
77 E_Buffer *e_buffer_new(char *file);
78 void e_buffer_free(E_Buffer *bf);
80 void e_buffer_newline(E_Buffer *bf);
81 void e_buffer_newline_first(E_Buffer *bf);
82 void e_buffer_joinline(E_Buffer *bf);
83 void e_buffer_splitline(E_Buffer *bf);
84 void e_buffer_cleanline(E_Buffer *bf);
85 void e_buffer_insert(E_Buffer *bf, int c);
86 void e_buffer_backspace(E_Buffer *bf);
87 void e_buffer_del(E_Buffer *bf);
88 void e_buffer_killline(E_Buffer *bf, int cut);
90 void e_buffer_up(E_Buffer *bf);
91 void e_buffer_down(E_Buffer *bf);
92 void e_buffer_left(E_Buffer *bf);
93 void e_buffer_right(E_Buffer *bf);
95 void e_buffer_goto(E_Buffer *bf, int line);
96 void e_buffer_goto_begin(E_Buffer *bf);
97 void e_buffer_goto_end(E_Buffer *bf);
98 void e_buffer_bol(E_Buffer *bf);
99 void e_buffer_eol(E_Buffer *bf);
100 void e_buffer_scroll(E_Buffer *bf, int nline, int dir);
102 void e_buffer_search(E_Buffer *bf, char *pattern, int dir);
103 int e_buffer_replace(E_Buffer *bf, char *pattern, char *replace);
105 #endif /* _ECO_BUFFER_H */