adb shell: Win32: fix Ctrl-C, tab completion, line editing, server echo

The 'adb shell' command on Windows has had problems:

* Ctrl-C killed the local Windows adb.exe process instead of sending the
Ctrl-C to the Android device.

* Local echo was enabled, causing everything typed to be displayed twice.

* Line input was enabled, so the Android device only received input
after hitting enter. This meant that tab completion did not work because
the tab wasn't seen by the shell until pressing enter.

* The usual input line editing keys did not work (Ctrl-A to go to the
beginning of the line, etc.).

This commit fixes these issues by reconfiguring the Win32 console and
then translating input into what Gnome Terminal would send, in effect
somewhat emulating a Unix terminal.

This does not fix all Win32 console issues, but is designed to be better
than what we had before, and to make the common day-to-day usage much
more comfortable and usable.

Change-Id: Idb10e0b634e27002804fa99c09a64e7176cf7c09
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
3 files changed