tconf.c - neatvi - [fork] simple vi-type editor with UTF-8 support
(HTM) git clone git://src.adamsgaard.dk/neatvi
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
tconf.c (1884B)
---
1 #include <stdio.h>
2 #include <string.h>
3 #include "vi.h"
4 #include "conf.h"
5 #include "kmap.h"
6
7 int conf_dirmark(int idx, char **pat, int *ctx, int *dir, int *grp)
8 {
9 if (idx < 0 || idx >= LEN(dirmarks))
10 return 1;
11 if (pat)
12 *pat = dirmarks[idx].pat;
13 if (ctx)
14 *ctx = dirmarks[idx].ctx;
15 if (dir)
16 *dir = dirmarks[idx].dir;
17 if (grp)
18 *grp = dirmarks[idx].grp;
19 return 0;
20 }
21
22 int conf_dircontext(int idx, char **pat, int *ctx)
23 {
24 if (idx < 0 || idx >= LEN(dircontexts))
25 return 1;
26 if (pat)
27 *pat = dircontexts[idx].pat;
28 if (ctx)
29 *ctx = dircontexts[idx].dir;
30 return 0;
31 }
32
33 int conf_placeholder(int idx, char **s, char **d, int *wid)
34 {
35 if (idx < 0 || idx >= LEN(placeholders))
36 return 1;
37 if (s)
38 *s = placeholders[idx].s;
39 if (d)
40 *d = placeholders[idx].d;
41 if (wid)
42 *wid = placeholders[idx].wid;
43 return 0;
44 }
45
46 int conf_highlight(int idx, char **ft, int **att, char **pat, int *end)
47 {
48 if (idx < 0 || idx >= LEN(highlights))
49 return 1;
50 if (ft)
51 *ft = highlights[idx].ft;
52 if (att)
53 *att = highlights[idx].att;
54 if (pat)
55 *pat = highlights[idx].pat;
56 if (end)
57 *end = highlights[idx].end;
58 return 0;
59 }
60
61 int conf_filetype(int idx, char **ft, char **pat)
62 {
63 if (idx < 0 || idx >= LEN(filetypes))
64 return 1;
65 if (ft)
66 *ft = filetypes[idx].ft;
67 if (pat)
68 *pat = filetypes[idx].pat;
69 return 0;
70 }
71
72 int conf_hlrev(void)
73 {
74 return SYN_REVDIR;
75 }
76
77 int conf_hlline(void)
78 {
79 return SYN_LINE;
80 }
81
82 int conf_mode(void)
83 {
84 return MKFILE_MODE;
85 }
86
87 char **conf_kmap(int id)
88 {
89 return kmaps[id];
90 }
91
92 int conf_kmapfind(char *name)
93 {
94 int i;
95 for (i = 0; i < LEN(kmaps); i++)
96 if (name && kmaps[i][0] && !strcmp(name, kmaps[i][0]))
97 return i;
98 return 0;
99 }
100
101 char *conf_digraph(int c1, int c2)
102 {
103 int i;
104 for (i = 0; i < LEN(digraphs); i++)
105 if (digraphs[i][0][0] == c1 && digraphs[i][0][1] == c2)
106 return digraphs[i][1];
107 return NULL;
108 }
109
110 char *conf_lnpref(void)
111 {
112 return LNPREF;
113 }