Update Console.tsx

This commit is contained in:
Charles Morgan 2020-10-14 11:38:59 -04:00
parent cdb881efaf
commit 807707c07e
No known key found for this signature in database
GPG key ID: D71946CD723249BD

View file

@ -60,7 +60,7 @@ export default () => {
const terminal = useMemo(() => new Terminal({ ...terminalProps }), []); const terminal = useMemo(() => new Terminal({ ...terminalProps }), []);
const fitAddon = new FitAddon(); const fitAddon = new FitAddon();
const searchAddon = new SearchAddon(); const searchAddon = new SearchAddon();
const searchBarAddon = new SearchBarAddon({ searchAddon }); const SearchBar = new SearchBarAddon({ searchAddon });
const { connected, instance } = ServerContext.useStoreState(state => state.socket); const { connected, instance } = ServerContext.useStoreState(state => state.socket);
const [ canSendCommands ] = usePermissions([ 'control.console' ]); const [ canSendCommands ] = usePermissions([ 'control.console' ]);
@ -90,24 +90,24 @@ export default () => {
terminal.open(ref.current); terminal.open(ref.current);
terminal.loadAddon(fitAddon); terminal.loadAddon(fitAddon);
terminal.loadAddon(searchAddon); terminal.loadAddon(searchAddon);
terminal.loadAddon(searchBarAddon); terminal.loadAddon(SearchBar);
fitAddon.fit(); fitAddon.fit();
// Add support for capturing keys // Add support for capturing keys
terminal.attachCustomKeyEventHandler((e: KeyboardEvent) => { terminal.attachCustomKeyEventHandler((e: KeyboardEvent) => {
// Ctrl + C ( Copy ) // Ctrl + C ( Copy )
if (e.ctrlKey && (e.key === 'c')) { if (e.ctrlKey && e.key === 'c') {
document.execCommand('copy'); document.execCommand('copy');
return false; return false;
} }
if (e.ctrlKey && (e.key === 'f')) { if (e.ctrlKey && e.key === 'f') {
searchAddonBar.show(); SearchBar.show();
return false; return false;
} }
if (e.key === 'Escape') { if (e.key === 'Escape') {
searchAddonBar.hidden(); SearchBar.hidden();
} }
return true; return true;
}); });