mirror of https://github.com/chzyer/readline.git
support insert tag char (#74)
This commit is contained in:
parent
4ffff9f41c
commit
31eb6be473
|
@ -0,0 +1,7 @@
|
|||
package readline
|
||||
|
||||
type TabCompleter struct{}
|
||||
|
||||
func (t *TabCompleter) Do([]rune, int) ([][]rune, int) {
|
||||
return [][]rune{[]rune("\t")}, 0
|
||||
}
|
|
@ -93,6 +93,9 @@ func (c *Config) Init() error {
|
|||
c.EOFPrompt = ""
|
||||
}
|
||||
|
||||
if c.AutoComplete == nil {
|
||||
c.AutoComplete = &TabCompleter{}
|
||||
}
|
||||
if c.FuncGetWidth == nil {
|
||||
c.FuncGetWidth = GetScreenWidth
|
||||
}
|
||||
|
|
|
@ -430,7 +430,13 @@ func (r *RuneBuffer) output() []byte {
|
|||
}
|
||||
|
||||
} else {
|
||||
buf.Write([]byte(string(r.buf)))
|
||||
for idx := range r.buf {
|
||||
if r.buf[idx] == '\t' {
|
||||
buf.WriteString(strings.Repeat(" ", TabWidth))
|
||||
} else {
|
||||
buf.WriteRune(r.buf[idx])
|
||||
}
|
||||
}
|
||||
if r.isInLineEdge() {
|
||||
buf.Write([]byte(" \b"))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue