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 void lbuf_rd(struct lbuf
*lbuf
, int fd
, int pos
);
12 void lbuf_wr(struct lbuf
*lbuf
, int fd
, int beg
, int end
);
13 void lbuf_rm(struct lbuf
*lbuf
, int beg
, int end
);
14 char *lbuf_cp(struct lbuf
*lbuf
, int beg
, int end
);
15 void lbuf_put(struct lbuf
*lbuf
, int pos
, char *s
);
16 char *lbuf_get(struct lbuf
*lbuf
, int pos
);
17 int lbuf_len(struct lbuf
*lbuf
);
18 void lbuf_mark(struct lbuf
*lbuf
, int mark
, int pos
, int off
);
19 int lbuf_markpos(struct lbuf
*lbuf
, int mark
, int *pos
, int *off
);
20 void lbuf_undo(struct lbuf
*lbuf
);
21 void lbuf_redo(struct lbuf
*lbuf
);
22 void lbuf_undomark(struct lbuf
*lbuf
);
23 void lbuf_undofree(struct lbuf
*lbuf
);
24 int lbuf_indents(struct lbuf
*lb
, int r
);
25 int lbuf_eol(struct lbuf
*lb
, int r
);
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
);
34 /* string buffer, variable-sized string */
35 struct sbuf
*sbuf_make(void);
36 void sbuf_free(struct sbuf
*sb
);
37 char *sbuf_done(struct sbuf
*sb
);
38 char *sbuf_buf(struct sbuf
*sb
);
39 void sbuf_chr(struct sbuf
*sb
, int c
);
40 void sbuf_str(struct sbuf
*sb
, char *s
);
41 void sbuf_mem(struct sbuf
*sb
, char *s
, int len
);
42 void sbuf_printf(struct sbuf
*sbuf
, char *s
, ...);
43 int sbuf_len(struct sbuf
*sb
);
44 void sbuf_cut(struct sbuf
*s
, int len
);
46 /* regular expression sets */
51 struct rset
*rset_make(int n
, char **pat
, int flg
);
52 int rset_find(struct rset
*re
, char *s
, int n
, int *grps
, int flg
);
53 void rset_free(struct rset
*re
);
56 int *ren_position(char *s
);
57 int ren_next(char *s
, int p
, int dir
);
58 int ren_eol(char *s
, int dir
);
59 int ren_pos(char *s
, int off
);
60 int ren_cursor(char *s
, int pos
);
61 int ren_noeol(char *s
, int p
);
62 int ren_off(char *s
, int pos
);
64 int ren_region(char *s
, int c1
, int c2
, int *l1
, int *l2
, int closed
);
65 char *ren_translate(char *s
, char *ln
);
66 int ren_cwid(char *s
, int pos
);
69 int dir_context(char *s
);
70 void dir_reorder(char *s
, int *ord
);
74 /* string registers */
75 char *reg_get(int c
, int *lnmode
);
76 void reg_put(int c
, char *s
, int lnmode
);
79 /* utf-8 helper functions */
84 char *uc_chr(char *s
, int off
);
85 int uc_off(char *s
, int off
);
86 char *uc_sub(char *s
, int beg
, int end
);
87 char *uc_dup(char *s
);
88 int uc_isspace(char *s
);
89 int uc_isprint(char *s
);
90 int uc_isdigit(char *s
);
91 int uc_isalpha(char *s
);
93 char **uc_chop(char *s
, int *n
);
94 char *uc_next(char *s
);
95 char *uc_prev(char *beg
, char *s
);
96 char *uc_beg(char *beg
, char *s
);
97 char *uc_end(char *s
);
98 char *uc_shape(char *beg
, char *s
);
99 char *uc_lastline(char *s
);
101 /* managing the terminal */
102 #define xrows (term_rows() - 1)
103 #define xcols (term_cols())
105 void term_init(void);
106 void term_done(void);
107 void term_suspend(void);
108 void term_str(char *s
);
109 void term_chr(int ch
);
110 void term_pos(int r
, int c
);
111 void term_clear(void);
112 void term_kill(void);
115 int term_read(int timeout
);
116 void term_record(void);
117 void term_commit(void);
118 char *term_att(int att
, int old
);
119 void term_push(char *s
, int n
);
120 char *term_cmd(int *n
);
122 #define TK_CTL(x) ((x) & 037)
123 #define TK_INT(c) ((c) < 0 || (c) == TK_ESC || (c) == TK_CTL('c'))
124 #define TK_ESC (TK_CTL('['))
126 /* line-oriented input and output */
127 char *led_prompt(char *pref
, char *post
, char **kmap
);
128 char *led_input(char *pref
, char *post
, char *ai
, int ai_max
, char **kmap
);
129 char *led_read(char **kmap
);
130 void led_print(char *msg
, int row
);
131 int led_pos(char *s
, int pos
);
135 void ex_command(char *cmd
);
136 char *ex_read(char *msg
);
137 void ex_show(char *msg
);
139 /* process management */
140 char *cmd_pipe(char *cmd
, char *s
);
142 /* syntax highlighting */
146 #define SYN_BGMK(b) ((b) << 16)
147 #define SYN_FG(a) ((a) & 0xffff)
148 #define SYN_BG(a) ((a) >> 16)
150 int *syn_highlight(char *ft
, char *s
);
151 char *syn_filetype(char *path
);
155 /* configuration variables */
156 char *conf_kmapalt(void);
157 int conf_dirmark(int idx
, char **pat
, int *ctx
, int *dir
, int *grp
);
158 int conf_dircontext(int idx
, char **pat
, int *ctx
);
159 int conf_placeholder(int idx
, char **s
, char **d
, int *wid
);
160 int conf_highlight(int idx
, char **ft
, int *att
, int *grp
, char **pat
);
161 int conf_filetype(int idx
, char **ft
, char **pat
);
162 int conf_highlight_revdir(int *att
);
164 /* global variables */
168 extern struct lbuf
*xb
;
175 extern char xpath_alt
[];