Add CodeMirrorDoc and the code folding addon.
Add wrappers around CodeMirrorDoc, which supports manipulating the contents in CMs. Add foldcode.js addon. This lays the foundation for handling skips. Change-Id: Ib5df6487b0fcde9bb3395ec64cf84fcf7ff125c1
This commit is contained in:
@@ -25,4 +25,8 @@ public interface Addons extends ClientBundle {
|
|||||||
@Source("selection/mark-selection.js")
|
@Source("selection/mark-selection.js")
|
||||||
@DoNotEmbed
|
@DoNotEmbed
|
||||||
DataResource mark_selection();
|
DataResource mark_selection();
|
||||||
|
|
||||||
|
@Source("fold/foldcode.js")
|
||||||
|
@DoNotEmbed
|
||||||
|
DataResource foldcode();
|
||||||
}
|
}
|
||||||
|
@@ -71,6 +71,10 @@ public class CodeMirror extends JavaScriptObject {
|
|||||||
this.addLineWidget(line, node, options);
|
this.addLineWidget(line, node, options);
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
|
public final native CodeMirrorDoc getDoc() /*-{
|
||||||
|
return this.getDoc();
|
||||||
|
}-*/;
|
||||||
|
|
||||||
public final native void scrollTo(int x, int y) /*-{
|
public final native void scrollTo(int x, int y) /*-{
|
||||||
this.scrollTo(x, y);
|
this.scrollTo(x, y);
|
||||||
}-*/;
|
}-*/;
|
||||||
|
33
gerrit-gwtui/src/main/java/net/codemirror/lib/CodeMirrorDoc.java
vendored
Normal file
33
gerrit-gwtui/src/main/java/net/codemirror/lib/CodeMirrorDoc.java
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (C) 2013 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package net.codemirror.lib;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.JavaScriptObject;
|
||||||
|
|
||||||
|
/** The Doc object representing the content in a CodeMirror */
|
||||||
|
public class CodeMirrorDoc extends JavaScriptObject {
|
||||||
|
|
||||||
|
public final native void replaceRange(String replacement,
|
||||||
|
LineCharacter from, LineCharacter to) /*-{
|
||||||
|
this.replaceRange(replacement, from, to);
|
||||||
|
}-*/;
|
||||||
|
|
||||||
|
public final native void insertText(String insertion, LineCharacter at) /*-{
|
||||||
|
this.replaceRange(insertion, at);
|
||||||
|
}-*/;
|
||||||
|
|
||||||
|
protected CodeMirrorDoc() {
|
||||||
|
}
|
||||||
|
}
|
@@ -47,6 +47,7 @@ class Loader {
|
|||||||
public void onSuccess(Void result) {}
|
public void onSuccess(Void result) {}
|
||||||
}));
|
}));
|
||||||
injectScript(Addons.I.mark_selection().getSafeUri(), group.add(cb));
|
injectScript(Addons.I.mark_selection().getSafeUri(), group.add(cb));
|
||||||
|
injectScript(Addons.I.foldcode().getSafeUri(), group.add(cb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user