pull/4837/head
filip mertens 10 months ago
parent 547d4d4596
commit 33bea35b12
  1. 9
      apps/remixdesktop/src/plugins/xtermPlugin.ts
  2. 15
      libs/remix-ui/terminal/src/lib/components/remix-ui-terminal-menu-buttons.tsx
  3. 14
      libs/remix-ui/xterm/src/lib/components/remix-ui-xterminals.tsx

@ -139,6 +139,7 @@ class XtermPluginClient extends ElectronBasePluginClient {
} }
async createTerminal(path?: string, shell?: string): Promise<number> { async createTerminal(path?: string, shell?: string): Promise<number> {
const start_time = Date.now()
console.log('createTerminal', path, shell || defaultShell) console.log('createTerminal', path, shell || defaultShell)
let parsedEnv: any = null let parsedEnv: any = null
if (!(process.platform === 'win32')) { if (!(process.platform === 'win32')) {
@ -172,7 +173,8 @@ class XtermPluginClient extends ElectronBasePluginClient {
this.sendData(data, uid) this.sendData(data, uid)
}) })
this.terminals[ptyProcess.pid] = ptyProcess this.terminals[ptyProcess.pid] = ptyProcess
const end_time = Date.now()
console.log('createTerminal', end_time - start_time)
return ptyProcess.pid return ptyProcess.pid
} }
@ -218,9 +220,6 @@ class XtermPluginClient extends ElectronBasePluginClient {
} }
async new(): Promise<void> { async new(): Promise<void> {
console.log('new terminal in client') this.emit('new')
const pid = await this.createTerminal(this.workingDir)
console.log('new terminal in client', pid)
this.emit('new', pid)
} }
} }

@ -12,9 +12,19 @@ export const RemixUITerminalMenuButtons = (props: RemixUiTerminalProps) => {
dispatch({ type: SET_OPEN, payload: true }) dispatch({ type: SET_OPEN, payload: true })
} }
function showTerminal(event: any): void { const showTerminal = async(event: any): Promise<void> => {
props.plugin.call('layout', 'minimize', props.plugin.profile.name, false) props.plugin.call('layout', 'minimize', props.plugin.profile.name, false)
if( xtermState.terminals.length === 0) {
const start_time = Date.now()
const pid = await props.plugin.call('xterm', 'createTerminal', xtermState.workingDir, null)
const end_time = Date.now()
console.log(`createTerminal took ${end_time - start_time} ms`)
dispatchXterm({ type: 'HIDE_ALL_TERMINALS', payload: null })
dispatchXterm({ type: 'SHOW_OUTPUT', payload: false }) dispatchXterm({ type: 'SHOW_OUTPUT', payload: false })
dispatchXterm({ type: 'ADD_TERMINAL', payload: { pid, queue: '', timeStamp: Date.now(), ref: null, hidden: false } })
} else {
dispatchXterm({ type: 'SHOW_OUTPUT', payload: false })
}
dispatch({ type: SET_OPEN, payload: true }) dispatch({ type: SET_OPEN, payload: true })
} }
@ -23,7 +33,8 @@ export const RemixUITerminalMenuButtons = (props: RemixUiTerminalProps) => {
<button id="tabOutput" data-id="tabOutput" className={`xtermButton btn btn-sm border-secondary mr-2 border ${!xtermState.showOutput ? '' : 'd-flex btn-secondary'}`} onClick={selectOutput}> <button id="tabOutput" data-id="tabOutput" className={`xtermButton btn btn-sm border-secondary mr-2 border ${!xtermState.showOutput ? '' : 'd-flex btn-secondary'}`} onClick={selectOutput}>
Output Output
</button> </button>
<button data-id="tabXTerm" id="tabXTerm" className={`xtermButton btn btn-sm border-secondary ${xtermState.terminalsEnabled ? 'd-block' : 'd-none'} ${xtermState.showOutput ? 'd-none' : 'btn-secondary'}`} onClick={showTerminal}> <button data-id="tabXTerm" id="tabXTerm" className={`xtermButton btn btn-sm border-secondary ${xtermState.terminalsEnabled ? 'd-block' : 'd-none'} ${xtermState.showOutput ? 'd-none' : 'btn-secondary'}`}
onClick={async(e) => await showTerminal(e)}>
<span className="far fa-terminal border-0 ml-1"></span> <span className="far fa-terminal border-0 ml-1"></span>
</button> </button>
</div> </div>

@ -33,10 +33,11 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => {
dispatchXterm({ type: 'REMOVE_TERMINAL', payload: pid }) dispatchXterm({ type: 'REMOVE_TERMINAL', payload: pid })
}) })
plugin.on('xterm', 'new', async (pid: number) => { plugin.on('xterm', 'new', async () => {
dispatchXterm({ type: 'ADD_TERMINAL', payload: { pid, queue: '', timeStamp: Date.now(), ref: null, hidden: false } }) const pid = await plugin.call('xterm', 'createTerminal', workingDir, null)
dispatchXterm({ type: 'SHOW_OUTPUT', payload: false })
dispatchXterm({ type: 'HIDE_ALL_TERMINALS', payload: null }) dispatchXterm({ type: 'HIDE_ALL_TERMINALS', payload: null })
dispatchXterm({ type: 'SHOW_OUTPUT', payload: false })
dispatchXterm({ type: 'ADD_TERMINAL', payload: { pid, queue: '', timeStamp: Date.now(), ref: null, hidden: false } })
}) })
@ -135,13 +136,6 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => {
}) })
} }
useEffect(() => {
if (!xtermState.showOutput) {
console.log('create terminal because of showOutput')
//if (terminals.length === 0) createTerminal('', plugin, xtermState.workingDir, dispatchXterm)
}
}, [xtermState.showOutput])
return (<> return (<>
{ <div style={{ flexGrow: 1 }} className={`flex-row ${xtermState.showOutput ? 'h-0 d-none' : 'h-100 d-flex'}`}> { <div style={{ flexGrow: 1 }} className={`flex-row ${xtermState.showOutput ? 'h-0 d-none' : 'h-100 d-flex'}`}>
<> <>

Loading…
Cancel
Save