diff --git a/ide/src/main/kotlin/befide/ide/ActionView.kt b/ide/src/main/kotlin/befide/ide/ActionView.kt index 616b952..911fda3 100644 --- a/ide/src/main/kotlin/befide/ide/ActionView.kt +++ b/ide/src/main/kotlin/befide/ide/ActionView.kt @@ -4,10 +4,12 @@ import befide.befunge.core.Interpreter import javafx.animation.Animation import javafx.animation.Timeline import javafx.beans.property.SimpleBooleanProperty +import javafx.stage.FileChooser import javafx.util.Duration import tornadofx.* import tornadofx.getValue import tornadofx.setValue +import java.io.File class ActionView(val interp: Interpreter, val codeView: CodeView, val ioView: IOView) : View() { var runTimeline: Timeline = timeline(false) { @@ -95,6 +97,20 @@ class ActionView(val interp: Interpreter, val codeView: CodeView, val ioView: IO spacer() + button("open") { + setOnAction { + val fc = FileChooser() + fc.title = "Open Befunge File" + + val file: File? = fc.showOpenDialog(primaryStage) + if (file != null){ + reset() + codeView.src = file.readText() + } + } + disableWhen(isRunningProperty) + } + button("reset") { setOnAction { reset() } enableWhen(canResetProperty.and(isRunningProperty.not()))