Commit d56f66d3 authored by Axel Howind's avatar Axel Howind

add some metods to editor API

parent c483b162
Pipeline #54236369 failed with stages
in 19 minutes and 13 seconds
......@@ -31,6 +31,7 @@ import javafx.scene.web.WebView;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URL;
import java.util.Iterator;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
......@@ -224,6 +225,30 @@ public abstract class EditorBase extends BorderPane {
return (String) bridge.callScript("jGetLine("+idx+");");
}
public void addLine(String s) {
bridge.callScript("jAddLine('"+escape(s)+"');");
}
public void setLine(int i, String s) {
bridge.callScript("jSetLine("+i+",'"+escape(s)+"');");
}
public Iterator<String> lineIterator() {
return new Iterator<String>() {
int i=0;
@Override
public boolean hasNext() {
return i<getLineCount();
}
@Override
public String next() {
return getLine(i++);
}
};
}
public void search() {
bridge.executeScript("jSearch();");
}
......
......@@ -173,6 +173,14 @@ function jGetTheme() {
return editor.getOption('theme');
}
function jSetLine(i,s) {
editor.replaceRange(s, {line: i, ch: 0}, {line: i});
}
function jAddLine(s) {
editor.replaceRange(s, {line: Infinity});
}
// track dirty state
editor.on('change', function() {
bridge.setDirty(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment