forked from bonzini/smalltalk
/
bold.m4
59 lines (57 loc) · 2.19 KB
/
bold.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# bold.m4 serial 1 (libsigsegv-2.0)
dnl Copyright (C) 1999-2002 Ralf S. Engelschall <rse@engelschall.com>
dnl Copyright (C) 2002 Bruno Haible <bruno@clisp.org>
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
# Determine the escape sequences for switching bold output on and off.
AC_DEFUN([RSE_BOLD],
[
dnl Not pretty.
dnl AC_REQUIRE([AC_PROG_AWK])
case $TERM in
# for the most important terminal types we directly know the sequences
xterm*|vt220*)
term_bold=`${AWK:-awk} 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null`
term_norm=`${AWK:-awk} 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null`
;;
vt100*)
term_bold=`${AWK:-awk} 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' </dev/null 2>/dev/null`
term_norm=`${AWK:-awk} 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' </dev/null 2>/dev/null`
;;
# for all others, we try to use a possibly existing `tput' or `tcout' utility
*)
paths=`echo "$PATH" | sed -e 's/:/ /g'`
for tool in tput tcout; do
for dir in $paths; do
if test -r "$dir/$tool"; then
for seq in bold md smso; do # 'smso' is last
bold="`$dir/$tool $seq 2>/dev/null`"
if test -n "$bold"; then
term_bold="$bold"
break
fi
done
if test -n "$term_bold"; then
for seq in sgr0 me rmso reset; do # 'reset' is last
norm="`$dir/$tool $seq 2>/dev/null`"
if test -n "$norm"; then
term_norm="$norm"
break
fi
done
fi
break
fi
done
if test -n "$term_bold" && test -n "$term_norm"; then
break
fi
done
;;
esac
echo "$term_bold" | tr -d '\n' > termbold
echo "$term_norm" | tr -d '\n' > termnorm
])