visual tweaks

This commit is contained in:
2018-11-26 12:35:47 -05:00
parent ff4b2600a1
commit 57520ef947
9 changed files with 124 additions and 62 deletions

18
.idea/artifacts/ide_jar.xml generated Normal file
View File

@@ -0,0 +1,18 @@
<component name="ArtifactManager">
<artifact type="jar" build-on-make="true" name="ide:jar">
<output-path>$PROJECT_DIR$/out/artifacts/ide_jar</output-path>
<root id="archive" name="ide.jar">
<element id="module-output" name="ide" />
<element id="module-output" name="befunge" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.2.60/kotlin-stdlib-jdk8-1.2.60.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.3.0/kotlin-stdlib-1.3.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/json/javax.json-api/1.1.2/javax.json-api-1.1.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/no/tornado/tornadofx/1.7.17/tornadofx-1.7.17.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/javax.json/1.1.2/javax.json-1.1.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.0/kotlin-stdlib-common-1.3.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.2.60/kotlin-stdlib-jdk7-1.2.60.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-reflect/1.2.60/kotlin-reflect-1.2.60.jar" path-in-jar="/" />
</root>
</artifact>
</component>

View File

@@ -29,7 +29,7 @@ class B93Interpreter : Interpreter {
override val stdInput = LinkedList<Char>() override val stdInput = LinkedList<Char>()
override val stdOutput = LinkedList<String>() override val stdOutput = LinkedList<String>()
private var outBuf: StringBuffer = StringBuffer() private var outBuf: StringBuffer = StringBuffer()
private var bufLimit = 10 private var bufLimit = 0
private val fungeMods = HashMap<Vec,Value>() private val fungeMods = HashMap<Vec,Value>()

View File

@@ -3,8 +3,11 @@ package befide.ide
import befide.befunge.core.Interpreter import befide.befunge.core.Interpreter
import javafx.animation.Animation import javafx.animation.Animation
import javafx.animation.Timeline import javafx.animation.Timeline
import javafx.beans.property.SimpleBooleanProperty
import javafx.util.Duration import javafx.util.Duration
import tornadofx.* import tornadofx.*
import tornadofx.getValue
import tornadofx.setValue
class ActionView(val interp: Interpreter, val codeView: CodeView, val ioView: IOView) : View() { class ActionView(val interp: Interpreter, val codeView: CodeView, val ioView: IOView) : View() {
var runTimeline: Timeline = timeline(false) { var runTimeline: Timeline = timeline(false) {
@@ -19,55 +22,87 @@ class ActionView(val interp: Interpreter, val codeView: CodeView, val ioView: IO
cycleCount = Animation.INDEFINITE cycleCount = Animation.INDEFINITE
} }
val isRunningProperty = SimpleBooleanProperty(false)
var isRunning by isRunningProperty
val canResetProperty = SimpleBooleanProperty(false)
var canReset by canResetProperty
fun start(rate: Double) {
stop()
isRunning = true
canReset = true
interp.funge.values = codeView.values
runTimeline.rate = rate
runTimeline.playFromStart()
}
fun step() {
canReset = true
interp.funge.values = codeView.values
interp.step()
}
fun stop() {
isRunning = false
runTimeline.stop()
}
fun reset() {
stop()
interp.reset()
ioView.reset()
canReset = false
}
fun clearCode() {
reset()
codeView.clear()
}
override val root = hbox { override val root = hbox {
button("step") { button("step") {
setOnAction { setOnAction { step() }
interp.funge.values = codeView.values disableWhen(isRunningProperty)
interp.step()
}
} }
button("reset") { separator { }
setOnAction {
interp.reset()
ioView.reset()
codeView.values = interp.funge.values
}
}
button("run") { button("run") {
setOnAction { setOnAction { start(10000.0) }
interp.funge.values = codeView.values
runTimeline.rate = 10000.0
runTimeline.playFromStart()
}
} }
button("walk") { button("walk") {
setOnAction { setOnAction { start(50.0) }
interp.funge.values = codeView.values
runTimeline.rate = 50.0
runTimeline.playFromStart()
}
} }
button("crawl") { button("crawl") {
setOnAction { setOnAction { start(4.0) }
interp.funge.values = codeView.values
runTimeline.rate = 4.0
runTimeline.playFromStart()
}
} }
separator {}
button("stop") { button("stop") {
setOnAction { setOnAction { stop() }
runTimeline.stop() enableWhen(isRunningProperty)
} }
spacer()
button("reset") {
setOnAction { reset() }
enableWhen(canResetProperty.and(isRunningProperty.not()))
}
button("clear") {
setOnAction { clearCode() }
disableWhen(isRunningProperty)
} }
} }
} }

View File

@@ -50,6 +50,14 @@ class CodeView(val interp: Interpreter) : View() {
cursorPos = interp.funge.nextVec(cursorPos, delta ?: cursorDelta) cursorPos = interp.funge.nextVec(cursorPos, delta ?: cursorDelta)
} }
fun clear() {
for (row in labels) {
for (lbl in row) {
lbl.value = Value(' ')
}
}
}
var src: String var src: String
get() = labels.joinToString("\n") { row -> get() = labels.joinToString("\n") { row ->
row.dropLastWhile { lbl -> row.dropLastWhile { lbl ->

View File

@@ -23,9 +23,11 @@ class EditorView : View("Befide") {
} }
init { init {
codeView.src = """v ;00000000; primaryStage.isResizable = false
>>>>>>>>>>>>>55+0g68*-90g68*-2*+80g68*-4*+70g68*-8*+v
@.+***288-*86g03+**88-*86g04+**84-*86g05+**44-*86g06<""" // codeView.src = """v ;00000000;
//>>>>>>>>>>>>>55+0g68*-90g68*-2*+80g68*-4*+70g68*-8*+v
//@.+***288-*86g03+**88-*86g04+**84-*86g05+**44-*86g06<"""
// codeView.src = """ 2>:3g" "-!v\ g30 < // codeView.src = """ 2>:3g" "-!v\ g30 <
// |!`"O":+1_:.:03p>03g+:"O"`| // |!`"O":+1_:.:03p>03g+:"O"`|

View File

@@ -7,3 +7,7 @@ class MainApp : App(EditorView::class) {
importStylesheet(resources["style.css"]) importStylesheet(resources["style.css"])
} }
} }
fun main(args: Array<String>) {
launch<MainApp>(args)
}

View File

@@ -3,7 +3,12 @@ package befide.ide
import befide.befunge.b93.padEnd import befide.befunge.b93.padEnd
import befide.befunge.core.Interpreter import befide.befunge.core.Interpreter
import befide.befunge.state.Value import befide.befunge.state.Value
import javafx.beans.property.SimpleListProperty
import javafx.beans.property.SimpleObjectProperty
import javafx.beans.property.SimpleStringProperty import javafx.beans.property.SimpleStringProperty
import javafx.collections.FXCollections
import javafx.scene.layout.Priority
import javafx.scene.text.Font
import tornadofx.* import tornadofx.*
import tornadofx.getValue import tornadofx.getValue
import tornadofx.setValue import tornadofx.setValue
@@ -11,39 +16,27 @@ import tornadofx.setValue
class StackView(val interp: Interpreter) : View() { class StackView(val interp: Interpreter) : View() {
val charOutProperty = SimpleStringProperty() val charOutProperty = SimpleStringProperty()
var charOut by charOutProperty var charOut by charOutProperty
val longOutProperty = SimpleStringProperty()
var longOut by longOutProperty
override val root = textarea(charOutProperty) {
override val root = hbox { addClass("stack-pane")
textarea(charOutProperty) { prefWidth = 150.0
maxWidth = 1.0 isEditable = false
paddingHorizontal = 1
prefRowCount = interp.funge.height
isEditable = false
}
textarea(longOutProperty) {
prefRowCount = interp.funge.height
prefWidth = 90.0
isEditable = false
}
} }
private fun <T> getStackStr(mapping: (Value) -> T): String { private fun <T> getStackStr(mapping: (Value) -> T): String {
return interp.stack.takeLast(interp.funge.height) val num = interp.funge.height - 3
return interp.stack.takeLast(num)
.map(mapping) .map(mapping)
.padEnd(interp.funge.height, "") .padEnd(num, "")
// .reversed() // .reversed()
.joinToString("\n") .joinToString("\n")
} }
init { init {
charOut = getStackStr { it.asChar ?: '*' } charOut = getStackStr { "${it.asChar ?: '\u2022'} (${it.value})" }
longOut = getStackStr { it.value }
interp.stackChanged += { interp.stackChanged += { _ ->
charOut = getStackStr { it.asChar ?: '*' } charOut = getStackStr { "${it.asChar ?: '\u2022'} (${it.value})" }
longOut = getStackStr { it.value }
} }
} }
} }

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: befide.ide.MainApp

View File

@@ -3,7 +3,7 @@
-fx-font-fill: black; -fx-font-fill: black;
} }
.code, .text-area { .code, .text-area, .stack-pane {
-fx-font-family: Consolas, monospace; -fx-font-family: Consolas, monospace;
-fx-text-fill: black; -fx-text-fill: black;
-fx-font-size: 18; -fx-font-size: 18;
@@ -14,7 +14,6 @@
-fx-border-radius: 2px; -fx-border-radius: 2px;
-fx-border-width: 1px; -fx-border-width: 1px;
-fx-background-color: #fff; -fx-background-color: #fff;
-fx-graphic: none;
} }
.code-num { .code-num {