pull/4837/head
filip mertens 9 months ago
parent b51abe09c5
commit d2effb5df7
  1. 17
      libs/remix-ui/solidity-compiler/src/lib/api/compiler-api.ts
  2. 2
      libs/remix-ui/xterm/src/lib/actions/index.ts
  3. 20
      libs/remix-ui/xterm/src/lib/components/remix-ui-xterminals.tsx

@ -203,14 +203,17 @@ export const CompilerApiMixin = (Base) => class extends Base {
return this.call('fileManager', 'saveCurrentFile') return this.call('fileManager', 'saveCurrentFile')
} }
resetResults () { resetResults() {
this.currentFile = '' try {
this.compilationDetails = { this.currentFile = ''
contractsDetails: {}, this.compilationDetails = {
contractMap: {} contractsDetails: {},
contractMap: {}
}
this.statusChanged({ key: 'none' })
} catch (e) {
// do nothing
} }
this.statusChanged({ key: 'none' })
// if (this.onResetResults) this.onResetResults()
} }
listenToEvents () { listenToEvents () {

@ -2,8 +2,6 @@ import { Actions } from "@remix-ui/xterm"
import { Plugin } from "@remixproject/engine" import { Plugin } from "@remixproject/engine"
export const createTerminal = async (shell: string = '', plugin: Plugin, workingDir: string, dispatch: React.Dispatch<Actions>) => { export const createTerminal = async (shell: string = '', plugin: Plugin, workingDir: string, dispatch: React.Dispatch<Actions>) => {
const shells: string[] = await plugin.call('xterm', 'getShells')
dispatch({ type: 'ADD_SHELLS', payload: shells })
const pid = await plugin.call('xterm', 'createTerminal', workingDir, shell) const pid = await plugin.call('xterm', 'createTerminal', workingDir, shell)
dispatch({ type: 'SHOW_OUTPUT', payload: false }) dispatch({ type: 'SHOW_OUTPUT', payload: false })
dispatch({ type: 'HIDE_ALL_TERMINALS', payload: null }) dispatch({ type: 'HIDE_ALL_TERMINALS', payload: null })

@ -25,6 +25,10 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => {
useEffect(() => { useEffect(() => {
setTimeout(async () => { setTimeout(async () => {
plugin.call('xterm', 'getShells').then((shells) => {
dispatchXterm({ type: 'ADD_SHELLS', payload: shells })
})
plugin.on('xterm', 'data', async (data: string, pid: number) => { plugin.on('xterm', 'data', async (data: string, pid: number) => {
writeToTerminal(data, pid) writeToTerminal(data, pid)
}) })
@ -34,10 +38,10 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => {
}) })
plugin.on('xterm', 'new', async () => { plugin.on('xterm', 'new', async () => {
const pid = await plugin.call('xterm', 'createTerminal', workingDir, null) const pid = await plugin.call('xterm', 'createTerminal', workingDir, null)
dispatchXterm({ type: 'HIDE_ALL_TERMINALS', payload: null }) 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 } }) dispatchXterm({ type: 'ADD_TERMINAL', payload: { pid, queue: '', timeStamp: Date.now(), ref: null, hidden: false } })
}) })
@ -47,7 +51,7 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => {
}) })
const workingDir = await plugin.call('fs', 'getWorkingDir') const workingDir = await plugin.call('fs', 'getWorkingDir')
if(workingDir && workingDir !== '') { if (workingDir && workingDir !== '') {
dispatchXterm({ type: 'ENABLE_TERMINALS', payload: null }) dispatchXterm({ type: 'ENABLE_TERMINALS', payload: null })
dispatchXterm({ type: 'SET_WORKING_DIR', payload: workingDir }) dispatchXterm({ type: 'SET_WORKING_DIR', payload: workingDir })
} }
@ -76,7 +80,7 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => {
useEffect(() => { useEffect(() => {
setTerminals(xtermState.terminals) setTerminals(xtermState.terminals)
if(xtermState.terminals.length === 0) { if (xtermState.terminals.length === 0) {
dispatchXterm({ type: 'SHOW_OUTPUT', payload: true }) dispatchXterm({ type: 'SHOW_OUTPUT', payload: true })
} }
}, [xtermState.terminals]) }, [xtermState.terminals])
@ -137,9 +141,9 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => {
} }
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'}`}>
<> <>
{ <div className={`flex-row w-100 h-100 ${xtermState.showOutput ? 'h-0 d-none' : 'h-100 d-flex'}`}> {<div className={`flex-row w-100 h-100 ${xtermState.showOutput ? 'h-0 d-none' : 'h-100 d-flex'}`}>
{terminals.map((xtermState) => { {terminals.map((xtermState) => {
return ( return (
<div className={`h-100 w-100 ${xtermState.hidden ? 'd-none' : 'd-block'}`} data-active={`${xtermState.hidden ? '0' : '1'}`} key={xtermState.pid} data-type="remixUIXT" data-id={`remixUIXT${xtermState.pid}`}> <div className={`h-100 w-100 ${xtermState.hidden ? 'd-none' : 'd-block'}`} data-active={`${xtermState.hidden ? '0' : '1'}`} key={xtermState.pid} data-type="remixUIXT" data-id={`remixUIXT${xtermState.pid}`}>

Loading…
Cancel
Save