pkg/term — pull request #2 by twpayne (2014-05-07 23:48:32+00:00)
Title: Add SetRaw and SetCbreak

This PR aims to fix #1. It adds `SetRaw` and `SetCbreak` functions, ported directly from [Python's tty module](https://docs.python.org/2/library/tty.html).

Notes:
* There seem to be three modes for serial devices: raw, cooked, and cbreak. Setting cooked mode reliably seems to be platform specific.
* [Different](http://www.lafn.org/~dave/linux/terminalIO.html) [sources](http://man7.org/tlpi/code/online/dist/tty/tty_functions.c.html) [vary](https://github.com/enthought/Python-2.7.3/blob/master/Lib/tty.py) on exactly how raw and cbreak mode should be set. This PR follows the Python implementation, on the assumption that it has been widely used and tested.
* This PR has only been (lightly) tested on Mac OS X with a PL2303 USB-to-serial driver.
* TIL that Go has a `&^=` operator.

Feedback welcome: all code can be improved!