jupyter-xeus / cpp-terminal

C++ library for writing multiplatform terminal applications
https://jupyter-xeus.github.io/cpp-terminal/
Other
490 stars 53 forks source link

mouse sending random characters to the terminal after examples/minimal ends #316

Closed wmarini closed 10 months ago

wmarini commented 10 months ago

Hello! I compiled the latest commit on my Ubuntu 22.04.3 Linux machine. After compiling, I found an issue with the "examples/minimal" program. When it finishes running, the mouse causes the terminal to display random characters when one of its button is pressed.

image

See below how to reproduce this issue:

$ git log -n 1 --oneline
$ git status
# moving to the `build` directory
$ cd ../build/cpp-terminal-master
$ cmake --build . --target clean
$ cmake --build .
$ examples/minimal

Full output (before I lost control of the mouse in that terminal):

wmarini@mineta:~/installs/cpp-terminal$ git log -n 1 --oneline
6059c0d (HEAD -> master, origin/master, origin/HEAD) Update attach_console_minimal.cpp
wmarini@mineta:~/installs/cpp-terminal$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
wmarini@mineta:~/installs/cpp-terminal$ cd ../build/cpp-terminal-master
wmarini@mineta:~/installs/build/cpp-terminal-master$ cmake --build . --target clean
[2/2] Cleaning all built files...
Cleaning... 91 files.
wmarini@mineta:~/installs/build/cpp-terminal-master$ cmake --build .
[14/85] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/event.cpp.o
/home/wmarini/installs/cpp-terminal/cpp-terminal/event.cpp: In member function ‘void Term::Event::parse(const string&)’:
/home/wmarini/installs/cpp-terminal/cpp-terminal/event.cpp:279:24: warning: ‘type’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  279 |     Term::Button::Type type;
      |                        ^~~~
[24/85] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/sigwinch.cpp.o
/home/wmarini/installs/cpp-terminal/cpp-terminal/platforms/sigwinch.cpp: In static member function ‘static bool Term::Private::Sigwinch::isSigwinch(const int&)’:
/home/wmarini/installs/cpp-terminal/cpp-terminal/platforms/sigwinch.cpp:101:11: warning: ignoring return value of ‘ssize_t read(int, void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  101 |     ::read(m_fd, &fdsi, sizeof(fdsi));
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
[85/85] Linking CXX executable tests/Events
certik commented 10 months ago

@wmarini thanks! I think this was probably caused by https://github.com/jupyter-xeus/cpp-terminal/pull/309.

@flagarde, do you think you could please have a look?

flagarde commented 10 months ago

@certik @wmarini Sure, I will have a look. This mouse event support is quite new and not yet bulletproof. Thx for the test and the feedback

flagarde commented 10 months ago

@wmarini could you tell me what terminal are you using ?

flagarde commented 10 months ago

@wmarini I found the problem and pushed a very naive fix. Please have a try

wmarini commented 10 months ago

@wmarini could you tell me what terminal are you using ?

It's a gnome-terminal.

$ echo $TERM
xterm-256color
$ echo $SHELL
/bin/bash
$ tty
/dev/pts/1
flagarde commented 10 months ago

@wmarini could you tell me what terminal are you using ?

It's a gnome-terminal.

$ echo $TERM
xterm-256color
$ echo $SHELL
/bin/bash
$ tty
/dev/pts/1

Thx I did some basic test with this terminal. Most of the problem reported should be fixed. There is still corner cases but I need more time to investigate. But the last commits should solve the issue you posted

wmarini commented 10 months ago

@wmarini could you tell me what terminal are you using ?

It's a gnome-terminal.

$ echo $TERM
xterm-256color
$ echo $SHELL
/bin/bash
$ tty
/dev/pts/1

Thx I did some basic test with this terminal. Most of the problem reported should be fixed. There is still corner cases but I need more time to investigate. But the last commits should solve the issue you posted

Yes, it 's fixed! A quick test with the last commit and that's working fine now! ;) Thank you!

flagarde commented 10 months ago

@wmarini Closing the issue then, thank you for the report