Rewrite website as a Hyprland desktop
This commit is contained in:
1 parent
7c52779cf6
commit
3065ad6092
197 files changed
+5609
-17779
No files matched your search
@@ -0,0 +1,52 @@
|
||||
export const pageWindowId = 'page';
|
||||
|
||||
export interface TerminalWindow {
|
||||
id: string;
|
||||
startupCommand: string;
|
||||
}
|
||||
|
||||
class WindowManager {
|
||||
terminals = $state<TerminalWindow[]>([]);
|
||||
focusedId = $state<string>(pageWindowId);
|
||||
maximizedId = $state<string | null>(null);
|
||||
launcherOpen = $state(false);
|
||||
|
||||
private nextTerminalNumber = 1;
|
||||
|
||||
openTerminal(startupCommand = '') {
|
||||
const terminal = { id: `kitty-${this.nextTerminalNumber++}`, startupCommand };
|
||||
this.terminals.push(terminal);
|
||||
this.focus(terminal.id);
|
||||
}
|
||||
|
||||
closeTerminal(id: string) {
|
||||
this.terminals = this.terminals.filter((terminal) => terminal.id !== id);
|
||||
if (this.maximizedId === id) this.maximizedId = null;
|
||||
if (this.focusedId === id) this.focusedId = this.terminals.at(-1)?.id ?? pageWindowId;
|
||||
}
|
||||
|
||||
closeAllTerminals() {
|
||||
this.terminals = [];
|
||||
this.maximizedId = null;
|
||||
this.focusedId = pageWindowId;
|
||||
}
|
||||
|
||||
focus(id: string) {
|
||||
this.focusedId = id;
|
||||
if (this.maximizedId && this.maximizedId !== id) this.maximizedId = null;
|
||||
}
|
||||
|
||||
toggleMaximize(id: string) {
|
||||
this.maximizedId = this.maximizedId === id ? null : id;
|
||||
this.focusedId = id;
|
||||
}
|
||||
|
||||
cycleFocus(openWindowIds: string[], step: number) {
|
||||
if (openWindowIds.length === 0) return;
|
||||
const index = openWindowIds.indexOf(this.focusedId);
|
||||
const nextIndex = (index + step + openWindowIds.length) % openWindowIds.length;
|
||||
this.focus(openWindowIds[nextIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
export const windowManager = new WindowManager();
|
||||
Reference in new issue
Block a user