KDE Konsole reacts on mouse clicks in a strange way

6

From time to time my KDE Konsole goes crazy, every time I click in it with the mouse it print out garbage characters :) It's not really annoying, I just close it, but I'm curious why this happens.

Ferenc Deak

Posted 2013-04-19T08:28:51.110

Reputation: 389

Answers

12

Let me guess: do you mean the effect that you get when you execute the following command?

printf '\e[?1000h'

What happens is the following. There are two kinds of programs running in a terminal emulator like konsole: those that rely on the basic mouse handling offered by the terminal program (e.g.: left button selects, middle button pastes), and those that want to do their own interpretation of mouse events. Most programs, such as bash, do the former, midnight commander (mc) is an example of the latter. If a program wants to interpret mouse events by itself, it sends a certain "escape sequence" (like the one above) to konsole, so that konsole sends back the coordinates of the mouse whenever a button is pressed; when the program stops, it sends another "escape sequence" to konsole, so that konsole returns to its normal mode.

What happened in your case is that konsole received the escape sequence without a cooperating program running. There are several possible reasons:

  • A badly programmed tool switched the mouse mode and then crashed without switching back.

  • You dumped some binary data, e.g., some executable program to the screen, which contained the mouse switching escape sequence.

  • You misspelled some escape sequence, that was supposed to, e.g., change the font or the background colour in your prompt and accidentally got the mouse switching escape sequence.

The same applies to other terminal emulator programs like xterm or gnome-terminal. (The mouse switching escape sequence was introduced in xterm; both konsole and gnome-terminal copied it.) By the way, it's usually not necessary to close konsole if something like this happens. You can use the reset command to return to the normal mode.

Uwe

Posted 2013-04-19T08:28:51.110

Reputation: 1 043

1TL;DR - use the reset command to return to normal mode – isapir – 2018-10-30T18:22:55.620

Yes, exactly this :) Excellent answer! – Ferenc Deak – 2013-04-22T07:30:44.297