Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using InputMode::Mouse triggers termbox assertion #32

Closed
panicbit opened this issue May 5, 2015 · 11 comments
Closed

Using InputMode::Mouse triggers termbox assertion #32

panicbit opened this issue May 5, 2015 · 11 comments

Comments

@panicbit
Copy link
Contributor

panicbit commented May 5, 2015

Using termbox.set_input_mode(InputMode::Mouse) and poll_event(…) triggers an assertion in termbox. It doesn't seem to trigger imediately after a poll but when deinitializing rust-/termbox.

Here's a minimal example:

extern crate rustbox;

fn main() {
    let rustbox = rustbox::RustBox::init(Default::default()).unwrap();
    rustbox.set_input_mode(rustbox::InputMode::Mouse);
    rustbox.poll_event(true);
}

What's weird, though, is that the equivalent C program does not trigger the assertion:

#include "termbox.h"

int main(int argc, char **argv) {
    tb_init();
    tb_select_input_mode(TB_INPUT_MOUSE);

    struct tb_event ev;
    tb_poll_event(&ev);

    tb_shutdown();
    return 0;
}
@sru
Copy link
Contributor

sru commented May 6, 2015

Both programs throw error on pressing escape key and only escape key. They do not throw error on other keys however. It's probably a bug in Termbox since tb_select_input_mode assigns the mode, overriding previous modes (reference). Therefore the assertion triggers because mode does not contain either TB_INPUT_ESC or TB_INPUT_ALT.

@panicbit
Copy link
Contributor Author

panicbit commented May 6, 2015

@sru I can not confirm this. I definitely don't get an assertion when pressing escape in the C version.

@sru
Copy link
Contributor

sru commented May 7, 2015

@panicbit That's odd. Maybe it's platform specific? I have only tested on Mac OS X (10.9.5), but I can try it on Linux later, when I get home. And I don't even know if Termbox runs on Windows.

@panicbit
Copy link
Contributor Author

panicbit commented May 7, 2015

@sru Or it might have to do with the terminal emulator used. I'm running ArchLinux and gnome-terminal.

@sru
Copy link
Contributor

sru commented May 7, 2015

@panicbit Might be. I am running iTerm, and it's messing up my terminal with bloat of characters written by the mouse input after the assertion :(

@panicbit
Copy link
Contributor Author

panicbit commented May 7, 2015

@sru You should be able to issue reset which should fix that.

@sru
Copy link
Contributor

sru commented May 7, 2015

@panicbit Huh, thanks for the tip!

@sru
Copy link
Contributor

sru commented May 7, 2015

@panicbit I still get the assertion only when pressing escape in C version using Archlinux and rxvt-unicode. It might be the terminal emulator.

@panicbit
Copy link
Contributor Author

panicbit commented May 7, 2015

@sru Still no issues using (C version, rxvt-unicode-9.21, nsf/termbox@7c154d98)

The way I build termbox and run the example:

python2 setup.py build
cp build/lib.*/termbox.so libtermbox.so       
gcc -ltermbox -L. -Isrc/ example.c -o example
LD_LIBRARY_PATH=. ./example

@panicbit
Copy link
Contributor Author

panicbit commented May 7, 2015

@sru I linked termbox statically now and I'm getting the assertion!

@panicbit
Copy link
Contributor Author

panicbit commented May 7, 2015

This is fixed now in termbox

@panicbit panicbit closed this as completed May 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants