2023年10月7日22:34:54
parent
36752301ab
commit
80b8f262f2
6
pom.xml
6
pom.xml
|
|
@ -448,7 +448,11 @@
|
||||||
<artifactId>timi-fx</artifactId>
|
<artifactId>timi-fx</artifactId>
|
||||||
<version>1.4.0</version>
|
<version>1.4.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>eu.mihosoft.monacofx</groupId>
|
||||||
|
<artifactId>MonacoFX</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.zhangmeng.tools.editors.ace.AceEditor;
|
||||||
import com.zhangmeng.tools.editors.monaco.MonacoEdit;
|
import com.zhangmeng.tools.editors.monaco.MonacoEdit;
|
||||||
import com.zhangmeng.tools.utils.ImagePath;
|
import com.zhangmeng.tools.utils.ImagePath;
|
||||||
import com.zhangmeng.tools.utils.ResourcesUtils;
|
import com.zhangmeng.tools.utils.ResourcesUtils;
|
||||||
|
import eu.mihosoft.monacofx.MonacoFX;
|
||||||
import javafx.beans.property.SimpleDoubleProperty;
|
import javafx.beans.property.SimpleDoubleProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
|
@ -38,7 +39,7 @@ public class EditListController {
|
||||||
private AnchorPane root;
|
private AnchorPane root;
|
||||||
|
|
||||||
private AceEditor acJsEditor;
|
private AceEditor acJsEditor;
|
||||||
private MonacoEdit monacoEdit;
|
private AnchorPane monacoEdit;
|
||||||
|
|
||||||
public static final String color_cell = "#f4f4f4";
|
public static final String color_cell = "#f4f4f4";
|
||||||
|
|
||||||
|
|
@ -315,15 +316,29 @@ public class EditListController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void monacoEdit(boolean flag) {
|
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);
|
listView.getSelectionModel().select(1);
|
||||||
|
|
||||||
if (!flag){
|
if (!flag){
|
||||||
monacoEdit = new MonacoEdit();
|
root = new AnchorPane(monacoFX);
|
||||||
root = monacoEdit;
|
WebView webView = monacoFX.getView();
|
||||||
WebView webView = monacoEdit.getWebView();
|
|
||||||
webView.prefWidthProperty().bind(root.widthProperty());
|
webView.prefWidthProperty().bind(root.widthProperty());
|
||||||
webView.prefHeightProperty().bind(root.heightProperty());
|
webView.prefHeightProperty().bind(root.heightProperty());
|
||||||
|
monacoEdit = root;
|
||||||
}else {
|
}else {
|
||||||
root = monacoEdit;
|
root = monacoEdit;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,15 +89,14 @@ public class MonacoEdit extends AnchorPane {
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
private void setMonacoText(String value) {
|
private void setMonacoText(String value) {
|
||||||
JSObject editor = (JSObject) engine.executeScript("window");
|
engine.executeScript("setValue()");
|
||||||
editor.call("setValue", value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置模式
|
* 设置模式
|
||||||
*/
|
*/
|
||||||
private void setMonacoMode(MonacoMode mode) {
|
private void setMonacoMode(MonacoMode mode) {
|
||||||
window.call("setModelLanguage", mode.getName());
|
engine.executeScript("setModelLanguage()");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue