0
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
72
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
IdentityDictionary subclass:#KeyboardMap
|
|
14 |
instanceVariableNames:'current'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Interface-Support'
|
|
18 |
!
|
|
19 |
|
|
20 |
KeyboardMap comment:'
|
46
|
21 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
72
|
22 |
All Rights Reserved
|
54
|
23 |
|
89
|
24 |
$Header: /cvs/stx/stx/libview/KeyboardMap.st,v 1.6 1995-02-06 00:37:29 claus Exp $
|
46
|
25 |
'!
|
0
|
26 |
|
46
|
27 |
!KeyboardMap class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
72
|
32 |
All Rights Reserved
|
0
|
33 |
|
46
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
0
|
42 |
|
46
|
43 |
version
|
|
44 |
"
|
89
|
45 |
$Header: /cvs/stx/stx/libview/KeyboardMap.st,v 1.6 1995-02-06 00:37:29 claus Exp $
|
46
|
46 |
"
|
|
47 |
!
|
0
|
48 |
|
46
|
49 |
documentation
|
|
50 |
"
|
|
51 |
instances of KeyboardMap are used for mapping keystrokes AND sequences
|
|
52 |
of keystrokes to a function key.
|
89
|
53 |
There is usually only one instance in the system - held in an instance
|
|
54 |
variable of Display.
|
|
55 |
|
|
56 |
The setup of this map is done in the 'smalltalk.rc' or one of the
|
|
57 |
'display.rc' files during startup.
|
|
58 |
To add a mapping (for example, to attach the logical function 'DoIt' to
|
|
59 |
the key-combination Cmd-'d'):
|
|
60 |
|
|
61 |
|m|
|
|
62 |
|
|
63 |
m := Display keyboardMap.
|
|
64 |
m bindValue:#DoIt to:#Cmdd.
|
|
65 |
|
|
66 |
Key sequences can also be defined (hey emacs fans ;-) as in:
|
|
67 |
|
|
68 |
|m|
|
|
69 |
|
|
70 |
m := Display keyboardMap.
|
|
71 |
m bindValue:#DoIt to:#Ctrlx followedBy:#Ctrld
|
|
72 |
|
|
73 |
Key prefixes are defined in the DeviceWorkstation>>translateKey: method.
|
|
74 |
Typical prefixes are Cmd (for Alt or Meta), Ctrl etc.
|
|
75 |
Some keyboards offer both Alt and Meta keys - on those, the first has a
|
|
76 |
prefix of Alt, the second has Cmd as prefix. Keyboards with only an Alt
|
|
77 |
key will will create prefix codes of Cmd for that.
|
|
78 |
|
|
79 |
To remove a mapping, use the same value for both logical and physical key,
|
|
80 |
as in:
|
|
81 |
|
|
82 |
|m|
|
|
83 |
|
|
84 |
m := Display keyboardMap.
|
|
85 |
m bindValue:#Cmdd to:#Cmdd.
|
46
|
86 |
"
|
|
87 |
! !
|
0
|
88 |
|
|
89 |
!KeyboardMap methodsFor:'accessing'!
|
|
90 |
|
89
|
91 |
bindValue:logicalKey to:aKey
|
|
92 |
aKey == logicalKey ifTrue:[
|
|
93 |
self removeKey:aKey
|
|
94 |
] ifFalse:[
|
|
95 |
self at:aKey put:logicalKey
|
|
96 |
]
|
0
|
97 |
!
|
|
98 |
|
89
|
99 |
bindValue:logicalKey to:key1 followedBy:key2
|
0
|
100 |
|submap|
|
|
101 |
|
89
|
102 |
submap := self at:key1 ifAbsent:[].
|
0
|
103 |
submap isNil ifTrue:[
|
72
|
104 |
submap := KeyboardMap new.
|
|
105 |
self at:key1 put:submap.
|
0
|
106 |
].
|
89
|
107 |
submap at:key2 put:logicalKey
|
0
|
108 |
!
|
|
109 |
|
|
110 |
valueFor:aKey
|
|
111 |
|where value|
|
|
112 |
|
89
|
113 |
where := (current notNil ifTrue:[current] ifFalse:[self]).
|
0
|
114 |
|
72
|
115 |
value := where at:aKey ifAbsent:aKey.
|
0
|
116 |
(value isMemberOf:KeyboardMap) ifTrue:[
|
72
|
117 |
current := value.
|
|
118 |
^ nil.
|
0
|
119 |
].
|
|
120 |
current := nil.
|
|
121 |
^ value
|
|
122 |
! !
|