HUUUGE dump of code, toast system in a svelte module, new reworked tailwing color palette, WIP cms, WIP API and probably much more that i forgot about.
This commit is contained in:
Executable → Regular
+17
-29
@@ -1,23 +1,19 @@
|
||||
<script lang="ts">
|
||||
import { ExitCode } from '$lib/stores/bash/metadata';
|
||||
import { initTerminal } from '$lib/stores/terminal/init.svelte';
|
||||
import { clear, print } from '$lib/stores/terminal/stdio/io';
|
||||
import { Terminal, type PrintData } from '$lib/stores/terminal/terminal';
|
||||
import Input from './terminal/Input.svelte';
|
||||
|
||||
const clearTerminal = (): void => clear();
|
||||
//const clearTerminal = (): void => clear();
|
||||
|
||||
const printOutput = (e: HTMLElement, d: PrintData): void => print(e, d);
|
||||
//const printOutput = (e: HTMLElement, d: PrintData): void => print(e, d);
|
||||
|
||||
export async function init(username: string, password: string) {
|
||||
try {
|
||||
terminal = await initTerminal({ username, password }, callbackInit, 'en_US');
|
||||
updateTerminal();
|
||||
//await initTerminal({ username, password }, callbackInit, 'en_US');
|
||||
updateTerminal(); //Rename this
|
||||
} catch (error) {
|
||||
console.error('terminal init failed', error);
|
||||
console.error('Failed to intialize the terminal', error);
|
||||
}
|
||||
|
||||
runTerminal();
|
||||
document.getElementById('terminal-window')?.classList.remove('hidden');
|
||||
}
|
||||
|
||||
function updateTerminal() {
|
||||
@@ -50,7 +46,7 @@
|
||||
return ctx.measureText('M').width;
|
||||
}
|
||||
|
||||
function inputHandler(event: KeyboardEvent) {
|
||||
/* function inputHandler(event: KeyboardEvent) {
|
||||
const terminalKeyInhibitor = terminal.getKeybindInhibitor();
|
||||
terminalKeyInhibitor.processKeystroke(event);
|
||||
|
||||
@@ -86,13 +82,9 @@
|
||||
}
|
||||
|
||||
elem.scrollTop = elem.scrollHeight;
|
||||
}
|
||||
} */
|
||||
|
||||
function runTerminal() {
|
||||
document.getElementById('terminal-window')?.classList.remove('hidden');
|
||||
}
|
||||
|
||||
//Callback initializer
|
||||
/* //Callback initializer
|
||||
const callbackInit = {
|
||||
print: (data: any) => {
|
||||
const e = document.getElementById('outputWrapper');
|
||||
@@ -102,39 +94,35 @@
|
||||
clear: clearTerminal,
|
||||
getWidth: getWidth,
|
||||
getFontSize: getFontSize
|
||||
};
|
||||
}; */
|
||||
|
||||
//Empty terminal variable where the terminal class instance will be stored
|
||||
let terminal: Terminal;
|
||||
let username: string = $state('');
|
||||
let cwd: string = $state('');
|
||||
const hostname = 'terminal'; //TODO: Change this to pull from config on db
|
||||
//let isProcessActive = $state(false);
|
||||
|
||||
let inputValue = $state<string>('');
|
||||
</script>
|
||||
|
||||
<label for="input" onkeydowncapture={(event) => inputHandler(event)} class="w-11/12">
|
||||
<label for="input" class="w-11/12">
|
||||
<div
|
||||
id="terminal"
|
||||
class=" terminal-window shadow-() h-full w-full rounded-md shadow-bg transition-discrete"
|
||||
class=" terminal-window flex size-full flex-col rounded-md shadow-subtle transition-discrete"
|
||||
>
|
||||
<div
|
||||
class="terminal-bar flex h-9 w-full flex-row items-center rounded-t-md bg-bg-dark text-center font-terminal text-sm font-bold text-primary-dark light:bg-bg-dark-light light:text-primary-light"
|
||||
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"
|
||||
>
|
||||
<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>
|
||||
<div class=" mr-2 flex grow">
|
||||
<h5>{username}</h5>
|
||||
<!-- prettier-ignore -->
|
||||
<h5 class=" mr-2">@terminal: </h5>
|
||||
<h5>{cwd}</h5>
|
||||
<div class=" mr-2 flex grow text-sm">
|
||||
<p>{username}@{hostname} {cwd}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="inner-content scroll-hidden h-7/8 origin-top overflow-y-auto rounded-b-md bg-bg-light-dark p-4 text-text-dark shadow-subtle light:bg-bg-lighter-light light:text-text-light"
|
||||
class="inner-content scroll-hidden grow origin-top overflow-y-auto rounded-b-md bg-surface-1 p-4 text-sm text-text-primary"
|
||||
id="cout"
|
||||
>
|
||||
<div id="outputWrapper"></div>
|
||||
|
||||
Reference in New Issue
Block a user