feat(terminal): terminal wrapper and context

This commit is contained in:
Pihkaal
2024-01-22 11:50:37 +01:00
parent 070e198b43
commit f7b43b47bf
2 changed files with 73 additions and 16 deletions

View File

@@ -0,0 +1,15 @@
import { createContext, useContext } from "react";
const TerminalContext = createContext<{ cols: number; height: number } | null>(
null,
);
export const TerminalContextProvider = TerminalContext.Provider;
export const useTerminal = () => {
const context = useContext(TerminalContext);
if (!context)
throw new Error("useTerminal must be used inside a Terminal component");
return context;
};