diff --git a/src/css/main.css b/src/css/main.css index 7330afb..8073d4a 100644 --- a/src/css/main.css +++ b/src/css/main.css @@ -73,6 +73,7 @@ a { color: var(--cyan); + display: inline-block; } a:visited { diff --git a/src/js/commands.ts b/src/js/commands.ts index daf5f32..fce3fdc 100644 --- a/src/js/commands.ts +++ b/src/js/commands.ts @@ -1,18 +1,21 @@ //// // temporary hack for browser commands -import { scrollback, content } from "./dom.js" -import { resize } from "./resize.js" -import { autoScroll } from "./scrollback.js" -import { sessionId } from "./session.js" -import { send } from "./websocket.js" +import type { CommandOutput } from "../shared/types" +import { scrollback, content } from "./dom" +import { resize } from "./resize" +import { autoScroll } from "./scrollback" +import { sessionId } from "./session" +import { send } from "./websocket" export const commands: string[] = [] -export const browserCommands: Record void> = { +export const browserCommands: Record void | Promise | CommandOutput> = { "browser-session": () => sessionId, clear: () => scrollback.innerHTML = "", - commands: () => commands.join(" "), + commands: () => { + return { html: "
" + commands.map(cmd => `${cmd}`).join("") + "
" } + }, fullscreen: () => document.body.requestFullscreen(), mode: (mode?: string) => { if (!mode) { @@ -33,4 +36,5 @@ export function cacheCommands(cmds: string[]) { commands.push(...cmds) commands.push(...Object.keys(browserCommands)) commands.sort() + console.log("CMDS", commands) } \ No newline at end of file diff --git a/src/js/completion.ts b/src/js/completion.ts index c859308..c6e295c 100644 --- a/src/js/completion.ts +++ b/src/js/completion.ts @@ -1,8 +1,8 @@ //// // tab completion -import { cmdInput } from "./dom.js" -import { commands } from "./commands.js" +import { cmdInput } from "./dom" +import { commands } from "./commands" export function initCompletion() { cmdInput.addEventListener("keydown", handleCompletion) diff --git a/src/js/cursor.ts b/src/js/cursor.ts index cc116d8..9ec4857 100644 --- a/src/js/cursor.ts +++ b/src/js/cursor.ts @@ -1,7 +1,7 @@ //// // Blinking c64 cursor -import { cmdInput, $ } from "./dom.js" +import { cmdInput, $ } from "./dom" const cursor = "Û" let cmdCursor: HTMLTextAreaElement diff --git a/src/js/drop.ts b/src/js/drop.ts index bd2c489..69b4bab 100644 --- a/src/js/drop.ts +++ b/src/js/drop.ts @@ -1,3 +1,7 @@ +//// +// Hack... works with the `upload` command. +// Dragging a file to the terminal fills in the on screen. + export function initDrop() { ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { document.body.addEventListener(eventName, preventDefaults, false); diff --git a/src/js/editor.ts b/src/js/editor.ts index 4ec7ede..7c71f9f 100644 --- a/src/js/editor.ts +++ b/src/js/editor.ts @@ -1,6 +1,6 @@ -import { scrollback } from "./dom.js" -import { send } from "./websocket.js" -import { focusInput } from "./focus.js" +import { scrollback } from "./dom" +import { send } from "./websocket" +import { focusInput } from "./focus" const INDENT_SIZE = 2 diff --git a/src/js/focus.ts b/src/js/focus.ts index 14ab2ef..be59fd3 100644 --- a/src/js/focus.ts +++ b/src/js/focus.ts @@ -1,7 +1,7 @@ //// // We try to keep the command textbox focused at all times. -import { cmdInput } from "./dom.js" +import { cmdInput } from "./dom" export function initFocus() { window.addEventListener("click", focusHandler) diff --git a/src/js/form.ts b/src/js/form.ts index 2a10d5a..a958404 100644 --- a/src/js/form.ts +++ b/src/js/form.ts @@ -1,10 +1,10 @@ //// // All forms are submitted via ajax. -import type { CommandResult, CommandOutput } from "../shared/types.js" -import { sessionId } from "./session.js" -import { setStatus, replaceOutput } from "./scrollback.js" -import { focusInput } from "./focus.js" +import type { CommandResult, CommandOutput } from "../shared/types" +import { sessionId } from "./session" +import { setStatus, replaceOutput } from "./scrollback" +import { focusInput } from "./focus" export function initForm() { document.addEventListener("submit", submitHandler) diff --git a/src/js/game.ts b/src/js/game.ts index f3dcc1e..066a7f2 100644 --- a/src/js/game.ts +++ b/src/js/game.ts @@ -1,10 +1,10 @@ -import type { Message } from "../shared/types.js" -import { GameContext, type InputState } from "../shared/game.js" -import { focusInput } from "./focus.js" -import { $$ } from "./dom.js" -import { randomId } from "../shared/utils.js" -import { setStatus, addOutput, insert } from "./scrollback.js" -import { browserCommands } from "./commands.js" +import type { Message } from "../shared/types" +import { GameContext, type InputState } from "../shared/game" +import { focusInput } from "./focus" +import { $$ } from "./dom" +import { randomId } from "../shared/utils" +import { setStatus, addOutput, insert } from "./scrollback" +import { browserCommands } from "./commands" const FPS = 30 const HEIGHT = 540 diff --git a/src/js/history.ts b/src/js/history.ts index 72adf6a..9d373c7 100644 --- a/src/js/history.ts +++ b/src/js/history.ts @@ -1,7 +1,7 @@ //// // Command input history storage and navigation. -import { cmdInput, cmdLine } from "./dom.js" +import { cmdInput, cmdLine } from "./dom" const history: string[] = ["one", "two", "three"] let idx = -1 diff --git a/src/js/hyperlink.ts b/src/js/hyperlink.ts index 818bebf..9208306 100644 --- a/src/js/hyperlink.ts +++ b/src/js/hyperlink.ts @@ -1,11 +1,11 @@ -import { runCommand } from "./shell.js" -import { focusInput } from "./focus.js" +import { runCommand } from "./shell" +import { focusInput } from "./focus" export function initHyperlink() { window.addEventListener("click", handleClick) } -function handleClick(e: MouseEvent) { +async function handleClick(e: MouseEvent) { const target = e.target if (!(target instanceof HTMLElement)) return @@ -18,7 +18,7 @@ function handleClick(e: MouseEvent) { if (href.startsWith("#")) { e.preventDefault() - runCommand(href.slice(1)) + await runCommand(href.slice(1)) focusInput() } } \ No newline at end of file diff --git a/src/js/input.ts b/src/js/input.ts index 524f88d..f151558 100644 --- a/src/js/input.ts +++ b/src/js/input.ts @@ -1,17 +1,16 @@ //// // Terminal input is handled by a