Add clear command (fix #4)
This commit is contained in:
@@ -6,6 +6,7 @@ const REPL = () => {
|
||||
const [history, manipulateHistory] = useState<string[]>([]);
|
||||
const inputRef = useRef<HTMLInputElement>();
|
||||
const onCommandExecuted = (result: string[]) => manipulateHistory(result.reverse().concat(history).slice(0, 1000));
|
||||
const onClearHistory = () => manipulateHistory([]);
|
||||
|
||||
const focusInput = () => {
|
||||
if (inputRef.current) inputRef.current.focus();
|
||||
@@ -13,7 +14,7 @@ const REPL = () => {
|
||||
|
||||
return (<>
|
||||
<REPLHistory history={history} inputRef={inputRef} />
|
||||
<REPLInput historyCallback={onCommandExecuted} inputRef={inputRef} />
|
||||
<REPLInput historyCallback={onCommandExecuted} historyClear={onClearHistory} inputRef={inputRef} />
|
||||
<div style={{flexGrow: 2}} onClick={focusInput}></div>
|
||||
</>);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user