Terminfo

Not sure if the second commit does the correct thing since it changes the behavior for values in [-32768;-3]