Skip to content

Commit

Permalink
Fixes #50
Browse files Browse the repository at this point in the history
  • Loading branch information
obscuren committed May 21, 2014
1 parent 941e0ba commit 3f5b348
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion ethereum/repl_darwin.go
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -59,6 +79,7 @@ func (self *JSRepl) setIndent() {
}

func (self *JSRepl) read() {
initReadLine()
L:
for {
switch result := readLine(&self.prompt); true {
Expand Down

0 comments on commit 3f5b348

Please sign in to comment.