I think it's ready for a review, except a few issues -
the WINCH handling works on UXTerm, but not on gnome-terminal.
gnome-terminal seems it automatically refresh the line before we refresh.
Can you confirm it?
When ctrlC on linux, we scroll up a line when needed.
not figure out a good way to do this.
The multiline mode doesn't work on dumb term, and linenoise doesn't, either.
Is it okay to leave the dumb support alone?
I can confirm that gnome-terminal is worse than xterm. On both, I can cause problems if I resize the window too quickly, and on both it looks good if I resize the window sufficiently slowly. But it seems "Sufficiently slowly" is much slower for gnome-terminal than it is for xterm.
fmt.Println() always moves the cursor down or scrolls the window up as needed. See review below.
It is okay to leave dumb support alone. (In fact, TERM=dumb is always multi-line as implemented by this patch series. When the related bug report was opened, I thought something else was meant by the term "multi-line").
Review: Looks good overall. Individual patch review:
"glyph width is more precise than rune length" looks obviously correct. Merged and pushed. Thanks.
"getPrefix/SuffixGlyphs takes care of doubleWidth rune". These functions count glyphs (not screen widths), so this change is incorrect. These functions exist to squash combining characters. This change doesn't add any visible bugs because liner currently only calls these functions with a parameter of "1" so incrementing past 1 to 2 doesn't change the result. But if liner ever needs >1, this will break. Please drop this patch.
"support MultiLineMode" adds SetMultiLineMode to the example in the README. I'd rather it didn't; I prefer single line mode. Also this change breaks on windows (see comment below).
"support SIGWINCH" seems fine.
"multiLine windows support" should be squashed into "support MultiLineMode" so bisecting doesn't break on Windows. Also it looks like there's a typo: I think you mean "emit" instead of "omit".
"multiline: support CtrlC" Please don't leave dead code in place. All instances of bottomScrollUp should be removed. Also, "FIXME: moveDown has no effect" can be fixed by calling "fmt.Println()" s.maxRows-cursorRows times instead of calling s.moveDown, since you don't need to preserve the cursor's horizontal position.
Fix #55 and influxdb/influxdb#4279