Make linenoise.h C++ compatible

I've made a few changes to linenoise.h so it can be included in a C++ application.

Also I ran into a bug with the escape sequence processing on a "real" serial connection where the first byte of the sequence could be lost if the `read` call returns 1 rather than 2 bytes.