- Termos library plugged in and partially working
This commit is contained in:
+2
-1
@@ -41,6 +41,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lucide/svelte": "^1.66.0",
|
"@lucide/svelte": "^1.66.0",
|
||||||
"@wterm/dom": "^0.5.9",
|
"@wterm/dom": "^0.5.9",
|
||||||
"@wterm/svelte": "^0.5.9"
|
"@wterm/svelte": "^0.5.9",
|
||||||
|
"termos": "file:/home/gornodox/Projects/termos/master/termos-0.1.1.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+836
-18
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -73,7 +73,6 @@
|
|||||||
|
|
||||||
function submit(): void {
|
function submit(): void {
|
||||||
onsubmit?.(value);
|
onsubmit?.(value);
|
||||||
value = '';
|
|
||||||
cursorPos = 0;
|
cursorPos = 0;
|
||||||
anchorPos = null;
|
anchorPos = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { type MWinAPI, type MWinParams } from '#lib/mwinlib/mwin_util.ts';
|
import { type MWinAPI, type MWinParams } from '#lib/mwinlib/mwin_util.ts';
|
||||||
|
import { resolvePointerToHome, type Shell } from 'termos';
|
||||||
import Input from './Input.svelte';
|
import Input from './Input.svelte';
|
||||||
import Movable from './Movable.svelte';
|
import Movable from './Movable.svelte';
|
||||||
|
|
||||||
@@ -10,6 +11,7 @@
|
|||||||
hostname = $bindable(),
|
hostname = $bindable(),
|
||||||
working_dir = $bindable(),
|
working_dir = $bindable(),
|
||||||
mwin = $bindable(),
|
mwin = $bindable(),
|
||||||
|
shell = $bindable(),
|
||||||
|
|
||||||
close
|
close
|
||||||
}: {
|
}: {
|
||||||
@@ -19,37 +21,53 @@
|
|||||||
hostname: string;
|
hostname: string;
|
||||||
working_dir: string;
|
working_dir: string;
|
||||||
mwin: MWinAPI | undefined;
|
mwin: MWinAPI | undefined;
|
||||||
|
shell: Shell | undefined;
|
||||||
close?: (id: number) => void;
|
close?: (id: number) => void;
|
||||||
} = $props();
|
} = $props();
|
||||||
|
|
||||||
//let isProcessActive = $state(false);
|
//let isProcessActive = $state(false);
|
||||||
|
const d = new TextDecoder('utf-8');
|
||||||
|
|
||||||
let inputValue = $state('');
|
let inputValue = $state('');
|
||||||
let inputComponent: any;
|
let inputComponent: any;
|
||||||
let outputWrapper: HTMLElement;
|
let outputWrapper: HTMLElement;
|
||||||
let count: [string, string][] = $state([]);
|
let scrollDiv: HTMLElement;
|
||||||
|
let stdout: string = '';
|
||||||
|
let count: [string, string, string][] = $state([]);
|
||||||
|
|
||||||
const mwinoptions: Partial<MWinParams> = {
|
const mwinoptions: Partial<MWinParams> = {
|
||||||
handle: '#terminal-bar',
|
handle: '#terminal-bar',
|
||||||
resizable: { threshold: 10, minWidth: 300, minHeight: 200 },
|
resizable: { threshold: 10, minWidth: 300, minHeight: 200 },
|
||||||
baseZIndex: 300,
|
baseZIndex: 300,
|
||||||
resizeHandle: '#terminal',
|
|
||||||
onAPI: (api: MWinAPI) => {
|
onAPI: (api: MWinAPI) => {
|
||||||
mwin = api;
|
mwin = api;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function onsubmit(value: string) {
|
async function onsubmit(value: string) {
|
||||||
if (value === 'clear') {
|
const input = value.trim();
|
||||||
count = [];
|
await shell!.execute(input);
|
||||||
return;
|
scrollDiv.scrollTop = scrollDiv.scrollHeight;
|
||||||
}
|
|
||||||
console.log(value);
|
|
||||||
count.push([value, working_dir]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
shell!.on('stdout', (payload) => {
|
||||||
|
const decoded = d.decode(payload.data);
|
||||||
|
stdout = stdout + decoded;
|
||||||
|
});
|
||||||
|
|
||||||
|
shell!.on('result', (payload) => {
|
||||||
|
if (payload.result.type === 'error') {
|
||||||
|
stdout = stdout + payload.result.error.message + '\n';
|
||||||
|
}
|
||||||
|
count.push([inputValue, resolvePointerToHome(shell!.State, shell!.Session.cwd), stdout]);
|
||||||
|
stdout = '';
|
||||||
|
inputValue = '';
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#snippet Out(value: string, path: string)}
|
{#snippet Out(value: string, path: string, stdout: string)}
|
||||||
<span
|
<span
|
||||||
><span class=" scroll-line text-tyellow">{username}</span><span>@</span><span class=" text-fg1"
|
><span class=" scroll-line text-tyellow">{username}</span><span>@</span><span class=" text-fg1"
|
||||||
>{hostname}</span
|
>{hostname}</span
|
||||||
@@ -57,6 +75,7 @@
|
|||||||
<span class="text-bg4">{path}</span><br /></span
|
<span class="text-bg4">{path}</span><br /></span
|
||||||
>
|
>
|
||||||
<span class=" scroll-line mr-[1ch]">$</span><span>{value}</span>
|
<span class=" scroll-line mr-[1ch]">$</span><span>{value}</span>
|
||||||
|
<div class=" whitespace-pre-wrap">{stdout}</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
||||||
<Movable
|
<Movable
|
||||||
@@ -86,7 +105,6 @@
|
|||||||
class="bg-term-minimize h-2.5 w-2.5 cursor-pointer rounded-2xl active:brightness-85"
|
class="bg-term-minimize h-2.5 w-2.5 cursor-pointer rounded-2xl active:brightness-85"
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Minimize terminal"
|
aria-label="Minimize terminal"
|
||||||
onclick={() => mwin?.minimize()}
|
|
||||||
></button>
|
></button>
|
||||||
</div>
|
</div>
|
||||||
<span class=" text-fg2 mx-auto text-sm font-medium">{username} — tsh</span>
|
<span class=" text-fg2 mx-auto text-sm font-medium">{username} — tsh</span>
|
||||||
@@ -94,6 +112,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="inner-content scroll-hidden text-fg4 font-ibm grow origin-top overflow-y-auto p-4 text-sm"
|
class="inner-content scroll-hidden text-fg4 font-ibm grow origin-top overflow-y-auto p-4 text-sm"
|
||||||
|
bind:this={scrollDiv}
|
||||||
id="cout"
|
id="cout"
|
||||||
onclick={() => inputComponent?.focusInput()}
|
onclick={() => inputComponent?.focusInput()}
|
||||||
onkeydown={() => inputComponent?.focusInput()}
|
onkeydown={() => inputComponent?.focusInput()}
|
||||||
@@ -102,7 +121,7 @@
|
|||||||
>
|
>
|
||||||
<div bind:this={outputWrapper} class="">
|
<div bind:this={outputWrapper} class="">
|
||||||
{#each count as c}
|
{#each count as c}
|
||||||
{@render Out(c[0], c[1])}
|
{@render Out(c[0], c[1], c[2])}
|
||||||
<div class="mb-3"></div>
|
<div class="mb-3"></div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
@@ -117,13 +136,3 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</Movable>
|
</Movable>
|
||||||
|
|
||||||
<style>
|
|
||||||
.inner-content {
|
|
||||||
scroll-snap-type: y mandatory;
|
|
||||||
scroll-behavior: auto;
|
|
||||||
}
|
|
||||||
.scroll-line {
|
|
||||||
scroll-snap-align: start;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
+66
-74
@@ -1,27 +1,40 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { rawJson } from '#lib/assets/fs.ts';
|
||||||
|
import Input from '#lib/modules/Input.svelte';
|
||||||
|
import StatusBar from '#lib/modules/StatusBar.svelte';
|
||||||
import Terminal from '#lib/modules/Terminal.svelte';
|
import Terminal from '#lib/modules/Terminal.svelte';
|
||||||
import TrayIcon from '#lib/modules/TrayIcon.svelte';
|
|
||||||
import type { MWinAPI } from '#lib/mwinlib/mwin_util.ts';
|
import type { MWinAPI } from '#lib/mwinlib/mwin_util.ts';
|
||||||
import { ChevronDown, Shell } from '@lucide/svelte';
|
import { mount, onMount, unmount } from 'svelte';
|
||||||
import { mount, unmount } from 'svelte';
|
import { resolvePointerToHome, Termos, type Shell } from 'termos';
|
||||||
|
|
||||||
function doSmth(e: MouseEvent): void {
|
const config = {
|
||||||
console.log(e);
|
groups: ['users'],
|
||||||
}
|
users: [
|
||||||
|
{
|
||||||
|
username: 'gornodox',
|
||||||
|
groups: ['users', 'sudoers'],
|
||||||
|
home: '/home/gornodox'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
general: {
|
||||||
|
user: 'gornodox'
|
||||||
|
},
|
||||||
|
filesystem: {
|
||||||
|
json: rawJson
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let shell: Shell | undefined = $state();
|
||||||
|
let api: MWinAPI | undefined = $state();
|
||||||
|
|
||||||
|
let value = $state('');
|
||||||
|
let input: Input | undefined = $state();
|
||||||
|
|
||||||
let date = $state(new Date());
|
let date = $state(new Date());
|
||||||
|
|
||||||
let settings = $state(false);
|
|
||||||
|
|
||||||
let wrapper: HTMLElement;
|
let wrapper: HTMLElement;
|
||||||
let terminalTray: TrayIcon | undefined = $state();
|
let index: number = $state(-1);
|
||||||
let api: MWinAPI | undefined = $state();
|
const instances = new Map<number, ReturnType<typeof mount>>();
|
||||||
|
|
||||||
let tray: HTMLElement | undefined = $state();
|
|
||||||
let index: number = $state(0);
|
|
||||||
const trayElements = new Map<number, ReturnType<typeof mount>>();
|
|
||||||
|
|
||||||
//const callbacks = [{ title: 'Open terminal', fn: doSmth }];
|
|
||||||
|
|
||||||
function add() {
|
function add() {
|
||||||
index++;
|
index++;
|
||||||
@@ -32,22 +45,23 @@
|
|||||||
props: {
|
props: {
|
||||||
id,
|
id,
|
||||||
wrapper,
|
wrapper,
|
||||||
username: 'gornodox',
|
username: shell!.Session.user.username,
|
||||||
hostname: 'termos',
|
hostname: 'termos',
|
||||||
working_dir: '~',
|
working_dir: resolvePointerToHome(shell!.State, shell!.Session.user.home),
|
||||||
mwin: api,
|
mwin: api,
|
||||||
|
shell,
|
||||||
close: remove
|
close: remove
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
trayElements.set(id, terminal);
|
instances.set(id, terminal);
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove(id: number): void {
|
function remove(id: number): void {
|
||||||
const m = trayElements.get(id);
|
const m = instances.get(id);
|
||||||
if (!m) return;
|
if (!m) return;
|
||||||
unmount(m);
|
unmount(m);
|
||||||
trayElements.delete(id);
|
instances.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
@@ -55,61 +69,39 @@
|
|||||||
date = new Date();
|
date = new Date();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
shell = await Termos.getShell(config);
|
||||||
|
|
||||||
|
window.addEventListener('keydown', (e) => {
|
||||||
|
if (e.ctrlKey && e.altKey && e.key === 't') {
|
||||||
|
add();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div class="h-dvh w-full p-4">
|
||||||
class=" fixed top-0 left-0 z-200 m-auto grid h-10 w-full grid-cols-[1fr_auto_1fr] items-center"
|
<div class=" bg-bg-full flex h-full flex-col rounded-md">
|
||||||
>
|
<div class="absolute top-12 left-1/2 -translate-x-1/2">
|
||||||
<div class="flex flex-row items-center gap-2 pl-3">
|
<span class="text-fg1 inline-flex items-baseline gap-2 font-mono text-sm tracking-[0.02em]">
|
||||||
<button>
|
<span class="text-fg3">Ctrl</span>
|
||||||
<Shell size={18} />
|
<span class="text-bg4 select-none" aria-hidden="true">+</span>
|
||||||
</button>
|
<span class="text-fg3">Alt</span>
|
||||||
<div bind:this={tray}></div>
|
<span class="text-bg4 select-none" aria-hidden="true">+</span>
|
||||||
</div>
|
<span class="text-tyellow font-semibold">T</span>
|
||||||
<div class=" flex flex-row items-center justify-center px-5">
|
</span>
|
||||||
<button>
|
</div>
|
||||||
<h2 class="font-primary text-lg">
|
<div bind:this={wrapper} id="terminal-wrapper" class="relative flex flex-1"></div>
|
||||||
{date.getHours().toString().length > 1 ? date.getHours() : `0${date.getHours()}`}:{date
|
<div class="bg-bg-soft border-bg3 w-full rounded-b-md border-t text-xs">
|
||||||
.getMinutes()
|
<StatusBar
|
||||||
.toString().length > 1
|
username="gornodox"
|
||||||
? date.getMinutes()
|
theme="gruvbox"
|
||||||
: `0${date.getMinutes()}`}:{date.getSeconds().toString().length > 1
|
windowCount={instances.size}
|
||||||
? date.getSeconds()
|
windowTitle="Termos"
|
||||||
: `0${date.getSeconds()}`}
|
version="v0.1.1_alpha"
|
||||||
</h2>
|
hash="a3d5b1c"
|
||||||
</button>
|
/>
|
||||||
<!-- <div class="-translate-y- fixed top-0 bg-green-700">Calendar, Maybe...</div> -->
|
|
||||||
</div>
|
|
||||||
<div class="fixed right-0 m-auto pr-1">
|
|
||||||
<div
|
|
||||||
class="bg-surface-2 flex flex-row-reverse items-center justify-center gap-3 rounded-full p-2"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
onclick={() => (settings = !settings)}
|
|
||||||
class="{settings ? 'rotate-180' : 'rotate-0'} transition-transform"
|
|
||||||
>
|
|
||||||
<ChevronDown size={18} />
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
|
||||||
class="absolute top-10 right-0 h-30 w-40 rounded-xl bg-green-700 transition-transform {settings
|
|
||||||
? 'mr-4 translate-x-0'
|
|
||||||
: 'mr-0 translate-x-full'}"
|
|
||||||
></div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
id="terminal-wrapper"
|
|
||||||
bind:this={wrapper}
|
|
||||||
class=" relative flex h-screen w-full flex-col items-center justify-center overflow-x-hidden"
|
|
||||||
>
|
|
||||||
<Terminal
|
|
||||||
id={10}
|
|
||||||
wrapper="#terminal-wrapper"
|
|
||||||
username="gornodox"
|
|
||||||
hostname="termos"
|
|
||||||
working_dir="~/Documents/Projects/gornodox.dev"
|
|
||||||
mwin={api}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -1,10 +1,30 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { rawJson } from '#lib/assets/fs.ts';
|
||||||
import Input from '#lib/modules/Input.svelte';
|
import Input from '#lib/modules/Input.svelte';
|
||||||
import StatusBar from '#lib/modules/StatusBar.svelte';
|
import StatusBar from '#lib/modules/StatusBar.svelte';
|
||||||
import Terminal from '#lib/modules/Terminal.svelte';
|
import Terminal from '#lib/modules/Terminal.svelte';
|
||||||
import type { MWinAPI } from '#lib/mwinlib/mwin_util.ts';
|
import type { MWinAPI } from '#lib/mwinlib/mwin_util.ts';
|
||||||
import { mount, onMount, unmount } from 'svelte';
|
import { mount, onMount, unmount } from 'svelte';
|
||||||
|
import { resolvePointerToHome, Termos, type Shell } from 'termos';
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
groups: ['users'],
|
||||||
|
users: [
|
||||||
|
{
|
||||||
|
username: 'gornodox',
|
||||||
|
groups: ['users', 'sudoers'],
|
||||||
|
home: '/home/gornodox'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
general: {
|
||||||
|
user: 'gornodox'
|
||||||
|
},
|
||||||
|
filesystem: {
|
||||||
|
json: rawJson
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let shell: Shell | undefined = $state();
|
||||||
let api: MWinAPI | undefined = $state();
|
let api: MWinAPI | undefined = $state();
|
||||||
|
|
||||||
let value = $state('');
|
let value = $state('');
|
||||||
@@ -25,10 +45,11 @@
|
|||||||
props: {
|
props: {
|
||||||
id,
|
id,
|
||||||
wrapper,
|
wrapper,
|
||||||
username: 'gornodox',
|
username: shell!.Session.user.username,
|
||||||
hostname: 'termos',
|
hostname: 'termos',
|
||||||
working_dir: '~/Documents/Projects/gornodox.dev',
|
working_dir: resolvePointerToHome(shell!.State, shell!.Session.user.home),
|
||||||
mwin: api,
|
mwin: api,
|
||||||
|
shell,
|
||||||
close: remove
|
close: remove
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -49,9 +70,11 @@
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
onMount(() => {
|
onMount(async () => {
|
||||||
|
shell = await Termos.getShell(config);
|
||||||
|
|
||||||
window.addEventListener('keydown', (e) => {
|
window.addEventListener('keydown', (e) => {
|
||||||
if (e.altKey && e.key === 'n') {
|
if (e.ctrlKey && e.altKey && e.key === 't') {
|
||||||
add();
|
add();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -60,14 +83,23 @@
|
|||||||
|
|
||||||
<div class="h-dvh w-full p-4">
|
<div class="h-dvh w-full p-4">
|
||||||
<div class=" bg-bg-full flex h-full flex-col rounded-md">
|
<div class=" bg-bg-full flex h-full flex-col rounded-md">
|
||||||
|
<div class="absolute top-12 left-1/2 -translate-x-1/2">
|
||||||
|
<span class="text-fg1 inline-flex items-baseline gap-2 font-mono text-sm tracking-[0.02em]">
|
||||||
|
<span class="text-fg3">Ctrl</span>
|
||||||
|
<span class="text-bg4 select-none" aria-hidden="true">+</span>
|
||||||
|
<span class="text-fg3">Alt</span>
|
||||||
|
<span class="text-bg4 select-none" aria-hidden="true">+</span>
|
||||||
|
<span class="text-tyellow font-semibold">T</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div bind:this={wrapper} id="terminal-wrapper" class="relative flex flex-1"></div>
|
<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">
|
<div class="bg-bg-soft border-bg3 w-full rounded-b-md border-t text-xs">
|
||||||
<StatusBar
|
<StatusBar
|
||||||
username="gornodox"
|
username="gornodox"
|
||||||
theme="gruvbox"
|
theme="gruvbox"
|
||||||
windowCount={0}
|
windowCount={instances.size}
|
||||||
windowTitle="Hello, World!"
|
windowTitle="Termos"
|
||||||
version="v0.0.1_alpha"
|
version="v0.1.1_alpha"
|
||||||
hash="a3d5b1c"
|
hash="a3d5b1c"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user