Source from https://code.google.com/p/fbterm/ , version 1.7.0