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
, 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 expression sets */
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
);
59 int *ren_position(char *s
);
60 int ren_next(char *s
, int p
, int dir
);
61 int ren_eol(char *s
, int dir
);
62 int ren_pos(char *s
, int off
);
63 int ren_cursor(char *s
, int pos
);
64 int ren_noeol(char *s
, int p
);
65 int ren_off(char *s
, int pos
);
67 int ren_region(char *s
, int c1
, int c2
, int *l1
, int *l2
, int closed
);
68 char *ren_translate(char *s
, char *ln
);
69 int ren_cwid(char *s
, int pos
);
72 int dir_context(char *s
);
73 void dir_reorder(char *s
, int *ord
);
77 /* string registers */
78 char *reg_get(int c
, int *lnmode
);
79 void reg_put(int c
, char *s
, int lnmode
);
82 /* utf-8 helper functions */
87 char *uc_chr(char *s
, int off
);
88 int uc_off(char *s
, int off
);
89 char *uc_sub(char *s
, int beg
, int end
);
90 char *uc_dup(char *s
);
91 int uc_isspace(char *s
);
92 int uc_isprint(char *s
);
93 int uc_isdigit(char *s
);
94 int uc_isalpha(char *s
);
96 int uc_isbell(char *c
);
97 int uc_iscomb(char *c
);
98 char **uc_chop(char *s
, int *n
);
99 char *uc_next(char *s
);
100 char *uc_prev(char *beg
, char *s
);
101 char *uc_beg(char *beg
, char *s
);
102 char *uc_end(char *s
);
103 char *uc_shape(char *beg
, char *s
);
104 char *uc_lastline(char *s
);
106 /* managing the terminal */
107 #define xrows (term_rows() - 1)
108 #define xcols (term_cols())
110 void term_init(void);
111 void term_done(void);
112 void term_suspend(void);
113 void term_str(char *s
);
114 void term_chr(int ch
);
115 void term_pos(int r
, int c
);
116 void term_clear(void);
117 void term_kill(void);
118 void term_room(int n
);
122 void term_record(void);
123 void term_commit(void);
124 char *term_att(int att
, int old
);
125 void term_push(char *s
, int n
);
126 char *term_cmd(int *n
);
128 #define TK_CTL(x) ((x) & 037)
129 #define TK_INT(c) ((c) < 0 || (c) == TK_ESC || (c) == TK_CTL('c'))
130 #define TK_ESC (TK_CTL('['))
132 /* line-oriented input and output */
133 char *led_prompt(char *pref
, char *post
, int *kmap
, char *syn
);
134 char *led_input(char *pref
, char *post
, int *kmap
, char *syn
);
135 void led_print(char *msg
, int row
, char *syn
);
136 void led_printmsg(char *s
, int row
, char *syn
);
137 char *led_read(int *kmap
);
138 int led_pos(char *s
, int pos
);
142 void ex_command(char *cmd
);
143 char *ex_read(char *msg
);
144 void ex_print(char *line
);
145 void ex_show(char *msg
);
146 int ex_init(char **files
);
149 char *ex_filetype(void);
150 struct lbuf
*ex_lbuf(void);
151 int ex_kwd(char **kwd
, int *dir
);
152 void ex_kwdset(char *kwd
, int dir
);
154 #define EXLEN 512 /* ex line length */
157 /* process management */
158 char *cmd_pipe(char *cmd
, char *s
, int iproc
, int oproc
);
159 int cmd_exec(char *cmd
);
161 /* syntax highlighting */
162 #define SYN_BD 0x010000
163 #define SYN_IT 0x020000
164 #define SYN_RV 0x040000
165 #define SYN_FGMK(f) (0x100000 | (f))
166 #define SYN_BGMK(b) (0x200000 | ((b) << 8))
168 #define SYN_FLG 0xff0000
169 #define SYN_FGSET(a) ((a) & 0x1000ff)
170 #define SYN_BGSET(a) ((a) & 0x20ff00)
171 #define SYN_FG(a) ((a) & 0xff)
172 #define SYN_BG(a) (((a) >> 8) & 0xff)
174 int *syn_highlight(char *ft
, char *s
);
175 char *syn_filetype(char *path
);
176 void syn_context(int att
);
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_hlrev(void);
188 int conf_hlline(void);
190 char **conf_kmap(int id
);
191 int conf_kmapfind(char *name
);
192 char *conf_digraph(int c1
, int c2
);
194 /* global variables */
210 extern int xkmap_alt
;