Previously the code enabled sending emulated up/down key press events to
the terminal only if the current screen is the alternate buffer. The
problem with this approach is that when detaching a tab/view, a new
TerminalDisplay is constructed and _isPrimaryScreen is initialized to
true even though the current screen in the detached tab is the alternate
one.
Since the Session is preserved when detaching a tab, move that bit of
code to Session, and query the Session about the currently used screen
buffer.