mirror of
https://github.com/urbit/shrub.git
synced 2024-12-25 04:52:06 +03:00
d98611a04b
Fully implements webterm support for multiple dill terminal sessions. Remaining work includes styling, session creation safety (name-wise), and general cleanup. Co-authored-by: tomholford <tomholford@users.noreply.github.com> Co-authored-by: liam-fitzgerald <liam@tlon.io>
31 lines
783 B
TypeScript
31 lines
783 B
TypeScript
import { Terminal } from 'xterm';
|
|
import { FitAddon } from 'xterm-addon-fit';
|
|
import create from 'zustand';
|
|
import produce from 'immer';
|
|
|
|
export type Session = { term: Terminal, fit: FitAddon, hasBell: boolean } | null;
|
|
export type Sessions = { [id: string]: Session; }
|
|
|
|
export interface TermState {
|
|
sessions: Sessions,
|
|
names: string[],
|
|
selected: string,
|
|
slogstream: null | EventSource,
|
|
theme: 'auto' | 'light' | 'dark',
|
|
//TODO: figure out the type
|
|
set: any,
|
|
}
|
|
|
|
const useTermState = create<TermState>((set, get) => ({
|
|
sessions: {} as Sessions,
|
|
names: [''],
|
|
selected: '', // empty string is default session
|
|
slogstream: null,
|
|
theme: 'auto',
|
|
set: (f: (draft: TermState) => void) => {
|
|
set(produce(f));
|
|
}
|
|
} as TermState));
|
|
|
|
export default useTermState;
|