summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <romangraef@loves.dicksinhisan.us>2021-12-07 20:55:45 +0100
committernea <romangraef@loves.dicksinhisan.us>2021-12-07 20:55:45 +0100
commit0b0670a115fc509d4ea84f0694287103adc8913b (patch)
treec4f5f8b6ec72468d598c19f914dd5782f4aaecc4
parent5843b02bad28bc82567c195ca0bb31515e3dbb36 (diff)
downloadneamoe-0b0670a115fc509d4ea84f0694287103adc8913b.tar.gz
neamoe-0b0670a115fc509d4ea84f0694287103adc8913b.tar.bz2
neamoe-0b0670a115fc509d4ea84f0694287103adc8913b.zip
noopen and comic sans
-rw-r--r--build.gradle.kts2
-rw-r--r--src/main/kotlin/moe/nea89/website/KConsole.kt15
-rw-r--r--src/main/kotlin/moe/nea89/website/Styles.kt6
-rw-r--r--webpack.config.d/noopenbrowser.js1
4 files changed, 17 insertions, 7 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index a88b52f..b7e026a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -23,6 +23,8 @@ kotlin {
val processResources by tasks.getting(Copy::class)
dependencies {
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0-RC")
+
implementation(enforcedPlatform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:0.0.1-pre.256-kotlin-1.5.31"))
implementation("org.jetbrains.kotlin-wrappers:kotlin-styled")
implementation(npm("@fontsource/comic-mono", "^4.5.0"))
diff --git a/src/main/kotlin/moe/nea89/website/KConsole.kt b/src/main/kotlin/moe/nea89/website/KConsole.kt
index d6e4349..b0ae06f 100644
--- a/src/main/kotlin/moe/nea89/website/KConsole.kt
+++ b/src/main/kotlin/moe/nea89/website/KConsole.kt
@@ -3,9 +3,9 @@ package moe.nea89.website
import kotlinx.browser.document
import kotlinx.html.dom.append
import kotlinx.html.js.pre
-import org.w3c.dom.HTMLElement
-import org.w3c.dom.HTMLPreElement
+import org.w3c.dom.*
import org.w3c.dom.events.KeyboardEvent
+import kotlin.collections.set
class KConsole(private val root: HTMLElement, private val text: HTMLPreElement) {
@@ -41,6 +41,10 @@ class KConsole(private val root: HTMLElement, private val text: HTMLPreElement)
scrollDown()
}
+ fun scrollDown() {
+ text.lastElementChild?.scrollIntoView()
+ }
+
fun rerender() {
val view = lines.joinToString(separator = "\n") + "\n${'$'} $input"
text.innerText = view
@@ -55,10 +59,8 @@ class KConsole(private val root: HTMLElement, private val text: HTMLPreElement)
val commands = mutableMapOf<String, Command>()
- fun scrollDown() {} // TODO scroooooll
-
- fun executeCommand(command: String) {
- val parts = shlex(command)
+ fun executeCommand(commandLine: String) {
+ val parts = shlex(commandLine)
if (parts.isNullOrEmpty()) {
addLine("Syntax Error")
return
@@ -108,5 +110,6 @@ class KConsole(private val root: HTMLElement, private val text: HTMLPreElement)
input += event.key
}
rerender()
+ scrollDown()
}
}
diff --git a/src/main/kotlin/moe/nea89/website/Styles.kt b/src/main/kotlin/moe/nea89/website/Styles.kt
index 6d10e7e..1705192 100644
--- a/src/main/kotlin/moe/nea89/website/Styles.kt
+++ b/src/main/kotlin/moe/nea89/website/Styles.kt
@@ -12,7 +12,8 @@ object Styles : StyleSheet("Styles") {
val comicMono = "\"Comic Mono\", monospace"
val global by css {
- root {
+ "*" {
+ padding(0.px)
margin(0.px)
boxSizing = BoxSizing.borderBox
}
@@ -26,6 +27,9 @@ object Styles : StyleSheet("Styles") {
".$consoleClass" {
width = 100.pct
height = 100.pct
+ pre {
+ fontFamily = comicMono
+ }
}
}
} \ No newline at end of file
diff --git a/webpack.config.d/noopenbrowser.js b/webpack.config.d/noopenbrowser.js
new file mode 100644
index 0000000..27eb2d8
--- /dev/null
+++ b/webpack.config.d/noopenbrowser.js
@@ -0,0 +1 @@
+(config.devServer = config.devServer || {}).open = false \ No newline at end of file