open file

This commit is contained in:
2018-11-26 12:54:47 -05:00
parent 133ef02945
commit 401c0a354a

View File

@@ -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()))