Use bracketed paste mode when available

Terminal bracketed paste mode is enabled by sending "\e[?2004h"
to the terminal.

This causes pastes to start with "\e[200" and end with "\e[201~",
which allows us to detect paste mode automatically.

At exit bracketed paste mode is stopped by sending "\e[?2004l".