diff --git a/operation.go b/operation.go index a1e5198..1e2a2b7 100644 --- a/operation.go +++ b/operation.go @@ -203,7 +203,8 @@ func (o *Operation) ioloop() { } // treat as EOF - o.buf.WriteString("^D\n") + o.buf.WriteString(o.cfg.EOFPrompt + "\n") + o.buf.Reset() o.errchan <- io.EOF case CharInterrupt: if o.IsSearchMode() { @@ -219,7 +220,8 @@ func (o *Operation) ioloop() { } o.buf.MoveToLineEnd() o.buf.Refresh(nil) - o.buf.WriteString("^C\n") + o.buf.WriteString(o.cfg.InterruptPrompt + "\n") + o.buf.Reset() o.errchan <- ErrInterrupt default: if o.IsSearchMode() { diff --git a/readline.go b/readline.go index dc49ff1..7ab8e45 100644 --- a/readline.go +++ b/readline.go @@ -23,6 +23,9 @@ type Config struct { // If VimMode is true, readline will in vim.insert mode by default VimMode bool + InterruptPrompt string + EOFPrompt string + Stdout io.Writer Stderr io.Writer @@ -43,6 +46,18 @@ func (c *Config) Init() error { if c.HistoryLimit <= 0 { c.HistoryLimit = 500 } + + if c.InterruptPrompt == "" { + c.InterruptPrompt = "^C" + } else if c.InterruptPrompt == "\n" { + c.InterruptPrompt = "" + } + if c.EOFPrompt == "" { + c.EOFPrompt = "^D" + } else if c.EOFPrompt == "\n" { + c.EOFPrompt = "" + } + return nil }