mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
terminal: focus when repl is requested
This commit is contained in:
committed by
David Lechner
parent
03f6c004db
commit
2d9a0ca39e
@@ -177,6 +177,16 @@ const Terminal: React.FC = (_props) => {
|
||||
[createContextMenu, xterm],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const listener = () => {
|
||||
xterm.focus();
|
||||
};
|
||||
|
||||
addEventListener('pb-terminal-focus', listener);
|
||||
|
||||
return () => removeEventListener('pb-terminal-focus', listener);
|
||||
}, [xterm]);
|
||||
|
||||
return (
|
||||
<ContextMenu2
|
||||
className="h-100"
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
write,
|
||||
} from '../ble-nordic-uart-service/actions';
|
||||
import { nordicUartSafeTxCharLength } from '../ble-nordic-uart-service/protocol';
|
||||
import { checksum } from '../hub/actions';
|
||||
import { checksum, repl } from '../hub/actions';
|
||||
import { HubRuntimeState } from '../hub/reducers';
|
||||
import { RootState } from '../reducers';
|
||||
import { defined } from '../utils';
|
||||
@@ -94,8 +94,13 @@ function* sendTerminalData(action: ReturnType<typeof sendData>): Generator {
|
||||
dataSource.next(action.value);
|
||||
}
|
||||
|
||||
function handleRepl(): void {
|
||||
dispatchEvent(new CustomEvent('pb-terminal-focus'));
|
||||
}
|
||||
|
||||
export default function* (): Generator {
|
||||
yield* takeEvery(didNotify, receiveUartData);
|
||||
yield* fork(receiveTerminalData);
|
||||
yield* takeEvery(sendData, sendTerminalData);
|
||||
yield* takeEvery(repl, handleRepl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user