blob: db18fa045edb67a4c91f003ecb1786acde788f56 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import React from "react";
import FindPrompt from "./FindPrompt";
import CommandPrompt from "./CommandPrompt";
import InfoMessage from "./InfoMessage";
import ErrorMessage from "./ErrorMessage";
import { useColorSchemeRefresh } from "../colorscheme/hooks";
import {
useCommandMode,
useErrorMessage,
useFindMode,
useInfoMessage,
} from "../app/hooks";
const Console: React.FC = () => {
const refreshColorScheme = useColorSchemeRefresh();
const { visible: visibleCommand, initialInputValue } = useCommandMode();
const { visible: visibleFind } = useFindMode();
const { visible: visibleInfo, message: infoMessage } = useInfoMessage();
const { visible: visibleError, message: errorMessage } = useErrorMessage();
React.useEffect(() => {
if (visibleCommand || visibleFind || visibleInfo || visibleError) {
refreshColorScheme();
}
}, [visibleCommand, visibleFind, visibleInfo, visibleError]);
if (visibleCommand) {
return <CommandPrompt initialInputValue={initialInputValue} />;
} else if (visibleFind) {
return <FindPrompt />;
} else if (visibleInfo) {
return <InfoMessage>{infoMessage}</InfoMessage>;
} else if (visibleError) {
return <ErrorMessage>{errorMessage}</ErrorMessage>;
}
return null;
};
export default Console;
|