2023年10月7日22:34:54
parent
36752301ab
commit
80b8f262f2
6
pom.xml
6
pom.xml
|
|
@ -448,7 +448,11 @@
|
|||
<artifactId>timi-fx</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>eu.mihosoft.monacofx</groupId>
|
||||
<artifactId>MonacoFX</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.zhangmeng.tools.editors.ace.AceEditor;
|
|||
import com.zhangmeng.tools.editors.monaco.MonacoEdit;
|
||||
import com.zhangmeng.tools.utils.ImagePath;
|
||||
import com.zhangmeng.tools.utils.ResourcesUtils;
|
||||
import eu.mihosoft.monacofx.MonacoFX;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
|
@ -38,7 +39,7 @@ public class EditListController {
|
|||
private AnchorPane root;
|
||||
|
||||
private AceEditor acJsEditor;
|
||||
private MonacoEdit monacoEdit;
|
||||
private AnchorPane monacoEdit;
|
||||
|
||||
public static final String color_cell = "#f4f4f4";
|
||||
|
||||
|
|
@ -315,15 +316,29 @@ public class EditListController {
|
|||
}
|
||||
|
||||
private void monacoEdit(boolean flag) {
|
||||
|
||||
MonacoFX monacoFX = new MonacoFX();
|
||||
// set initial text
|
||||
monacoFX.getEditor().getDocument().setText(
|
||||
"#include <stdio.h>\n" +
|
||||
"int main() {\n" +
|
||||
" // printf() displays the string inside quotation\n" +
|
||||
" printf(\"Hello, World!\");\n" +
|
||||
" return 0;\n" +
|
||||
"}");
|
||||
|
||||
// use a predefined language like 'c'
|
||||
monacoFX.getEditor().setCurrentLanguage("c");
|
||||
monacoFX.getEditor().setCurrentTheme("vs-dark");
|
||||
|
||||
//默认选择第一个
|
||||
listView.getSelectionModel().select(1);
|
||||
|
||||
if (!flag){
|
||||
monacoEdit = new MonacoEdit();
|
||||
root = monacoEdit;
|
||||
WebView webView = monacoEdit.getWebView();
|
||||
root = new AnchorPane(monacoFX);
|
||||
WebView webView = monacoFX.getView();
|
||||
webView.prefWidthProperty().bind(root.widthProperty());
|
||||
webView.prefHeightProperty().bind(root.heightProperty());
|
||||
monacoEdit = root;
|
||||
}else {
|
||||
root = monacoEdit;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,15 +89,14 @@ public class MonacoEdit extends AnchorPane {
|
|||
* @param value
|
||||
*/
|
||||
private void setMonacoText(String value) {
|
||||
JSObject editor = (JSObject) engine.executeScript("window");
|
||||
editor.call("setValue", value);
|
||||
engine.executeScript("setValue()");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置模式
|
||||
*/
|
||||
private void setMonacoMode(MonacoMode mode) {
|
||||
window.call("setModelLanguage", mode.getName());
|
||||
engine.executeScript("setModelLanguage()");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue