diff --git a/go.mod b/go.mod index 66180f6..8ba5d4b 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,8 @@ -module github.com/chzyer/readline +module github.com/henderjon/readline go 1.15 require ( github.com/chzyer/test v1.0.0 - golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 + golang.org/x/sys v0.12.0 ) - -require github.com/chzyer/logex v1.2.1 diff --git a/go.sum b/go.sum index 2358df0..2234adc 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,9 @@ github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= +github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI= +github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk= github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= -golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng= golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/readline.go b/readline.go index 63b9171..38100e7 100644 --- a/readline.go +++ b/readline.go @@ -1,20 +1,20 @@ // Readline is a pure go implementation for GNU-Readline kind library. // // example: -// rl, err := readline.New("> ") -// if err != nil { -// panic(err) -// } -// defer rl.Close() // -// for { -// line, err := rl.Readline() -// if err != nil { // io.EOF -// break -// } -// println(line) -// } +// rl, err := readline.New("> ") +// if err != nil { +// panic(err) +// } +// defer rl.Close() // +// for { +// line, err := rl.Readline() +// if err != nil { // io.EOF +// break +// } +// println(line) +// } package readline import ( @@ -68,6 +68,8 @@ type Config struct { // it use in IM usually. UniqueEditLine bool + DisableBell bool + // filter input runes (may be used to disable CtrlZ or for translating some keys to different actions) // -> output = new (translated) rune and true/false if continue with processing this one FuncFilterInputRune func(rune) (rune, bool) @@ -301,9 +303,10 @@ func (i *Instance) Write(b []byte) (int, error) { // WriteStdin prefill the next Stdin fetch // Next time you call ReadLine() this value will be writen before the user input // ie : -// i := readline.New() -// i.WriteStdin([]byte("test")) -// _, _= i.Readline() +// +// i := readline.New() +// i.WriteStdin([]byte("test")) +// _, _= i.Readline() // // gives // diff --git a/terminal.go b/terminal.go index 38413d0..1e1774a 100644 --- a/terminal.go +++ b/terminal.go @@ -214,7 +214,9 @@ func (t *Terminal) ioloop() { } func (t *Terminal) Bell() { - fmt.Fprintf(t, "%c", CharBell) + if !t.cfg.DisableBell { + fmt.Fprintf(t, "%c", CharBell) + } } func (t *Terminal) Close() error {