Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
0395c174
Commit
0395c174
authored
Mar 10, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/ethereum: fix line editing setup and history
parent
80985f97
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
js.go
cmd/ethereum/js.go
+11
-6
No files found.
cmd/ethereum/js.go
View file @
0395c174
...
...
@@ -63,6 +63,7 @@ type jsre struct {
ethereum
*
eth
.
Ethereum
xeth
*
xeth
.
XEth
ps1
string
atexit
func
()
prompter
}
...
...
@@ -77,11 +78,13 @@ func newJSRE(ethereum *eth.Ethereum) *jsre {
js
.
prompter
=
dumbterm
{
bufio
.
NewReader
(
os
.
Stdin
)}
}
else
{
lr
:=
liner
.
NewLiner
()
lr
.
SetCtrlCAborts
(
true
)
defer
lr
.
Close
()
js
.
withHistory
(
func
(
hist
*
os
.
File
)
{
lr
.
ReadHistory
(
hist
)
})
defer
js
.
withHistory
(
func
(
hist
*
os
.
File
)
{
hist
.
Truncate
(
0
);
lr
.
WriteHistory
(
hist
)
}
)
lr
.
SetCtrlCAborts
(
true
)
js
.
prompter
=
lr
js
.
atexit
=
func
()
{
js
.
withHistory
(
func
(
hist
*
os
.
File
)
{
hist
.
Truncate
(
0
);
lr
.
WriteHistory
(
hist
)
})
lr
.
Close
()
}
}
return
js
}
...
...
@@ -100,7 +103,6 @@ func (self *jsre) UnlockAccount(addr []byte) bool {
}
// TODO: allow retry
if
err
:=
self
.
ethereum
.
AccountManager
()
.
Unlock
(
addr
,
pass
);
err
!=
nil
{
fmt
.
Println
(
"Unlocking failed: "
,
err
)
return
false
}
else
{
fmt
.
Println
(
"Account is now unlocked for this session."
)
...
...
@@ -127,7 +129,7 @@ func (self *jsre) interactive() {
for
{
input
,
err
:=
self
.
Prompt
(
self
.
ps1
)
if
err
!=
nil
{
return
break
}
if
input
==
""
{
continue
...
...
@@ -136,7 +138,7 @@ func (self *jsre) interactive() {
self
.
setIndent
()
if
indentCount
<=
0
{
if
input
==
"exit"
{
return
break
}
hist
:=
str
[
:
len
(
str
)
-
1
]
self
.
AppendHistory
(
hist
)
...
...
@@ -144,6 +146,9 @@ func (self *jsre) interactive() {
str
=
""
}
}
if
self
.
atexit
!=
nil
{
self
.
atexit
()
}
}
func
(
self
*
jsre
)
withHistory
(
op
func
(
*
os
.
File
))
{
...
...
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