3 ms·
I think by default your terminal is in "cooked" mode, where stdin is buffered a line at a time. Try cat /dev/fd/0 then type some things including backspace
by evmar 13y ago
I think by default your terminal is in "cooked" mode, where stdin is buffered a line at a time. Try
cat /dev/fd/0
then type some things including backspace and enter.
However, you don't need ncurses to change this behavior. termios is the lower-level C API. You can do it from Go with the syscall APIs but I suspect it might be frustrating to make portable.
https://code.google.com/p/go/source/browse/ssh/terminal/util.go?repo=crypto&r=33d6505b6597ddd49a330ed2f8707bcb2c52318c#37 https://code.google.com/p/go/source/browse/ssh/terminal/util...
- zellyn 13y agoYep, it's a bit gnarly. But at least linux/MacOS is straightforward: https://groups.google.com/d/msg/golang-nuts/yRkGpw624-I/htJtgKNUIZMJ https://groups.google.com/d/msg/golang-nuts/yRkGpw624-I/htJt...
- songgao 13y agoThere's a package that does that: https://github.com/nsf/termbox-go https://github.com/nsf/termbox-go
- jevinskie 13y agoAh you're right, I was thinking TTY didn't buffer at all but it does line buffering. That is contrasted to regular buffering if it wasn't a TTY.