MovableAPI Fully Implemented!! :)
This commit is contained in:
+33
-63
@@ -1,12 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { movable } from '$lib/movable/movable_controller.svelte';
|
||||
import type { MovableAPI } from '$lib/movable/util';
|
||||
import Input from './terminal/Input.svelte';
|
||||
|
||||
let { username }: { username: string } = $props();
|
||||
|
||||
//const clearTerminal = (): void => clear();
|
||||
|
||||
//const printOutput = (e: HTMLElement, d: PrintData): void => print(e, d);
|
||||
|
||||
export async function init(username: string, password: string) {
|
||||
try {
|
||||
//await initTerminal({ username, password }, callbackInit, 'en_US');
|
||||
@@ -48,74 +46,46 @@
|
||||
return ctx.measureText('M').width;
|
||||
}
|
||||
|
||||
/* function inputHandler(event: KeyboardEvent) {
|
||||
const terminalKeyInhibitor = terminal.getKeybindInhibitor();
|
||||
terminalKeyInhibitor.processKeystroke(event);
|
||||
|
||||
const processKeyInhibitor = terminal.getProcessKeyInhibitor();
|
||||
if (processKeyInhibitor != ExitCode.ERROR) {
|
||||
processKeyInhibitor.processKeystroke(event);
|
||||
}
|
||||
|
||||
console.log(processKeyInhibitor, terminalKeyInhibitor);
|
||||
switch (event.key) {
|
||||
case 'Enter': {
|
||||
terminal.executeCommand(inputValue);
|
||||
updateTerminal();
|
||||
break;
|
||||
}
|
||||
case 'ArrowRight': {
|
||||
//TODO: Move cursor visually
|
||||
}
|
||||
case 'ArrowLeft': {
|
||||
//TODO: Move cursor visually
|
||||
}
|
||||
case 'ArrowUp': {
|
||||
//TODO: Make a traverse history function with up/down args
|
||||
}
|
||||
case 'ArrowDown': {
|
||||
//TODO: Make a traverse history function with up/down args
|
||||
}
|
||||
}
|
||||
|
||||
const elem = document.getElementById('cout');
|
||||
if (!elem) {
|
||||
throw new Error('cant scroll to bottom, element is null');
|
||||
}
|
||||
|
||||
elem.scrollTop = elem.scrollHeight;
|
||||
} */
|
||||
|
||||
/* //Callback initializer
|
||||
const callbackInit = {
|
||||
print: (data: any) => {
|
||||
const e = document.getElementById('outputWrapper');
|
||||
if (!e) return;
|
||||
printOutput(e, data);
|
||||
},
|
||||
clear: clearTerminal,
|
||||
getWidth: getWidth,
|
||||
getFontSize: getFontSize
|
||||
}; */
|
||||
let cwd: string = $state('');
|
||||
const hostname = 'terminal'; //TODO: Change this to pull from config on db
|
||||
//let isProcessActive = $state(false);
|
||||
|
||||
let movableAPI: MovableAPI;
|
||||
let inputValue = $state('');
|
||||
</script>
|
||||
|
||||
<label for="input" class="w-11/12">
|
||||
<div
|
||||
class="terminal-wrapper relative flex h-screen w-1/2 flex-col items-center justify-center bg-red-400"
|
||||
>
|
||||
<div
|
||||
id="terminal"
|
||||
class=" terminal-window flex size-full flex-col rounded-md shadow-subtle transition-discrete"
|
||||
class="absolute flex size-full h-256 w-512 flex-col rounded-md shadow-subtle transition-discrete will-change-auto"
|
||||
use:movable={{
|
||||
wrapper: '.terminal-wrapper',
|
||||
handle: '.terminal-bar',
|
||||
baseZIndex: 10,
|
||||
resizable: { threshold: 24, minWidth: 500, minHeight: 300 },
|
||||
onAPI: (api) => (movableAPI = api)
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="terminal-bar flex h-9 w-full flex-row items-center rounded-t-md bg-surface-2 text-center font-terminal text-sm font-bold text-primary"
|
||||
class="terminal-bar flex h-9 w-full flex-row items-center rounded-t-md bg-surface-2 text-center font-terminal text-sm font-bold text-primary select-none"
|
||||
>
|
||||
<div class="dots-wrapper mx-2.5 flex h-full flex-row items-center justify-center gap-2.5">
|
||||
<button class="size-2.5 cursor-pointer rounded-full p-0" title=""></button>
|
||||
<button class="size-2.5 cursor-pointer rounded-full p-0" title=""></button>
|
||||
<button class="size-2.5 cursor-pointer rounded-full p-0" title=""></button>
|
||||
<div class="dots-wrapper mx-3 flex h-full flex-row items-center justify-center gap-3">
|
||||
<button
|
||||
class="size-3 cursor-pointer rounded-full p-0"
|
||||
title=""
|
||||
onclick={() => movableAPI.close()}
|
||||
></button>
|
||||
<button
|
||||
class="size-3 cursor-pointer rounded-full p-0"
|
||||
title=""
|
||||
onclick={() => movableAPI.maximize()}
|
||||
></button>
|
||||
<button
|
||||
class="size-3 cursor-pointer rounded-full p-0"
|
||||
title=""
|
||||
onclick={() => movableAPI.minimize()}
|
||||
></button>
|
||||
</div>
|
||||
<div class=" mr-2 flex grow text-sm">
|
||||
<p>{username}@{hostname} {cwd}</p>
|
||||
@@ -126,10 +96,10 @@
|
||||
id="cout"
|
||||
>
|
||||
<div id="outputWrapper"></div>
|
||||
<Input autofocus bind:value={inputValue} blinkDelay={500} />
|
||||
<Input bind:value={inputValue} blinkDelay={500} />
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
* {
|
||||
|
||||
Reference in New Issue
Block a user