hundredrabbits / Orca-c

Live Programming Environment(C Port)
http://wiki.xxiivv.com/orca
MIT License
485 stars 48 forks source link

Ensure console mouse events are turned off on exit #82

Closed Russtopia closed 2 years ago

Russtopia commented 2 years ago

If user uses mouse at all during a session, after exiting via CTRL-Q the (Linux) terminal will still spew out mouse events; this patch turns off the XTerm mouse reporting on exit.

npisanti commented 2 years ago

thanks for the hint! there is already a quit label for cleaning up things on quit, at line 3853 https://github.com/hundredrabbits/Orca-c/blob/master/tui_main.c#L3853 so it would be nice to add the printf before line 3858 https://github.com/hundredrabbits/Orca-c/blob/master/tui_main.c#L3858

as is possible to disable mouse on compiling, the code has to be guarded with #ifndef FEAT_NOMOUSE, like this

#ifndef FEAT_NOMOUSE
  printf("\033[?1003l\n"); // turn off console mouse events if they were active
#endif

then the tui_main.c file has to be formatted with clang-format, so that later commits are kept clean. As the committed code would be totally different, if you want you can open another PR for this or i can just fix this and push the changes, let me know what you prefer.

Russtopia commented 2 years ago

Ah, OK. I will re-work it and and update the push, thanks!

Russtopia commented 2 years ago

OK, I updated the PR, thanks.

npisanti commented 2 years ago

hi again! the position is fine, but it lacks the #ifdnef guards to disable that code when the --no-mouse option is used on compiling (as i stated in the comment above), can you plase add those two lines before and after the printf?

Russtopia commented 2 years ago

Fixed. My apologies for rushing and not reading your comment thoroughly.

npisanti commented 2 years ago

ok, that's perfect now, thanks for the fix!