111 lines
2.7 KiB
Svelte
111 lines
2.7 KiB
Svelte
<script lang="ts">
|
|
import Input from '#lib/modules/Input.svelte';
|
|
import StatusBar from '#lib/modules/StatusBar.svelte';
|
|
import Terminal from '#lib/modules/Terminal.svelte';
|
|
import type { MWinAPI } from '#lib/mwinlib/mwin_util.ts';
|
|
import { mount, onMount, unmount } from 'svelte';
|
|
|
|
let api: MWinAPI | undefined = $state();
|
|
|
|
let value = $state('');
|
|
let input: Input | undefined = $state();
|
|
|
|
let date = $state(new Date());
|
|
|
|
let wrapper: HTMLElement;
|
|
let index: number = $state(-1);
|
|
const instances = new Map<number, ReturnType<typeof mount>>();
|
|
|
|
function add() {
|
|
index++;
|
|
const id = index;
|
|
|
|
const terminal = mount(Terminal, {
|
|
target: wrapper,
|
|
props: {
|
|
id,
|
|
wrapper,
|
|
username: 'gornodox',
|
|
hostname: 'termos',
|
|
working_dir: '~',
|
|
mwin: api,
|
|
close: remove
|
|
}
|
|
});
|
|
|
|
instances.set(id, terminal);
|
|
}
|
|
|
|
function remove(id: number): void {
|
|
const m = instances.get(id);
|
|
if (!m) return;
|
|
unmount(m);
|
|
instances.delete(id);
|
|
}
|
|
|
|
$effect(() => {
|
|
setInterval(() => {
|
|
date = new Date();
|
|
}, 1000);
|
|
});
|
|
|
|
onMount(() => {
|
|
window.addEventListener('keydown', (e) => {
|
|
if (e.altKey && e.key === 'n') {
|
|
add();
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<div class="h-dvh w-full p-4">
|
|
<div class=" bg-bg-full flex h-full flex-col rounded-md">
|
|
<div bind:this={wrapper} id="terminal-wrapper" class="relative flex flex-1"></div>
|
|
<div class="bg-bg-soft border-bg3 w-full rounded-b-md border-t text-xs">
|
|
<StatusBar
|
|
username="gornodox"
|
|
theme="gruvbox"
|
|
windowCount={0}
|
|
windowTitle="Hello, World!"
|
|
version="v0.0.1_alpha"
|
|
hash="a3d5b1c"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- <div class="h-dvh w-full p-4">
|
|
<div class="bg-bg-soft border-border text-glow size-full rounded-xl font-mono tracking-widest">
|
|
<div class=" border-border grid grid-cols-[1fr_auto_1fr] rounded-t-xl border-b px-2 py-1.5">
|
|
<div></div>
|
|
<div class="text-fg text-[10px] uppercase">
|
|
<span class="">gornodox@termos</span>
|
|
<span class=" normal-case"> — ~/Downloads</span>
|
|
</div>
|
|
<div></div>
|
|
</div>
|
|
<div
|
|
class=" bg-bg border-border fixed bottom-full grid grid-cols-[1fr_auto_1fr] rounded-b-xl border-b px-2 py-1.5"
|
|
>
|
|
<div></div>
|
|
<div class="text-fg text-[10px] uppercase">
|
|
<span class="">gornodox@termos</span>
|
|
<span class=" normal-case"> — ~/Downloads</span>
|
|
</div>
|
|
<div></div>
|
|
</div>
|
|
</div>
|
|
</div> -->
|
|
<!-- <div
|
|
onclick={() => input?.focusInput()}
|
|
onkeydown={() => input?.focusInput()}
|
|
role="textbox"
|
|
tabindex="-1"
|
|
class=" bg-bg-base scroll-hidden text-glow relative h-screen w-full overflow-y-auto p-4 text-sm"
|
|
>
|
|
<Input bind:value blinkDelay={500} bind:this={input} />
|
|
</div>
|
|
<div class="bg-bg fixed bottom-0 flex w-full flex-row px-3">
|
|
<p class="text-md">Uptime: 09:10:01</p>
|
|
</div> -->
|