fix logging to terminal

pull/1703/head
yann300 3 years ago
parent 503df540e5
commit 88ad43cbb3
  1. 12
      apps/remix-ide/src/app/panels/terminal.js
  2. 30
      libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx
  3. 3
      libs/remix-ui/terminal/src/lib/types/terminalTypes.ts
  4. 2
      package.json

@ -86,8 +86,6 @@ class Terminal extends Plugin {
this.call('menuicons', 'select', 'debugger')
this.call('debugger', 'debug', hash)
})
this.logHtmlResponse = []
this.logResponse = []
}
onActivation () {
@ -102,13 +100,11 @@ class Terminal extends Plugin {
}
logHtml (html) {
this.logHtmlResponse.push(html.innerText)
this.renderComponent()
this.terminalApi.logHtml(html)
}
log (message) {
this.logResponse.push(message)
this.renderComponent()
this.terminalApi.log(message)
}
render () {
@ -116,9 +112,11 @@ class Terminal extends Plugin {
}
renderComponent () {
const onReady = (api) => { this.terminalApi = api }
ReactDOM.render(
<RemixUiTerminal
plugin = {this}
plugin={this}
onReady={onReady}
/>,
this.element
)

@ -24,7 +24,7 @@ export interface ClipboardEvent<T = Element> extends SyntheticEvent<T, any> {
}
export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
const { call, _deps, on, config, event, gistHandler, logHtmlResponse, logResponse, version } = props.plugin
const { call, _deps, on, config, event, gistHandler, version } = props.plugin
const [toggleDownUp, setToggleDownUp] = useState('fa-angle-double-down')
const [_cmdIndex, setCmdIndex] = useState(-1)
const [_cmdTemp, setCmdTemp] = useState('')
@ -68,11 +68,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
commandHistoryIndex: 0
})
const [logState, setLogState] = useState({
logIndex: 0,
htmlLogIndex: 0
})
const [searchInput, setSearchInput] = useState('')
const [showTableHash, setShowTableHash] = useState([])
@ -89,18 +84,15 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
}
useEffect(() => {
if (logHtmlResponse.length > 0) {
scriptRunnerDispatch({ type: 'html', payload: { message: logHtmlResponse.slice(logState.htmlLogIndex) } })
setLogState(prevState => ({ ...prevState, htmlLogIndex: logHtmlResponse.length }))
}
}, [logHtmlResponse.length])
useEffect(() => {
if (logResponse.length > 0) {
scriptRunnerDispatch({ type: 'log', payload: { message: logResponse.slice(logState.logIndex) } })
setLogState(prevState => ({ ...prevState, logIndex: logResponse.length }))
}
}, [logResponse.length])
props.onReady({
logHtml: (html) => {
scriptRunnerDispatch({ type: 'html', payload: { message: [html.innerText] } })
},
log: (message) => {
scriptRunnerDispatch({ type: 'log', payload: { message: [message] } })
}
})
}, [])
// events
useEffect(() => {
@ -126,7 +118,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
useEffect(() => {
scrollToBottom()
}, [newstate.journalBlocks.length, logHtmlResponse.length, toaster])
}, [newstate.journalBlocks.length, toaster])
function execute (file, cb) {
function _execute (content, cb) {

@ -24,5 +24,6 @@ export const LISTEN_ON_NETWORK = 'listenOnNetWork'
export const CMD_HISTORY = 'cmdHistory'
export interface RemixUiTerminalProps {
plugin: any
plugin: any,
onReady: (api: any) => void
}

@ -72,7 +72,7 @@
"nightwatch_local_staticAnalysis": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.js --env=chrome",
"nightwatch_local_signingMessage": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/signingMessage.test.js --env=chrome",
"nightwatch_local_specialFunctions": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/specialFunctions.test.js --env=chrome",
"nightwatch_local_solidityUnitTests": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.js --env=chrome",
"nightwatch_local_solidityUnitTests": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.js --env=firefox",
"nightwatch_local_remixd": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/remixd.test.js --env=chrome",
"nightwatch_local_terminal": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/terminal.test.js --env=chrome",
"nightwatch_local_gist": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/gist.spec.js --env=chrome",

Loading…
Cancel
Save