10

Is there anyway to have jEdits keyboard controls behave the same way that a native Mac OS app does?

By behave I mean command+left moves the caret to the start of the line, alt+left moves to the beginning of the current word etc.

BefittingTheorem
  • 10,459
  • 15
  • 69
  • 96
  • good question! Any progress on that? I was wondering the same myself. But I couldn't find anything on the web either. I'm afraid you do have to create the bindings on your own. .. – RngTng Mar 29 '10 at 18:19
  • no progress, no response :) Yea it's more that jedit does not recognise some of the mac keys when making bindings so it's not just an issue of making mappings. I know in the previous version of jedit that it had a plugin for the mac. But that was removed due to it not working with JDK6 as far as I know. – BefittingTheorem Mar 30 '10 at 08:58

3 Answers3

10

First the ALT key needs to be enabled. Do this in the startup.bsh file located in:

JEDIT_HOME/Contents/Resources/Java/startup/startup.bsh

On Mac OX this would typically be:

/Applications/jEdit.app/Contents/Resources/Java/startup/startup.bsh

The following lines should be uncommented:

Debug.ALT_KEY_PRESSED_DISABLED = false;
Debug.ALTERNATIVE_DISPATCHER = false;

You can now include the ALT key in keymappings, where

C => CMD
M => ALT
Go to End of Line: C+Right  
Go to Start of Line: C+Left 
Go to Next Word: M+Right 
Go to Previous Word: M+Left 
Select Next Word: MS+Right 
Select Previous Word: MS+Left 
Select to End of Line: CS+Right 
Select to Start of Line: CS+Left
BefittingTheorem
  • 10,459
  • 15
  • 69
  • 96
  • This was very helpful, but didn't quite give me all the functionality I wanted. As of version 5.1.0, If you search that `startup.bsh` file for 'MacOS', there are a few other lines to uncomment (`KeyEventTranslator.setModifierMapping`); doing so solves @BrianHeylin's original question. – JJ Zabkar Dec 10 '13 at 18:52
  • Thanks a lot Brian. Only adding that in jEdit 5.3.0 it's needed to add the lines `Debug.ALT_KEY_PRESSED_DISABLED = false;' and 'Debug.ALTERNATIVE_DISPATCHER = false;` manually. – Jorge Gil Nov 04 '15 at 05:07
3

Unfortunately Brian's findings do not play well with QWERTZ keyboards: it disables the possibility to enter chars like pipe, curly brackets, or whatever uses the ALT-key as modifier.

According to the comments in startup.bsh:

/*{{{ Remapping modifier keys part II */

/* Note if you chose to make use of the M+ (option key) prefix on MacOS, you
 * will need to disable a little piece of code: */
//Debug.ALT_KEY_PRESSED_DISABLED = false;
/* Otherwise M+ will be ignored for the purposes of keyboard shortcuts. */

/* But if you enable this, you might find that Option+8 for example invokes your
 * macro but also inserts a bulletpoint, as per standard Macintosh keyboard
 * behavior. To disable the Option key for inserting special high ASCII
 * characters, uncomment this. Note that it has wider implications, notably
 * DROVAK keyboard shortcuts will be mapped as if the keyboard was QWERTY. */
//Debug.ALTERNATIVE_DISPATCHER = false;

/*}}}*/

only uncommenting Debug.ALT_KEY_PRESSED_DISABLED should do the trick, but here[1] it doesn't - I can either use ALT as modifier for shortcuts, or as a modifier for entering chars.. a prior section also deals with the mapping of modifiers:

/*{{{ Remapping modifier keys part I */

/* The below is the default, swap the items around to
 * change meaning of C+, A+, M+, S+.
 */
//KeyEventTranslator.setModifierMapping(InputEvent.CTRL_MASK,
//  InputEvent.ALT_MASK, InputEvent.META_MASK,
//  InputEvent.SHIFT_MASK);

/* ... and this the MacOS default: */
//KeyEventTranslator.setModifierMapping(InputEvent.META_MASK,  /* == C+ */
//  InputEvent.CTRL_MASK,  /* == A+ */
//  InputEvent.ALT_MASK,   /* == M+ */
//  InputEvent.SHIFT_MASK  /* == S+ */);

/*}}}*/

but whatever combination of settings I tried, I wasn't able to achieve a setup with both options (ALT as modifier for shortcuts and textinput) working.

So: any hint/fix would be highly appreciated. ;-)

[1] here means: jEdit 4.3.2 @ OSX 10.5.8 (Java 1.5.0_30) with QWERTZ (German) keyboard

Sufian
  • 6,405
  • 16
  • 66
  • 120
jdlx
  • 125
  • 8
  • I'm having the same problem, with a QWERTY keyboard. :( Can't input a # via jEdit?? – Nick Mar 30 '12 at 16:29
1

A solution that works for me:

Create some macros that insert the special alt-characters you need into the textArea (one macro per character).

Then you can change the setup to enable the alt-key for jedit (I enabled only the first of the two properties).

After that you can assign alt-shortcuts for the macros you recorded in a way that the special characters will be insterted by the same shortcus as before.

After that you can change the shortcut-setup for text-navigation to match the mac-standard and you will still have the special characters available through the defined macro-shortcuts.