sync: wip changes

This commit is contained in:
2026-03-24 13:58:59 +01:00
parent 6cc4837a8e
commit 475ba9d8ab
10 changed files with 227 additions and 21 deletions

15
src/shell/Shell.ts Normal file
View File

@@ -0,0 +1,15 @@
import type { Terminal } from '../terminal/Terminal'
import type { EventBroadcaster } from '../utils/EventBroadcaster'
export abstract class Shell {
broadcaster: EventBroadcaster
terminal: Terminal
constructor(broadcaster: EventBroadcaster, terminal: Terminal) {
this.broadcaster = broadcaster
this.terminal = terminal
}
abstract Init(): void
abstract HandleKeyInput(key: string, isCharacter: boolean): void
}

42
src/shell/Wush.ts Normal file
View File

@@ -0,0 +1,42 @@
// Web-Uno Shell
// the best name I could come up with lmao
import { Terminal } from '../terminal/Terminal'
import type { EventBroadcaster } from '../utils/EventBroadcaster'
import { Shell } from './Shell'
export class Wush extends Shell {
constructor(broadcaster: EventBroadcaster, terminal: Terminal) {
super(broadcaster, terminal)
}
Init() {
this.broadcaster.on('keydown', (key: string, isCharacter: boolean) =>
this.HandleKeyInput(key, isCharacter),
)
this.Prompt()
}
Prompt() {
this.terminal.Write('hi -> ')
}
HandleKeyInput(key: string, isCharacter: boolean) {
console.log(key)
console.log(isCharacter)
if (!isCharacter)
switch (key) {
case 'Backspace':
this.terminal.RemoveCells(1)
break
case 'Enter':
this.Prompt()
break
}
else {
this.terminal.Write(key)
this.terminal.AdjustCursorPosition(1, 0)
}
}
}