File: keymapping.html

package info (click to toggle)
geda-doc 20020209-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 112 kB
  • ctags: 12
  • sloc: makefile: 27
file content (373 lines) | stat: -rw-r--r-- 12,445 bytes parent folder | download | duplicates (3)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD><TITLE>How To Setup Keymapping In gschem</TITLE>
<META http-equiv="Content-Type" content="text/html; charset= ISO-8859-1">
</HEAD>
<BODY BGCOLOR=silver TEXT=black>
<!--HTMLHEAD-->
<!--ENDHTML-->
<!--CUT DEF section 1 -->
<BR>
<BR>

<H1 ALIGN=center>How To Setup Keymapping In gschem</H1>
<H3 ALIGN=center>Stefan Petersen, spe@geda.seul.org<BR>	<FONT SIZE=1>This document is released under GPL 
	(http://www.fsf.org/copyleft/gpl.html)</FONT><BR>
<BR>
1999-07-24
</H3><BR><BR><BR><BR>
<BR>
<!--TOC section About this document-->

<H2>About this document</H2>
The purpose of this document is to try to explain how key mapping 
works in gEDA/gschem schematic entry program. It uses the langauge
Scheme a lot, which is a Lisp-dialect and is used in gschem as a
scripting language. If you're not familiar with this language, please
see the dictionary (see appendix <A HREF="#dict">A</A>, page <A HREF="#dict">X</A>,
for a short description of common data structures used in Scheme.<BR>
<BR>
<!--TOC section Functionality-->

<H2>1&nbsp;&nbsp; Functionality</H2>
When you press a button in gschem, a Scheme function is called.
This function (<TT>press-key</TT>) accepts one argument, the name of 
the pressed key. Then there are Scheme routines to evaluate which key 
you pressed and call the appropriate action.<BR>
<BR>
Since the evaluation routines are written in Scheme it's simple to change
the behaviour of what happens when you presses a key. You can 
implement macros or do several things at each key press. For example,
the ``repeat-last-key command is implemented completly in Scheme.<BR>
<BR>
<!--TOC section Keymaps-->

<H2>2&nbsp;&nbsp; Keymaps</H2>
The current implementation is built-up around ``keymaps''. A keymap is
a list with pairs. Each pairs first element (the car-element) is which 
key to react on, and the second element (cdr) is a ``what-to-do-next''. 
This can either be an action, a function to call or another keymap.<BR>
<BR>
<!--TOC subsection An example on keymaps-->

<H3>2.1&nbsp;&nbsp; An example on keymaps</H3>
Two simple examples of keymaps is seen in figure <A HREF="#example1">1</A> and
figure <A HREF="#example2">2</A>.<BR>
<BR>
<BLOCKQUOTE><HR  SIZE=2>
<PRE>
(define global-keymap
  '(("Escape" . cancel)
    ("a" . add-keymap)))
</PRE>

<A NAME="example1"></A>
<DIV ALIGN=center>Figure 1: First example of an simple keymap</DIV>
<HR  SIZE=2></BLOCKQUOTE>In figure <A HREF="#example1">1</A> is the keymap called <TT>global-keymap</TT>. 
This keymap is the first keymap used. If you for example press the 'a'-key,
<TT>global-keymap</TT> tells us that next key pressed will be interpreted
by <TT>add-keymap</TT> (see figure <A HREF="#example2">2</A>).<BR>
<BR>
<BLOCKQUOTE><HR  SIZE=2>
<PRE>
(define add-keymap
  '(("c" . add-component)
    ("a" . add-attribute)
    ("n" . add-net-hotkey)))
</PRE>

<A NAME="example2"></A>
<DIV ALIGN=center>Figure 2: Second example of an simple keymap</DIV>
<HR  SIZE=2></BLOCKQUOTE>If you, after you pressed 'a', press a 'c' the built-in action 
<TT>add-component</TT> comes to live. This is exactly what had happend
if you had selected Add, Component...in the menubar.<BR>
<BR>
When an action has been performed the current keymap is reset back to<BR><TT>global-keymap</TT>.<BR>
<BR>
Available built-in actions are listed in appendix <A HREF="#builtins">B</A>.<BR>
<BR>
<!--TOC subsection Description of keys-->

<H3>2.2&nbsp;&nbsp; Description of keys</H3>
The key are described as:<BR>
<BR>

<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD  ALIGN=left NOWRAP>For a</TD>
<TD  ALIGN=center NOWRAP>--</TD>
<TD  ALIGN=left NOWRAP>``a''</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>For Shift-A</TD>
<TD  ALIGN=center NOWRAP>--</TD>
<TD  ALIGN=left NOWRAP>``Shift A''</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>For Control-a</TD>
<TD  ALIGN=center NOWRAP>--</TD>
<TD  ALIGN=left NOWRAP>``Control a''</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>For Alt-a</TD>
<TD  ALIGN=center NOWRAP>--</TD>
<TD  ALIGN=left NOWRAP>``Alt a''</TD>
</TR></TABLE><BR>
There are a few simple rules to follow when keys for a new keymap is
defined:
<UL>
<LI>
Everything is case sensitive

<LI>At this point in time you can only have one modifier 
 (shift, control, alt) at a time.

<LI>Keys must be unique in each keymap, especially the global one 

<LI>Strings (without any modifers) are the same strings specified
 for the keys in the file /usr/lib/X11/XKeysymDB (at least on 
 a linux box)
</UL><!--TOC subsection Actions-->

<H3>2.3&nbsp;&nbsp; Actions</H3>
The built-in actions that can be called are listed in appendix 
<A HREF="#builtins">B</A>.<BR>
<BR>
Sometimes you may notice that there are similar actions, like
<TT> edit-rotate-90</TT> and <TT> edit-rotate-90-hotkey</TT>.
They do the same thing, just that the <TT>-hotkey</TT> actions is
run immediately, while the other wait for you to select 
something.<BR>
<BR>
<!--TOC subsection Function calls-->

<H3>2.4&nbsp;&nbsp; Function calls</H3>
If the cdr-element is an ordinary Scheme function that function is called. 
The function can't receive any arguments.<BR>
<BR>
This can be used if you want to do complex tasks, like several actions
in a row or do some calculation. You can do rather advanced actions since
the Guile dialect of Scheme used in gschem is extended from plain Scheme.
For further information on Guile, please see the Guile documentation.<BR>
<BR>
<!--TOC subsection Another keymap-->

<H3>2.5&nbsp;&nbsp; Another keymap</H3>
If the cdr-element is another keymap then that command is a multi-key command,
ie you need to press at least two keys to cause an action. The first key is
desribed in the first keymap, which points to the next keymap. The 
second keymap describes what should happen when the second key is pressed.<BR>
<BR>
<!--TOC section Where are the key mappings stored-->

<H2>3&nbsp;&nbsp; Where are the key mappings stored</H2>
The keymap is stored in the startup file for gschem, namely<BR><TT>&lt;startpath, typically /usr/local&gt;/share/gEDA/system-gschemrc</TT>.<BR>
<BR>
You can then redefine or add keymaps as you like (I think) in your local
setup file for gschem,<BR><TT>~/.gEDA/gschemrc</TT><BR>
<BR>
The Scheme functions used to resolve keypresses to actions are stored at<BR><TT>&lt;startpath, typically /usr/local&gt;/share/gEDA/scheme/gschem.scm</TT>.<BR>This is configurable in the <TT>gschemrc</TT> files.<BR>
<BR>
<!--TOC section Dictionary<A NAME="dict"></A>-->

<H2>A&nbsp;&nbsp; Dictionary<A NAME="dict"></A></H2>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD  ALIGN=left NOWRAP><B>function</B></TD>
<TD  VALIGN=top ALIGN=left>A subprogram in Scheme, C or other programming 
languages.</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP><B>action</B></TD>
<TD  VALIGN=top ALIGN=left>What gschem (in this case) does when you press a key or a set
of keys.</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP><B>list</B></TD>
<TD  VALIGN=top ALIGN=left>A data structure very common in Lisp-looking languages like 
Scheme. Simply put, a long list of values.</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP><B>pair</B></TD>
<TD  VALIGN=top ALIGN=left>(also dotted pair) A datstructure also very common in 
Lisp-looking languages.</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP><B>car element</B></TD>
<TD  VALIGN=top ALIGN=left>First element in a pair. Since lists are decendents 
from pairs, <TT>car</TT> is also the first element in a list.</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP><B>cdr element</B></TD>
<TD  VALIGN=top ALIGN=left>(pronounced <EM>cudr</EM>) The second element in a pair. 
In the list case it denotes the rest of list.</TD>
</TR></TABLE><BR>
<!--TOC section Built-in actions in gschem<A NAME="builtins"></A>-->

<H2>B&nbsp;&nbsp; Built-in actions in gschem<A NAME="builtins"></A></H2>
Run 
<PRE>
grep gh_register_procedure_0_0 gschem/src/g_register.c
</PRE>
and do some work in emacsen.<BR>
<BR>

<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD  ALIGN=left NOWRAP>file-new-window</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>file-new</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>file-open</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>file-script</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>file-save</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>file-save-as</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>file-save-all</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>file-print</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>file-image</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>file-close-window</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>file-quit</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-select</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-copy</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-copy-hotkey</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-move</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-move-hotkey</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-delete</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-rotate-90</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-rotate-90-hotkey</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-mirror</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-mirror-hotkey</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-slot</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-color</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-edit</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-lock</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-unlock</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-translate</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-embed</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-unembed</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>edit-hidden</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>view-redraw</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>view-zoom-full</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>view-zoom-limits</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>view-zoom-in</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>view-zoom-out</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>view-zoom-box</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>view-zoom-box-hotkey</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>view-pan</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>view-pan-hotkey</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>view-update-nets</TD>
</TR></TABLE>

<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD  ALIGN=left NOWRAP>page-manager</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>page-next</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>page-prev</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>page-new</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>page-close</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>page-discard</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>page-print</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-component</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-attribute</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-net</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-net-hotkey</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-text</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-line</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-line-hotkey</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-box</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-box-hotkey</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-circle</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-circle-hotkey</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-arc</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-arc-hotkey</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-pin</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>add-pin-hotkey</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>hierarchy-open-symbol</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>attributes-attach</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>attributes-detach</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>attributes-show-name</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>attributes-show-value</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>attributes-show-both</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>attributes-visibility-toggle</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>options-text-size</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>options-snap-size</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>options-action-feedback</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>options-grid</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>options-snap</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>options-show-log-window</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>options-show-coord-window</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>misc-misc</TD>
</TR>
<TR><TD  ALIGN=left NOWRAP>cancel</TD>
</TR></TABLE>
<!--HTMLFOOT-->
<!--ENDHTML-->

<!--FOOTER-->
<HR  SIZE=2>
<BLOCKQUOTE><EM>This document was translated from L<sup>A</sup>T<sub>E</sub>X by </EM><A HREF="http://para.inria.fr/~maranget/hevea/index.html"><EM>H</EM><EM><FONT SIZE=2><sup>E</sup></FONT></EM><EM>V</EM><EM><FONT SIZE=2><sup>E</sup></FONT></EM><EM>A</EM></A><EM>.
</EM></BLOCKQUOTE></BODY>
</HTML>