status bar
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
<script lang="ts">
|
||||
import { petals } from '#lib/stores/petals.ts';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let {
|
||||
value = $bindable(''),
|
||||
blinkDelay = 250,
|
||||
autofocus = true,
|
||||
oninput = () => {}
|
||||
oninput = () => {},
|
||||
onsubmit = () => {}
|
||||
}: {
|
||||
value?: string;
|
||||
blinkDelay?: number;
|
||||
autofocus?: boolean;
|
||||
oninput?: (value: string) => void;
|
||||
onsubmit?: (value: string) => void;
|
||||
} = $props();
|
||||
|
||||
let container: HTMLElement;
|
||||
@@ -46,7 +47,7 @@
|
||||
e.ctrlKey ? moveTo(nextWordBoundary(cursorPos), e.shiftKey) : moveCursor(1, e.shiftKey),
|
||||
Backspace: () => deleteCharBefore(),
|
||||
Delete: () => deleteCharAfter(),
|
||||
Enter: () => gust()
|
||||
Enter: () => submit()
|
||||
};
|
||||
|
||||
let selection = $derived.by(() => {
|
||||
@@ -64,9 +65,16 @@
|
||||
return selection.active && i >= selection.start && i < selection.end;
|
||||
}
|
||||
|
||||
function submit(): void {
|
||||
onsubmit?.(value);
|
||||
value = '';
|
||||
cursorPos = 0;
|
||||
anchorPos = null;
|
||||
}
|
||||
|
||||
function gust(): void {
|
||||
if (!container) return;
|
||||
petals(container, { duration: 4000, swayAmp: 26, hideOriginals: false });
|
||||
//petals(container, { duration: 4000, swayAmp: 26, hideOriginals: false });
|
||||
value = '';
|
||||
cursorPos = 0;
|
||||
anchorPos = null;
|
||||
@@ -237,6 +245,7 @@
|
||||
|
||||
function handleMouseDown(e: MouseEvent): void {
|
||||
e.preventDefault();
|
||||
container?.focus();
|
||||
const idx = charIndexFromEvent(e);
|
||||
const clickPos = idx ?? value.length;
|
||||
|
||||
@@ -294,7 +303,7 @@
|
||||
|
||||
<div
|
||||
id="terminal-input"
|
||||
class="font-terminal relative inline-block whitespace-nowrap outline-none select-none"
|
||||
class="relative inline-block font-mono whitespace-nowrap outline-none select-none"
|
||||
bind:this={container}
|
||||
tabindex="1"
|
||||
role="textbox"
|
||||
@@ -306,11 +315,12 @@
|
||||
onmousedown={handleMouseDown}
|
||||
style="--cursor-index: {cursorPos};"
|
||||
>
|
||||
<span class="prompt inline-block w-[1ch] text-center">$</span>
|
||||
<!-- <span class="text-fg-dim inline-block">~/Downloads</span> -->
|
||||
<span class="prompt text-fg inline-block w-[1ch] text-center">$</span>
|
||||
<span class="inline cursor-text" aria-hidden="true">
|
||||
{#each value.split('') as char, i}
|
||||
<span
|
||||
class="char inline-block w-[1ch] text-center whitespace-pre"
|
||||
class="char text-glow inline-block w-[1ch] text-center leading-relaxed whitespace-pre-wrap"
|
||||
class:selected={isSelected(i)}
|
||||
data-char-index={i}>{char}</span
|
||||
>
|
||||
@@ -318,7 +328,7 @@
|
||||
</span>
|
||||
<div
|
||||
id="curs"
|
||||
class="cursor bg-text-primary absolute bottom-[0.2rem] h-px w-[1ch]"
|
||||
class="cursor bg-fg absolute bottom-1 h-px w-[1ch]"
|
||||
class:animate-cursor-blink={!blinkPaused && !selection.active}
|
||||
></div>
|
||||
</div>
|
||||
@@ -334,7 +344,7 @@
|
||||
|
||||
.char.selected {
|
||||
transition: none;
|
||||
background-color: var(--color-highlight);
|
||||
background-color: var(--);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user