7

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.

1 Answer 1

14

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.

2
  • Yes, exactly this :) Excellent answer! Apr 22, 2013 at 7:30
  • 4
    TL;DR - use the reset command to return to normal mode
    – isapir
    Oct 30, 2018 at 18:22

You must log in to answer this question.

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