peterh/liner — pull request #16 by lucacervasio (2014-05-23 12:20:37+00:00)
Title: Printing Above Prompt

Hi, I'm using your package to implement a CLI. While writing on the prompt line, I dump logs on the screen (using `fmt.Println`) and they overwrite the prompt, which is annoying to me.

So I tried to improve the package adding a `line.PrintAbovePrompt` func. Hope I didn't mess up the code.
Let me know what you think and in case I'll try to correct.

Thanks
Luca

Here a working example (I'm importing `github.com/lucacervasio/liner` just because I forked your repo for the PR).

```go
package main

import (
"fmt"
"github.com/lucacervasio/liner"
"os"
"os/signal"
"strings"
"time"
)

var line *liner.State = liner.NewLiner()

func main() {
go logsDumper()
defer line.Close()

c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
for sig := range c {
// sig is a ^C, handle it
if sig.String() == "interrupt" {
fmt.Printf("\n")
line.Close()
os.Exit(0)
}
}
}()

baseCmds := []string{"exit", "help", "version", "list", "status", "shutdown", "uptime"}

line.SetCompleter(func(line string) (c []string) {
for _, n := range baseCmds {
if strings.HasPrefix(n, strings.ToLower(line)) {
c = append(c, n)
}
}
return
})

for {

if cmd, err := line.Prompt("Prompt> "); err != nil {
fmt.Println("Error reading line: ", err)
} else {
if cmd != "" && cmd != "\n" && cmd != "\r\n" {
line.AppendHistory(cmd)
fmt.Println("Ei you said", cmd)
}
}

}

}

func logsDumper() {
for {
line.PrintAbovePrompt("Hello")
time.Sleep(2 * time.Second)
}
}
```