Implemented program event filtering.

Fixed terminal cursor going out of bounds.