luaposix icon indicating copy to clipboard operation
luaposix copied to clipboard

curses mouse support

Open daurnimator opened this issue 11 years ago • 16 comments

Can we get curses mouse support? i.e.

  • mousemask
  • get_mouse
  • ungetmouse
  • wenclose
  • wmouse_trafo

We do already have KEY_MOUSE; which I found a bit weird.

daurnimator avatar Feb 16 '15 10:02 daurnimator

Well, I'd quite like to have this too, but none of the functions you mentions are in the POSIX spec: http://pubs.opengroup.org/onlinepubs/007908799/cursesix.html

KEY_MOUSE was introduced when I audited the defined KEY_ constants to integrate the curses apis fully into luaposix, so I should probably remove that too :(

However, maybe there's a case for adding an optional posix.curses.mouse module for this? @rrthomas, WDYT?

gvvaughan avatar Feb 16 '15 10:02 gvvaughan

As far as I can see, these are ncurses functions. As Gary says, they're not POSIX functions; therefore they don't belong in luaposix. I can see two sensible routes:

  1. Split out the curses library from luaposix, and add the functions to a new luacurses (with suitable #ifdefs so that the library can be built for any curses).
  2. Start a new luancurses library of just ncurses-specific functions, and depend on luaposix for the POSIX functions.

My inclination is towards 1, since it avoids having curses functions in two namespaces (or alternatively two libraries writing to the same namespace), and provides a route to supporting curses without needing POSIX (some curses libraries are available on non-POSIX platforms). Also, other languages mostly package curses as a single library, so it won't confuse many programmers (other than those used to the status quo) that curses functions are not found in luaposix; probably the reverse, it'll make them easier to find.

rrthomas avatar Feb 16 '15 11:02 rrthomas

Agreed. I'll leave this ticket open as a reminder that this work remains to be done.

As a first step, could you open a new luacurses github project as a sibling of luaposix? Unless you think an entirely separate luacurses/luacurses is more idiomatic?

Out of curiosity, what was the motivation for combining the luaposix and lua curses recently?

gvvaughan avatar Feb 16 '15 13:02 gvvaughan

I merged the projects back when lcurses was POSIX-only and managing a single project seemed easier than two. I don't have time to re-split the projects at present; I suggest that this be done when someone actually contributes code to implement the requested mouse support (or any other non-POSIX curses functions).

I agree that KEY_MOUSE should be removed from luaposix.

rrthomas avatar Feb 16 '15 21:02 rrthomas

I'm happy to perform the split (no promises as to when, mind you!), but don't have permission to create the github project under the luaposix user. If you could create an empty project and give me a commit bit, I'll do all the file wrangling to separate everything out.

I've been meaning to look into adding mouse support to Zile for a long time, so even if no-one else contributes code before I finally get around to it, I have no problem with writing the bindings myself :-)

gvvaughan avatar Feb 16 '15 21:02 gvvaughan

....unless, of course, you think a luacurses/luacurses project makes more sense... in which case I can handle that part too.

gvvaughan avatar Feb 16 '15 21:02 gvvaughan

It would seem more sensible for it to be an independent project.

rrthomas avatar Feb 16 '15 22:02 rrthomas

True enough... then I'll get to in due course :-) @daurnimator your patches will certainly speed things along considerably!

gvvaughan avatar Feb 16 '15 22:02 gvvaughan

@daurnimator your patches will certainly speed things along considerably!

o.o I don't have any patches :P

daurnimator avatar Feb 16 '15 22:02 daurnimator

@daurnimator your patches would certainly speed things along considerably (compared to waiting for me to do it)!

gvvaughan avatar Jul 04 '15 16:07 gvvaughan

KEY_MOUSE was removed in luaposix 33.0.0 but is still mentioned in documentation.

mpeterv avatar Oct 06 '15 14:10 mpeterv

Thanks Peter. Fixed in 666bbd8.

gvvaughan avatar Oct 06 '15 20:10 gvvaughan

I've created a new github.com/lcurses/lcurses project, based on github.com/rrthomas/lcurses release with all the luaposix changes merged back. I've invited you (@rrthomas and @gvvaughan) to join the organisation if you'd like to join, and would like to make a pull-request to remove the curses module from luaposix if that's acceptable?

How do I upload a new lcurses luarock to luarocks.org?

jjandresson avatar Jan 10 '16 17:01 jjandresson

That's awesome, thank you!

I accepted your lcurses org invitation, and fixed up the gh-pages branch so that the link at the top of the page works. I also hooked lcurses/lcurses up with a my travis-ci.org account (https://travis-ci.org/lcurses/lcurses/builds) so that the 'build: passing' badge in README.md points to a real project and runs the specl checks on every commit, just like luaposix does.

You should probably either remove the waffle.io badge (ready: 0) from README.md, or else click through and sign up for a waffle.io page to manage issues through their nice UI.

I'd be very happy to accept a matching changeset for luaposix to complete the split back into two projects. Please create a pull-request when you're ready.

Regarding uploading rocks: You can just create an account at luarocks.org and then go ahead and use 'luarocks upload' at the command-line to add your updated lcurses rock to luarocks.org, but that will add it to your accounts manifest. Once your luaposix changeset to complete the split has been merged here, one of us should email leafo and ask for access to the root manifest for lcurses so that people using luarocks will get the latest version rather than the old lcurses-6.2 rock currently in an unclaimed account. @rrthomas, would you like to upload future releases of lcurses to luarocks? Or would you prefer me (or @jjandresson if you're volunteering to maintain lcurses from here on out) to do that?

gvvaughan avatar Jan 10 '16 18:01 gvvaughan

Hi both, I'm very happy for you to look after lcurses; I'm not really using it at present, so happy to pass it on to the next maintainer(s)!

rrthomas avatar Jan 11 '16 11:01 rrthomas

I would be very happy to look after lcurses (with some help if I get stuck). I'm working on binding the curses mouse support... and I'll post back to this issue when I've done it.

jjandresson avatar Jan 23 '16 18:01 jjandresson