xref: /freebsd/contrib/ncurses/misc/gen_edit.sh (revision 3b68c491d37196bb76a95bce3c02f7c6d5ba22fd)
1#!/bin/sh
2##############################################################################
3# Copyright 2020,2021 Thomas E. Dickey                                       #
4# Copyright 2004-2011,2012 Free Software Foundation, Inc.                    #
5#                                                                            #
6# Permission is hereby granted, free of charge, to any person obtaining a    #
7# copy of this software and associated documentation files (the "Software"), #
8# to deal in the Software without restriction, including without limitation  #
9# the rights to use, copy, modify, merge, publish, distribute, distribute    #
10# with modifications, sublicense, and/or sell copies of the Software, and to #
11# permit persons to whom the Software is furnished to do so, subject to the  #
12# following conditions:                                                      #
13#                                                                            #
14# The above copyright notice and this permission notice shall be included in #
15# all copies or substantial portions of the Software.                        #
16#                                                                            #
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
20# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
23# DEALINGS IN THE SOFTWARE.                                                  #
24#                                                                            #
25# Except as contained in this notice, the name(s) of the above copyright     #
26# holders shall not be used in advertising or otherwise to promote the sale, #
27# use or other dealings in this Software without prior written               #
28# authorization.                                                             #
29##############################################################################
30#
31# Author: Thomas E. Dickey
32#
33# $Id: gen_edit.sh,v 1.7 2021/09/04 15:55:29 tom Exp $
34# Generate a sed-script for converting the terminfo.src to the form which will
35# be installed.
36#
37# Assumes:
38#	The leaf directory names (lib, tabset, terminfo)
39#
40
41linux_dft=linux2.2
42
43: "${datadir=/usr/share}"
44: "${WHICH_LINUX=$linux_dft}"
45: "${WHICH_XTERM=xterm-new}"
46: "${XTERM_KBS=BS}"
47
48# If we're not installing into /usr/share/, we'll have to adjust the location
49# of the tabset files in terminfo.src (which are in a parallel directory).
50TABSET=${datadir}/tabset
51if test "x$TABSET" != "x/usr/share/tabset" ; then
52cat <<EOF
53s%/usr/share/tabset%$TABSET%g
54EOF
55fi
56
57if test "$WHICH_XTERM" != "xterm-new" ; then
58echo "** using $WHICH_XTERM terminal description for XTerm entry" >&2
59cat <<EOF
60/^# This is xterm for ncurses/,/^$/{
61	s/use=xterm-new,/use=$WHICH_XTERM,/
62}
63EOF
64fi
65
66if test "$XTERM_KBS" != "BS" ; then
67echo "** using DEL for XTerm backspace-key" >&2
68cat <<EOF
69/^xterm+kbs|fragment for backspace key/,/^#/{
70	s/kbs=^H,/kbs=^?,/
71}
72EOF
73fi
74
75# Work around incompatibities built into Linux console.  The 2.6 series added
76# a patch to fixup the SI/SO behavior, which is closer to vt100, but the older
77# kernels do not recognize those controls.  All of the kernels recognize the
78# older flavor of rmacs/smacs, but beginning in the late 1990s, changes made
79# as part of implementing UTF-8 prevent using those for line-drawing when the
80# console is in UTF-8 mode.  Taking into account the fact that it took about
81# ten years to provide (and distribute) the 2.6 series' change for SI/SO, the
82# default remains "linux2.2".
83case x$WHICH_LINUX in #(vi
84xauto)
85	system=`uname -s 2>/dev/null`
86	if test "x$system" = xLinux
87	then
88		case x`uname -r` in
89		x1.*)
90			WHICH_LINUX=linux-c
91			;;
92		x2.[0-4]*)
93			WHICH_LINUX=linux2.2
94			;;
95		*)
96			WHICH_LINUX=linux3.0
97			;;
98		esac
99	else
100		WHICH_LINUX=$linux_dft
101	fi
102	;;
103xlinux*)
104	# allow specific setting
105	;;
106*)
107	WHICH_LINUX=$linux_dft
108	;;
109esac
110
111if test $WHICH_LINUX != $linux_dft
112then
113echo "** using $WHICH_LINUX terminal description for Linux console" >&2
114cat <<EOF
115/^# This is Linux console for ncurses/,/^$/{
116	s/use=$linux_dft,/use=$WHICH_LINUX,/
117}
118EOF
119fi
120