1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en"
6 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
7 <title>geda:kig_howto
</title>
8 <meta name=
"generator" content=
"DokuWiki Release rc2007-05-24" />
9 <meta name=
"robots" content=
"index,follow" />
10 <meta name=
"date" content=
"2007-05-24T22:27:25-0400" />
11 <meta name=
"keywords" content=
"geda,kig_howto" />
12 <link rel=
"search" type=
"application/opensearchdescription+xml" href=
"http://geda.seul.org/wiki/lib/exe/opensearch.php" title=
"geda Wiki" />
13 <link rel=
"start" href=
"http://geda.seul.org/wiki/" />
14 <link rel=
"contents" href=
"http://geda.seul.org/wiki/geda:kig_howto?do=index" title=
"Index" />
15 <link rel=
"alternate" type=
"application/rss+xml" title=
"Recent Changes" href=
"http://geda.seul.org/wiki/feed.php" />
16 <link rel=
"alternate" type=
"application/rss+xml" title=
"Current Namespace" href=
"http://geda.seul.org/wiki/feed.php?mode=list&ns=geda" />
17 <link rel=
"alternate" type=
"text/html" title=
"Plain HTML" href=
"http://geda.seul.org/wiki/_export/xhtml/geda:kig_howto" />
18 <link rel=
"alternate" type=
"text/plain" title=
"Wiki Markup" href=
"http://geda.seul.org/wiki/_export/raw/geda:kig_howto" />
19 <link rel=
"stylesheet" media=
"all" type=
"text/css" href=
"lib/exe/css" />
20 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"lib/exe/001css" />
21 <link rel=
"stylesheet" media=
"print" type=
"text/css" href=
"lib/exe/002css" />
24 <div class=
"dokuwiki export">
26 <div class=
"tocheader toctoggle" id=
"toc__header">Table of Contents
</div>
27 <div id=
"toc__inside">
30 <li class=
"level1"><div class=
"li"><span class=
"li"><a href=
"#how_to_setup_keymapping_in_gschem" class=
"toc">How To Setup Keymapping In gschem
</a></span></div>
32 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#about_this_document" class=
"toc">About this document
</a></span></div></li>
33 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#functionality" class=
"toc">Functionality
</a></span></div></li>
34 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#keymaps" class=
"toc">Keymaps
</a></span></div>
36 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#an_example_on_keymaps" class=
"toc">An example on keymaps
</a></span></div></li>
37 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#description_of_keys" class=
"toc">Description of keys
</a></span></div></li>
38 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#actions" class=
"toc">Actions
</a></span></div></li>
39 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#function_calls" class=
"toc">Function calls
</a></span></div></li>
40 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#another_keymap" class=
"toc">Another keymap
</a></span></div></li>
43 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#where_are_the_key_mappings_stored" class=
"toc">Where are the key mappings stored
</a></span></div>
45 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#appendix_a_--_dictionary" class=
"toc">Appendix A -- Dictionary
</a></span></div></li>
48 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#appendix_b_--_built-in_actions_in_gschem" class=
"toc">Appendix B -- Built-in actions in gschem
</a></span></div></li></ul>
55 <h1><a name=
"how_to_setup_keymapping_in_gschem" id=
"how_to_setup_keymapping_in_gschem">How To Setup Keymapping In gschem
</a></h1>
59 by: Stefan Petersen, spe@geda.seul.org This document is released under
<a href=
"http://www.fsf.org/copyleft/gpl.html" class=
"urlextern" title=
"http://www.fsf.org/copyleft/gpl.html" rel=
"nofollow">GPL
</a>
67 <!-- SECTION "How To Setup Keymapping In gschem" [1-177] -->
68 <h2><a name=
"about_this_document" id=
"about_this_document">About this document
</a></h2>
72 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, page X, for a short description of common data structures used in Scheme.
76 <!-- SECTION "About this document" [178-588] -->
77 <h2><a name=
"functionality" id=
"functionality">Functionality
</a></h2>
81 When you press a button in gschem, a Scheme function is called. This function (press-key) 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/>
82 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.
86 <!-- SECTION "Functionality" [589-1128] -->
87 <h2><a name=
"keymaps" id=
"keymaps">Keymaps
</a></h2>
91 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.
95 <!-- SECTION "Keymaps" [1129-1427] -->
96 <h3><a name=
"an_example_on_keymaps" id=
"an_example_on_keymaps">An example on keymaps
</a></h3>
100 Two simple examples of keymaps are seen in Figure
1 and Figure
2.
102 <pre class=
"code">(define global-keymap
103 '((
"Escape
" . cancel)
104 (
"a
" . add-keymap)))
</pre>
107 Figure
1: First example of an simple keymap
111 In figure
1 is the keymap called global-keymap. This keymap is the first keymap used. If you for example press the ‘a’-key, global-keymap tells us that next key pressed will be interpreted by add-keymap (see figure
2).
113 <pre class=
"code">(define add-keymap
114 '((
"c
" . add-component)
115 (
"a
" . add-attribute)
116 (
"n
" . add-net-hotkey)))
</pre>
119 Figure
2: Second example of an simple keymap
123 If you, after you pressed ‘a’, press a ‘c’ the built-in action add-component comes to live. This is exactly what had happend if you had selected Add, Component
…in the menubar.
<br/>
124 When an action has been performed the current keymap is reset back to global-keymap.
<br/>
125 Available built-in actions are listed in appendix B.
129 <!-- SECTION "An example on keymaps" [1428-2357] -->
130 <h3><a name=
"description_of_keys" id=
"description_of_keys">Description of keys
</a></h3>
134 The key are described as:
136 <table class=
"inline">
138 <td> For a
</td><td> “a”
</td>
141 <td class=
"leftalign"> For Shift-A
</td><td> “Shift A”
</td>
144 <td> For Control-a
</td><td> “Control a”
</td>
147 <td> For Alt-a
</td><td> “Alt a”
</td>
152 There are a few simple rules to follow when keys for a new keymap is defined:
155 <li class=
"level1"><div class=
"li"> Everything is case sensitive
</div>
157 <li class=
"level1"><div class=
"li"> At this point in time you can only have one modifier (shift, control, alt) at a time.
</div>
159 <li class=
"level1"><div class=
"li"> Keys must be unique in each keymap, especially the global one
</div>
161 <li class=
"level1"><div class=
"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)
</div>
166 <!-- SECTION "Description of keys" [2358-2925] -->
167 <h3><a name=
"actions" id=
"actions">Actions
</a></h3>
171 The built-in actions that can be called are listed in Appendix B.
<br/>
172 Sometimes you may notice that there are similar actions, like edit-rotate-
90 and edit-rotate-
90-hotkey. They do the same thing, just that the -hotkey actions is run immediately, while the other wait for you to select something.
176 <!-- SECTION "Actions" [2926-3240] -->
177 <h3><a name=
"function_calls" id=
"function_calls">Function calls
</a></h3>
181 If the cdr-element is an ordinary Scheme function that function is called. The function can’t receive any arguments.
<br/>
182 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.
186 <!-- SECTION "Function calls" [3241-3674] -->
187 <h3><a name=
"another_keymap" id=
"another_keymap">Another keymap
</a></h3>
191 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.
195 <!-- SECTION "Another keymap" [3675-3997] -->
196 <h2><a name=
"where_are_the_key_mappings_stored" id=
"where_are_the_key_mappings_stored">Where are the key mappings stored
</a></h2>
200 The keymap is stored in the startup file for gschem, namely
<code><startpath, typically /usr/local
>/share/gEDA/system-gschemrc
</code>.
<br/>
201 You can then redefine or add keymaps as you like (I think) in your local setup file for gschem, ~/.gEDA/gschemrc
205 The Scheme functions used to resolve keypresses to actions are stored at
<code><startpath, typically /usr/local
>/share/gEDA/scheme/gschem.scm
</code>. This is configurable in the gschemrc files.
209 <!-- SECTION "Where are the key mappings stored" [3998-4471] -->
210 <h3><a name=
"appendix_a_--_dictionary" id=
"appendix_a_--_dictionary">Appendix A -- Dictionary
</a></h3>
212 <table class=
"inline">
214 <td> <strong>function
</strong> </td><td>A subprogram in Scheme, C or other programming languages.
</td>
217 <td><strong>action
</strong> </td><td>What gschem (in this case) does when you press a key or a set of keys.
</td>
220 <td><strong>list
</strong> </td><td>A data structure very common in Lisp-looking languages like Scheme. Simply put, a long list of values.
</td>
223 <td><strong>pair
</strong> </td><td>(also dotted pair) A datstructure also very common in Lisp-looking languages.
</td>
226 <td><strong>car element
</strong> </td><td>First element in a pair. Since lists are decendents from pairs, car is also the first element in a list.
</td>
229 <td><strong>cdr element
</strong> </td><td>(pronounced cudr) The second element in a pair. In the list case it denotes the rest of list.
</td>
234 <!-- SECTION "Appendix A -- Dictionary" [4472-5116] -->
235 <h2><a name=
"appendix_b_--_built-in_actions_in_gschem" id=
"appendix_b_--_built-in_actions_in_gschem">Appendix B -- Built-in actions in gschem
</a></h2>
239 Run:
<pre STYLE=
"background : Lightgreen;margin-left : 2em"><font size=
"+0">grep gh_register_procedure_0_0 gschem/src/g_register.c
</font></pre>
243 and do some work in emacsen.
247 <pre STYLE=
"background : Lightgreen;margin-left : 2em"><font size=
"+0">file-new-window
265 edit-rotate-
90-hotkey
309 hierarchy-open-symbol
313 attributes-show-value
315 attributes-visibility-toggle
318 options-action-feedback
321 options-show-log-window
322 options-show-coord-window
328 <!-- SECTION "Appendix B -- Built-in actions in gschem" [5117-] --></div>