# Ncurses - how do you get mousemask working?

**URL:** <https://www.ruby-forum.com/t/ncurses-how-do-you-get-mousemask-working/49952>\
**Category:** Ruby\
**Created:** [December 10, 2005, 9:54pm UTC](https://www.ruby-forum.com/t/ncurses-how-do-you-get-mousemask-working/49952 "2005-12-10T21:54:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lymans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a183cd/32.png) [@lymans](https://www.ruby-forum.com/u/lymans)\
**Post date:** [December 10, 2005, 9:54pm UTC](https://www.ruby-forum.com/t/ncurses-how-do-you-get-mousemask-working/49952/1 "2005-12-10T21:54:30Z")

</div>

I’ve tried… and I’ve looked around.

A few other projects have the line with ‘Ncurses::mousemask…’ in  
them - but it’s always commented out… like they couldn’t get it  
working either.

Is this feature not functional?

I’ve currently got ‘Ncurses::mousemask(Ncurses::ALL\_MOUSE\_EVENTS,[])’  
and the error ‘wrong number of arguments (2 for 1)’ and as soon as I  
drop the second arg I get the error ‘oldmask (2nd argument) must be an  
empty Array’ which is kinda bothersome… 🙂

Any hints? Tobias?

-Rich

---

<div class="post-metadata">

**Author:** ![lymans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a183cd/32.png) [@lymans](https://www.ruby-forum.com/u/lymans)\
**Post date:** [December 12, 2005, 10:37pm UTC](https://www.ruby-forum.com/t/ncurses-how-do-you-get-mousemask-working/49952/2 "2005-12-12T22:37:50Z")

</div>

- Richard L. (removed\_email\_address@domain.invalid) wrote:

> I’ve tried… and I’ve looked around.
> 
> A few other projects have the line with ‘Ncurses::mousemask…’ in  
> them - but it’s always commented out… like they couldn’t get it  
> working either.

They couldn’t

> Is this feature not functional?

It’s a bug in the method definition; see below.

> I’ve currently got ‘Ncurses::mousemask(Ncurses::ALL\_MOUSE\_EVENTS,[])’  
> and the error ‘wrong number of arguments (2 for 1)’ and as soon as I  
> drop the second arg I get the error ‘oldmask (2nd argument) must be an  
> empty Array’ which is kinda bothersome… 🙂

It’s a bug in the library. It’s been there forever (I came across it  
when I was trying to add mouse support to Raggle, then just forgot to  
send a patch upstream).

> Any hints? Tobias?

Apply this patch (also attached):

diff -ur ncurses-ruby-0.9.2/ncurses\_wrap.c  
ncurses-ruby-0.9.2-mousemask/ncurses\_wrap.c  
— ncurses-ruby-0.9.2/ncurses\_wrap.c 2005-12-12 16:33:00.000000000  
-0500  
+++ ncurses-ruby-0.9.2-mousemask/ncurses\_wrap.c 2005-02-26  
19:22:13.000000000 -0500  
@@ -2387,7 +2387,7 @@  
NCFUNC(ungetmouse, 1);  
#endif  
#ifdef HAVE\_MOUSEMASK

- NCFUNC(mousemask, 2);

- NCFUNC(mousemask, 1);  
#endif  
#ifdef HAVE\_WENCLOSE  
rb\_define\_module\_function(mNcurses, “wenclose?”,

---

<div class="post-metadata">

**Author:** ![lymans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a183cd/32.png) [@lymans](https://www.ruby-forum.com/u/lymans)\
**Post date:** [December 12, 2005, 10:46pm UTC](https://www.ruby-forum.com/t/ncurses-how-do-you-get-mousemask-working/49952/3 "2005-12-12T22:46:53Z")

</div>

- Paul D. (removed\_email\_address@domain.invalid) wrote:

> > Any hints? Tobias?

Err, my patch is backwards… Here’s the correct one (again, attached):

diff -ur ncurses-ruby-0.9.2/ncurses\_wrap.c  
ncurses-ruby-0.9.2-mousemask\_fix/ncurses\_wrap.c  
— ncurses-ruby-0.9.2/ncurses\_wrap.c 2005-02-26 19:22:13.000000000  
-0500  
+++ ncurses-ruby-0.9.2-mousemask\_fix/ncurses\_wrap.c 2005-12-12  
16:42:11.000000000 -0500  
@@ -2387,7 +2387,7 @@  
NCFUNC(ungetmouse, 1);  
#endif  
#ifdef HAVE\_MOUSEMASK

- NCFUNC(mousemask, 1);

- NCFUNC(mousemask, 2);  
#endif  
#ifdef HAVE\_WENCLOSE  
rb\_define\_module\_function(mNcurses, “wenclose?”,

> - NCFUNC(mousemask, 1);  
> #endif  
> #ifdef HAVE\_WENCLOSE  
> rb\_define\_module\_function(mNcurses, “wenclose?”,
> 
> –  
> Paul D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) pabs in #ruby-lang (OPN IRC)  
> [http://www.pablotron.org/](http://www.pablotron.org/) OpenPGP Key ID: 0x82C29562

---

<div class="post-metadata">

**Author:** ![lymans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a183cd/32.png) [@lymans](https://www.ruby-forum.com/u/lymans)\
**Post date:** [December 14, 2005, 12:08pm UTC](https://www.ruby-forum.com/t/ncurses-how-do-you-get-mousemask-working/49952/4 "2005-12-14T12:08:26Z")

</div>

Richard L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks for the reply, but I think I’m going to move away from  
> ncurses… you can’t get CTRL- to be unique can you? I haven’t  
> found anywhere in the docs where it allows you to detect the CTRL key  
> on it’s own.

That’s a terminal-dependent feature. If the terminal supports it,  
one can write a terminfo that describes it (as a function-key).  
(n)curses supports up to 60 function keys (which you would probably  
find too limiting 😉

bye.

---

<div class="post-metadata">

**Author:** ![lymans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a183cd/32.png) [@lymans](https://www.ruby-forum.com/u/lymans)\
**Post date:** [December 13, 2005, 7:15pm UTC](https://www.ruby-forum.com/t/ncurses-how-do-you-get-mousemask-working/49952/5 "2005-12-13T19:15:33Z")

</div>

Thanks for the reply, but I think I’m going to move away from  
ncurses… you can’t get CTRL- to be unique can you? I haven’t  
found anywhere in the docs where it allows you to detect the CTRL key  
on it’s own.

If you can’t, then that’s the straw that breaks it.

Again - thanks for the reply.

-Rich
