#!/usr/bin/env python ''' This is a test of the effect of DECOM (origin mode) when saving and restoring the cursor position with DECSC and DECRC. ''' import sys import time def write(s): sys.stdout.write(s) sys.stdout.flush() write('\033[?6h') # Enable origin mode write('\033[2J') # Clear screen write('\033[9;16r1') # Set margins and output 1 time.sleep(1) write('\033[3;40H2') # Move to center and output 2 time.sleep(1) write('\0337') # Save cursor position write('\033[r3') # Reset margins and output 3 time.sleep(1) write('\03384') # Restore position and output 4 time.sleep(1) write('\033[?6l') # Disable origin mode write('\033[20H') # Move cursor down