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
16421106
Commit
16421106
authored
May 19, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added multi-line support
parent
3b7707c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
9 deletions
+35
-9
javascript_console.go
ethereum/javascript_console.go
+3
-2
repl_darwin.go
ethereum/repl_darwin.go
+31
-6
repl_windows.go
ethereum/repl_windows.go
+1
-1
No files found.
ethereum/javascript_console.go
View file @
16421106
...
...
@@ -101,14 +101,15 @@ func (self *JSRE) Run(code string) (otto.Value, error) {
type
JSRepl
struct
{
re
*
JSRE
prompt
string
}
func
NewJSRepl
(
ethereum
*
eth
.
Ethereum
)
*
JSRepl
{
return
&
JSRepl
{
re
:
NewJSRE
(
ethereum
)}
return
&
JSRepl
{
re
:
NewJSRE
(
ethereum
)
,
prompt
:
"> "
}
}
func
(
self
*
JSRepl
)
Start
()
{
fmt
.
Println
(
"Eth JavaScript console"
)
self
.
read
()
}
...
...
ethereum/repl_darwin.go
View file @
16421106
...
...
@@ -6,7 +6,11 @@ package main
// #include <readline/readline.h>
// #include <readline/history.h>
import
"C"
import
"unsafe"
import
(
"strings"
"unsafe"
)
func
readLine
(
prompt
*
string
)
*
string
{
var
p
*
C
.
char
...
...
@@ -37,19 +41,40 @@ func addHistory(s string) {
C
.
free
(
unsafe
.
Pointer
(
p
))
}
func
(
self
*
JSRepl
)
read
()
{
prompt
:=
"eth >>> "
var
indentCount
=
0
var
str
=
""
func
(
self
*
JSRepl
)
setIndent
()
{
open
:=
strings
.
Count
(
str
,
"{"
)
open
+=
strings
.
Count
(
str
,
"("
)
closed
:=
strings
.
Count
(
str
,
"}"
)
closed
+=
strings
.
Count
(
str
,
")"
)
indentCount
=
open
-
closed
if
indentCount
<=
0
{
self
.
prompt
=
"> "
}
else
{
self
.
prompt
=
strings
.
Join
(
make
([]
string
,
indentCount
*
2
),
".."
)
self
.
prompt
+=
" "
}
}
func
(
self
*
JSRepl
)
read
()
{
L
:
for
{
switch
result
:=
readLine
(
&
prompt
);
true
{
switch
result
:=
readLine
(
&
self
.
prompt
);
true
{
case
result
==
nil
:
break
L
//exit loop
case
*
result
!=
""
:
//ignore blank lines
addHistory
(
*
result
)
//allow user to recall this line
str
+=
*
result
+
"
\n
"
self
.
setIndent
()
if
indentCount
<=
0
{
addHistory
(
str
)
//allow user to recall this line
self
.
parseInput
(
*
result
)
self
.
parseInput
(
str
)
}
}
}
}
ethereum/repl_windows.go
View file @
16421106
...
...
@@ -9,7 +9,7 @@ import (
func
(
self
*
JSRepl
)
read
()
{
reader
:=
bufio
.
NewReader
(
os
.
Stdin
)
for
{
fmt
.
Printf
(
"eth >>> "
)
fmt
.
Printf
(
self
.
prompt
)
str
,
_
,
err
:=
reader
.
ReadLine
()
if
err
!=
nil
{
fmt
.
Println
(
"Error reading input"
,
err
)
...
...
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