kmap.h: switch the mapping of K and L in kmap_fa[]
[neatvi.git] / vi.h
blob2624230287bff2dfaebbde067fac0b22c0c420ae
1 /* neatvi main header */
3 /* helper macros */
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);
26 /* motions */
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 */
47 #define RE_ICASE 1
48 #define RE_NOTBOL 2
49 #define RE_NOTEOL 4
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);
55 /* rendering lines */
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);
63 int ren_wid(char *s);
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);
68 /* text direction */
69 int dir_context(char *s);
70 void dir_reorder(char *s, int *ord);
71 void dir_init(void);
72 void dir_done(void);
74 /* string registers */
75 char *reg_get(int c, int *lnmode);
76 void reg_put(int c, char *s, int lnmode);
77 void reg_done(void);
79 /* utf-8 helper functions */
80 int uc_len(char *s);
81 int uc_wid(char *s);
82 int uc_slen(char *s);
83 int uc_code(char *s);
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);
92 int uc_kind(char *c);
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);
113 int term_rows(void);
114 int term_cols(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);
133 /* ex commands */
134 void ex(void);
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 */
143 #define SYN_BD 0x100
144 #define SYN_IT 0x200
145 #define SYN_RV 0x400
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);
152 void syn_init(void);
153 void syn_done(void);
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 */
165 #define PATHLEN 512
167 extern int xvis;
168 extern struct lbuf *xb;
169 extern int xrow;
170 extern int xoff;
171 extern int xtop;
172 extern int xled;
173 extern int xrow_alt;
174 extern char xpath[];
175 extern char xpath_alt[];
176 extern int xquit;
177 extern int xic;
178 extern int xai;
179 extern int xdir;
180 extern int xshape;
181 extern int xorder;
182 extern char xft[];