Those are xterm-style "mouse" events. You could in principle turn off those using a suitable
reset does it already as part of the
rs2 string in the terminal description (see output of "infocmp").
reset uses this for instance:
and prefers the latter (the former is a hard-reset). The
\E is the escape character. Offhand, that first chunk in
\E\[!p is a soft-reset, which generally resets the mouse along with most other useful things. A printf would be
which is more typing than
(even if you use some non-standard
echo which knows about
\E). But that comment about arrow keys: the soft reset puts the cursor-keys back in normal mode, while vi thinks they're in application mode.
To disable only the mouse, take a look at the output of
That tells ncurses how to enable/disable the mouse. Your terminal description isn't exactly that, but the
1000 is the normal mouse mode that your example shows. So... you could do this
(lowercase L disables), and kill just the mouse.
You're seeing those because "some program" doesn't clean up after itself.