1 /* neatvi main header */
4 #define LEN(a) (sizeof(a) / sizeof((a)[0]))
5 #define MIN(a, b) ((a) < (b) ? (a) : (b))
6 #define MAX(a, b) ((a) < (b) ? (b) : (a))
8 /* line buffer, managing a number of lines */
9 struct lbuf
*lbuf_make(void);
10 void lbuf_free(struct lbuf
*lbuf
);
11 int lbuf_rd(struct lbuf
*lbuf
, int fd
, int beg
, int end
);
12 int lbuf_wr(struct lbuf
*lbuf
, int fd
, int beg
, int end
);
13 void lbuf_edit(struct lbuf
*lbuf
, char *s
, int beg
, int end
);
14 char *lbuf_cp(struct lbuf
*lbuf
, int beg
, int end
);
15 char *lbuf_get(struct lbuf
*lbuf
, int pos
);
16 int lbuf_len(struct lbuf
*lbuf
);
17 void lbuf_mark(struct lbuf
*lbuf
, int mark
, int pos
, int off
);
18 int lbuf_jump(struct lbuf
*lbuf
, int mark
, int *pos
, int *off
);
19 int lbuf_undo(struct lbuf
*lbuf
);
20 int lbuf_redo(struct lbuf
*lbuf
);
21 int lbuf_modified(struct lbuf
*lb
);
22 void lbuf_saved(struct lbuf
*lb
, int clear
);
23 int lbuf_indents(struct lbuf
*lb
, int r
);
24 int lbuf_eol(struct lbuf
*lb
, int r
);
25 void lbuf_globset(struct lbuf
*lb
, int pos
, int dep
);
26 int lbuf_globget(struct lbuf
*lb
, int pos
, int dep
);
28 int lbuf_findchar(struct lbuf
*lb
, char *cs
, int cmd
, int n
, int *r
, int *o
);
29 int lbuf_search(struct lbuf
*lb
, char *kw
, int dir
, int *r
, int *o
, int *len
);
30 int lbuf_paragraphbeg(struct lbuf
*lb
, int dir
, int *row
, int *off
);
31 int lbuf_sectionbeg(struct lbuf
*lb
, int dir
, char *sec
, int *row
, int *off
);
32 int lbuf_wordbeg(struct lbuf
*lb
, int big
, int dir
, int *row
, int *off
);
33 int lbuf_wordend(struct lbuf
*lb
, int big
, int dir
, int *row
, int *off
);
34 int lbuf_pair(struct lbuf
*lb
, int *row
, int *off
);
36 /* string buffer, variable-sized string */
37 struct sbuf
*sbuf_make(void);
38 void sbuf_free(struct sbuf
*sb
);
39 char *sbuf_done(struct sbuf
*sb
);
40 char *sbuf_buf(struct sbuf
*sb
);
41 void sbuf_chr(struct sbuf
*sb
, int c
);
42 void sbuf_str(struct sbuf
*sb
, char *s
);
43 void sbuf_mem(struct sbuf
*sb
, char *s
, int len
);
44 void sbuf_printf(struct sbuf
*sbuf
, char *s
, ...);
45 int sbuf_len(struct sbuf
*sb
);
46 void sbuf_cut(struct sbuf
*s
, int len
);
48 /* regular expressions */
52 /* regular expression sets: searching for multiple regular expressions */
53 struct rset
*rset_make(int n
, char **pat
, int flg
);
54 int rset_find(struct rset
*re
, char *s
, int n
, int *grps
, int flg
);
55 void rset_free(struct rset
*re
);
56 char *re_read(char **src
);
57 /* searching for a single pattern regular expression */
58 struct rstr
*rstr_make(char *re
, int flg
);
59 int rstr_find(struct rstr
*rs
, char *s
, int n
, int *grps
, int flg
);
60 void rstr_free(struct rstr
*rs
);
63 int *ren_position(char *s
);
64 int ren_next(char *s
, int p
, int dir
);
65 int ren_eol(char *s
, int dir
);
66 int ren_pos(char *s
, int off
);
67 int ren_cursor(char *s
, int pos
);
68 int ren_noeol(char *s
, int p
);
69 int ren_off(char *s
, int pos
);
71 int ren_region(char *s
, int c1
, int c2
, int *l1
, int *l2
, int closed
);
72 char *ren_translate(char *s
, char *ln
);
73 int ren_cwid(char *s
, int pos
);
76 int dir_context(char *s
);
77 void dir_reorder(char *s
, int *ord
);
81 /* string registers */
82 char *reg_get(int c
, int *lnmode
);
83 void reg_put(int c
, char *s
, int lnmode
);
86 /* utf-8 helper functions */
91 char *uc_chr(char *s
, int off
);
92 int uc_off(char *s
, int off
);
93 char *uc_sub(char *s
, int beg
, int end
);
94 char *uc_dup(char *s
);
95 char *uc_cat(char *s
, char *r
);
96 int uc_isspace(char *s
);
97 int uc_isprint(char *s
);
98 int uc_isdigit(char *s
);
99 int uc_isalpha(char *s
);
100 int uc_kind(char *c
);
101 int uc_isbell(char *c
);
102 int uc_iscomb(char *c
);
103 char **uc_chop(char *s
, int *n
);
104 char *uc_next(char *s
);
105 char *uc_prev(char *beg
, char *s
);
106 char *uc_beg(char *beg
, char *s
);
107 char *uc_end(char *s
);
108 char *uc_shape(char *beg
, char *s
);
109 char *uc_lastline(char *s
);
111 /* managing the terminal */
112 #define xrows (term_rows())
113 #define xcols (term_cols())
115 void term_init(void);
116 void term_done(void);
117 void term_suspend(void);
118 void term_str(char *s
);
119 void term_chr(int ch
);
120 void term_pos(int r
, int c
);
121 void term_clear(void);
122 void term_kill(void);
123 void term_room(int n
);
124 void term_window(int row
, int cnt
);
129 void term_record(void);
130 void term_commit(void);
131 char *term_att(int att
, int old
);
132 void term_push(char *s
, int n
);
133 char *term_cmd(int *n
);
135 #define TK_CTL(x) ((x) & 037)
136 #define TK_INT(c) ((c) < 0 || (c) == TK_ESC || (c) == TK_CTL('c'))
137 #define TK_ESC (TK_CTL('['))
139 /* line-oriented input and output */
140 char *led_prompt(char *pref
, char *post
, int *kmap
, char *syn
, char *hist
);
141 char *led_input(char *pref
, char *post
, int *kmap
, char *syn
);
142 void led_print(char *msg
, int row
, char *syn
);
143 void led_printmsg(char *s
, int row
, char *syn
);
144 char *led_read(int *kmap
);
145 int led_pos(char *s
, int pos
);
149 int ex_command(char *cmd
);
150 char *ex_read(char *msg
);
151 void ex_print(char *line
);
152 void ex_show(char *msg
);
153 int ex_init(char **files
);
156 char *ex_filetype(void);
157 struct lbuf
*ex_lbuf(void);
158 int ex_kwd(char **kwd
, int *dir
);
159 void ex_kwdset(char *kwd
, int dir
);
161 #define EXLEN 512 /* ex line length */
164 /* process management */
165 char *cmd_pipe(char *cmd
, char *s
, int oproc
);
166 int cmd_exec(char *cmd
);
168 /* syntax highlighting */
169 #define SYN_BD 0x010000
170 #define SYN_IT 0x020000
171 #define SYN_RV 0x040000
172 #define SYN_FGMK(f) (0x100000 | (f))
173 #define SYN_BGMK(b) (0x200000 | ((b) << 8))
175 #define SYN_FLG 0xff0000
176 #define SYN_FGSET(a) ((a) & 0x1000ff)
177 #define SYN_BGSET(a) ((a) & 0x20ff00)
178 #define SYN_FG(a) ((a) & 0xff)
179 #define SYN_BG(a) (((a) >> 8) & 0xff)
181 int *syn_highlight(char *ft
, char *s
);
182 char *syn_filetype(char *path
);
183 void syn_context(int att
);
184 int syn_merge(int old
, int new);
188 /* configuration variables */
189 int conf_dirmark(int idx
, char **pat
, int *ctx
, int *dir
, int *grp
);
190 int conf_dircontext(int idx
, char **pat
, int *ctx
);
191 int conf_placeholder(int idx
, char **s
, char **d
, int *wid
);
192 int conf_highlight(int idx
, char **ft
, int **att
, char **pat
, int *end
);
193 int conf_filetype(int idx
, char **ft
, char **pat
);
194 int conf_hlrev(void);
195 int conf_hlline(void);
196 int conf_hlmode(void);
197 int conf_hlback(void);
199 char **conf_kmap(int id
);
200 int conf_kmapfind(char *name
);
201 char *conf_digraph(int c1
, int c2
);
202 char *conf_lnpref(void);
203 char *conf_definition(char *ft
);
204 char *conf_section(char *ft
);
205 char *conf_ecmd(void);
207 /* global variables */
223 extern int xkmap_alt
;
228 /* tag file handling */
230 int tag_find(char *name
, int *pos
, int dir
, char *path
, int pathlen
, char *cmd
, int cmdlen
);