xref: /openbsd/lib/libcurses/tinfo/MKkeys_list.sh (revision 4bdff4be)
1# $OpenBSD: MKkeys_list.sh,v 1.2 2023/10/17 09:52:09 nicm Exp $
2#! /bin/sh
3# $Id: MKkeys_list.sh,v 1.2 2023/10/17 09:52:09 nicm Exp $
4##############################################################################
5# Copyright 2019-2020,2022 Thomas E. Dickey                                  #
6# Copyright 2001-2003,2017 Free Software Foundation, Inc.                    #
7#                                                                            #
8# Permission is hereby granted, free of charge, to any person obtaining a    #
9# copy of this software and associated documentation files (the "Software"), #
10# to deal in the Software without restriction, including without limitation  #
11# the rights to use, copy, modify, merge, publish, distribute, distribute    #
12# with modifications, sublicense, and/or sell copies of the Software, and to #
13# permit persons to whom the Software is furnished to do so, subject to the  #
14# following conditions:                                                      #
15#                                                                            #
16# The above copyright notice and this permission notice shall be included in #
17# all copies or substantial portions of the Software.                        #
18#                                                                            #
19# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
20# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
21# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
22# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
23# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
24# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
25# DEALINGS IN THE SOFTWARE.                                                  #
26#                                                                            #
27# Except as contained in this notice, the name(s) of the above copyright     #
28# holders shall not be used in advertising or otherwise to promote the sale, #
29# use or other dealings in this Software without prior written               #
30# authorization.                                                             #
31##############################################################################
32#
33# MKkey_defs.sh -- generate list of function-keys for terminfo database
34#
35# Author: Thomas E. Dickey 2001
36#
37# Extract function-key names from the Caps file
38#
39: ${AWK-awk}
40if test $# != 0
41then
42	DATA="$*"
43else
44	DATA=../../include/Caps
45fi
46
47data=data$$
48trap 'rm -f $data; exit 1' 1 2 3 15
49trap 'rm -f $data' 0
50cat $DATA | sed -e 's/[	][	]*/	/g' >$data
51
52cat <<EOF
53# These definitions were generated by $0 $DATA
54KEY_BREAK
55KEY_SRESET
56KEY_RESET
57KEY_RESIZE
58EOF
59
60${AWK-awk} <$data '
61/^#/		{next;}
62/^capalias/	{next;}
63/^infoalias/	{next;}
64/^userdef/	{next;}
65
66$5 != "-" {
67		if (substr($5, 1, 4) == "KEY_" ) {
68			printf "%s	%s\n", $5, $1
69	}
70}
71'
72