summaryrefslogtreecommitdiff
path: root/linux/bin/beschreibe
blob: 3b824dac5d217147b186a3d83f5880fb86df0687 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash

# Verzeichnis muss eventuell an den Ort der Compose angepasst werden:
COMPOSE=/usr/share/X11/locale/en_US.UTF-8/Compose
KEYSYM=/usr/include/X11/keysymdef.h
n=10
typeset -i j=0

while [ ! "$beschreibung" ]
do
	case ${1-" "} in
	" ")
		echo Aufruf: $0 [OPTION] BESCHREIBUNG
		echo »$0 --help« gibt Ihnen mehr Informationen.
		exit;;
	--help)
		echo Aufruf: $0 [OPTION] BESCHREIBUNG
		echo »$0« versucht ein Zeichen anhand einer Beschreibung zu identifizieren
		echo Option:
		echo -e "  -n               gibt maximal 2n statt 10 Vorschläge aus"
		exit;;
	\ )
		echo $0: Kein Suchkriterium eingegeben!
		echo Versuchen Sie »$0 --help« für weitere Informationen.
		exit;;
	-*)
		n=`echo $1 | cut -c2-`
		shift;;
	*)
		beschreibung=${*?$0: Fehler! Versuchen Sie »$0 --help« für weitere Informationen.}
	esac
done

anzahl=`grep -iw $beschreibung $COMPOSE | head -$n | wc -l`
if [ $anzahl -gt 0 ]
then
	for i in $(seq 1 $anzahl)
	do
		j=j+1
		ausgabe=1
		a[$j]=`grep -iw $beschreibung $COMPOSE | grep ^\< | head -$i | tail -1 | cut -f2 -d \"`
		echo $j\) ${a[$j]}
	done
fi

anzahl2=`grep -i [\ _]$beschreibung[\ _] $KEYSYM | head -$n | wc -l`
if [ $anzahl2 -gt 0 ]
then
	for i in $(seq 1 $anzahl2)
	do
		c=`grep -i [\ _]$beschreibung[\ _] $KEYSYM | grep ^#define  | head -$i | tail -1 | cut -f2- -d\* | cut -f2- -d+ | cut -f1 -d\ `
		c1=`echo $c | cut -c1-2`
		c2=`echo $c | cut -c3`
		c3=`echo $c | cut -c4`

		case $c1 in
		00)
			j=j+1
			ausgabe=1
			a[$j]=`echo -e \\\x${c2}`
			echo $j\) ${a[$j]}
			;;
		03)	
			if [ "$c2" = "C" ]
			then
				j=j+1
				ausgabe=1
				a[$j]=`echo -e \\\xcf\\\x8${c3}`
				echo $j\) ${a[$j]}

			else
				j=j+1
				ausgabe=1
				a[$j]=`echo -e \\\xce\\\x${c2}${c3}`
				echo $j\) ${a[$j]}
			fi
			;;
		*)
			;;
		esac	
	done
fi

if [ $ausgabe ]
then
	read -p 'welches Zeichen suchen Sie: ' zahl
	echo
else
	echo „$beschreibung“ ist unbekannt, versuchen Sie eine andere Beschreibung.
	exit
fi

if [ ${a[$zahl]} ]
then
	wiemitneo ${a[$zahl]}
fi