mirror of https://github.com/chzyer/readline.git
adds Config option to disable bell; DisableBell
This commit is contained in:
parent
7f93d88cd5
commit
d25ac56026
|
@ -1,6 +1,7 @@
|
||||||
// Readline is a pure go implementation for GNU-Readline kind library.
|
// Readline is a pure go implementation for GNU-Readline kind library.
|
||||||
//
|
//
|
||||||
// example:
|
// example:
|
||||||
|
//
|
||||||
// rl, err := readline.New("> ")
|
// rl, err := readline.New("> ")
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// panic(err)
|
// panic(err)
|
||||||
|
@ -14,7 +15,6 @@
|
||||||
// }
|
// }
|
||||||
// println(line)
|
// println(line)
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
package readline
|
package readline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -68,6 +68,8 @@ type Config struct {
|
||||||
// it use in IM usually.
|
// it use in IM usually.
|
||||||
UniqueEditLine bool
|
UniqueEditLine bool
|
||||||
|
|
||||||
|
DisableBell bool
|
||||||
|
|
||||||
// filter input runes (may be used to disable CtrlZ or for translating some keys to different actions)
|
// 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
|
// -> output = new (translated) rune and true/false if continue with processing this one
|
||||||
FuncFilterInputRune func(rune) (rune, bool)
|
FuncFilterInputRune func(rune) (rune, bool)
|
||||||
|
@ -301,6 +303,7 @@ func (i *Instance) Write(b []byte) (int, error) {
|
||||||
// WriteStdin prefill the next Stdin fetch
|
// WriteStdin prefill the next Stdin fetch
|
||||||
// Next time you call ReadLine() this value will be writen before the user input
|
// Next time you call ReadLine() this value will be writen before the user input
|
||||||
// ie :
|
// ie :
|
||||||
|
//
|
||||||
// i := readline.New()
|
// i := readline.New()
|
||||||
// i.WriteStdin([]byte("test"))
|
// i.WriteStdin([]byte("test"))
|
||||||
// _, _= i.Readline()
|
// _, _= i.Readline()
|
||||||
|
|
|
@ -214,7 +214,9 @@ func (t *Terminal) ioloop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Terminal) Bell() {
|
func (t *Terminal) Bell() {
|
||||||
|
if !t.cfg.DisableBell {
|
||||||
fmt.Fprintf(t, "%c", CharBell)
|
fmt.Fprintf(t, "%c", CharBell)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Terminal) Close() error {
|
func (t *Terminal) Close() error {
|
||||||
|
|
Loading…
Reference in New Issue