about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2011-02-03 22:34:16 +0000
committerMarco Peereboom <marco@conformal.com>2011-02-03 22:34:16 +0000
commit0495524560147b41a2f24ca447bb246e82b18497 (patch)
tree32c5fc306505768528a938bb4fc475efe7eb9579
parent961d92c8132824eaa0a9369a493572f60f199b30 (diff)
downloadxombrero-0495524560147b41a2f24ca447bb246e82b18497.tar.gz
and print the shiny new keybindings in set
-rw-r--r--xxxterm.c50
1 files changed, 47 insertions, 3 deletions
diff --git a/xxxterm.c b/xxxterm.c
index ff75fdd..739eae8 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -506,6 +506,7 @@ char		*get_runtime_dir(struct settings *);
 void		walk_alias(struct settings *, void (*)(struct settings *, char *, void *), void *);
 void		walk_cookie_wl(struct settings *, void (*)(struct settings *, char *, void *), void *);
 void		walk_js_wl(struct settings *, void (*)(struct settings *, char *, void *), void *);
+void		walk_kb(struct settings *, void (*)(struct settings *, char *, void *), void *);
 void		walk_mime_type(struct settings *, void (*)(struct settings *, char *, void *), void *);
 
 struct special {
@@ -547,7 +548,7 @@ struct special		s_js = {
 struct special		s_kb = {
 	add_kb,
 	NULL,
-	NULL//walk_kb
+	walk_kb
 };
 
 struct special		s_cookie_wl = {
@@ -1366,8 +1367,10 @@ walk_cookie_wl(struct settings *s,
 {
 	struct domain		*d;
 
-	if (s == NULL || cb == NULL)
+	if (s == NULL || cb == NULL) {
 		show_oops_s("walk_cookie_wl invalid parameters");
+		return;
+	}
 
 	RB_FOREACH_REVERSE(d, domain_list, &c_wl)
 		cb(s, d->d, cb_args);
@@ -1379,8 +1382,10 @@ walk_js_wl(struct settings *s,
 {
 	struct domain		*d;
 
-	if (s == NULL || cb == NULL)
+	if (s == NULL || cb == NULL) {
 		show_oops_s("walk_js_wl invalid parameters");
+		return;
+	}
 
 	RB_FOREACH_REVERSE(d, domain_list, &js_wl)
 		cb(s, d->d, cb_args);
@@ -4457,6 +4462,45 @@ struct key_binding {
 TAILQ_HEAD(keybinding_list, key_binding);
 
 void
+walk_kb(struct settings *s,
+    void (*cb)(struct settings *, char *, void *), void *cb_args)
+{
+	struct key_binding	*k;
+	char			str[1024];
+
+	if (s == NULL || cb == NULL) {
+		show_oops_s("walk_kb invalid parameters");
+		return;
+	}
+
+	TAILQ_FOREACH(k, &kbl, entry) {
+		if (k->name == NULL)
+			continue;
+		str[0] = '\0';
+
+		strlcat(str, k->name, sizeof str);
+		strlcat(str, ",", sizeof str);
+
+		if (k->mask & GDK_SHIFT_MASK)
+			strlcat(str, "S+", sizeof str);
+		if (k->mask & GDK_CONTROL_MASK)
+			strlcat(str, "C+", sizeof str);
+		if (k->mask & GDK_MOD1_MASK)
+			strlcat(str, "M1+", sizeof str);
+		if (k->mask & GDK_MOD2_MASK)
+			strlcat(str, "M2+", sizeof str);
+		if (k->mask & GDK_MOD3_MASK)
+			strlcat(str, "M3+", sizeof str);
+		if (k->mask & GDK_MOD4_MASK)
+			strlcat(str, "M4+", sizeof str);
+		if (k->mask & GDK_MOD5_MASK)
+			strlcat(str, "M5+", sizeof str);
+
+		strlcat(str, gdk_keyval_name(k->key), sizeof str);
+		cb(s, str, cb_args);
+	}
+}
+void
 init_keybindings(void)
 {
 	int			i;