Permalink
Browse files

While we're at it, rename submap to parent

Should be more consistent with other programs.

Signed-off-by: David Benjamin <davidben@mit.edu>
  • Loading branch information...
1 parent 13ebf92 commit 44cc9abbc2c15abaf4cd5fe0d1fc62b0e0936913 @davidben davidben committed May 24, 2010
Showing with 22 additions and 22 deletions.
  1. +1 −1 doc/code.txt
  2. +14 −14 keymap.c
  3. +6 −6 keys.c
  4. +1 −1 owl.h
View
@@ -85,7 +85,7 @@ keymap: Contains both keymap and keyhandler. A keymap is contains a
bindings in keymaps. It also handles ESC as a prefix for
Meta. At any one time, there is exactly one active
keymap which determines where keybindings are looked for
- (along with its submaps).
+ (along with its parents).
list: Simple list abstraction. (Uses realloc to resize the list.)
View
@@ -2,7 +2,7 @@
#include "owl.h"
static void _owl_keymap_format_bindings(const owl_keymap *km, owl_fmtext *fm);
-static void _owl_keymap_format_with_submaps(const owl_keymap *km, owl_fmtext *fm);
+static void _owl_keymap_format_with_parents(const owl_keymap *km, owl_fmtext *fm);
/* returns 0 on success */
int owl_keymap_init(owl_keymap *km, const char *name, const char *desc, void (*default_fn)(owl_input), void (*prealways_fn)(owl_input), void (*postalways_fn)(owl_input))
@@ -11,7 +11,7 @@ int owl_keymap_init(owl_keymap *km, const char *name, const char *desc, void (*d
if ((km->name = owl_strdup(name)) == NULL) return(-1);
if ((km->desc = owl_strdup(desc)) == NULL) return(-1);
if (0 != owl_list_create(&km->bindings)) return(-1);
- km->submap = NULL;
+ km->parent = NULL;
km->default_fn = default_fn;
km->prealways_fn = prealways_fn;
km->postalways_fn = postalways_fn;
@@ -26,9 +26,9 @@ void owl_keymap_cleanup(owl_keymap *km)
owl_list_cleanup(&km->bindings, (void (*)(void *))owl_keybinding_delete);
}
-void owl_keymap_set_submap(owl_keymap *km, const owl_keymap *submap)
+void owl_keymap_set_parent(owl_keymap *km, const owl_keymap *parent)
{
- km->submap = submap;
+ km->parent = parent;
}
/* creates and adds a key binding */
@@ -98,9 +98,9 @@ void owl_keymap_get_details(const owl_keymap *km, owl_fmtext *fm, int recurse)
owl_fmtext_append_normal(fm, km->desc);
owl_fmtext_append_normal(fm, "\n");
}
- if (km->submap) {
- owl_fmtext_append_normal(fm, OWL_TABSTR "Has submap: ");
- owl_fmtext_append_normal(fm, km->submap->name);
+ if (km->parent) {
+ owl_fmtext_append_normal(fm, OWL_TABSTR "Has parent: ");
+ owl_fmtext_append_normal(fm, km->parent->name);
owl_fmtext_append_normal(fm, "\n");
}
owl_fmtext_append_normal(fm, "\n");
@@ -119,17 +119,17 @@ void owl_keymap_get_details(const owl_keymap *km, owl_fmtext *fm, int recurse)
owl_fmtext_append_bold(fm, "\nKey bindings:\n\n");
if (recurse) {
- _owl_keymap_format_with_submaps(km, fm);
+ _owl_keymap_format_with_parents(km, fm);
} else {
_owl_keymap_format_bindings(km, fm);
}
}
-static void _owl_keymap_format_with_submaps(const owl_keymap *km, owl_fmtext *fm)
+static void _owl_keymap_format_with_parents(const owl_keymap *km, owl_fmtext *fm)
{
while (km) {
_owl_keymap_format_bindings(km, fm);
- km = km->submap;
+ km = km->parent;
if (km) {
owl_fmtext_append_bold(fm, "\nInherited from ");
owl_fmtext_append_bold(fm, km->name);
@@ -272,17 +272,17 @@ int owl_keyhandler_process(owl_keyhandler *kh, owl_input j)
return(-1);
}
- /* deal with the always_fn for the map and submaps */
- for (km=kh->active; km; km=km->submap) {
+ /* deal with the always_fn for the map and parents */
+ for (km=kh->active; km; km=km->parent) {
if (km->prealways_fn) {
km->prealways_fn(j);
}
}
/* search for a match. goes through active keymap and then
- * through submaps... TODO: clean this up so we can pull
+ * through parents... TODO: clean this up so we can pull
* keyhandler and keymap apart. */
- for (km=kh->active; km; km=km->submap) {
+ for (km=kh->active; km; km=km->parent) {
for (i=owl_list_get_size(&km->bindings)-1; i>=0; i--) {
kb = owl_list_get_element(&km->bindings, i);
match = owl_keybinding_match(kb, kh);
View
12 keys.c
@@ -29,7 +29,7 @@ void owl_keys_setup_keymaps(owl_keyhandler *kh) {
km_editwin = km = owl_keyhandler_create_and_add_keymap(kh, "edit",
"Text editing and command window",
owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
- owl_keymap_set_submap(km_editwin, km_global);
+ owl_keymap_set_parent(km_editwin, km_global);
/*
BIND_CMD("F1", "help", "");
BIND_CMD("HELP", "help", "");
@@ -98,7 +98,7 @@ void owl_keys_setup_keymaps(owl_keyhandler *kh) {
km_ew_multi = km = owl_keyhandler_create_and_add_keymap(kh, "editmulti",
"Multi-line text editing",
owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
- owl_keymap_set_submap(km_ew_multi, km_editwin);
+ owl_keymap_set_parent(km_ew_multi, km_editwin);
BIND_CMD("UP", "edit:move-up-line", "");
BIND_CMD("M-[ A", "edit:move-up-line", "");
@@ -128,7 +128,7 @@ void owl_keys_setup_keymaps(owl_keyhandler *kh) {
km_ew_onel = km = owl_keyhandler_create_and_add_keymap(kh, "editline",
"Single-line text editing",
owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
- owl_keymap_set_submap(km_ew_onel, km_editwin);
+ owl_keymap_set_parent(km_ew_onel, km_editwin);
BIND_CMD("C-u", "edit:delete-all", "Clears the entire line");
@@ -153,7 +153,7 @@ void owl_keys_setup_keymaps(owl_keyhandler *kh) {
km_ew_onel = km = owl_keyhandler_create_and_add_keymap(kh, "editresponse",
"Single-line response to question",
owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
- owl_keymap_set_submap(km_ew_onel, km_editwin);
+ owl_keymap_set_parent(km_ew_onel, km_editwin);
BIND_CMD("C-u", "edit:delete-all", "Clears the entire line");
@@ -168,7 +168,7 @@ void owl_keys_setup_keymaps(owl_keyhandler *kh) {
km_viewwin = km = owl_keyhandler_create_and_add_keymap(kh, "popless",
"Pop-up window (eg, help)",
owl_keys_default_invalid, NULL, owl_keys_popless_postalways);
- owl_keymap_set_submap(km_viewwin, km_global);
+ owl_keymap_set_parent(km_viewwin, km_global);
BIND_CMD("SPACE", "popless:scroll-down-page", "");
BIND_CMD("NPAGE", "popless:scroll-down-page", "");
@@ -221,7 +221,7 @@ void owl_keys_setup_keymaps(owl_keyhandler *kh) {
km_mainwin = km = owl_keyhandler_create_and_add_keymap(kh, "recv",
"Main window / message list",
owl_keys_default_invalid, owl_keys_recwin_prealways, NULL);
- owl_keymap_set_submap(km_mainwin, km_global);
+ owl_keymap_set_parent(km_mainwin, km_global);
BIND_CMD("C-x C-c", "start-command quit", "");
BIND_CMD("F1", "help", "");
BIND_CMD("h", "help", "");
View
2 owl.h
@@ -475,7 +475,7 @@ typedef struct _owl_keymap {
char *name; /* name of keymap */
char *desc; /* description */
owl_list bindings; /* key bindings */
- const struct _owl_keymap *submap; /* submap */
+ const struct _owl_keymap *parent; /* parent */
void (*default_fn)(owl_input j); /* default action (takes a keypress) */
void (*prealways_fn)(owl_input j); /* always called before a keypress is received */
void (*postalways_fn)(owl_input j); /* always called after keypress is processed */

0 comments on commit 44cc9ab

Please sign in to comment.