mirror of
https://github.com/urbit/shrub.git
synced 2024-12-21 09:51:36 +03:00
d7ec69803f
Needs to be made prettier by displaying only after a delay, have a cute little animation, etc.
39 lines
929 B
TypeScript
39 lines
929 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,
|
|
pending: number,
|
|
subscriptionId: number | null,
|
|
} | 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,
|
|
}
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
const useTermState = create<TermState>((set, get) => ({
|
|
sessions: {} as Sessions,
|
|
names: [''],
|
|
selected: '', // empty string is default session
|
|
slogstream: null,
|
|
theme: 'auto',
|
|
// eslint-disable-next-line no-unused-vars
|
|
set: (f: (draft: TermState) => void) => {
|
|
set(produce(f));
|
|
}
|
|
} as TermState));
|
|
|
|
export default useTermState;
|