linux: limit cursor position to within screen
remove some debug printfs