return myEditor.visualPositionToXY(magnificationPosition);
}
});
- putClientProperty("sun.lwawt.macosx.CInputMethod.selectPreviousGlyph.callback", new Runnable() {
- @Override
- public void run() {
- // This is supposed to be called from sun.lwawt.macosx.CInputMethod class of a custom JDK,
- // built for IntelliJ platform running on MacOS.
- // This is required to support input of accented characters using press-and-hold method (http://support.apple.com/kb/PH11264).
- // Non-patched JDK supports this functionality only for TextComponent/JTextComponent descendants.
- int caretOffset = myEditor.getCaretModel().getOffset();
- if (caretOffset > 0) {
- myEditor.getSelectionModel().setSelection(caretOffset - 1, caretOffset);
- }
- }
- });
myApplication = (ApplicationImpl)ApplicationManager.getApplication();
}
public final boolean myUseNewRendering = Registry.is("editor.new.rendering");
final EditorView myView;
+ private boolean myCharKeyPressed;
+ private boolean myNeedToSelectPreviousChar;
+
private final TIntFunction myLineNumberAreaWidthFunction = new TIntFunction() {
@Override
public int execute(int lineNumber) {
myPanel.add(myScrollPane);
}
- myEditorComponent.addKeyListener(new KeyAdapter() {
+ myEditorComponent.addKeyListener(new KeyListener() {
@Override
public void keyTyped(@NotNull KeyEvent event) {
+ myNeedToSelectPreviousChar = false;
if (event.isConsumed()) {
return;
}
event.consume();
}
}
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() >= KeyEvent.VK_A && e.getKeyCode() <= KeyEvent.VK_Z) {
+ myCharKeyPressed = true;
+ }
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ myCharKeyPressed = false;
+ }
});
MyMouseAdapter mouseAdapter = new MyMouseAdapter();
@Override
@Nullable
public AttributedCharacterIterator getSelectedText(AttributedCharacterIterator.Attribute[] attributes) {
+ if (myCharKeyPressed) {
+ myNeedToSelectPreviousChar = true;
+ }
String text = getSelectionModel().getSelectedText();
return text == null ? null : new AttributedString(text).getIterator();
}
}
private void replaceInputMethodText(@NotNull InputMethodEvent e) {
+ if (myNeedToSelectPreviousChar && SystemInfo.isMac && Registry.is("ide.mac.pressAndHold.workaround")) {
+ // This is required to support input of accented characters using press-and-hold method (http://support.apple.com/kb/PH11264).
+ // JDK currently properly supports this functionality only for TextComponent/JTextComponent descendants.
+ // For our editor component we need this workaround.
+ myNeedToSelectPreviousChar = false;
+ getCaretModel().runForEachCaret(new CaretAction() {
+ @Override
+ public void perform(Caret caret) {
+ int caretOffset = caret.getOffset();
+ if (caretOffset > 0) {
+ caret.setSelection(caretOffset - 1, caretOffset);
+ }
+ }
+ });
+ }
+
int commitCount = e.getCommittedCharacterCount();
AttributedCharacterIterator text = e.getText();
ide.mac.disableMacScrollbars=false
ide.mac.disableMacScrollbars.restartRequired=true
ide.mac.disableMacScrollbars.description=Disables OS X overlay scrollbars
+ide.mac.pressAndHold.workaround=true
+ide.mac.pressAndHold.workaround.description=Enable workaround for press-and-hold input method for accented characters on Mac OS
ide.perProjectModality=false
ide.perProjectModality.description=New modality approach. All dialogs are DOCUMENT_MODAL expect ide-wide dialogs