summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/kotlin/moe/nea89/website/KConsole.kt7
-rw-r--r--src/main/kotlin/moe/nea89/website/index.kt3
2 files changed, 7 insertions, 3 deletions
diff --git a/src/main/kotlin/moe/nea89/website/KConsole.kt b/src/main/kotlin/moe/nea89/website/KConsole.kt
index 89617b8..dd37223 100644
--- a/src/main/kotlin/moe/nea89/website/KConsole.kt
+++ b/src/main/kotlin/moe/nea89/website/KConsole.kt
@@ -13,6 +13,7 @@ import org.w3c.dom.HTMLPreElement
import org.w3c.dom.events.KeyboardEvent
import kotlin.collections.set
+
class KConsole(
private val root: HTMLElement,
private val text: HTMLPreElement,
@@ -21,7 +22,7 @@ class KConsole(
) {
val fileAccessor = fileSystem?.let { FileAccessor(it) }
-
+ var PS1 = "$"
companion object {
val shlexRegex =
""""([^"\\]+|\\.)+"|([^ "'\\]+|\\.)+|'([^'\\]+|\\.)+'""".toRegex()
@@ -78,7 +79,7 @@ class KConsole(
fun rerender() {
if (state == KConsole.ConsoleState.SHELLPROMPT) {
- prompt.innerText = "${'$'} $input"
+ prompt.innerText = "$PS1 $input"
} else {
prompt.innerText = ""
}
@@ -143,7 +144,7 @@ class KConsole(
when (event.key) {
"Enter" -> {
val toExecute = input
- addLine("${'$'} $toExecute")
+ addLine("$PS1 $toExecute")
input = ""
executeCommand(toExecute)
}
diff --git a/src/main/kotlin/moe/nea89/website/index.kt b/src/main/kotlin/moe/nea89/website/index.kt
index edc1add..e52d942 100644
--- a/src/main/kotlin/moe/nea89/website/index.kt
+++ b/src/main/kotlin/moe/nea89/website/index.kt
@@ -28,10 +28,13 @@ val defaultFileSystem = fileSystem {
}
fun main() {
+
require("@fontsource/comic-mono/index.css")
injectGlobal(Styles.global)
val root = document.body!!.append.div()
val console = KConsole.createFor(root, fileSystem = defaultFileSystem)
+ console.PS1 = ">"
+ console.rerender()
console.registerCommand(command("cwd", "pwd") {
val fa = requireFileAccessor()
console.addLine(fa.currentDir.joinToString(separator = "/", prefix = "/"))