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
);
19 int lbuf_markpos(struct lbuf
*lbuf
, int mark
);
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
);
25 /* string buffer, variable-sized string */
26 struct sbuf
*sbuf_make(void);
27 void sbuf_free(struct sbuf
*sb
);
28 char *sbuf_done(struct sbuf
*sb
);
29 char *sbuf_buf(struct sbuf
*sb
);
30 void sbuf_chr(struct sbuf
*sb
, int c
);
31 void sbuf_str(struct sbuf
*sb
, char *s
);
32 void sbuf_mem(struct sbuf
*sb
, char *s
, int len
);
33 void sbuf_printf(struct sbuf
*sbuf
, char *s
, ...);
34 int sbuf_len(struct sbuf
*sb
);
35 void sbuf_cut(struct sbuf
*s
, int len
);
37 /* regular expression sets */
42 struct rset
*rset_make(int n
, char **pat
, int flg
);
43 int rset_find(struct rset
*re
, char *s
, int n
, int *grps
, int flg
);
44 void rset_free(struct rset
*re
);
47 int *ren_position(char *s
);
48 int ren_next(char *s
, int p
, int dir
);
49 int ren_eol(char *s
, int dir
);
50 int ren_pos(char *s
, int off
);
51 int ren_cursor(char *s
, int pos
);
52 int ren_noeol(char *s
, int p
);
53 int ren_off(char *s
, int pos
);
55 int ren_region(char *s
, int c1
, int c2
, int *l1
, int *l2
, int closed
);
56 char *ren_translate(char *s
, char *ln
);
57 int ren_cwid(char *s
, int pos
);
60 int dir_context(char *s
);
61 void dir_reorder(char *s
, int *ord
);
65 /* string registers */
66 char *reg_get(int c
, int *lnmode
);
67 void reg_put(int c
, char *s
, int lnmode
);
70 /* utf-8 helper functions */
75 char *uc_chr(char *s
, int off
);
76 int uc_off(char *s
, int off
);
77 char *uc_sub(char *s
, int beg
, int end
);
78 char *uc_dup(char *s
);
79 int uc_isspace(char *s
);
80 int uc_isprint(char *s
);
81 int uc_isdigit(char *s
);
82 int uc_isalpha(char *s
);
84 char **uc_chop(char *s
, int *n
);
85 char *uc_next(char *s
);
86 char *uc_beg(char *beg
, char *s
);
87 char *uc_end(char *beg
, char *s
);
88 char *uc_shape(char *beg
, char *s
);
90 /* managing the terminal */
91 #define xrows (term_rows() - 1)
92 #define xcols (term_cols())
96 void term_str(char *s
);
97 void term_chr(int ch
);
98 void term_pos(int r
, int c
);
99 void term_clear(void);
100 void term_kill(void);
103 int term_read(int timeout
);
104 void term_record(void);
105 void term_commit(void);
107 #define TK_CTL(x) ((x) & 037)
108 #define TK_INT(c) ((c) < 0 || (c) == TK_ESC || (c) == TK_CTL('c'))
109 #define TK_ESC (TK_CTL('['))
111 /* line-oriented input and output */
112 char *led_prompt(char *pref
, char *post
, char **kmap
);
113 char *led_input(char *pref
, char *post
, char *ai
, int ai_max
, char **kmap
);
114 void led_print(char *msg
, int row
);
115 char *led_keymap(char *kmap
, int c
);
116 int led_pos(char *s
, int pos
);
120 void ex_command(char *cmd
);
121 char *ex_read(char *msg
);
122 void ex_show(char *msg
);
124 /* process management */
125 char *cmd_pipe(char *cmd
, char *s
);
127 /* configuration variables */
128 char *conf_kmapalt(void);
129 int conf_dirmark(int idx
, char **pat
, int *ctx
, int *dir
, int *grp
);
130 int conf_dircontext(int idx
, char **pat
, int *ctx
);
131 int conf_placeholder(int idx
, char **s
, char **d
, int *wid
);
133 /* global variables */
137 extern struct lbuf
*xb
;
144 extern char xpath_alt
[];