!148 feature: #I85N2Z 完善编译运行界面
Merge pull request !148 from cccqyu/feature-I85N2Z
This commit is contained in:
commit
edb9bab320
@ -47,5 +47,6 @@ module org.jcnc.jnotepad {
|
|||||||
exports org.jcnc.jnotepad.component.module.hbox;
|
exports org.jcnc.jnotepad.component.module.hbox;
|
||||||
exports org.jcnc.jnotepad.component.stage.topmenu.help;
|
exports org.jcnc.jnotepad.component.stage.topmenu.help;
|
||||||
exports org.jcnc.jnotepad.component.stage.topmenu.plugin;
|
exports org.jcnc.jnotepad.component.stage.topmenu.plugin;
|
||||||
|
exports org.jcnc.jnotepad.component.module.vbox.components;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package org.jcnc.jnotepad.common.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SplitPane常量类
|
||||||
|
* *
|
||||||
|
* <p>用于记录SplitPane中子组件的索引</p>
|
||||||
|
*
|
||||||
|
* @author cccqyu
|
||||||
|
*/
|
||||||
|
public class SplitPaneItemConstants {
|
||||||
|
|
||||||
|
// rootSplitPane
|
||||||
|
|
||||||
|
// 上部
|
||||||
|
public static final int ROOT_SPLIT_PANE_TOP_SPLIT_PANE = 0;
|
||||||
|
// 底部
|
||||||
|
public static final int ROOT_SPLIT_PANE_CMDBox = 1;
|
||||||
|
|
||||||
|
// rootSplitPane中的上部面板
|
||||||
|
// 左侧
|
||||||
|
public static final int TOP_SPLIT_PANE_DIRECTORY_SIDEBAR_PANE = 0;
|
||||||
|
// 右侧
|
||||||
|
public static final int TOP_SPLIT_PANE_CENTER_TAB_PANE = 1;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
package org.jcnc.jnotepad.component.module.vbox;
|
||||||
|
|
||||||
|
import javafx.scene.control.Tab;
|
||||||
|
import javafx.scene.control.TabPane;
|
||||||
|
import org.jcnc.jnotepad.component.module.vbox.components.DebugBox;
|
||||||
|
import org.jcnc.jnotepad.component.module.vbox.components.CmdTerminalBox;
|
||||||
|
import org.jcnc.jnotepad.component.module.vbox.components.RunBox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 底部Run,Debug,Cmd面板
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author cccqyu
|
||||||
|
*/
|
||||||
|
public class BuildPanel extends TabPane {
|
||||||
|
|
||||||
|
private static BuildPanel instance = null;
|
||||||
|
|
||||||
|
public static BuildPanel getInstance() {
|
||||||
|
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new BuildPanel();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final CmdTerminalBox cmdTerminalBox;
|
||||||
|
private final RunBox runBox;
|
||||||
|
private final DebugBox debugBox;
|
||||||
|
|
||||||
|
private BuildPanel() {
|
||||||
|
cmdTerminalBox = new CmdTerminalBox();
|
||||||
|
runBox = new RunBox();
|
||||||
|
debugBox = new DebugBox();
|
||||||
|
|
||||||
|
Tab runTab = new Tab("运行",runBox);
|
||||||
|
runTab.setClosable(false);
|
||||||
|
|
||||||
|
Tab buildTab = new Tab("构建", debugBox);
|
||||||
|
buildTab.setClosable(false);
|
||||||
|
|
||||||
|
Tab cmdTab = new Tab("控制台",cmdTerminalBox);
|
||||||
|
cmdTab.setClosable(false);
|
||||||
|
this.getTabs().addAll(runTab,buildTab,cmdTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CmdTerminalBox getCmdTerminalBox() {
|
||||||
|
return cmdTerminalBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RunBox getRunBox() {
|
||||||
|
return runBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DebugBox getBuildBox() {
|
||||||
|
return debugBox;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.jcnc.jnotepad.component.module.vbox;
|
package org.jcnc.jnotepad.component.module.vbox.components;
|
||||||
|
|
||||||
import javafx.animation.KeyFrame;
|
import javafx.animation.KeyFrame;
|
||||||
import javafx.animation.Timeline;
|
import javafx.animation.Timeline;
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package org.jcnc.jnotepad.component.module.vbox.components;
|
||||||
|
|
||||||
|
import org.jcnc.jnotepad.component.module.TextCodeArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debug终端界面。
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author cccqyu
|
||||||
|
*/
|
||||||
|
public class DebugBox extends TextCodeArea {
|
||||||
|
public DebugBox() {
|
||||||
|
super();
|
||||||
|
this.setEditable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.appendText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package org.jcnc.jnotepad.component.module.vbox.components;
|
||||||
|
|
||||||
|
import org.jcnc.jnotepad.component.module.TextCodeArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run终端界面。
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author cccqyu
|
||||||
|
*/
|
||||||
|
public class RunBox extends TextCodeArea {
|
||||||
|
|
||||||
|
|
||||||
|
public RunBox() {
|
||||||
|
super();
|
||||||
|
this.setEditable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.appendText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -3,15 +3,20 @@ package org.jcnc.jnotepad.controller.event.handler.toolbar;
|
|||||||
|
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
|
import org.jcnc.jnotepad.views.manager.BuildPanelManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author luke
|
* 终端处理器
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author cccqyu
|
||||||
*/
|
*/
|
||||||
public class RunBtn implements EventHandler<ActionEvent> {
|
public class RunBtn implements EventHandler<ActionEvent> {
|
||||||
|
|
||||||
@Override
|
private static final BuildPanelManager BUILD_PANEL_MANAGER = BuildPanelManager.getInstance();
|
||||||
public void handle(ActionEvent actionEvent) {
|
|
||||||
// TODO: 2023/10/6 点击按钮,打开下方侧边栏的运行输出栏
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(ActionEvent event) {
|
||||||
|
BUILD_PANEL_MANAGER.controlShow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,68 @@
|
|||||||
|
package org.jcnc.jnotepad.views.manager;
|
||||||
|
|
||||||
|
import javafx.scene.control.SplitPane;
|
||||||
|
import org.jcnc.jnotepad.component.module.TextCodeArea;
|
||||||
|
import org.jcnc.jnotepad.views.root.center.main.MainBorderPane;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建底部三大菜单管理类
|
||||||
|
*
|
||||||
|
* <p>管理构建三大菜单操作</p>
|
||||||
|
*
|
||||||
|
* @author cccqyu
|
||||||
|
*/
|
||||||
|
public class BuildPanelManager {
|
||||||
|
|
||||||
|
private BuildPanelManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单例模式,保证只有一个 BuildPanelManager 实例
|
||||||
|
*/
|
||||||
|
private static final BuildPanelManager INSTANCE = new BuildPanelManager();
|
||||||
|
|
||||||
|
|
||||||
|
public static BuildPanelManager getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static final MainBorderPane MAIN_BORDER_PANE = MainBorderPane.getInstance();
|
||||||
|
private static boolean isShow = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 控制终端显示
|
||||||
|
*/
|
||||||
|
public void controlShow() {
|
||||||
|
|
||||||
|
// 获取root分割面板
|
||||||
|
SplitPane root = (SplitPane) MAIN_BORDER_PANE.getCenter();
|
||||||
|
|
||||||
|
if (isShow) {
|
||||||
|
root.setDividerPositions(1);
|
||||||
|
} else {
|
||||||
|
// 展开分割条,文件树
|
||||||
|
root.setDividerPositions(0.7);
|
||||||
|
}
|
||||||
|
isShow = !isShow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void controlShow(boolean bool) {
|
||||||
|
|
||||||
|
// 获取root分割面板
|
||||||
|
SplitPane root = (SplitPane) MAIN_BORDER_PANE.getCenter();
|
||||||
|
|
||||||
|
if (!bool) {
|
||||||
|
root.setDividerPositions(1);
|
||||||
|
} else {
|
||||||
|
// 展开分割条,文件树
|
||||||
|
root.setDividerPositions(0.7);
|
||||||
|
}
|
||||||
|
isShow = !isShow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(TextCodeArea textCodeArea, String text) {
|
||||||
|
textCodeArea.appendText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -3,6 +3,7 @@ package org.jcnc.jnotepad.views.manager;
|
|||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.scene.control.SplitPane;
|
import javafx.scene.control.SplitPane;
|
||||||
import javafx.scene.control.TreeItem;
|
import javafx.scene.control.TreeItem;
|
||||||
|
import org.jcnc.jnotepad.common.constants.SplitPaneItemConstants;
|
||||||
import org.jcnc.jnotepad.common.manager.ApplicationCacheManager;
|
import org.jcnc.jnotepad.common.manager.ApplicationCacheManager;
|
||||||
import org.jcnc.jnotepad.controller.event.handler.toolbar.OpenDirectory;
|
import org.jcnc.jnotepad.controller.event.handler.toolbar.OpenDirectory;
|
||||||
import org.jcnc.jnotepad.model.entity.DirFileModel;
|
import org.jcnc.jnotepad.model.entity.DirFileModel;
|
||||||
@ -44,26 +45,25 @@ public class DirectorySidebarManager {
|
|||||||
|
|
||||||
private static final double LAST_DIVIDER_POSITION = 0.3;
|
private static final double LAST_DIVIDER_POSITION = 0.3;
|
||||||
|
|
||||||
|
private static boolean isShow = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 控制文件树显示
|
* 控制文件树显示
|
||||||
*/
|
*/
|
||||||
public void controlShow() {
|
public void controlShow() {
|
||||||
// 获取分割面板
|
// 获取root分割面板
|
||||||
SplitPane center = (SplitPane) MAIN_BORDER_PANE.getCenter();
|
SplitPane root = (SplitPane) MAIN_BORDER_PANE.getCenter();
|
||||||
// 获取分割条位置
|
|
||||||
double dividerPosition = center.getDividerPositions()[0];
|
|
||||||
// 保留分割条位置一位小数
|
|
||||||
String formattedNumber = String.format("%.1f", dividerPosition);
|
|
||||||
double roundedNumber = Double.parseDouble(formattedNumber);
|
|
||||||
|
|
||||||
// 分割条位置不等于 代表展开
|
// 获取root的上部分割面板
|
||||||
if (Double.compare(roundedNumber, 0.0) != 0) {
|
SplitPane topSplitPane = (SplitPane) root.getItems().get(SplitPaneItemConstants.ROOT_SPLIT_PANE_TOP_SPLIT_PANE);
|
||||||
// 收缩分割条 收缩文件树
|
|
||||||
center.setDividerPositions(0.0);
|
if (isShow) {
|
||||||
|
topSplitPane.setDividerPositions(0);
|
||||||
} else {
|
} else {
|
||||||
// 展开分割条,文件树
|
// 展开分割条,文件树
|
||||||
center.setDividerPositions(LAST_DIVIDER_POSITION);
|
topSplitPane.setDividerPositions(LAST_DIVIDER_POSITION);
|
||||||
}
|
}
|
||||||
|
isShow = !isShow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,10 +74,13 @@ public class DirectorySidebarManager {
|
|||||||
public void controlShow(boolean bool) {
|
public void controlShow(boolean bool) {
|
||||||
if (bool) {
|
if (bool) {
|
||||||
// 获取分割面板
|
// 获取分割面板
|
||||||
SplitPane center = (SplitPane) MAIN_BORDER_PANE.getCenter();
|
SplitPane root = (SplitPane) MAIN_BORDER_PANE.getCenter();
|
||||||
center.setDividerPositions(LAST_DIVIDER_POSITION);
|
// 获取root的上部分割面板
|
||||||
}
|
SplitPane topSplitPane = (SplitPane) root.getItems().get(SplitPaneItemConstants.ROOT_SPLIT_PANE_TOP_SPLIT_PANE);
|
||||||
|
|
||||||
|
topSplitPane.setDividerPositions(LAST_DIVIDER_POSITION);
|
||||||
|
isShow = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
package org.jcnc.jnotepad.views.manager;
|
package org.jcnc.jnotepad.views.manager;
|
||||||
|
|
||||||
|
import javafx.geometry.Orientation;
|
||||||
import javafx.scene.control.SplitPane;
|
import javafx.scene.control.SplitPane;
|
||||||
|
import org.jcnc.jnotepad.common.constants.SplitPaneItemConstants;
|
||||||
|
import org.jcnc.jnotepad.component.module.vbox.BuildPanel;
|
||||||
import org.jcnc.jnotepad.views.root.center.main.MainBorderPane;
|
import org.jcnc.jnotepad.views.root.center.main.MainBorderPane;
|
||||||
import org.jcnc.jnotepad.views.root.center.main.center.directory.DirectorySidebarPane;
|
import org.jcnc.jnotepad.views.root.center.main.center.directory.DirectorySidebarPane;
|
||||||
import org.jcnc.jnotepad.views.root.center.main.center.tab.CenterTabPane;
|
import org.jcnc.jnotepad.views.root.center.main.center.tab.CenterTabPane;
|
||||||
@ -17,7 +20,8 @@ public class MainBorderPaneManager {
|
|||||||
private static final DirectorySidebarPane DIRECTORY_SIDEBAR_PANE = DirectorySidebarPane.getInstance();
|
private static final DirectorySidebarPane DIRECTORY_SIDEBAR_PANE = DirectorySidebarPane.getInstance();
|
||||||
|
|
||||||
// 默认分割条位置
|
// 默认分割条位置
|
||||||
private static final double defaultDividerPositions = 0.3;
|
private static final double TOP_SPLIT_PANEL_DEFAULT_DIVIDER_POSITIONS = 0.3;
|
||||||
|
|
||||||
private MainBorderPaneManager() {
|
private MainBorderPaneManager() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -27,13 +31,30 @@ public class MainBorderPaneManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initMainBorderPane() {
|
public void initMainBorderPane() {
|
||||||
// 文件树和文本框的布局
|
// 总分割面板
|
||||||
SplitPane splitPane = new SplitPane();
|
SplitPane rootSplitPane = new SplitPane();
|
||||||
splitPane.getItems().add(0, DIRECTORY_SIDEBAR_PANE);
|
// 设置上下布局
|
||||||
splitPane.getItems().add(1, CenterTabPane.getInstance());
|
rootSplitPane.setOrientation(Orientation.VERTICAL);
|
||||||
splitPane.setDividerPositions(defaultDividerPositions);
|
rootSplitPane.setDividerPositions(1);
|
||||||
|
|
||||||
|
|
||||||
|
// 上部面板
|
||||||
|
// 文件树和文本框的布局
|
||||||
|
SplitPane topSplitPane = new SplitPane();
|
||||||
|
topSplitPane.getItems().add(SplitPaneItemConstants.TOP_SPLIT_PANE_DIRECTORY_SIDEBAR_PANE, DIRECTORY_SIDEBAR_PANE);
|
||||||
|
topSplitPane.getItems().add(SplitPaneItemConstants.TOP_SPLIT_PANE_CENTER_TAB_PANE, CenterTabPane.getInstance());
|
||||||
|
topSplitPane.setDividerPositions(TOP_SPLIT_PANEL_DEFAULT_DIVIDER_POSITIONS);
|
||||||
|
|
||||||
|
// 下部
|
||||||
|
// 构建三大菜单
|
||||||
|
BuildPanel buildPanel = BuildPanel.getInstance();
|
||||||
|
|
||||||
|
rootSplitPane.getItems().add(SplitPaneItemConstants.ROOT_SPLIT_PANE_TOP_SPLIT_PANE, topSplitPane);
|
||||||
|
rootSplitPane.getItems().add(SplitPaneItemConstants.ROOT_SPLIT_PANE_CMDBox, buildPanel);
|
||||||
|
|
||||||
|
// 将总分割面板设置在布局中部
|
||||||
|
MAIN_BORDER_PANE.setCenterComponent(rootSplitPane);
|
||||||
|
|
||||||
|
|
||||||
// 将文件树以及文本框设置在布局中部
|
|
||||||
MAIN_BORDER_PANE.setCenterComponent(splitPane);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,10 +54,13 @@ public class SidebarToolBarManager extends AbstractManager<Node> {
|
|||||||
.setImageViewEssentialAttribute(10D, 10D, true, 2.5D, 2.5D)
|
.setImageViewEssentialAttribute(10D, 10D, true, 2.5D, 2.5D)
|
||||||
.setButtonEssentialAttribute(20D, 20D)
|
.setButtonEssentialAttribute(20D, 20D)
|
||||||
.setEventHandler(new DirTreeBtn()).build());
|
.setEventHandler(new DirTreeBtn()).build());
|
||||||
|
|
||||||
|
|
||||||
|
// Cmd 按钮
|
||||||
registerNode(
|
registerNode(
|
||||||
new SideBarButtonBuilder()
|
new SideBarButtonBuilder()
|
||||||
.setButton(sidebarToolBar.getRunButton())
|
.setButton(sidebarToolBar.getRunButton())
|
||||||
.setImageView(new ImageView(new Image("directory.png")))
|
.setImageView(new ImageView(new Image("cmd.png")))
|
||||||
.setImageViewEssentialAttribute(10D, 10D, true, 2.5D, 2.5D)
|
.setImageViewEssentialAttribute(10D, 10D, true, 2.5D, 2.5D)
|
||||||
.setButtonEssentialAttribute(20D, 20D)
|
.setButtonEssentialAttribute(20D, 20D)
|
||||||
.setEventHandler(new RunBtn()).build());
|
.setEventHandler(new RunBtn()).build());
|
||||||
|
|||||||
@ -4,9 +4,10 @@ import javafx.event.ActionEvent;
|
|||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.scene.control.Menu;
|
import javafx.scene.control.Menu;
|
||||||
import javafx.scene.control.MenuItem;
|
import javafx.scene.control.MenuItem;
|
||||||
import javafx.scene.control.TextArea;
|
|
||||||
import org.jcnc.jnotepad.api.core.views.top.menu.AbstractTopMenu;
|
import org.jcnc.jnotepad.api.core.views.top.menu.AbstractTopMenu;
|
||||||
|
import org.jcnc.jnotepad.component.module.vbox.BuildPanel;
|
||||||
import org.jcnc.jnotepad.util.LogUtil;
|
import org.jcnc.jnotepad.util.LogUtil;
|
||||||
|
import org.jcnc.jnotepad.views.manager.BuildPanelManager;
|
||||||
import org.jcnc.jnotepad.views.manager.CenterTabPaneManager;
|
import org.jcnc.jnotepad.views.manager.CenterTabPaneManager;
|
||||||
import org.jcnc.jnotepad.views.root.center.main.center.tab.CenterTab;
|
import org.jcnc.jnotepad.views.root.center.main.center.tab.CenterTab;
|
||||||
|
|
||||||
@ -24,6 +25,8 @@ import static org.jcnc.jnotepad.common.constants.TextConstants.RUN;
|
|||||||
*/
|
*/
|
||||||
public class RunTopMenu extends AbstractTopMenu {
|
public class RunTopMenu extends AbstractTopMenu {
|
||||||
CenterTab centerTab = CenterTabPaneManager.getInstance().getSelected();
|
CenterTab centerTab = CenterTabPaneManager.getInstance().getSelected();
|
||||||
|
private static final BuildPanelManager BUILD_PANEL_MANAGER = BuildPanelManager.getInstance();
|
||||||
|
private static final BuildPanel BUILD_PANEL = BuildPanel.getInstance();
|
||||||
private static final RunTopMenu INSTANCE = new RunTopMenu();
|
private static final RunTopMenu INSTANCE = new RunTopMenu();
|
||||||
private final Map<String, MenuItem> runMenuItems = new HashMap<>();
|
private final Map<String, MenuItem> runMenuItems = new HashMap<>();
|
||||||
|
|
||||||
@ -61,12 +64,12 @@ public class RunTopMenu extends AbstractTopMenu {
|
|||||||
return runMenuItems;
|
return runMenuItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHandler<ActionEvent> codeRun = event -> {
|
EventHandler<ActionEvent> codeRun = event -> {
|
||||||
// 创建一个TextArea用于输出编译后的结果
|
// 创建一个TextArea用于输出编译后的结果
|
||||||
TextArea resultTextArea = new TextArea();
|
// TextArea resultTextArea = new TextArea();
|
||||||
resultTextArea.setPrefRowCount(10);
|
// resultTextArea.setPrefRowCount(10);
|
||||||
resultTextArea.setPrefColumnCount(40);
|
// resultTextArea.setPrefColumnCount(40);
|
||||||
resultTextArea.setEditable(false); // 禁止编辑
|
// resultTextArea.setEditable(false); // 禁止编辑
|
||||||
|
|
||||||
// 获取TextCodeArea的文本内容
|
// 获取TextCodeArea的文本内容
|
||||||
|
|
||||||
@ -86,13 +89,14 @@ public class RunTopMenu extends AbstractTopMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 编译和运行C代码
|
// 编译和运行C代码
|
||||||
compileAndRunCode(fileName, resultTextArea);
|
// compileAndRunCode(fileName, resultTextArea);
|
||||||
|
compileAndRunCode(fileName);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编译和运行C代码的方法
|
* 编译和运行C代码的方法
|
||||||
*/
|
*/
|
||||||
private void compileAndRunCode(String fileName, TextArea resultTextArea) {
|
private void compileAndRunCode(String fileName) {
|
||||||
try {
|
try {
|
||||||
// 创建ProcessBuilder并指定GCC编译命令
|
// 创建ProcessBuilder并指定GCC编译命令
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder("gcc", fileName, "-o", "temp");
|
ProcessBuilder processBuilder = new ProcessBuilder("gcc", fileName, "-o", "temp");
|
||||||
@ -124,9 +128,9 @@ public class RunTopMenu extends AbstractTopMenu {
|
|||||||
while ((line = runReader.readLine()) != null) {
|
while ((line = runReader.readLine()) != null) {
|
||||||
result.append(line).append("\n");
|
result.append(line).append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示运行结果
|
// 显示运行结果
|
||||||
resultTextArea.setText(result.toString());
|
BUILD_PANEL_MANAGER.controlShow(true);
|
||||||
|
BUILD_PANEL_MANAGER.setText(BUILD_PANEL.getRunBox(),result.toString());
|
||||||
} else {
|
} else {
|
||||||
System.out.println("编译失败,返回代码:" + compileExitCode);
|
System.out.println("编译失败,返回代码:" + compileExitCode);
|
||||||
}
|
}
|
||||||
@ -145,8 +149,11 @@ public class RunTopMenu extends AbstractTopMenu {
|
|||||||
registerMenuItem(topMenuBar.getRunItem(), RUN, "runItem", codeRun);
|
registerMenuItem(topMenuBar.getRunItem(), RUN, "runItem", codeRun);
|
||||||
|
|
||||||
|
|
||||||
// 调试
|
// 调试 test
|
||||||
registerMenuItem(topMenuBar.getDeBugItem(), DE_BUG, "deBugItem", null);
|
registerMenuItem(topMenuBar.getDeBugItem(), DE_BUG, "deBugItem", event -> {
|
||||||
|
BUILD_PANEL_MANAGER.controlShow(true);
|
||||||
|
BUILD_PANEL_MANAGER.setText(BUILD_PANEL.getBuildBox(),"待开发");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/main/resources/cmd.png
Normal file
BIN
src/main/resources/cmd.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 462 B |
Loading…
x
Reference in New Issue
Block a user