1d522f475Smrg#!/bin/sh
204b94745Smrg# $XTermId: doublechars.sh,v 1.26 2022/04/25 23:25:41 tom Exp $
320d2c4d2Smrg# -----------------------------------------------------------------------------
420d2c4d2Smrg# this file is part of xterm
5d522f475Smrg#
64419d26bSmrg# Copyright 1999-2021,2022 by Thomas E. Dickey
7ad37e533Smrg#
820d2c4d2Smrg#                         All Rights Reserved
9ad37e533Smrg#
1020d2c4d2Smrg# Permission is hereby granted, free of charge, to any person obtaining a
1120d2c4d2Smrg# copy of this software and associated documentation files (the
1220d2c4d2Smrg# "Software"), to deal in the Software without restriction, including
1320d2c4d2Smrg# without limitation the rights to use, copy, modify, merge, publish,
1420d2c4d2Smrg# distribute, sublicense, and/or sell copies of the Software, and to
1520d2c4d2Smrg# permit persons to whom the Software is furnished to do so, subject to
1620d2c4d2Smrg# the following conditions:
17ad37e533Smrg#
1820d2c4d2Smrg# The above copyright notice and this permission notice shall be included
1920d2c4d2Smrg# in all copies or substantial portions of the Software.
20ad37e533Smrg#
2120d2c4d2Smrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2220d2c4d2Smrg# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2320d2c4d2Smrg# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2420d2c4d2Smrg# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
2520d2c4d2Smrg# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2620d2c4d2Smrg# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2720d2c4d2Smrg# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28ad37e533Smrg#
2920d2c4d2Smrg# Except as contained in this notice, the name(s) of the above copyright
3020d2c4d2Smrg# holders shall not be used in advertising or otherwise to promote the
3120d2c4d2Smrg# sale, use or other dealings in this Software without prior written
3220d2c4d2Smrg# authorization.
3320d2c4d2Smrg# -----------------------------------------------------------------------------
34d522f475Smrg# Illustrate the use of double-size characters by drawing successive lines in
35d522f475Smrg# the commonly used video attributes.
36d522f475Smrg#
37d522f475Smrg# Use the -w option to force the output to wrap.  It will look ugly, because
38d522f475Smrg# the double-high lines will be split.
39d522f475Smrg
40d522f475SmrgESC=""
41ad37e533SmrgCSI="${ESC}["
420bd37d32SmrgCMD='/bin/echo'
43d522f475SmrgOPT='-n'
44d522f475SmrgSUF=''
455307cd1aSmrg: "${TMPDIR=/tmp}"
465307cd1aSmrgTMP=`(mktemp "$TMPDIR/xterm.XXXXXXXX") 2>/dev/null` || TMP="$TMPDIR/xterm$$"
47d522f475Smrgeval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null
485307cd1aSmrg{ test ! -f "$TMP" || test -s "$TMP"; } &&
49ad37e533Smrgfor verb in "printf" "print" ; do
505307cd1aSmrg    rm -f "$TMP"
51d522f475Smrg    eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
525307cd1aSmrg    if test -f "$TMP" ; then
535307cd1aSmrg	if test ! -s "$TMP" ; then
54d522f475Smrg	    CMD="$verb"
55d522f475Smrg	    OPT=
56d522f475Smrg	    SUF='\c'
57d522f475Smrg	    break
58d522f475Smrg	fi
59d522f475Smrg    fi
60d522f475Smrgdone
615307cd1aSmrgrm -f "$TMP"
62d522f475Smrg
635307cd1aSmrgITAL=no
64d522f475SmrgSAVE=yes
65d522f475SmrgWRAP=no
66d522f475Smrgif test $# != 0 ; then
67d522f475Smrg    while test $# != 0
68d522f475Smrg    do
69d522f475Smrg    	case $1 in
705307cd1aSmrg	-i)	ITAL=yes ;;
71d522f475Smrg	-n)	SAVE=no ;;
72d522f475Smrg	-w)	WRAP=yes ;;
735307cd1aSmrg	*)
745307cd1aSmrg		echo "usage: $0 [-i] [-n] [-w]"
755307cd1aSmrg		exit 1
76d522f475Smrg	esac
77d522f475Smrg	shift
78d522f475Smrg    done
79d522f475Smrgfi
80d522f475Smrg
81d522f475Smrgif test $SAVE = yes ; then
82d522f475Smrg    exec </dev/tty
83d522f475Smrg    old=`stty -g`
84d522f475Smrg    stty raw -echo min 0  time 5
85d522f475Smrg
86ad37e533Smrg    $CMD $OPT "${CSI}18t${SUF}" > /dev/tty
875307cd1aSmrg    IFS=';' read -r junk high wide
88d522f475Smrg
89d522f475Smrg    stty $old
90d522f475Smrg
91ad37e533Smrg    wide=`echo "$wide"|sed -e 's/t.*//'`
92ad37e533Smrg    original=${CSI}8\;${high}\;${wide}t${SUF}
93d522f475Smrg
944419d26bSmrg    trap '$CMD $OPT "$original" >/dev/tty; exit 1' 1 2 3 15
954419d26bSmrg    trap '$CMD $OPT "$original" >/dev/tty' 0
96d522f475Smrg
97d522f475Smrgfi
98d522f475Smrg
99d522f475Smrgif test $WRAP = yes ; then
100d522f475Smrg	# turn on wrapping and force the screen to 80 columns
101ad37e533Smrg	$CMD $OPT "${CSI}?7h" >/dev/tty
102ad37e533Smrg	$CMD $OPT "${CSI}?40l" >/dev/tty
103d522f475Smrgelse
104d522f475Smrg	# force the screen to 132 columns
105ad37e533Smrg	$CMD $OPT "${CSI}?40h" >/dev/tty
106ad37e533Smrg	$CMD $OPT "${CSI}?3h" >/dev/tty
107d522f475Smrgfi
108d522f475Smrg
109d522f475Smrgfor SGR in 0 1 4 5 7
110d522f475Smrgdo
111ad37e533Smrg	$CMD $OPT "${CSI}0;${SGR}m" >/dev/tty
1125307cd1aSmrg	test "$ITAL" = yes && $CMD $OPT "${CSI}3m" >/dev/tty
113d522f475Smrg	for DBL in 5 3 4 6 5
114d522f475Smrg	do
115d522f475Smrg		$CMD $OPT "${ESC}#${DBL}" >/dev/tty
116d522f475Smrg		echo "The quick brown fox jumps over the lazy dog" >/dev/tty
117d522f475Smrg	done
118d522f475Smrg	echo
119d522f475Smrgdone
120ad37e533Smrg$CMD $OPT "${CSI}0m" >/dev/tty
121