urbit/pkg/interface/webterm/state.ts

21 lines
572 B
TypeScript
Raw Normal View History

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;