1

While running some program (Configure), my terminal will be messed up. My typing is not shown. I can use "stty sane" to fix it but I notice that whenever I click my mouse on the terminal (I use PuTTY), strange characters appear. e.g.

# O:#O: O:#O: 7-#7- BE#BE ...

They seem to be 5 character sequences and if I click on the same location, the same sequence appears.

I know that I can fix it using "reset" but I want to understand what they are and if there is a way to fix it without reset. And maybe even a way to find the root cause of what inside "Configure" messed up my terminal.

1 Answer 1

2

Those are xterm-style "mouse" events. You could in principle turn off those using a suitable printf or echo, but reset does it already as part of the rs1 or rs2 string in the terminal description (see output of "infocmp").

reset uses this for instance:

    rs1=\Ec,                                                                
    rs2=\E[!p\E[?3;4l\E[4l\E>,

and prefers the latter (the former is a hard-reset). The \E is the escape character. Offhand, that first chunk in rs2, \E\[!p is a soft-reset, which generally resets the mouse along with most other useful things. A printf would be

printf '\033[!p'

which is more typing than

reset

(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 infocmp -x:

XM=\E[?1006;1000%?%p1%{1}%=%th%el%;,

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

printf '\033[?1000l'

(lowercase L disables), and kill just the mouse.

You're seeing those because "some program" doesn't clean up after itself.

1
  • Thank you! That last printf 1000l seems to do the trick for my mouse!
    – some user
    Dec 2, 2021 at 1:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .