Changes in keymap.c [8a921b5:44cc9ab]
Legend:
- Unmodified
- Added
- Removed
-
keymap.c
r8a921b5 r44cc9ab 1 1 #include <string.h> 2 2 #include "owl.h" 3 4 static void _owl_keymap_format_bindings(const owl_keymap *km, owl_fmtext *fm); 5 static void _owl_keymap_format_with_parents(const owl_keymap *km, owl_fmtext *fm); 3 6 4 7 /* returns 0 on success */ … … 9 12 if ((km->desc = owl_strdup(desc)) == NULL) return(-1); 10 13 if (0 != owl_list_create(&km->bindings)) return(-1); 11 km-> submap= NULL;14 km->parent = NULL; 12 15 km->default_fn = default_fn; 13 16 km->prealways_fn = prealways_fn; … … 24 27 } 25 28 26 void owl_keymap_set_ submap(owl_keymap *km, const owl_keymap *submap)27 { 28 km-> submap = submap;29 void owl_keymap_set_parent(owl_keymap *km, const owl_keymap *parent) 30 { 31 km->parent = parent; 29 32 } 30 33 … … 86 89 87 90 /* Appends details about the keymap to fm */ 88 void owl_keymap_get_details(const owl_keymap *km, owl_fmtext *fm) 89 { 90 int i, nbindings; 91 const owl_keybinding *kb; 92 91 void owl_keymap_get_details(const owl_keymap *km, owl_fmtext *fm, int recurse) 92 { 93 93 owl_fmtext_append_bold(fm, "KEYMAP - "); 94 94 owl_fmtext_append_bold(fm, km->name); … … 99 99 owl_fmtext_append_normal(fm, "\n"); 100 100 } 101 if (km-> submap) {102 owl_fmtext_append_normal(fm, OWL_TABSTR "Has submap: ");103 owl_fmtext_append_normal(fm, km-> submap->name);101 if (km->parent) { 102 owl_fmtext_append_normal(fm, OWL_TABSTR "Has parent: "); 103 owl_fmtext_append_normal(fm, km->parent->name); 104 104 owl_fmtext_append_normal(fm, "\n"); 105 105 } … … 119 119 120 120 owl_fmtext_append_bold(fm, "\nKey bindings:\n\n"); 121 if (recurse) { 122 _owl_keymap_format_with_parents(km, fm); 123 } else { 124 _owl_keymap_format_bindings(km, fm); 125 } 126 } 127 128 static void _owl_keymap_format_with_parents(const owl_keymap *km, owl_fmtext *fm) 129 { 130 while (km) { 131 _owl_keymap_format_bindings(km, fm); 132 km = km->parent; 133 if (km) { 134 owl_fmtext_append_bold(fm, "\nInherited from "); 135 owl_fmtext_append_bold(fm, km->name); 136 owl_fmtext_append_bold(fm, ":\n\n"); 137 } 138 } 139 } 140 141 static void _owl_keymap_format_bindings(const owl_keymap *km, owl_fmtext *fm) 142 { 143 int i, nbindings; 144 const owl_keybinding *kb; 145 121 146 nbindings = owl_list_get_size(&km->bindings); 122 147 for (i=0; i<nbindings; i++) { … … 248 273 } 249 274 250 /* deal with the always_fn for the map and submaps */251 for (km=kh->active; km; km=km-> submap) {275 /* deal with the always_fn for the map and parents */ 276 for (km=kh->active; km; km=km->parent) { 252 277 if (km->prealways_fn) { 253 278 km->prealways_fn(j); … … 256 281 257 282 /* search for a match. goes through active keymap and then 258 * through submaps... TODO: clean this up so we can pull283 * through parents... TODO: clean this up so we can pull 259 284 * keyhandler and keymap apart. */ 260 for (km=kh->active; km; km=km-> submap) {285 for (km=kh->active; km; km=km->parent) { 261 286 for (i=owl_list_get_size(&km->bindings)-1; i>=0; i--) { 262 287 kb = owl_list_get_element(&km->bindings, i);
Note: See TracChangeset
for help on using the changeset viewer.