terminal.py: Fix home/end/page up/page down