Nano zoom fix #13

This commit is contained in:
LukeGus
2024-12-05 19:49:18 -06:00
parent 1f75dc0bd2
commit 474965835f
2 changed files with 65 additions and 28 deletions

View File

@@ -100,6 +100,11 @@ const App = () => {
socket.current.onmessage = (event) => {
console.log('Received message:', event.data);
terminal.current.write(event.data);
const parsedData = JSON.parse(event.data);
if (parsedData.type === 'process_closed') {
notifyServerOfResize();
}
};
socket.current.onerror = (error) => {
@@ -114,6 +119,21 @@ const App = () => {
};
};
const notifyServerOfResize = () => {
if (socket.current && socket.current.readyState === WebSocket.OPEN) {
const { rows, cols } = terminal.current;
socket.current.send(
JSON.stringify({
type: 'resize',
rows,
cols,
height: terminalRef.current.offsetHeight,
width: terminalRef.current.offsetWidth,
})
);
}
};
const handleInputChange = (event, setState) => {
setState(event.target.value);
};