jEdit is one of the best cross-platform text editors out there (note the difference: it's just a text editor, not a word processor!) and certainly the choice of editor for many programmers. It's written in Java, so you can run it pretty much on all sorts of OSes (Windows, Mac, various Linux distros, OS/2, VMS ... just to name a few that it was already tested with). However on Mac OS X you'll run into the Alt/Option key problem pretty soon. By default the Mac version does not recognize Alt for use in shortcuts, which pretty much crapples the whole thing. Of course, there's an easy solution.
A generic Google search did not give me the hits I was looking for, but restricting the search to the jedit.org site I found the
answer instantly. You'll have to go inside the application folder of jEdit (you know: right click the jEdit application in Finder and hit "Show package contents"), go to the
Contents/Resources/Java/startup
folder and you'll hopefully find a
startup.bsh
script in there. Copy this script to your settings folder (
$HOME/.jedit/startup
) and uncomment this part:
/* ... and this the MacOS default: */
KeyEventTranslator.setModifierMapping(
InputEvent.META_MASK, /* == C+ */
InputEvent.CTRL_MASK, /* == A+ */
InputEvent.ALT_MASK, /* == M+ */
InputEvent.SHIFT_MASK /* == S+ */
);
and the following two lines:
Debug.ALT_KEY_PRESSED_DISABLED = false;
Debug.ALTERNATIVE_DISPATCHER = false;
Now restart jEdit and you should be able to specify shortcuts with Alt/Option in them. You can test various shortcuts with the Keyboard Tester (you find it in the "Utilities/Troubleshooting" menu.
Comments
You just saved me a lot of
Re: You just save me
Option key is *sort of* fixed, but some characters still fail
In other words, option-2 generates a ™ (TM) symbol, and looking at the keyboard troubleshooter, it actually generates a specific ASCII value *without* the Meta modifier being set at all!
I wonder if there is any way to fix this? I would like to remap, say, "option 2" to "split window horizontally" like I have it in emacs, but I can't figure out if that is possible.
It's weird, because option-3 of course can be remapped with no trouble.
Nice post - doesn't work for me though
I copied the file and made the changes as you suggested, yet I still can't use short cuts that use the alt/option key.
The Keyboard tester allows me to input shortcuts that use alt/option... But jedit still doesn't seem to recognize them
The shortcut I use the most is the change indent level (Alt+Right or Alt+Left)...
Re: Nice post - doesn't work for me though
properties
andstartup.bsh
files to this post (they are in the HOME directory of the Mac at/Users/<username>/.jedit
and/Users/<username>/.jedit/startup
respectively), you might want to compare these with yours.Thanks for providing your
Perhaps I have some OS level shortcut that is preventing it from working... Oh well.
Note that on Snow Leopard,
Re: Nice post - doesn't work for me though
I've attached a screenshot of my Keyboard Tester output for Alt+Left and Alt+Right shortcuts. Is this what you see if you try to input these shortcuts into your Keyboard Tester? Before the
startup.bsh
modifications the "Specify Shortcut" window did not show me anything, when I pressed a shortcut involving the Alt key, however the keycodes were output into the opened document ("Untitled-1" as seen on my screenshot). After the modifications instartup.bsh
the "Specify Shortcut" window started to show me the names of the shortcuts, even the ones with an Alt key in them (the "M" stands for the Alt key in my screenshot example).Do you see the names of Alt/Option shortcuts appear in the "Specify Shortcut" window of Keyboard Tester? If yes, then I've got no clue. If no, then it'd probably mean that jEdit does not parse your startup.bsh for some reason.
Ah ha! So, I finally
So, I finally figured out what was happening. The default keybindings ignore the 'Alt/Option' key. Additionally, the lines in startup.bsh that are commented out and say they are for MacOS says to map the 'Alt/Option' key to a Meta key. However, there are no shortcuts defined as Meta-(keystroke).
If the Alt/Option key sends 'Meta', then the key is useless - as there are no defaults specified that use 'Meta', there are only 'Control', 'Alt', and some 'Shift' ones.
What I did was this:
KeyEventTranslator.setModifierMapping(
InputEvent.META_MASK,
InputEvent.ALT_MASK,
InputEvent.CTRL_MASK,
InputEvent.SHIFT_MASK);
Debug.ALT_KEY_PRESSED_DISABLED = false;
Debug.ALTERNATIVE_DISPATCHER = false;
That way, the command key becomes the Control Key, and the 'Alt/Option' key sends Alt.
Thanks for your help!
Re: Ah ha!
Yes, they do. I was not aware that you expected the startup.bsh changes to activate the "A+" shortcuts just by themselves. Those changes do no such thing since they map the Alt key to "M+". I've manually configured all my shortcuts that I use regularily and made some shortcuts to use "M+" (which became the Alt key due to startup.bsh). By default no shortcuts take use of "M+" so enabling the Alt key for it won't make a difference in itself.
Mapping the Alt key to "A+" is a good solution too. This way a lot of the default jEdit shortcuts will be available through the Alt key.
I'm happy you could make it work for you and maybe our discussion will help others too to understand how the Alt, Meta, Control and Shift mappings work.
As I would like to use some
Event KEY_PRESSED,keyCode=0x9d,keyChar=0xffff,modifiers=0x4,consumed=0 filtered
Event KEY_PRESSED,keyCode=0x10,keyChar=0xffff,modifiers=0x5,consumed=0 filtered
Event KEY_PRESSED,keyCode=0x37,keyChar=0x37,modifiers=0x5,consumed=0 passed
==> Translated to CS<0,37>
Event KEY_TYPED,keyCode=0x0,keyChar=0x37,modifiers=0x5,consumed=0 filtered
Event KEY_RELEASED,keyCode=0x37,keyChar=0x37,modifiers=0x5,consumed=0 passed
Event KEY_RELEASED,keyCode=0x10,keyChar=0xffff,modifiers=0x4,consumed=0 filtered
Event KEY_RELEASED,keyCode=0x9d,keyChar=0xffff,modifiers=0x0,consumed=0 filtered
What does it mean and can you help me get my backslash back?