Ugh. Some of this is ugly. We should really include <curses.h> etc, but there are too many name clashes for that right now.
Let's see how nasty it is to clean things up. For real.
This is a slightly updated version of uemacs-PK (PK is Pekka Kutvonen) which was used at Helsinki University a long time ago. My fingers cannot be retrained.