1 /*-
2  * Copyright (c) 2002 Jordan DeLong
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the author nor the names of contributors may be
14  *    used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 #ifndef OPTIONS_H
30 #define OPTIONS_H
31 
32 /* how long paren flashing flashes the matching paren */
33 #define FLASH_DURATION		300
34 
35 /* types of options */
36 enum {
37 	OPT_INT,
38 	OPT_UINT,
39 	OPT_BOOL,
40 	OPT_CHAR,
41 	OPT_STRING,
42 	OPT_COLOR,
43 	OPT_CALL
44 };
45 
46 /* entry in the options hash */
47 struct opt {
48 	LIST_ENTRY(opt) o_list;
49 
50 	int	type;
51 	u_char	*name;
52 	int	setable;/* option is setable at runtime */
53 
54 	/*
55 	 * pointer to either storage for the value; or in the case of
56 	 * OPT_CALL points to a function that is called with a single
57 	 * argument char * when the option is changed.
58 	 */
59 	void	*val;
60 };
61 LIST_HEAD(optlist, opt);
62 
63 /* hash of option names to opt_t */
64 #define OPTIONS_BUCKETS	16
65 extern optlist_t	*options_hash;
66 
67 /* general options are accessible here */
68 struct options {
69 	u_char	*autoviews;
70 	int	tabwidth;
71 	int	killringmax;
72 	int	markringmax;
73 	int	stickyhomekey;
74 	int	chunkyscroll;
75 	int	noexplicitmark;
76 	int	highbitmeta;
77 	int	icasesearch;
78 	int	autoindent;
79 	int	parenflash;
80 	int	forcefilenl;
81 	int	printnlatend;
82 	u_char	intrchar;
83 	u_char	blanklinechar;
84 };
85 
86 extern options_t options;
87 
88 void	options_init();
89 void	options_shutdown();
90 void	options_add(u_char *name, int type, void *var, int setable);
91 void	options_rm(u_char *);
92 opt_t	*options_lookup(u_char *name);
93 void	options_set(opt_t *, u_char *strval);
94 
95 #endif
96