From 0b72acee1574d2a337e0e48d4f2c655d7b77aaf0 Mon Sep 17 00:00:00 2001 From: echo <91651232+exhq@users.noreply.github.com> Date: Sun, 4 Sep 2022 20:07:11 +0430 Subject: added paste support --- src/jsMain/kotlin/moe/nea89/website/KConsole.kt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/jsMain/kotlin/moe/nea89/website/KConsole.kt b/src/jsMain/kotlin/moe/nea89/website/KConsole.kt index 3c5fad1..7cf7d6c 100644 --- a/src/jsMain/kotlin/moe/nea89/website/KConsole.kt +++ b/src/jsMain/kotlin/moe/nea89/website/KConsole.kt @@ -1,5 +1,6 @@ package moe.nea89.website +import kotlinx.browser.window import kotlinx.browser.document import kotlinx.dom.addClass import kotlinx.html.InputType @@ -178,7 +179,10 @@ class KConsole( } fun keydown(event: KeyboardEvent) { - if (event.altKey || event.ctrlKey || event.metaKey) return + if (event.altKey || event.metaKey) return + if (event.ctrlKey) { + handleControlDown(event); return + } if (event.isComposing) return if (state != ConsoleState.SHELLPROMPT) return if (justHandledInput) { @@ -209,3 +213,15 @@ class KConsole( scrollDown() } } +fun handleControlDown(event: KeyboardEvent){ + if (event.key == "v"){ + window.navigator.clipboard.readText().then{ + input += it + event.preventDefault() + rerender() + scrollDown() + } + + } + } +} -- cgit From 9e0bce2dc11ea0d43bf0a0451babf0e1c73f670c Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Sun, 4 Sep 2022 17:42:43 +0200 Subject: Update KConsole.kt --- src/jsMain/kotlin/moe/nea89/website/KConsole.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/jsMain/kotlin/moe/nea89/website/KConsole.kt b/src/jsMain/kotlin/moe/nea89/website/KConsole.kt index 7cf7d6c..a7b1102 100644 --- a/src/jsMain/kotlin/moe/nea89/website/KConsole.kt +++ b/src/jsMain/kotlin/moe/nea89/website/KConsole.kt @@ -181,7 +181,8 @@ class KConsole( fun keydown(event: KeyboardEvent) { if (event.altKey || event.metaKey) return if (event.ctrlKey) { - handleControlDown(event); return + handleControlDown(event) + return } if (event.isComposing) return if (state != ConsoleState.SHELLPROMPT) return @@ -212,16 +213,16 @@ class KConsole( rerender() scrollDown() } -} -fun handleControlDown(event: KeyboardEvent){ + + + fun handleControlDown(event: KeyboardEvent){ if (event.key == "v"){ - window.navigator.clipboard.readText().then{ + event.preventDefault() + window.navigator.clipboard.readText().then { input += it - event.preventDefault() rerender() scrollDown() } - } } } -- cgit