No res/builtin/platformHTMLBindings.xml in Windows 1.05

Discussion of bugs in Mozilla Firefox
Post Reply
bender647
Posts: 3
Joined: July 14th, 2005, 5:37 pm

No res/builtin/platformHTMLBindings.xml in Windows 1.05

Post by bender647 »

Every release of Firefox clobbers my readline keybindings and I have
to visit every box I work on patching platformHTMLBindings.xml
to restore them.

Except with 1.05 it doesn't appear that this file is used anymore (even though
there is a faq linkable from the 1.05 release notes specifically saying it is).

My FreeBSD keybindings seem to still work, presumably from the gtk config,
but how would one change bindings in Firefox now on a Windows machine?
avenan
Posts: 1
Joined: July 15th, 2005, 6:39 am

Post by avenan »

Not sure its the officially correct way, but this worked for me:
1) Find chrome/toolkit.jar
2) Open jar file, and edit/replace content/global/platformHTMLBindings.xml
3) Make a backup of the toolkit.jar so if things go wrong, you don't get angry with me
4) jar 0cvf toolkit.jar content
5) If you didn't just overwrite the original toolkit.jar, copy the jar you just created to chrome/toolkit.jar
6) restart firefox

res/builtin/platformHTMLBindings.xml seems to be missing on all 1.0.5 builds...loving the behavior change on a minor release. :(
bender647
Posts: 3
Joined: July 14th, 2005, 5:37 pm

Thanks avenan

Post by bender647 »

Thanks for the tips, I had a feeling the file was hidden in an
archive but hadn't searched yet.

Some tips for people like me who know little about Java:

I knew jar was a Java archive, but thought they were just zip
files. You saved me some grief, I'll bet. I didn't have any Java
development tools available, but managed to find a version of jar
(gjar) on a Slackware Linux disk in the gcc-java package. So my
work was done on a Linux box.

The 'jar xf toolkit.jar' command consistently failed for one reason
or another (CRC or bad header), so I just unzip'd the j'archives.

I patched the contents/global/platformHTMLBindings.xml files.
In the toolkit.jar from my FreeBSD install, this was straightforward
using the Linux box. On the Windows ME and Windows XP files, I had
to translate line-endings using 'fromdos' and 'todos' to allow my
patches to apply.

I used your command-line 'jar 0cvf toolkit.jar content' to recreate
the new toolkit.jar and it thankfully worked with the gcc version
of jar.

Replaced the toolkit.jar and restarted Firefox: this worked on FreeBSD,
Windows ME, Windows XP (my custom keybindings are back).

If someone knows how to write an Emacs or Readline keybinding extension,
that would be great appreciated! This is getting harder and harder
every "minor" release.
jwmillerusa
Posts: 1
Joined: October 12th, 2005, 6:00 pm

Post by jwmillerusa »

Thanks avenan and bender647... finally something that worked for this. Since I spent so long trying to figure this out, here's how I did it, for any other vi/vim-lovers out there.

Vi/Vim-like key-bindings (h j k l, shift-g, shift-h (for go to home))
...on Windows, for Firefox version 1.0.7

1. Found the file called toolkit.jar
For me, this was in /Mozilla Firefox/chrome/
2. Made a backup copy of toolkit.jar
3. Unpacked toolkit.jar from the command line using:
> jar.exe -xvf toolkit.jar

Note: I had jar.exe already as part of JBuilder, which is free from Borland.
This unpacked into a folder called "content".

4. Made the following edits to content\global\platformHTMLBindings.xml

...in the section under <binding id="browser">, added:

<handler event="keypress" key="k" command="cmd_scrollLineUp" />
<handler event="keypress" key="j" command="cmd_scrollLineDown" />
<handler event="keypress" key="h" command="cmd_scrollLeft" />
<handler event="keypress" key="l" command="cmd_scrollRight" />
<handler event="keypress" key="h" command="cmd_scrollTop" modifiers="shift"/>
<handler event="keypress" key="g" command="cmd_scrollBottom" modifiers="shift"/>

5. Repacked toolkit.jar from the command line using:
> jar.exe 0cvf toolkit.jar content

6. Replaced the old toolkit.jar with my new one.
7. In Firefox, entered "about:config" in the url address bar, and verified the following setting:
accessibility.typeaheadfind == false
8. Restarted Firefox, and the new key-bindings worked. ;)

(Update: I just upgraded to Firefox 1.5.0.1 and this method worked fine. -Jeff 2006-02-13)
Last edited by jwmillerusa on February 13th, 2006, 9:42 am, edited 1 time in total.
bender647
Posts: 3
Joined: July 14th, 2005, 5:37 pm

For the Xemacs/Readline crowd

Post by bender647 »

Here's my patch that more or less works with some fuzz
for all versions of Mozilla or Firefox (although this particular
code was applied to Windows XP/Firefox 1.07. The forum
may destroy some formatting, so use it as a guide only :

Code: Select all

--- platformHTMLBindings.xml.orig       2005-09-21 20:37:01.000000000 -0400
+++ platformHTMLBindings.xml    2005-09-21 20:38:24.000000000 -0400
@@ -6,6 +6,27 @@
 
   <binding id="inputFields">
     <handlers>
+
+    <!-- Emacsish single-line motion and delete keys -->
+    <handler event="keypress" key="a" modifiers="control"
+        command="cmd_beginLine"/>
+    <handler event="keypress" key="e" modifiers="control"
+        command="cmd_endLine"/>
+    <handler event="keypress" key="b" modifiers="control"
+        command="cmd_charPrevious"/>
+    <handler event="keypress" key="f" modifiers="control"
+        command="cmd_charNext"/>
+    <handler event="keypress" key="h" modifiers="control"
+        command="cmd_deleteCharBackward"/>
+    <handler event="keypress" key="d" modifiers="control"
+        command="cmd_deleteCharForward"/>
+    <handler event="keypress" key="w" modifiers="control"
+        command="cmd_deleteWordBackward"/>
+    <handler event="keypress" key="u" modifiers="control"
+        command="cmd_deleteToBeginningOfLine"/>
+    <handler event="keypress" key="k" modifiers="control"
+        command="cmd_deleteToEndOfLine"/>
+
     <handler event="keypress" keycode="VK_LEFT" command="cmd_charPrevious"/>
     <handler event="keypress" keycode="VK_RIGHT" command="cmd_charNext"/>
     <handler event="keypress" keycode="VK_LEFT" modifiers="shift"
@@ -20,7 +41,7 @@
     <handler event="keypress" key="z" command="cmd_redo" modifiers="accel,shift" />
     <handler event="keypress" key="z" modifiers="accel" command="cmd_undo"/>
 
-      <handler event="keypress" key="a" modifiers="accel" command="cmd_selectAll"/>
+      <!--<handler event="keypress" key="a" modifiers="accel" command="cmd_selectAll"/>-->
       <handler event="keypress" keycode="VK_UP" command="cmd_charPrevious"/>
       <handler event="keypress" keycode="VK_DOWN" command="cmd_charNext"/>
       <handler event="keypress" keycode="VK_UP" modifiers="shift" command="cmd_selectCharPrevious"/>
@@ -65,6 +86,27 @@
 
   <binding id="textAreas">
     <handlers>
+
+    <!-- Emacsish single-line motion and delete keys -->
+    <handler event="keypress" key="a" modifiers="control"
+        command="cmd_beginLine"/>
+    <handler event="keypress" key="e" modifiers="control"
+        command="cmd_endLine"/>
+    <handler event="keypress" id="key_left" key="b" modifiers="control"
+        command="cmd_charPrevious"/>
+    <handler event="keypress" id="key_right" key="f" modifiers="control"
+        command="cmd_charNext"/>
+    <handler event="keypress" id="key_delback" key="h" modifiers="control"
+        command="cmd_deleteCharBackward"/>
+    <handler event="keypress" id="key_delforw" key="d" modifiers="control"
+        command="cmd_deleteCharForward"/>
+    <handler event="keypress" id="key_delwback" key="w" modifiers="control"
+        command="cmd_deleteWordBackward"/>
+    <handler event="keypress" id="key_del_bol" key="u" modifiers="control"
+        command="cmd_deleteToBeginningOfLine"/>
+    <handler event="keypress" id="key_del_eol" key="k" modifiers="control"
+        command="cmd_deleteToEndOfLine"/>
+
     <handler event="keypress" keycode="VK_LEFT" command="cmd_charPrevious"/>
     <handler event="keypress" keycode="VK_RIGHT" command="cmd_charNext"/>
     <handler event="keypress" keycode="VK_LEFT" modifiers="shift"
@@ -84,7 +126,7 @@
     <handler event="keypress" key="v" modifiers="accel" command="cmd_paste"/>
     <handler event="keypress" key="z" modifiers="accel" command="cmd_undo"/>
     <handler event="keypress" key="z" command="cmd_redo" modifiers="accel,shift" />
-      <handler event="keypress" key="a" modifiers="accel" command="cmd_selectAll"/>
+      <!--<handler event="keypress" key="a" modifiers="accel" command="cmd_selectAll"/>-->
       <handler event="keypress" keycode="VK_HOME"
         command="cmd_beginLine"/>
       <handler event="keypress" keycode="VK_END"
@@ -183,6 +225,33 @@
 
   <binding id="editor">
     <handlers>
+
+      <!-- Emacsish single-line motion and delete keys -->
+      <handler event="keypress" key="a" modifiers="control"
+          command="cmd_beginLine"/>
+      <handler event="keypress" key="e" modifiers="control"
+          command="cmd_endLine"/>
+      <handler event="keypress" id="key_left" key="b" modifiers="control"
+          command="cmd_charPrevious"/>
+      <handler event="keypress" id="key_right" key="f" modifiers="control"
+          command="cmd_charNext"/>
+      <handler event="keypress" id="key_delback" key="h" modifiers="control"
+          command="cmd_deleteCharBackward"/>
+      <handler event="keypress" id="key_delforw" key="d" modifiers="control"
+          command="cmd_deleteCharForward"/>
+      <handler event="keypress" id="key_delwback" key="w" modifiers="control"
+          command="cmd_deleteWordBackward"/>
+      <handler event="keypress" id="key_del_bol" key="u" modifiers="control"
+          command="cmd_deleteToBeginningOfLine"/>
+      <handler event="keypress" id="key_del_eol" key="k" modifiers="control"
+          command="cmd_deleteToEndOfLine"/>
+
+      <!-- Emacsish multi-line motion and delete keys -->
+      <handler event="keypress" id="key_linedown" key="n" modifiers="control"
+          command="cmd_lineNext"/>
+      <handler event="keypress" id="key_lineup" key="p" modifiers="control"
+          command="cmd_linePrevious"/>
+
       <handler event="keypress" keycode="VK_LEFT" command="cmd_charPrevious"/>
       <handler event="keypress" keycode="VK_RIGHT" command="cmd_charNext"/>
       <handler event="keypress" keycode="VK_LEFT" command="cmd_selectCharPrevious" modifiers="shift"/>
@@ -196,7 +265,7 @@
       <handler event="keypress" key="x" command="cmd_cut" modifiers="accel"/>
       <handler event="keypress" key="c" command="cmd_copy" modifiers="accel"/>
       <handler event="keypress" key="v" command="cmd_paste" modifiers="accel"/>
-      <handler event="keypress" key="a" command="cmd_selectAll" modifiers="accel"/>
+      <!--<handler event="keypress" key="a" command="cmd_selectAll" modifiers="accel"/>-->
       <handler event="keypress" keycode="VK_DELETE" modifiers="shift" command="cmd_cutOrDelete"/>
       <handler event="keypress" keycode="VK_DELETE" modifiers="control" command="cmd_deleteWordForward"/>
       <handler event="keypress" keycode="VK_INSERT" modifiers="control" command="cmd_copy"/>
Post Reply