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