option.h revision 221715
160786Sps/*
2221715Sdelphij * Copyright (C) 1984-2011  Mark Nudelman
360786Sps *
460786Sps * You may distribute under the terms of either the GNU General Public
560786Sps * License or the Less License, as specified in the README file.
660786Sps *
760786Sps * For more information about less, or for information on how to
860786Sps * contact the author, see the README file.
960786Sps */
1060786Sps
1160786Sps
1260786Sps#define	END_OPTION_STRING	('$')
1360786Sps
1460786Sps/*
1560786Sps * Types of options.
1660786Sps */
1760786Sps#define	BOOL		01	/* Boolean option: 0 or 1 */
1860786Sps#define	TRIPLE		02	/* Triple-valued option: 0, 1 or 2 */
1960786Sps#define	NUMBER		04	/* Numeric option */
2060786Sps#define	STRING		010	/* String-valued option */
2160786Sps#define	NOVAR		020	/* No associated variable */
2260786Sps#define	REPAINT		040	/* Repaint screen after toggling option */
2360786Sps#define	NO_TOGGLE	0100	/* Option cannot be toggled with "-" cmd */
2460786Sps#define	HL_REPAINT	0200	/* Repaint hilites after toggling option */
2560786Sps#define	NO_QUERY	0400	/* Option cannot be queried with "_" cmd */
26128345Stjr#define	INIT_HANDLER	01000	/* Call option handler function at startup */
2760786Sps
2860786Sps#define	OTYPE		(BOOL|TRIPLE|NUMBER|STRING|NOVAR)
2960786Sps
30221715Sdelphij#define OLETTER_NONE    '\1'     /* Invalid option letter */
31221715Sdelphij
3260786Sps/*
3360786Sps * Argument to a handling function tells what type of activity:
3460786Sps */
3560786Sps#define	INIT	0	/* Initialization (from command line) */
3660786Sps#define	QUERY	1	/* Query (from _ or - command) */
3760786Sps#define	TOGGLE	2	/* Change value (from - command) */
3860786Sps
3960786Sps/* Flag to toggle_option to specify how to "toggle" */
4060786Sps#define	OPT_NO_TOGGLE	0
4160786Sps#define	OPT_TOGGLE	1
4260786Sps#define	OPT_UNSET	2
4360786Sps#define	OPT_SET		3
4460786Sps#define OPT_NO_PROMPT	0100
4560786Sps
4660786Sps/* Error code from findopt_name */
4760786Sps#define OPT_AMBIG       1
4860786Sps
4960786Spsstruct optname
5060786Sps{
5160786Sps	char *oname;            /* Long (GNU-style) option name */
5260786Sps	struct optname *onext;  /* List of synonymous option names */
5360786Sps};
5460786Sps
55221715Sdelphij#define OPTNAME_MAX	32	/* Max length of long option name */
56221715Sdelphij
57128345Stjrstruct loption
5860786Sps{
5960786Sps	char oletter;		/* The controlling letter (a-z) */
6060786Sps	struct optname *onames; /* Long (GNU-style) option name */
6160786Sps	int otype;		/* Type of the option */
6260786Sps	int odefault;		/* Default value */
6360786Sps	int *ovar;		/* Pointer to the associated variable */
6460786Sps	void (*ofunc)();	/* Pointer to special handling function */
6560786Sps	char *odesc[3];		/* Description of each value */
6660786Sps};
6760786Sps
68