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

New "compatible" option to use ncurses mouse API #33

Closed
wants to merge 1 commit into from
Closed

New "compatible" option to use ncurses mouse API #33

wants to merge 1 commit into from

Conversation

GitMensch
Copy link
Contributor

Check for new possible define PDC_USE_NCURSES_MOUSE_VERSION to let PDCurses define NCURSES_MOUSE_VERSION.
This is useful when the program including curses.h doesn't know if it is from PDCurses or ncurses. In the later case defining NCURSES_MOUSE_VERSION beforehand would be wrong.

Check for new possible define `PDC_USE_NCURSES_MOUSE_VERSION` to let PDCurses define `NCURSES_MOUSE_VERSION`.
This is useful when the program including curses.h doesn't know if it is from PDCurses or ncurses. In the later case defining `NCURSES_MOUSE_VERSION` beforehand would be wrong.
@wmcbrine
Copy link
Owner

I dunno, it seems to me that users could just as easily put an #ifndef NCURSES_MOUSE_VERSION etc. block (or more succinctly, #ifdef PDCURSES etc.) into their own code directly, instead of #define PDC_USE_NCURSES_MOUSE_VERSION.

Re: the "with" and "to use" you added to the comments, although small, these should really be a separate patch. I see where you were going there -- your revision is from the point of view of the application. As it was, the comments described building the library itself. In truth, the defines are needed at both times, and perhaps a more extensive revision is needed here to clarify that.

@GitMensch
Copy link
Contributor Author

I'll "redo" and separate both parts of the PR as soon as it is clear how we proceed.

The current docs and header say to do:

#define NCURSES_MOUSE_VERSION 2
#include <curses.h>

The problem: if the application works normally using ncurses (and the source itself doesn't know which curses header is there before including it) we already define NCURSES_MOUSE_VERSION and curses.h defines it again.

And in the end - we may have a version of curses that doesn't have any ncurses mouse support - but still we have the define because we manually added it (and break in the code as we use undefined symbols).

My approach is to

#define PDC_USE_NCURSES_MOUSE_VERSION
#include <curses.h>

Result:

  • old PDCurses (no matter if it supports ncurses mouse or if it is a pre 3 version) has no NCURSES_MOUSE_VERSION defined
  • new PDCurses has NCURSES_MOUSE_VERSION defined within itself and does so with the appropriate (not guessed) level
  • ncurses has NCURSES_MOUSE_VERSION *only if it supports it, in the level it supports
  • other curses won't have NCURSES_MOUSE_VERSION defined

Do you have any better name than PDC_USE_NCURSES_MOUSE_VERSION ?

@GitMensch
Copy link
Contributor Author

@wmcbrine Please reinspect and either close or pull.

wmcbrine added a commit that referenced this pull request Dec 28, 2018
before including curses.h, to invoke the ncurses-style mouse interface,
instead of NCURSES_MOUSE_VERSION. (The old way will also still work.)
After Simon Sobisch (see PR #33).
@wmcbrine
Copy link
Owner

OK, I've put this in as PDC_NCMOUSE.

@wmcbrine wmcbrine closed this Dec 28, 2018
@GitMensch GitMensch deleted the patch-1 branch December 28, 2018 18:29
polluks pushed a commit to polluks/PDCurses that referenced this pull request Aug 3, 2019
before including curses.h, to invoke the ncurses-style mouse interface,
instead of NCURSES_MOUSE_VERSION. (The old way will also still work.)
After Simon Sobisch (see PR wmcbrine#33).
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

Successfully merging this pull request may close these issues.

2 participants