about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--xxxterm.1123
-rw-r--r--xxxterm.c82
-rw-r--r--xxxterm.conf84
3 files changed, 148 insertions, 141 deletions
diff --git a/xxxterm.1 b/xxxterm.1
index 8ae7c9e..fa4a491 100644
--- a/xxxterm.1
+++ b/xxxterm.1
@@ -75,14 +75,22 @@ Display version and exit.
 The following notation is used throughout this page:
 .Pp
 .Bl -tag -width Ds -offset indent -compact
-.It Cm C
+.It Cm C-
 Control
-.It Cm M
-Meta (sometimes marked Alt)
-.It Cm M1
-Mouse button 1
-.It Cm S
+.It Cm M1-
+Meta 1 (sometimes marked Alt)
+.It Cm M2-
+Meta 2
+.It Cm M3-
+Meta 3
+.It Cm M4-
+Meta 4 (sometimes marked Windows)
+.It Cm M5-
+Meta 2
+.It Cm S-
 Shift
+.It Cm MB1
+Mouse button 1
 .El
 .Pp
 To browse to a specific address,
@@ -218,7 +226,7 @@ and back.
 These commands then are used to create, destroy, and move between tabs.
 .Pp
 .Bl -tag -width "C-plus, C-equalXXX" -offset indent -compact
-.It Cm C-M1
+.It Cm C-MB1
 Open new tab with the clicked link
 .It Cm C-t
 Create new tab with focus in URL entry
@@ -735,31 +743,12 @@ Each keyboard shortcut requires exactly one entry in the configuration file.
 A shortcut can have multiple entries in the configuration file.
 The format of the keybinding entry is as follows
 keybinding = action,keystroke(s).
-For example, "keybinding = tabnew,C+t" where
+For example, "keybinding = tabnew,C-t" where
 .Cm tabnew
 is the action and
-.Cm C+t
+.Cm C-t
 are
 the keystrokes.
-The following notation is used for
-.Cm keystrokes :
-.Pp
-.Bl -tag -width Ds -offset indent -compact
-.It Cm C+
-Control
-.It Cm M1+
-Meta 1 (sometimes marked Alt)
-.It Cm M2+
-Meta 2
-.It Cm M3+
-Meta 3
-.It Cm M4+
-Meta 4 (sometimes marked Windows)
-.It Cm M5+
-Meta 2
-.It Cm S+
-Shift
-.El
 .Pp
 Shift should be used sparingly since it gets in the way of non-USA keyboards.
 See the accompanying configuration file for examples.
@@ -776,48 +765,48 @@ entry on the configuration file.
 .It Cm cookiejar
 Bring up the cookie jar screen.
 Default
-.Cm M1+j .
+.Cm M1-j .
 .It Cm downloadmgr
 Bring up the download manager screen.
 Default
-.Cm M1+d .
+.Cm M1-d .
 .It Cm history
 Bring up the history screen.
 Default
-.Cm M1+h .
+.Cm M1-h .
 .It Cm print
 Bring up print page or pane dialog.
 Default
-.Cm C+p .
+.Cm C-p .
 .It Cm quit
 Terminate
 .Nm
 session and close all tabs.
 Default
-.Cm C+q .
+.Cm C-q .
 .It Cm restart
 Restart
 .Nm
 while maintaining most state.
 Temporary cookies and Java Script whitelist items will be discarded.
 Default
-.Cm M1+q .
+.Cm M1-q .
 .It Cm togglejs
 Toggle Java Script whitelist entry for
 .Cm FQDN
 of the current tab.
 Default
-.Cm C+j .
+.Cm C-j .
 .It Cm togglecookie
 Toggle cookie whitelist entry for
 .Cm FQDN
 of the current tab.
 Default
-.Cm M1+c .
+.Cm M1-c .
 .It Cm togglesrc
 Toggle between source and normal view.
 Default
-.Cm C+s .
+.Cm C-s .
 .It Cm yankuri
 Yank (copy) URL of current tab into the clipboard.
 Default
@@ -861,28 +850,28 @@ Go to previous web page.
 Default
 .Cm BackSpace
 and
-.Cm M1+Left .
+.Cm M1-Left .
 .It Cm goforward
 Go to next web page.
 Default
-.Cm S+BackSpace
+.Cm S-BackSpace
 and
-.Cm M1+Right .
+.Cm M1-Right .
 .It Cm reload
 Refresh web page.
 Default
 .Cm F5 ,
-.Cm C+l
+.Cm C-l
 and
-.Cm C+r .
+.Cm C-r .
 .It Cm reloadforce
 Refresh web page bypassing all cache entries.
 Default
-.Cm C+R .
+.Cm C-R .
 .It Cm favorites
 Bring up favorites screen.
 Default
-.Cm M1+f .
+.Cm M1-f .
 .It Cm scrolldown
 Go "one line" down.
 Default
@@ -911,23 +900,23 @@ and
 Go "one page" down.
 Default
 .Cm Space ,
-.Cm C+f
+.Cm C-f
 and
 .Cm PageDown .
 .It Cm scrollhalfdown
 Go "one half a page" down.
 Default
-.Cm C+d .
+.Cm C-d .
 .It Cm scrollpageup
 Go "one page" up.
 Default
 .Cm PageUp
 and
-.Cm C+b .
+.Cm C-b .
 .It Cm scrollhalfup
 Go "one half a page" up.
 Default
-.Cm C+u .
+.Cm C-u .
 .It Cm scrollright
 Scroll page to the right.
 Default
@@ -951,11 +940,11 @@ Default
 .It Cm tabnew
 Create a new tab.
 Default
-.Cm C+t .
+.Cm C-t .
 .It Cm tabclose
 Close current tab.
 Default
-.Cm C+w .
+.Cm C-w .
 .It Cm tabundoclose
 Reopen last closed tab.
 Default
@@ -963,75 +952,75 @@ Default
 .It Cm tabgoto1
 Go to tab 1 (first tab).
 Default
-.Cm C+1 .
+.Cm C-1 .
 .It Cm tabgoto2
 Go to tab 2.
 Default
-.Cm C+2 .
+.Cm C-2 .
 .It Cm tabgoto3
 Go to tab 3.
 Default
-.Cm C+3 .
+.Cm C-3 .
 .It Cm tabgoto4
 Go to tab 4.
 Default
-.Cm C+4 .
+.Cm C-4 .
 .It Cm tabgoto5
 Go to tab 5.
 Default
-.Cm C+5 .
+.Cm C-5 .
 .It Cm tabgoto6
 Go to tab 6.
 Default
-.Cm C+6 .
+.Cm C-6 .
 .It Cm tabgoto7
 Go to tab 7.
 Default
-.Cm C+7 .
+.Cm C-7 .
 .It Cm tabgoto8
 Go to tab 8.
 Default
-.Cm C+8 .
+.Cm C-8 .
 .It Cm tabgoto9
 Go to tab 9.
 Default
-.Cm C+9 .
+.Cm C-9 .
 .It Cm tabgoto10
 Go to tab 10.
 Default
-.Cm C+10 .
+.Cm C-10 .
 .It Cm tabgotofirst
 Go to first tab.
 Default
-.Cm C+less .
+.Cm C-less .
 .It Cm tabgotolast
 Go to last tab.
 Default
-.Cm C+greater .
+.Cm C-greater .
 .It Cm tabgotonext
 Go to next tab.
 If the current tab is the last tab
 .Nm
 will go to the first tab.
 Default
-.Cm C+Right .
+.Cm C-Right .
 .It Cm tabgotoprev
 Go to previous tab.
 If the current tab is the first tab
 .Nm
 will go to the last tab.
 Default
-.Cm C+Left .
+.Cm C-Left .
 .It Cm focusout
 Make fonts on current tab smaller.
 Default
-.Cm C+minus .
+.Cm C-minus .
 .It Cm focusin
 Make fonts on current tab bigger.
 Default
-.Cm C+equal
+.Cm C-equal
 and
-.Cm C+plus .
+.Cm C-plus .
 .El
 .Sh HISTORY
 .Nm
diff --git a/xxxterm.c b/xxxterm.c
index 9fa5665..0b7e52c 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -134,6 +134,7 @@ u_int32_t		swm_debug = 0
 			    | XT_D_FAVORITE
 			    | XT_D_PRINTING
 			    | XT_D_COOKIE
+			    | XT_D_KEYBINDING
 			    ;
 #else
 #define DPRINTF(x...)
@@ -4581,23 +4582,27 @@ walk_kb(struct settings *s,
 			continue;
 		str[0] = '\0';
 
+		/* sanity */
+		if (gdk_keyval_name(k->key) == NULL)
+			continue;
+
 		strlcat(str, k->name, sizeof str);
 		strlcat(str, ",", sizeof str);
 
 		if (k->mask & GDK_SHIFT_MASK)
-			strlcat(str, "S+", sizeof str);
+			strlcat(str, "S-", sizeof str);
 		if (k->mask & GDK_CONTROL_MASK)
-			strlcat(str, "C+", sizeof str);
+			strlcat(str, "C-", sizeof str);
 		if (k->mask & GDK_MOD1_MASK)
-			strlcat(str, "M1+", sizeof str);
+			strlcat(str, "M1-", sizeof str);
 		if (k->mask & GDK_MOD2_MASK)
-			strlcat(str, "M2+", sizeof str);
+			strlcat(str, "M2-", sizeof str);
 		if (k->mask & GDK_MOD3_MASK)
-			strlcat(str, "M3+", sizeof str);
+			strlcat(str, "M3-", sizeof str);
 		if (k->mask & GDK_MOD4_MASK)
-			strlcat(str, "M4+", sizeof str);
+			strlcat(str, "M4-", sizeof str);
 		if (k->mask & GDK_MOD5_MASK)
-			strlcat(str, "M5+", sizeof str);
+			strlcat(str, "M5-", sizeof str);
 
 		strlcat(str, gdk_keyval_name(k->key), sizeof str);
 		cb(s, str, cb_args);
@@ -4629,8 +4634,7 @@ keybinding_clearall(void)
 {
 	struct key_binding	*k, *next;
 
-	for (k = TAILQ_FIRST(&kbl); k != TAILQ_LAST(&kbl, keybinding_list);
-	    k = next) {
+	for (k = TAILQ_FIRST(&kbl); k; k = next) {
 		next = TAILQ_NEXT(k, entry);
 		if (k->name == NULL)
 			continue;
@@ -4643,42 +4647,38 @@ keybinding_clearall(void)
 }
 
 int
-keybinding_add(char *kb, struct key_binding *orig)
+keybinding_add(char *kb, char *value, struct key_binding *orig)
 {
 	struct key_binding	*k;
-	char			*name, *value, *s;
 	guint			keyval, mask = 0;
 	int			i;
 
-	DNPRINTF(XT_D_KEYBINDING, "keybinding_add: %s\n", kb);
+	DNPRINTF(XT_D_KEYBINDING, "keybinding_add: %s %s %s\n", kb, value, orig->name);
 
-	s = strstr(kb, ",");
-	if (s == NULL)
+	if (orig == NULL)
+		return (1);
+	if (strcmp(kb, orig->name))
 		return (1);
-	*s = '\0';
-
-	name = kb;
-	value = s + 1;
 
 	/* find modifier keys */
-	if (strstr(value, "S+"))
+	if (strstr(value, "S-"))
 		mask |= GDK_SHIFT_MASK;
-	if (strstr(value, "C+"))
+	if (strstr(value, "C-"))
 		mask |= GDK_CONTROL_MASK;
-	if (strstr(value, "M1+"))
+	if (strstr(value, "M1-"))
 		mask |= GDK_MOD1_MASK;
-	if (strstr(value, "M2+"))
+	if (strstr(value, "M2-"))
 		mask |= GDK_MOD2_MASK;
-	if (strstr(value, "M3+"))
+	if (strstr(value, "M3-"))
 		mask |= GDK_MOD3_MASK;
-	if (strstr(value, "M4+"))
+	if (strstr(value, "M4-"))
 		mask |= GDK_MOD4_MASK;
-	if (strstr(value, "M5+"))
+	if (strstr(value, "M5-"))
 		mask |= GDK_MOD5_MASK;
 
 	/* find keyname */
 	for (i = strlen(value) - 1; i > 0; i--)
-		if (value[i] == '+')
+		if (value[i] == '-')
 			value = &value[i + 1];
 
 	/* validate keyname */
@@ -4687,10 +4687,22 @@ keybinding_add(char *kb, struct key_binding *orig)
 		warnx("invalid keybinding name %s", value);
 		return (1);
 	}
+	/* must run this test too, gtk+ doesn't handle 10 for example */
+	if (gdk_keyval_name(keyval) == NULL) {
+		warnx("invalid keybinding name %s", value);
+		return (1);
+	}
+
+	/* make sure it isn't a dupe */
+	TAILQ_FOREACH(k, &kbl, entry)
+		if (k->key == keyval && k->mask == mask) {
+			warnx("duplicate keybinding for %s", value);
+			return (1);
+		}
 
 	/* add keyname */
 	k = g_malloc0(sizeof *k);
-	k->name = name;
+	k->name = orig->name;
 	k->mask = mask;
 	k->use_in_entry = orig->use_in_entry;
 	k->key = keyval;
@@ -4714,6 +4726,7 @@ int
 add_kb(struct settings *s, char *entry)
 {
 	int			i;
+	char			*kb, *value;
 
 	DNPRINTF(XT_D_KEYBINDING, "add_kb: %s\n", entry);
 
@@ -4723,18 +4736,23 @@ add_kb(struct settings *s, char *entry)
 		return (0);
 	}
 
+	kb = strstr(entry, ",");
+	if (kb == NULL)
+		return (1);
+	*kb = '\0';
+	value = kb + 1;
+
 	/* make sure it is a valid keybinding */
 	for (i = 0; i < LENGTH(keys); i++)
-		if (keys[i].name && !strncmp(entry, keys[i].name,
-		    strlen(keys[i].name))) {
-			DNPRINTF(XT_D_KEYBINDING, "%s 0x%x %d 0x%x\n",
+		if (keys[i].name && !strcmp(entry, keys[i].name)) {
+			DNPRINTF(XT_D_KEYBINDING, "add_kb: %s 0x%x %d 0x%x\n",
 			    keys[i].name,
 			    keys[i].mask,
 			    keys[i].use_in_entry,
 			    keys[i].key);
 
-			return (keybinding_add(entry, &keys[i]));
-			}
+			return (keybinding_add(entry, value, &keys[i]));
+		}
 
 	return (1);
 }
diff --git a/xxxterm.conf b/xxxterm.conf
index d00f227..f2fea89 100644
--- a/xxxterm.conf
+++ b/xxxterm.conf
@@ -127,15 +127,15 @@
 #
 # default keybindings
 #
-# keybinding	= cookiejar,M1+j
-# keybinding	= downloadmgr,M1+d
-# keybinding	= history,M1+h
-# keybinding	= print,C+p
-# keybinding	= quit,C+q
-# keybinding	= restart,M1+q
-# keybinding	= togglejs,C+j
-# keybinding	= togglecookie,M1+c
-# keybinding	= togglesrc,C+s
+# keybinding	= cookiejar,M1-j
+# keybinding	= downloadmgr,M1-d
+# keybinding	= history,M1-h
+# keybinding	= print,C-p
+# keybinding	= quit,C-q
+# keybinding	= restart,M1-q
+# keybinding	= togglejs,C-j
+# keybinding	= togglecookie,M1-c
+# keybinding	= togglesrc,C-s
 # keybinding	= yankuri,y
 # keybinding	= pasteuricur,p
 # keybinding	= pasteurinew,P
@@ -145,14 +145,14 @@
 # keybinding	= focussearch,F7
 # keybinding	= hinting,f
 # keybinding	= goback,BackSpace
-# keybinding	= goback,M1+Left
-# keybinding	= goforward,S+BackSpace
-# keybinding	= goforward,M1+Right
+# keybinding	= goback,M1-Left
+# keybinding	= goforward,S-BackSpace
+# keybinding	= goforward,M1-Right
 # keybinding	= reload,F5
-# keybinding	= reload,C+r
-# keybinding	= reloadforce,C+R
-# keybinding	= reload,C+l
-# keybinding	= favorites,M1+f
+# keybinding	= reload,C-r
+# keybinding	= reloadforce,C-R
+# keybinding	= reload,C-l
+# keybinding	= favorites,M1-f
 # keybinding	= scrolldown,j
 # keybinding	= scrolldown,Down
 # keybinding	= scrollup,k
@@ -161,36 +161,36 @@
 # keybinding	= scrollbottom,End
 # keybinding	= scrolltop,g
 # keybinding	= scrolltop,Home
-# keybinding	= scrollpagedown,Space
-# keybinding	= scrollpagedown,C+f
-# keybinding	= scrollpagedown,PageDown
-# keybinding	= scrollhalfdown,C+d
-# keybinding	= scrollpageup,PageUp
-# keybinding	= scrollpageup,C+b
-# keybinding	= scrollhalfup,C+u
+# keybinding	= scrollpagedown,space
+# keybinding	= scrollpagedown,C-f
+# keybinding	= scrollpagedown,Page_Down
+# keybinding	= scrollhalfdown,C-d
+# keybinding	= scrollpageup,Page_Up
+# keybinding	= scrollpageup,C-b
+# keybinding	= scrollhalfup,C-u
 # keybinding	= scrollright,l
 # keybinding	= scrollright,Right
 # keybinding	= scrollfarright,dollar
 # keybinding	= scrollleft,h
 # keybinding	= scrollleft,Left
 # keybinding	= scrollfarleft,0
-# keybinding	= tabnew,C+t
-# keybinding	= tabclose,C+w
+# keybinding	= tabnew,C-t
+# keybinding	= tabclose,C-w
 # keybinding	= tabundoclose,U
-# keybinding	= tabgoto1,C+1
-# keybinding	= tabgoto2,C+2
-# keybinding	= tabgoto3,C+3
-# keybinding	= tabgoto4,C+4
-# keybinding	= tabgoto5,C+5
-# keybinding	= tabgoto6,C+6
-# keybinding	= tabgoto7,C+7
-# keybinding	= tabgoto8,C+8
-# keybinding	= tabgoto9,C+9
-# keybinding	= tabgoto10,C+10
-# keybinding	= tabgotofirst,C+less
-# keybinding	= tabgotolast,C+greater
-# keybinding	= tabgotoprev,C+Left
-# keybinding	= tabgotonext,C+Right
-# keybinding	= focusout,C+minus
-# keybinding	= focusin,C+equal
-# keybinding	= focusin,C+plus
+# keybinding	= tabgoto1,C-1
+# keybinding	= tabgoto2,C-2
+# keybinding	= tabgoto3,C-3
+# keybinding	= tabgoto4,C-4
+# keybinding	= tabgoto5,C-5
+# keybinding	= tabgoto6,C-6
+# keybinding	= tabgoto7,C-7
+# keybinding	= tabgoto8,C-8
+# keybinding	= tabgoto9,C-9
+# keybinding	= tabgoto10,C-0
+# keybinding	= tabgotofirst,C-less
+# keybinding	= tabgotolast,C-greater
+# keybinding	= tabgotoprev,C-Left
+# keybinding	= tabgotonext,C-Right
+# keybinding	= focusout,C-minus
+# keybinding	= focusin,C-equal
+# keybinding	= focusin,C-plus