diff options
author | nea <romangraef@loves.dicksinhisan.us> | 2021-12-07 20:55:45 +0100 |
---|---|---|
committer | nea <romangraef@loves.dicksinhisan.us> | 2021-12-07 20:55:45 +0100 |
commit | 0b0670a115fc509d4ea84f0694287103adc8913b (patch) | |
tree | c4f5f8b6ec72468d598c19f914dd5782f4aaecc4 /src/main/kotlin/moe/nea89 | |
parent | 5843b02bad28bc82567c195ca0bb31515e3dbb36 (diff) | |
download | neamoe-0b0670a115fc509d4ea84f0694287103adc8913b.tar.gz neamoe-0b0670a115fc509d4ea84f0694287103adc8913b.tar.bz2 neamoe-0b0670a115fc509d4ea84f0694287103adc8913b.zip |
noopen and comic sans
Diffstat (limited to 'src/main/kotlin/moe/nea89')
-rw-r--r-- | src/main/kotlin/moe/nea89/website/KConsole.kt | 15 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea89/website/Styles.kt | 6 |
2 files changed, 14 insertions, 7 deletions
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 |