diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-22 05:36:55 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-22 05:36:55 +0800 |
commit | 3f5b348451a8acd4c22be1c320808dd4eadc38d3 (patch) | |
tree | a57d4ef7706cf6f8a6c94eb37ba3295f6886e192 /ethereum/repl_darwin.go | |
parent | 941e0ba60adfb1f1f279f5c406eab5e4ab9d6e21 (diff) | |
download | dexon-3f5b348451a8acd4c22be1c320808dd4eadc38d3.tar.gz dexon-3f5b348451a8acd4c22be1c320808dd4eadc38d3.tar.zst dexon-3f5b348451a8acd4c22be1c320808dd4eadc38d3.zip |
Fixes #50
Diffstat (limited to 'ethereum/repl_darwin.go')
-rw-r--r-- | ethereum/repl_darwin.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/ethereum/repl_darwin.go b/ethereum/repl_darwin.go index 1b98c2150..cb11adfc7 100644 --- a/ethereum/repl_darwin.go +++ b/ethereum/repl_darwin.go @@ -1,17 +1,37 @@ 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 := make(chan os.Signal, 1) + signal.Notify(c, syscall.SIGWINCH) + go func() { + for sig := range c { + switch sig { + case syscall.SIGWINCH: + C.rl_resize_terminal() + default: + + } + } + }() +} + func readLine(prompt *string) *string { var p *C.char @@ -59,6 +79,7 @@ func (self *JSRepl) setIndent() { } func (self *JSRepl) read() { + initReadLine() L: for { switch result := readLine(&self.prompt); true { |