Reimplement terminal parameters in C; clean up term.c, create terminal.c.