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
b7dc1e95
Commit
b7dc1e95
authored
Sep 11, 2017
by
serapath
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ADD save command input history and use arrow keys to navigate
parent
c5a01723
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
4 deletions
+30
-4
terminal.js
src/app/panels/terminal.js
+30
-4
No files found.
src/app/panels/terminal.js
View file @
b7dc1e95
...
...
@@ -189,6 +189,7 @@ class Terminal {
self
.
_view
.
input
=
yo
`
<span class=
${
css
.
input
}
contenteditable="true" onkeydown=
${
change
}
></span>
`
self
.
_view
.
input
.
innerText
=
'
\
n'
self
.
_view
.
cli
=
yo
`
<div class=
${
css
.
cli
}
>
<span class=
${
css
.
prompt
}
>
${
'>'
}
</span>
...
...
@@ -397,19 +398,44 @@ class Terminal {
self
.
event
.
trigger
(
'resize'
,
[
self
.
_api
.
getPosition
(
event
)])
}
self
.
_cmdHistory
=
[]
self
.
_cmdTemp
=
''
return
self
.
_view
.
el
function
change
(
event
)
{
if
(
self
.
_view
.
input
.
innerText
.
length
===
0
)
self
.
_view
.
input
.
innerText
+=
'
\
n'
if
(
event
.
which
===
13
)
{
if
(
event
.
ctrlKey
)
{
// <ctrl+enter>
self
.
_view
.
input
.
appendChild
(
document
.
createElement
(
'br'
))
self
.
scroll2bottom
()
self
.
_view
.
input
.
innerText
+=
'
\
n'
putCursor2End
(
self
.
_view
.
input
)
self
.
scroll2bottom
()
}
else
{
// <enter>
event
.
preventDefault
()
self
.
commands
.
script
(
self
.
_view
.
input
.
innerText
)
self
.
_view
.
input
.
innerHTML
=
''
var
script
=
self
.
_view
.
input
.
innerText
.
trim
()
self
.
_view
.
input
.
innerText
=
'
\
n'
if
(
script
.
length
)
{
self
.
_cmdHistory
.
push
(
'
\
n'
+
script
)
self
.
commands
.
script
(
script
)
}
}
}
else
if
(
event
.
which
===
38
)
{
// <arrowUp>
var
len
=
self
.
_cmdHistory
.
length
if
(
len
===
0
)
return
event
.
preventDefault
()
if
(
self
.
_cmdIndex
===
undefined
)
{
self
.
_cmdIndex
=
len
-
1
self
.
_cmdTemp
=
self
.
_view
.
input
.
innerText
}
else
if
(
self
.
_cmdIndex
===
0
)
return
else
self
.
_cmdIndex
-=
1
self
.
_view
.
input
.
innerText
=
self
.
_cmdHistory
[
self
.
_cmdIndex
]
self
.
scroll2bottom
()
}
else
if
(
event
.
which
===
40
)
{
// <arrowDown>
if
(
self
.
_cmdIndex
===
undefined
)
return
else
if
(
self
.
_cmdIndex
===
self
.
_cmdHistory
.
length
-
1
)
self
.
_cmdIndex
=
undefined
else
self
.
_cmdIndex
+=
1
self
.
_view
.
input
.
innerText
=
self
.
_cmdHistory
[
self
.
_cmdIndex
]
||
self
.
_cmdTemp
putCursor2End
(
self
.
_view
.
input
)
self
.
scroll2bottom
()
}
}
function
putCursor2End
(
editable
)
{
...
...
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