File: tf-keys.cmd

package info (click to toggle)
tf5 5.0beta8-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,800 kB
  • ctags: 3,102
  • sloc: ansic: 25,492; perl: 103; makefile: 82; sh: 79
file content (51 lines) | stat: -rw-r--r-- 1,241 bytes parent folder | download | duplicates (17)
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
/* reads user input keys and produces tinyfugue-keybinding macros */
/* written by a.sahlbach@earthbox.escape.de                       */

CALL RxFuncAdd 'SysGetKey', 'RexxUtil', 'SysGetKey'
keybuffer = ''
DO FOREVER
   SAY "--- Press keys and <cr> to produce a tf-keymacro with no istrip"
   SAY "--- Press only <cr> to end"
   CALL readbuffer
   IF Length(keybuffer) = 0 THEN LEAVE
   kmacro = ''
   i = 1
   DO WHILE i <= Length(keybuffer)
      key = SubStr(keybuffer,i,1)
      IF BitAnd(key,'80'x) = '80'x THEN
         kmacro = kmacro||'^['
      key = BitAnd(key,'7f'x)
      IF isctrl(key) THEN
         kmacro = kmacro||'^'ctrl(key)
      ELSE
         kmacro = kmacro||key
      i = i + 1
   END
   SAY "tf-macro for key-sequence "C2X(keybuffer)":"
   SAY " /def -b'"kmacro"' = <macro-action>"
END
EXIT 

ctrl:
   ret = BitAnd(C2D(Translate(Arg(1)))+C2D('@'),'7f'x)
RETURN D2C(ret)
   
isctrl: 
   knum = C2D(Arg(1))
   IF ((knum >= 0) & (knum <= 31)) | (knum >= 127) THEN
      ret = 1
   ELSE 
      ret = 0
RETURN ret

readbuffer:
   keybuffer = ""
   rkey = ""
   DO WHILE rkey <> D2C(13)
      IF rkey = X2C('E0') THEN rkey = D2C(0)
      keybuffer = keybuffer||rkey
      rkey = SysGetKey('NOECHO')
   END
   SAY ""
RETURN