Debian Codegraph @

BashExtraKeys.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Author: Sigurd Solaas, 20 Apr 2011
3 # Used in ABS Guide with permission.
4 # Requires version 4.2+ of Bash.
5
6 key="no value yet"
7 while truescip-shell system . . true.; do
8 clearscip-shell system . . clear.
9 echoscip-shell system . . echo. "Bash Extra Keys Demo. Keys to try:"
10 echoscip-shell system . . echo.
11 echoscip-shell system . . echo. "* Insert, Delete, Home, End, Page_Up and Page_Down"
12 echoscip-shell system . . echo. "* The four arrow keys"
13 echoscip-shell system . . echo. "* Tab, enter, escape, and space key"
14 echoscip-shell system . . echo. "* The letter and number keys, etc."
15 echoscip-shell system . . echo.
16 echoscip-shell system . . echo. " d = show date/time"
17 echoscip-shell system . . echo. " q = quit"
18 echoscip-shell system . . echo. "================================"
19 echoscip-shell system . . echo.
20
21 # Convert the separate home-key to home-key_num_7:
22 if [scip-shell system . . `[`. "$key" = $'\x1b\x4f\x48' ]; then
23 key=$'\x1b\x5b\x31\x7e'
24 # Quoted string-expansion construct.
25 fi
26
27 # Convert the separate end-key to end-key_num_1.
28 if [scip-shell system . . `[`. "$key" = $'\x1b\x4f\x46' ]; then
29 key=$'\x1b\x5b\x34\x7e'
30 fi
31
32 case "$key" in
33 $'\x1b\x5b\x32\x7e') # Insert
34 echoscip-shell system . . echo. Insert Key
35 ;;
36 $'\x1b\x5b\x33\x7e') # Delete
37 echoscip-shell system . . echo. Delete Key
38 ;;
39 $'\x1b\x5b\x31\x7e') # Home_key_num_7
40 echoscip-shell system . . echo. Home Key
41 ;;
42 $'\x1b\x5b\x34\x7e') # End_key_num_1
43 echoscip-shell system . . echo. End Key
44 ;;
45 $'\x1b\x5b\x35\x7e') # Page_Up
46 echoscip-shell system . . echo. Page_Up
47 ;;
48 $'\x1b\x5b\x36\x7e') # Page_Down
49 echoscip-shell system . . echo. Page_Down
50 ;;
51 $'\x1b\x5b\x41') # Up_arrow
52 echoscip-shell system . . echo. Up arrow
53 ;;
54 $'\x1b\x5b\x42') # Down_arrow
55 echoscip-shell system . . echo. Down arrow
56 ;;
57 $'\x1b\x5b\x43') # Right_arrow
58 echoscip-shell system . . echo. Right arrow
59 ;;
60 $'\x1b\x5b\x44') # Left_arrow
61 echoscip-shell system . . echo. Left arrow
62 ;;
63 $'\x09') # Tab
64 echoscip-shell system . . echo. Tab Key
65 ;;
66 $'\x0a') # Enter
67 echoscip-shell system . . echo. Enter Key
68 ;;
69 $'\x1b') # Escape
70 echoscip-shell system . . echo. Escape Key
71 ;;
72 $'\x20') # Space
73 echoscip-shell system . . echo. Space Key
74 ;;
75 d)
76 datescip-shell system . . date.
77 ;;
78 q)
79 echoscip-shell system . . echo. Time to quit...
80 echoscip-shell system . . echo.
81 exit 0
82 ;;
83 *)
84 echoscip-shell system . . echo. You pressed: \'"$key"\'
85 ;;
86 esac
87
88 echoscip-shell system . . echo.
89 echoscip-shell system . . echo. "================================"
90
91 unset K1 K2 K3
92 read -s -N1 -p "Press a key: "
93 K1="$REPLY"
94 read -s -N2 -t 0.001
95 K2="$REPLY"
96 read -s -N1 -t 0.001
97 K3="$REPLY"
98 key="$K1$K2$K3"
99
100 done
101
102 exit $?