|
|
@ -19,17 +19,12 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => { |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
plugin.on('xterm', 'loaded', async () => { |
|
|
|
plugin.on('xterm', 'loaded', async () => { |
|
|
|
console.log('xterms loaded') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
plugin.on('xterm', 'data', async (data: string, pid: number) => { |
|
|
|
plugin.on('xterm', 'data', async (data: string, pid: number) => { |
|
|
|
console.log('xterm data', data, pid) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writeToTerminal(data, pid) |
|
|
|
writeToTerminal(data, pid) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
plugin.on('xterm', 'close', async (pid: number) => { |
|
|
|
plugin.on('xterm', 'close', async (pid: number) => { |
|
|
|
console.log('xterm close', pid) |
|
|
|
|
|
|
|
setTerminals(prevState => { |
|
|
|
setTerminals(prevState => { |
|
|
|
return prevState.filter(xtermState => xtermState.pid !== pid) |
|
|
|
return prevState.filter(xtermState => xtermState.pid !== pid) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -52,13 +47,11 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => { |
|
|
|
}, [terminals]) |
|
|
|
}, [terminals]) |
|
|
|
|
|
|
|
|
|
|
|
const send = (data: string, pid: number) => { |
|
|
|
const send = (data: string, pid: number) => { |
|
|
|
console.log('send', data) |
|
|
|
|
|
|
|
plugin.call('xterm', 'keystroke', data, pid) |
|
|
|
plugin.call('xterm', 'keystroke', data, pid) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const createTerminal = async () => { |
|
|
|
const createTerminal = async () => { |
|
|
|
const pid = await plugin.call('xterm', 'createTerminal') |
|
|
|
const pid = await plugin.call('xterm', 'createTerminal') |
|
|
|
console.log('pid', pid) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTerminals(prevState => { |
|
|
|
setTerminals(prevState => { |
|
|
|
return [...prevState, { |
|
|
|
return [...prevState, { |
|
|
|