mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-13 06:16:58 +02:00
VIM-818 Enable key repeat on Mac OS X every time it gets reset by the OS
This commit is contained in:
src/com/maddyhome/idea/vim
@@ -186,6 +186,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
search.saveData(element);
|
||||
history.saveData(element);
|
||||
key.saveData(element);
|
||||
editor.saveData(element);
|
||||
|
||||
return element;
|
||||
}
|
||||
@@ -211,6 +212,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
search.readData(element);
|
||||
history.readData(element);
|
||||
key.readData(element);
|
||||
editor.readData(element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -368,19 +370,23 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
||||
private void updateState() {
|
||||
if (isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
boolean requiresRestart = false;
|
||||
if (previousStateVersion < 2 && SystemInfo.isMac) {
|
||||
if (SystemInfo.isMac) {
|
||||
final MacKeyRepeat keyRepeat = MacKeyRepeat.getInstance();
|
||||
final Boolean enabled = keyRepeat.isEnabled();
|
||||
if (enabled == null || !enabled) {
|
||||
final Boolean isKeyRepeat = editor.isKeyRepeat();
|
||||
if ((enabled == null || !enabled) && (isKeyRepeat == null || isKeyRepeat)) {
|
||||
if (Messages.showYesNoDialog("Do you want to enable repeating keys in Mac OS X on press and hold " +
|
||||
"(requires restart)?\n\n" +
|
||||
"(You can do it manually by running 'defaults write -g " +
|
||||
"ApplePressAndHoldEnabled 0' in the console).", IDEAVIM_NOTIFICATION_TITLE,
|
||||
Messages.getQuestionIcon()
|
||||
) == Messages.YES) {
|
||||
Messages.getQuestionIcon()) == Messages.YES) {
|
||||
editor.setKeyRepeat(true);
|
||||
keyRepeat.setEnabled(true);
|
||||
requiresRestart = true;
|
||||
}
|
||||
else {
|
||||
editor.setKeyRepeat(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (previousStateVersion > 0 && previousStateVersion < 3) {
|
||||
|
@@ -16,6 +16,7 @@ import com.maddyhome.idea.vim.helper.*;
|
||||
import com.maddyhome.idea.vim.option.OptionChangeEvent;
|
||||
import com.maddyhome.idea.vim.option.OptionChangeListener;
|
||||
import com.maddyhome.idea.vim.option.Options;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -34,6 +35,7 @@ public class EditorGroup {
|
||||
private boolean isBlockCursor = false;
|
||||
private boolean isAnimatedScrolling = false;
|
||||
private boolean isRefrainFromScrolling = false;
|
||||
private Boolean isKeyRepeat = null;
|
||||
|
||||
private final CaretListener myLineNumbersCaretListener = new CaretAdapter() {
|
||||
@Override
|
||||
@@ -163,6 +165,38 @@ public class EditorGroup {
|
||||
}
|
||||
}
|
||||
|
||||
public void saveData(@NotNull Element element) {
|
||||
if (isKeyRepeat != null) {
|
||||
final Element editor = new Element("editor");
|
||||
element.addContent(editor);
|
||||
final Element keyRepeat = new Element("key-repeat");
|
||||
keyRepeat.setAttribute("enabled", Boolean.toString(isKeyRepeat));
|
||||
editor.addContent(keyRepeat);
|
||||
}
|
||||
}
|
||||
|
||||
public void readData(@NotNull Element element) {
|
||||
final Element editor = element.getChild("editor");
|
||||
if (editor != null) {
|
||||
final Element keyRepeat = editor.getChild("key-repeat");
|
||||
if (keyRepeat != null) {
|
||||
final String enabled = keyRepeat.getAttributeValue("enabled");
|
||||
if (enabled != null) {
|
||||
isKeyRepeat = Boolean.valueOf(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Boolean isKeyRepeat() {
|
||||
return isKeyRepeat;
|
||||
}
|
||||
|
||||
public void setKeyRepeat(@Nullable Boolean value) {
|
||||
this.isKeyRepeat = value;
|
||||
}
|
||||
|
||||
private static class LineNumbersGutterProvider implements TextAnnotationGutterProvider {
|
||||
private boolean isEnabled;
|
||||
|
||||
|
Reference in New Issue
Block a user