xref: /openbsd-src/usr.bin/less/option.h (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /*	$OpenBSD: option.h,v 1.2 2001/01/29 01:58:03 niklas Exp $	*/
2 
3 /*
4  * Copyright (c) 1984,1985,1989,1994,1995  Mark Nudelman
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice in the documentation and/or other materials provided with
14  *    the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
22  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 
30 #define	END_OPTION_STRING	('$')
31 
32 /*
33  * Types of options.
34  */
35 #define	BOOL		01	/* Boolean option: 0 or 1 */
36 #define	TRIPLE		02	/* Triple-valued option: 0, 1 or 2 */
37 #define	NUMBER		04	/* Numeric option */
38 #define	STRING		010	/* String-valued option */
39 #define	NOVAR		020	/* No associated variable */
40 #define	REPAINT		040	/* Repaint screen after toggling option */
41 #define	NO_TOGGLE	0100	/* Option cannot be toggled with "-" cmd */
42 #define	HL_REPAINT	0200	/* Repaint hilites after toggling option */
43 #define	NO_QUERY	0400	/* Option cannot be queried with "_" cmd */
44 
45 #define	OTYPE		(BOOL|TRIPLE|NUMBER|STRING|NOVAR)
46 
47 /*
48  * Argument to a handling function tells what type of activity:
49  */
50 #define	INIT	0	/* Initialization (from command line) */
51 #define	QUERY	1	/* Query (from _ or - command) */
52 #define	TOGGLE	2	/* Change value (from - command) */
53 
54 /* Flag to toggle_option to specify how to "toggle" */
55 #define	OPT_NO_TOGGLE	0
56 #define	OPT_TOGGLE	1
57 #define	OPT_UNSET	2
58 #define	OPT_SET		3
59 
60 struct option
61 {
62 	char oletter;		/* The controlling letter (a-z) */
63 	int otype;		/* Type of the option */
64 	int odefault;		/* Default value */
65 	int *ovar;		/* Pointer to the associated variable */
66 	void (*ofunc)();	/* Pointer to special handling function */
67 	char *odesc[3];		/* Description of each value */
68 };
69 
70