Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
b1314aa9
Commit
b1314aa9
authored
Jul 09, 2021
by
tizah
Committed by
davidzagi93@gmail.com
Sep 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remix id terminal update
parent
520bcedc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
154 additions
and
0 deletions
+154
-0
terminal.js
apps/remix-ide/src/app/panels/terminal.js
+12
-0
remix-ui-terminal.tsx
libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx
+142
-0
No files found.
apps/remix-ide/src/app/panels/terminal.js
View file @
b1314aa9
...
...
@@ -92,6 +92,18 @@ class Terminal extends Plugin {
}
onActivation
()
{
this
.
on
(
'scriptRunner'
,
'log'
,
(
msg
)
=>
{
this
.
commands
.
log
.
apply
(
this
.
commands
,
msg
.
data
)
})
this
.
on
(
'scriptRunner'
,
'info'
,
(
msg
)
=>
{
this
.
commands
.
info
.
apply
(
this
.
commands
,
msg
.
data
)
})
this
.
on
(
'scriptRunner'
,
'warn'
,
(
msg
)
=>
{
this
.
commands
.
warn
.
apply
(
this
.
commands
,
msg
.
data
)
})
this
.
on
(
'scriptRunner'
,
'error'
,
(
msg
)
=>
{
this
.
commands
.
error
.
apply
(
this
.
commands
,
msg
.
data
)
})
this
.
renderComponent
()
}
...
...
libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx
View file @
b1314aa9
<<
<
<<<<
HEAD
import
React
,
{
useState
,
useEffect
,
useReducer
,
useRef
,
SyntheticEvent
,
MouseEvent
}
from
'
react
'
// eslint-disable-line
import
{
useKeyPress
}
from
'
.
/
custom
-
hooks
/
useKeyPress
'
// eslint-disable-line
import
{
useWindowResize
}
from
'
beautiful
-
react
-
hooks
'
...
...
@@ -9,6 +10,9 @@ import {allCommands, allPrograms} from './commands' // eslint-disable-line
import
{
CopyToClipboard
}
from
'@
remix
-
ui
/
clipboard
'
// eslint-disable-line
import
{
ModalDialog
}
from
'@
remix
-
ui
/
modal
-
dialog
'
// eslint-disable-line
import
TerminalWelcomeMessage
from
'
.
/
terminalWelcome
'
// eslint-disable-line
=======
import
React
,
{
useState
,
useEffect
,
useRef
,
SyntheticEvent
}
from
'
react
'
// eslint-disable-line
>
>>>>>>
69029a97a (remix id terminal update)
import './remix-ui-terminal.css'
// const TxLogger from '../../../apps/'
...
...
@@ -31,6 +35,7 @@ export interface RemixUiTerminalProps {
options
:
any
data
:
any
cmdInterpreter
:
any
<<
<
<<<<
HEAD
command
:
any
version
:
any
config
:
any
...
...
@@ -46,6 +51,13 @@ export interface RemixUiTerminalProps {
txListener
:
any
,
eventsDecoder
:
any
,
logHtml
:
any
=======
registerCommand
:
any
}
export interface ClipboardEvent
<
T
=
Element
>
extends SyntheticEvent
<
T
,
any
>
{
clipboardData
:
DataTransfer
;
>>>>>>>
69029
a97a
(
remix
id
terminal
update
)
}
export interface ClipboardEvent
<
T
=
Element
>
extends SyntheticEvent
<
T
,
any
>
{
...
...
@@ -54,6 +66,7 @@ export interface ClipboardEvent<T = Element> extends SyntheticEvent<T, any> {
export const RemixUiTerminal = (props: RemixUiTerminalProps) =
>
{
const
[
toggleDownUp
,
setToggleDownUp
]
=
useState
(
'fa-angle-double-down'
)
<<
<
<<<<
HEAD
const
[
_cmdIndex
,
setCmdIndex
]
=
useState
(-1)
const
[
_cmdTemp
,
setCmdTemp
]
=
useState
('')
const
[
_cmdHistory
,
setCmdHistory
]
=
useState
([])
...
...
@@ -93,10 +106,31 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
useWindowResize(() =
>
{
setWindowHeight
(
window
.
innerHeight
)
=======
const
[
inserted
,
setInserted
]
=
useState
(
false
)
const
[
state
,
setState
]
=
useState
({
data
:
{
// lineLength: props.options.lineLength || 80,
session
:
[],
activeFilters
:
{
commands
:
{},
input
:
''
},
filterFns
:
{}
},
_commands
:
{},
commands
:
{},
_JOURNAL
:
[],
_jobs
:
[],
_INDEX
:
{},
_INDEXall
:
[],
_INDEXallMain
:
[],
_INDEXcommands
:
{},
_INDEXcommandsMain
:
{}
>>>>>>>
69029
a97a
(
remix
id
terminal
update
)
})
// terminal inputRef
const
inputEl
=
useRef
(
null
)
<<
<
<<<<
HEAD
const
messagesEndRef
=
useRef
(
null
)
const
scrollToBottom
=
()
=
>
{
...
...
@@ -215,6 +249,8 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
}
}
=======
>>>>>>>
69029a97a (remix id terminal update)
// events
useEffect(() =
>
{
// window.addEventListener('resize', function ()
{
...
...
@@ -229,6 +265,25 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
//
}
}
, [])
// handle events
const handlePaste = (event: ClipboardEvent
<
HTMLInputElement
>
) =
>
{
// Do something
const
selection
=
window
.
getSelection
()
if
(
!
selection
.
rangeCount
)
return
false
event
.
preventDefault
()
event
.
stopPropagation
()
var
clipboard
=
(
event
.
clipboardData
)
// || window.clipboardData
var
text
=
clipboard
.
getData
(
'text/plain'
)
text
=
text
.
replace
(
/
[^\x
20-
\x
FF
]
/gi
,
''
)
// remove non-UTF-8 characters
var
temp
=
document
.
createElement
(
'div'
)
temp
.
innerHTML
=
text
var
textnode
=
document
.
createTextNode
(
temp
.
textContent
)
selection
.
getRangeAt
(
0
).
insertNode
(
textnode
)
selection
.
empty
()
// self.scroll2bottom()
// placeCaretAtEnd(event.currentTarget)
}
const handleMinimizeTerminal = (event) =
>
{
event
.
preventDefault
()
event
.
stopPropagation
()
...
...
@@ -244,6 +299,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
console
.
log
(
props
.
event
,
'event.trigger'
)
}
<
<<<<<<
HEAD
const
focusinput
=
()
=
>
{
inputEl
.
current
.
focus
()
}
...
...
@@ -337,9 +393,60 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
inputEl
.
current
.
focus
()
}
else
{
setCmdTemp
(
inputEl
.
current
.
innerText
)
=======
// const reattached = (event) =>
{
// let el = event.currentTarget
// var isBottomed = el.scrollHeight - el.scrollTop - el.clientHeight < 30
// if (isBottomed)
{
//
}
else
{
// // if (!inserted)
//
}
//
}
const
registerCommand
=
(
name
,
command
,
opts
)
=>
{
const
{
_commands
,
_INDEXcommands
,
_INDEXallMain
,
_INDEXcommandsMain
,
_INDEXall
,
commands
}
=
state
// TODO if no _commands[name] throw an error
// TODO if typeof command !== 'function' throw error
_commands
[
name
]
=
command
_INDEXcommands
[
name
]
=
[]
_INDEXallMain
[
name
]
=
[]
// TODO _command function goes here
commands
[
name
]
=
function
_command
()
{
const
steps
=
[]
const
args
=
[...
arguments
]
const
gidx
=
0
const
idx
=
0
const
step
=
0
const
root
=
{
steps
,
cmd
:
name
,
gidx
,
idx
}
const
ITEM
=
{
root
,
cmd
:
name
,
el
:
{}
}
root
.
gidx
=
_INDEXallMain
.
push
(
ITEM
)
-
1
root
.
idx
=
_INDEXcommandsMain
[
name
].
push
(
ITEM
)
-
1
function
append
(
cmd
,
params
,
el
)
{
let
item
=
{
el
,
cmd
,
root
,
gidx
,
idx
,
step
,
args
:
[...
arguments
]
}
if
(
cmd
)
{
item
=
{
el
,
cmd
,
root
,
gidx
,
idx
,
step
,
args
}
}
else
{
// item = ITEM
item
.
el
=
el
cmd
=
name
}
item
.
gidx
=
_INDEXall
.
push
(
item
)
-
1
item
.
idx
=
_INDEXcommands
[
cmd
].
push
(
item
)
-
1
item
.
step
=
steps
.
push
(
item
)
-
1
item
.
args
=
params
_appendItem
(
item
)
}
>>>>>>>
69029
a97a
(
remix
id
terminal
update
)
}
return
commands
[
name
]
}
<
<<<<<<
HEAD
/* start of mouse events */
const
mousedown
=
(
event
:
MouseEvent
)
=
>
{
...
...
@@ -837,6 +944,27 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
setPaste
(
true
)
setAutoCompleteState
(
prevState
=>
({
...
prevState
,
activeSuggestion
:
0
,
showSuggestions
:
false
}))
}
=======
const _appendItem = (item: any) =
>
{
let
{
_JOURNAL
,
_jobs
,
data
}
=
state
const
self
=
props
const
{
el
,
gidx
}
=
item
_JOURNAL
[
gidx
]
=
item
if
(
!
_jobs
.
length
)
{
// requestAnimationFrame(function updateTerminal ()
{
// self._jobs.forEach(el => self._view.journal.appendChild(el))
// self.scroll2bottom()
_jobs
=
[]
}
if
(
data
.
activeFilters
.
commands
[
item
.
cmd
])
_jobs
.
push
(
el
)
}
const
focusinput
=
()
=>
{
inputEl
.
current
.
focus
()
}
>>>>>>>
69029
a97a
(
remix
id
terminal
update
)
return
(
<
div
style=
{
{
height
:
'323px'
,
flexGrow
:
1
}
}
className=
'panel'
>
...
...
@@ -899,6 +1027,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
zIndex
:
-1
}}
></
div
>
<
div
className=
"terminal"
>
<
<<<<<<
HEAD
<
div
id=
'journal'
className=
'journal'
data
-
id=
'terminalJournal'
>
{
!
clearConsole
&&
<
TerminalWelcomeMessage
packageJson=
{
props
.
version
}
/>
}
{
newstate
.
journalBlocks
&&
newstate
.
journalBlocks
.
map
((
x
,
index
)
=>
{
...
...
@@ -933,6 +1062,19 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
<
div
id=
"terminalCli"
data
-
id=
"terminalCli"
className=
"cli"
onClick=
{
focusinput
}
>
<
span
className=
"prompt"
>
{
'>'
}
</
span
>
<
input
className=
"input"
ref=
{
inputEl
}
spellCheck=
"false"
contentEditable=
"true"
id=
"terminalCliInput"
data
-
id=
"terminalCliInput"
onChange=
{
(
event
)
=>
onChange
(
event
)
}
onKeyDown=
{
(
event
)
=>
handleKeyDown
(
event
)
}
value=
{
autoCompletState
.
userInput
}
onPaste=
{
handlePaste
}
></
input
>
=======
<
div
id=
"journal"
className=
"journal"
data
-
id=
"terminalJournal"
>
<
div
className=
"anchor"
>
{
/* ${background} */
}
<
div
className=
"overlay background"
></
div
>
{
/* ${text} */
}
<
div
className=
"overlay text"
></
div
>
</
div
>
</
div
>
<
div
id=
"terminalCli"
data
-
id=
"terminalCli"
className=
"cli"
onClick=
{
focusinput
}
>
<
span
className=
"prompt"
>
{
'>'
}
</
span
>
<
span
className=
"input"
ref=
{
inputEl
}
spellCheck=
"false"
contentEditable=
"true"
id=
"terminalCliInput"
data
-
id=
"terminalCliInput"
onPaste=
{
handlePaste
}
></
span
>
>>>>>>>
69029a97a (remix id terminal update)
</
div
>
</
div
>
</
div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment