Use temporary navigation hacks for 'j' and 'k'
Before VIM mode is fixed, the temporary hacks will be used for vertical navigation. Change-Id: I149a9b015f179bf41f116cd7dafe7cd72da19286
This commit is contained in:
parent
523738fb98
commit
b65d7ad54c
@ -232,6 +232,8 @@ public class CodeMirrorDemo extends Screen {
|
||||
cm.on("cursorActivity", updateActiveLine(cm));
|
||||
cm.on("scroll", doScroll(cm));
|
||||
// TODO: Prevent right click from updating the cursor.
|
||||
cm.addKeyMap(KeyMap.create().on("'j'", moveCursorDown(cm, 1)));
|
||||
cm.addKeyMap(KeyMap.create().on("'k'", moveCursorDown(cm, -1)));
|
||||
cm.addKeyMap(KeyMap.create().on("'u'", upToChange()));
|
||||
cm.addKeyMap(KeyMap.create().on("'o'", toggleOpenBox(cm)));
|
||||
cm.addKeyMap(KeyMap.create().on("Enter", toggleOpenBox(cm)));
|
||||
@ -239,9 +241,12 @@ public class CodeMirrorDemo extends Screen {
|
||||
if (Gerrit.isSignedIn()) {
|
||||
cm.addKeyMap(KeyMap.create().on("'c'", insertNewDraft(cm)));
|
||||
}
|
||||
// TODO: Work on a better way for customizing keybindings.
|
||||
for (String s : new String[]{"C", "O", "R", "U", "Ctrl-C", "Ctrl-F",
|
||||
"Enter"}) {
|
||||
/**
|
||||
* TODO: Work on a better way for customizing keybindings and remove
|
||||
* temporary navigation hacks.
|
||||
*/
|
||||
for (String s : new String[]{"C", "J", "K", "O", "R", "U", "Ctrl-C",
|
||||
"Ctrl-F", "Enter"}) {
|
||||
CodeMirror.disableUnwantedKey("vim", s);
|
||||
}
|
||||
}
|
||||
@ -746,6 +751,14 @@ public class CodeMirrorDemo extends Screen {
|
||||
};
|
||||
}
|
||||
|
||||
private Runnable moveCursorDown(final CodeMirror cm, final int numLines) {
|
||||
return new Runnable() {
|
||||
public void run() {
|
||||
cm.moveCursorDown(numLines);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Runnable upToChange() {
|
||||
return new Runnable() {
|
||||
public void run() {
|
||||
|
@ -233,12 +233,17 @@ public class CodeMirror extends JavaScriptObject {
|
||||
$wnd.CodeMirror.keyMap[category][name] = undefined;
|
||||
}-*/;
|
||||
|
||||
public static native void defineVimEx(String name, String prefix, Runnable thunk) /*-{
|
||||
public static final native void defineVimEx(String name, String prefix,
|
||||
Runnable thunk) /*-{
|
||||
$wnd.CodeMirror.Vim.defineEx(name, prefix, $entry(function() {
|
||||
thunk.@java.lang.Runnable::run()();
|
||||
}));
|
||||
}-*/;
|
||||
|
||||
public final native void moveCursorDown(int numLines) /*-{
|
||||
this.moveV(numLines, "line");
|
||||
}-*/;
|
||||
|
||||
public final native Element getGutterElement() /*-{
|
||||
return this.getGutterElement();
|
||||
}-*/;
|
||||
|
Loading…
Reference in New Issue
Block a user