wip
This commit is contained in:
parent
a4b08dd811
commit
03caf64231
|
|
@ -1,8 +1,9 @@
|
|||
////
|
||||
// this file controls the command textbox
|
||||
// input is handled by a <textarea> and friends
|
||||
//
|
||||
|
||||
import { cmdTextbox, cmdLine } from "./dom.js"
|
||||
import { runCommand } from "./shell.js"
|
||||
|
||||
export function initInput() {
|
||||
cmdTextbox.addEventListener("keydown", inputHandler)
|
||||
|
|
@ -12,17 +13,17 @@ function inputHandler(event: KeyboardEvent) {
|
|||
const target = event.target as HTMLElement
|
||||
if (target?.id !== cmdTextbox.id) return
|
||||
|
||||
console.log(event.key)
|
||||
if (event.key === "Tab") {
|
||||
event.preventDefault()
|
||||
} else if (event.shiftKey && event.key === "Enter") {
|
||||
cmdTextbox.rows += 1
|
||||
cmdLine.dataset.extended = "true"
|
||||
console.log(cmdTextbox.value)
|
||||
} else if (event.key === "Enter") {
|
||||
cmdTextbox.value = ""
|
||||
cmdTextbox.rows = 1
|
||||
cmdLine.dataset.extended = "false"
|
||||
event.preventDefault()
|
||||
|
||||
runCommand(cmdTextbox.value)
|
||||
}
|
||||
}
|
||||
7
src/js/shell.ts
Normal file
7
src/js/shell.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
////
|
||||
// the shell runs on the server and processes input, returning output
|
||||
//
|
||||
|
||||
export function runCommand(input: string) {
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user