summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/moe/nea89/website/KConsole.kt4
-rw-r--r--src/main/kotlin/moe/nea89/website/ShellExecutionContext.kt1
-rw-r--r--src/main/kotlin/moe/nea89/website/index.kt3
3 files changed, 6 insertions, 2 deletions
diff --git a/src/main/kotlin/moe/nea89/website/KConsole.kt b/src/main/kotlin/moe/nea89/website/KConsole.kt
index 29e2264..6c4f707 100644
--- a/src/main/kotlin/moe/nea89/website/KConsole.kt
+++ b/src/main/kotlin/moe/nea89/website/KConsole.kt
@@ -52,7 +52,6 @@ class KConsole(
fun addLine(line: String) {
lines.add(line)
- scrollDown()
}
fun scrollDown() {
@@ -61,8 +60,9 @@ class KConsole(
fun rerender() {
var view = lines.joinToString(separator = "\n")
- if (state == ConsoleState.SHELLPROMPT)
+ if (state == ConsoleState.SHELLPROMPT) {
view += "\n${'$'} $input"
+ }
text.innerText = view
}
diff --git a/src/main/kotlin/moe/nea89/website/ShellExecutionContext.kt b/src/main/kotlin/moe/nea89/website/ShellExecutionContext.kt
index 9040f95..cec0b9e 100644
--- a/src/main/kotlin/moe/nea89/website/ShellExecutionContext.kt
+++ b/src/main/kotlin/moe/nea89/website/ShellExecutionContext.kt
@@ -33,6 +33,7 @@ class ShellExecutionContext(
fun run(
console: KConsole, command: Command, name: String, args: List<String>
) {
+ console.state = KConsole.ConsoleState.IN_PROGRAM
val se = ShellExecutionContext(console, name, args)
command.runner.createCoroutine(se, object : Continuation<Unit> {
override val context: CoroutineContext
diff --git a/src/main/kotlin/moe/nea89/website/index.kt b/src/main/kotlin/moe/nea89/website/index.kt
index a2577ad..4a69a14 100644
--- a/src/main/kotlin/moe/nea89/website/index.kt
+++ b/src/main/kotlin/moe/nea89/website/index.kt
@@ -5,6 +5,7 @@ import kotlinx.browser.document
import kotlinx.html.dom.append
import kotlinx.html.js.div
import styled.injectGlobal
+import kotlin.time.Duration.Companion.milliseconds
val defaultFileSystem = fileSystem {
"etc" {
@@ -60,9 +61,11 @@ fun main() {
is KFile.Directory -> {
val longestName = file.files.keys.maxOf { it.length }
file.files.forEach { (name, file) ->
+ wait(200.milliseconds)
console.addLine(
name + " ".repeat(longestName + 1 - name.length) + file.fileType
)
+ console.rerender()
}
}
else -> "is a ${file.fileType}"