xref: /freebsd/contrib/nvi/common/seq.h (revision 110d525ec6188f3c9dc4f54c4bc1cced2f7184cd)
1b8ba871bSPeter Wemm /*-
2b8ba871bSPeter Wemm  * Copyright (c) 1992, 1993, 1994
3b8ba871bSPeter Wemm  *	The Regents of the University of California.  All rights reserved.
4b8ba871bSPeter Wemm  * Copyright (c) 1992, 1993, 1994, 1995, 1996
5b8ba871bSPeter Wemm  *	Keith Bostic.  All rights reserved.
6b8ba871bSPeter Wemm  *
7b8ba871bSPeter Wemm  * See the LICENSE file for redistribution information.
8b8ba871bSPeter Wemm  */
9b8ba871bSPeter Wemm 
10b8ba871bSPeter Wemm /*
11b8ba871bSPeter Wemm  * Map and abbreviation structures.
12b8ba871bSPeter Wemm  *
13*f0957ccaSPeter Wemm  * The map structure is singly linked list, sorted by input string and by
14b8ba871bSPeter Wemm  * input length within the string.  (The latter is necessary so that short
15b8ba871bSPeter Wemm  * matches will happen before long matches when the list is searched.)
16b8ba871bSPeter Wemm  * Additionally, there is a bitmap which has bits set if there are entries
17b8ba871bSPeter Wemm  * starting with the corresponding character.  This keeps us from walking
18b8ba871bSPeter Wemm  * the list unless it's necessary.
19b8ba871bSPeter Wemm  *
20b8ba871bSPeter Wemm  * The name and the output fields of a SEQ can be empty, i.e. NULL.
21b8ba871bSPeter Wemm  * Only the input field is required.
22b8ba871bSPeter Wemm  *
23b8ba871bSPeter Wemm  * XXX
24b8ba871bSPeter Wemm  * The fast-lookup bits are never turned off -- users don't usually unmap
25b8ba871bSPeter Wemm  * things, though, so it's probably not a big deal.
26b8ba871bSPeter Wemm  */
27b8ba871bSPeter Wemm struct _seq {
28*f0957ccaSPeter Wemm 	SLIST_ENTRY(_seq) q;		/* Linked list of all sequences. */
29b8ba871bSPeter Wemm 	seq_t	 stype;			/* Sequence type. */
30b8ba871bSPeter Wemm 	CHAR_T	*name;			/* Sequence name (if any). */
31b8ba871bSPeter Wemm 	size_t	 nlen;			/* Name length. */
32b8ba871bSPeter Wemm 	CHAR_T	*input;			/* Sequence input keys. */
33b8ba871bSPeter Wemm 	size_t	 ilen;			/* Input keys length. */
34b8ba871bSPeter Wemm 	CHAR_T	*output;		/* Sequence output keys. */
35b8ba871bSPeter Wemm 	size_t	 olen;			/* Output keys length. */
36b8ba871bSPeter Wemm 
37b8ba871bSPeter Wemm #define	SEQ_FUNCMAP	0x01		/* If unresolved function key.*/
38b8ba871bSPeter Wemm #define	SEQ_NOOVERWRITE	0x02		/* Don't replace existing entry. */
39b8ba871bSPeter Wemm #define	SEQ_SCREEN	0x04		/* If screen specific. */
40b8ba871bSPeter Wemm #define	SEQ_USERDEF	0x08		/* If user defined. */
41b8ba871bSPeter Wemm 	u_int8_t flags;
42b8ba871bSPeter Wemm };
43