ggerganov / imtui

ImTui: Immediate Mode Text-based User Interface C++ Library
https://imtui.ggerganov.com
MIT License
3.04k stars 127 forks source link

Mouse events reported in terminal #11

Closed safarp closed 4 years ago

safarp commented 4 years ago

When I run imtui-example-ncurses0 or hnterm (with mouse support enabled) in my Linux terminal, the mouse events are reported into the terminal after the apps are exited.

I believe that it is because of the printf("\033[?1003h\n");. When I add a code to disable mouse movement printf("\033[?1003l\n"); before the application is exited, everything is fine and mouse events are not reported into the terminal anymore.

I also found some useful information about it here.

ggerganov commented 4 years ago

Thanks for the report. I just pushed a fix

AaronKel commented 5 months ago

I think the shutdown mechanism needs to be expanded because you can still see the mouse events in the event of a SIGINT or SIGSEGV I added something like this to fix it but I guess it can be handled more elegantly

void finish(int sig){
    ImTui_ImplText_Shutdown();
    ImTui_ImplNcurses_Shutdown();

    exit(0);
}

int main() {
    signal(SIGINT, finish);