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 int lbuf_glob(struct lbuf
*lb
, int pos
, int v
);
27 int lbuf_findchar(struct lbuf
*lb
, char *cs
, int cmd
, int n
, int *r
, int *o
);
28 int lbuf_search(struct lbuf
*lb
, char *kw
, int dir
, int *r
, int *o
, int *len
);
29 int lbuf_paragraphbeg(struct lbuf
*lb
, int dir
, int *row
, int *off
);
30 int lbuf_sectionbeg(struct lbuf
*lb
, int dir
, int *row
, int *off
);
31 int lbuf_wordbeg(struct lbuf
*lb
, int big
, int dir
, int *row
, int *off
);
32 int lbuf_wordend(struct lbuf
*lb
, int big
, int dir
, int *row
, int *off
);
33 int lbuf_pair(struct lbuf
*lb
, int *row
, int *off
);
35 /* string buffer, variable-sized string */
36 struct sbuf
*sbuf_make(void);
37 void sbuf_free(struct sbuf
*sb
);
38 char *sbuf_done(struct sbuf
*sb
);
39 char *sbuf_buf(struct sbuf
*sb
);
40 void sbuf_chr(struct sbuf
*sb
, int c
);
41 void sbuf_str(struct sbuf
*sb
, char *s
);
42 void sbuf_mem(struct sbuf
*sb
, char *s
, int len
);
43 void sbuf_printf(struct sbuf
*sbuf
, char *s
, ...);
44 int sbuf_len(struct sbuf
*sb
);
45 void sbuf_cut(struct sbuf
*s
, int len
);
47 /* regular expression sets */
52 struct rset
*rset_make(int n
, char **pat
, int flg
);
53 int rset_find(struct rset
*re
, char *s
, int n
, int *grps
, int flg
);
54 void rset_free(struct rset
*re
);
55 char *re_read(char **src
);
58 int *ren_position(char *s
);
59 int ren_next(char *s
, int p
, int dir
);
60 int ren_eol(char *s
, int dir
);
61 int ren_pos(char *s
, int off
);
62 int ren_cursor(char *s
, int pos
);
63 int ren_noeol(char *s
, int p
);
64 int ren_off(char *s
, int pos
);
66 int ren_region(char *s
, int c1
, int c2
, int *l1
, int *l2
, int closed
);
67 char *ren_translate(char *s
, char *ln
);
68 int ren_cwid(char *s
, int pos
);
71 int dir_context(char *s
);
72 void dir_reorder(char *s
, int *ord
);
76 /* string registers */
77 char *reg_get(int c
, int *lnmode
);
78 void reg_put(int c
, char *s
, int lnmode
);
81 /* utf-8 helper functions */
86 char *uc_chr(char *s
, int off
);
87 int uc_off(char *s
, int off
);
88 char *uc_sub(char *s
, int beg
, int end
);
89 char *uc_dup(char *s
);
90 int uc_isspace(char *s
);
91 int uc_isprint(char *s
);
92 int uc_isdigit(char *s
);
93 int uc_isalpha(char *s
);
95 int uc_isbell(char *c
);
96 int uc_iscomb(char *c
);
97 char **uc_chop(char *s
, int *n
);
98 char *uc_next(char *s
);
99 char *uc_prev(char *beg
, char *s
);
100 char *uc_beg(char *beg
, char *s
);
101 char *uc_end(char *s
);
102 char *uc_shape(char *beg
, char *s
);
103 char *uc_lastline(char *s
);
105 /* managing the terminal */
106 #define xrows (term_rows() - 1)
107 #define xcols (term_cols())
109 void term_init(void);
110 void term_done(void);
111 void term_suspend(void);
112 void term_str(char *s
);
113 void term_chr(int ch
);
114 void term_pos(int r
, int c
);
115 void term_clear(void);
116 void term_kill(void);
117 void term_room(int n
);
121 void term_record(void);
122 void term_commit(void);
123 char *term_att(int att
, int old
);
124 void term_push(char *s
, int n
);
125 char *term_cmd(int *n
);
127 #define TK_CTL(x) ((x) & 037)
128 #define TK_INT(c) ((c) < 0 || (c) == TK_ESC || (c) == TK_CTL('c'))
129 #define TK_ESC (TK_CTL('['))
131 /* line-oriented input and output */
132 char *led_prompt(char *pref
, char *post
, char **kmap
);
133 char *led_input(char *pref
, char *post
, char **kmap
);
134 char *led_read(char **kmap
);
135 void led_print(char *msg
, int row
);
136 void led_printmsg(char *s
, int row
);
137 int led_pos(char *s
, int pos
);
141 void ex_command(char *cmd
);
142 char *ex_read(char *msg
);
143 void ex_print(char *line
);
144 void ex_show(char *msg
);
145 int ex_init(char **files
);
148 char *ex_filetype(void);
149 char **ex_kmap(void);
150 char *ex_kmapalt(void);
151 struct lbuf
*ex_lbuf(void);
152 int ex_kwd(char **kwd
, int *dir
);
153 void ex_kwdset(char *kwd
, int dir
);
155 #define EXLEN 512 /* ex line length */
158 /* process management */
159 char *cmd_pipe(char *cmd
, char *s
, int iproc
, int oproc
);
160 int cmd_exec(char *cmd
);
162 /* syntax highlighting */
163 #define SYN_BD 0x010000
164 #define SYN_IT 0x020000
165 #define SYN_RV 0x040000
166 #define SYN_FGMK(f) (0x100000 | (f))
167 #define SYN_BGMK(b) (0x200000 | ((b) << 8))
169 #define SYN_FLG 0xff0000
170 #define SYN_FGSET(a) ((a) & 0x1000ff)
171 #define SYN_BGSET(a) ((a) & 0x20ff00)
172 #define SYN_FG(a) ((a) & 0xff)
173 #define SYN_BG(a) (((a) >> 8) & 0xff)
175 int *syn_highlight(char *ft
, char *s
);
176 char *syn_filetype(char *path
);
177 int syn_merge(int old
, int new);
181 /* configuration variables */
182 int conf_dirmark(int idx
, char **pat
, int *ctx
, int *dir
, int *grp
);
183 int conf_dircontext(int idx
, char **pat
, int *ctx
);
184 int conf_placeholder(int idx
, char **s
, char **d
, int *wid
);
185 int conf_highlight(int idx
, char **ft
, int **att
, char **pat
, int *end
);
186 int conf_filetype(int idx
, char **ft
, char **pat
);
187 int conf_highlight_revdir(int *att
);
188 char **conf_kmap(char *name
);
189 char *conf_digraph(int c1
, int c2
);
191 /* global variables */