peterh/liner — pull request #12 by michaelmacinnis (2014-04-19 00:05:44+00:00)
Title: Switching oh to liner

Hi Peter,

I recently modified my shell (https://github.com/michaelmacinnis/oh) to use your liner line editing library.

I had to make a few modifications. You may not be interested in these changes but I thought I would send a pull request anyway.

### Losing characters
Because I'm sharing the terminal with other applications I can't use bufio (unless you know how to stop it from stealing characters). I've modified liner to use unbuffered input and copied the readRune structure and methods from src/pkg/fmt/scan.go

### Terminal mode problems
Sharing the terminal with other applications also causes problems for programs that expect the terminal to be in canonical mode. I changed Prompt to set the terminal mode before prompting and restore it after reading a line.

### Unsupported terminals
Using unbuffered input and setting/resetting the terminal mode mode make it seem less likely that one would want to use liner on an unsupported terminal. I changed NewLiner to panic on an unsupported terminal and exposed UnsupportedTerminal to allow callers to check if the terminal is supported before calling NewLiner.

### Auto-complete if there is only one completion
I've changed tabComplete to automatically return the completion if there is only a single completion.

### Tab and shift-tab cycle through completions
I also changed tabComplete so that tab and shift-tab cycle through completions.

### Windows
I don't have a Windows development machine for testing but I have attempted to keep the Windows version in sync.

Thanks for writing liner!

Michael.