diff options
author | zelig <viktor.tron@gmail.com> | 2014-05-24 01:25:49 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2014-05-24 01:25:49 +0800 |
commit | 72df038d25c50a27adae8ea528dcedd3537267cf (patch) | |
tree | 44b358714448d492dcf8cdcddb4d1e6e57c4318b /ethereum/repl_darwin.go | |
parent | 7f1a4c377c18055137909521d809251248b7b5af (diff) | |
parent | d35380c19e5ce92b57158e7780f7105dc4136916 (diff) | |
download | go-tangerine-72df038d25c50a27adae8ea528dcedd3537267cf.tar go-tangerine-72df038d25c50a27adae8ea528dcedd3537267cf.tar.gz go-tangerine-72df038d25c50a27adae8ea528dcedd3537267cf.tar.bz2 go-tangerine-72df038d25c50a27adae8ea528dcedd3537267cf.tar.lz go-tangerine-72df038d25c50a27adae8ea528dcedd3537267cf.tar.xz go-tangerine-72df038d25c50a27adae8ea528dcedd3537267cf.tar.zst go-tangerine-72df038d25c50a27adae8ea528dcedd3537267cf.zip |
Merge branch 'develop' of github.com:ethereum/go-ethereum into develop
Diffstat (limited to 'ethereum/repl_darwin.go')
-rw-r--r-- | ethereum/repl_darwin.go | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/ethereum/repl_darwin.go b/ethereum/repl_darwin.go index 1b98c2150..b61d4edd7 100644 --- a/ethereum/repl_darwin.go +++ b/ethereum/repl_darwin.go @@ -1,17 +1,42 @@ package main +// #cgo darwin CFLAGS: -I/usr/local/opt/readline/include +// #cgo darwin LDFLAGS: -L/usr/local/opt/readline/lib // #cgo LDFLAGS: -lreadline // #include <stdio.h> // #include <stdlib.h> // #include <readline/readline.h> // #include <readline/history.h> import "C" - import ( + "os" + "os/signal" "strings" + "syscall" "unsafe" ) +func initReadLine() { + C.rl_catch_sigwinch = 0 + C.rl_catch_signals = 0 + c := make(chan os.Signal, 1) + signal.Notify(c, syscall.SIGWINCH) + signal.Notify(c, os.Interrupt) + go func() { + for sig := range c { + switch sig { + case syscall.SIGWINCH: + C.rl_resize_terminal() + + case os.Interrupt: + C.rl_cleanup_after_signal() + default: + + } + } + }() +} + func readLine(prompt *string) *string { var p *C.char @@ -59,6 +84,7 @@ func (self *JSRepl) setIndent() { } func (self *JSRepl) read() { + initReadLine() L: for { switch result := readLine(&self.prompt); true { @@ -76,7 +102,7 @@ L: break L } - addHistory(str) //allow user to recall this line + addHistory(str[:len(str)-1]) //allow user to recall this line self.parseInput(str) |