2021-12-16 01:15:43 +01:00
|
|
|
import { useRef, useState } from "react";
|
2021-12-15 18:56:32 +01:00
|
|
|
import REPLInput from "./REPLInput";
|
2021-12-16 00:21:14 +01:00
|
|
|
import REPLHistory from "./REPLHistory";
|
2021-12-15 18:56:32 +01:00
|
|
|
|
|
|
|
const REPL = () => {
|
2021-12-16 00:21:14 +01:00
|
|
|
const [history, manipulateHistory] = useState<string[]>([]);
|
2021-12-16 01:15:43 +01:00
|
|
|
const inputRef = useRef<HTMLInputElement>();
|
2021-12-16 00:21:14 +01:00
|
|
|
const onCommandExecuted = (result: string[]) => manipulateHistory(result.reverse().concat(history).slice(0, 1000));
|
|
|
|
|
|
|
|
return (<>
|
2021-12-16 01:15:43 +01:00
|
|
|
<REPLHistory history={history} inputRef={inputRef} />
|
|
|
|
<REPLInput historyCallback={onCommandExecuted} inputRef={inputRef} />
|
2021-12-16 00:21:14 +01:00
|
|
|
</>);
|
2021-12-15 18:56:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default REPL;
|