urbit/pkg/interface/webterm/state.ts
fang 04f16e047b
webterm: backport
Doesn't quite compile, untested.
2021-11-25 13:00:52 +01:00

21 lines
572 B
TypeScript

import { Terminal } from 'xterm';
import { FitAddon } from 'xterm-addon-fit';
import { createState } from "../src/logic/state/base";
type Session = { term: Terminal, fit: FitAddon };
type Sessions = { [id: string]: Session; }
export interface TermState {
sessions: Sessions,
selected: string,
slogstream: null | EventSource,
};
const useTermState = createState<TermState>('Term', {
sessions: {},
selected: '', // empty string is default session
slogstream: null,
}, ['sessions', 'slogstream']); //TODO consider persisting
export default useTermState;