0

Is there a way to find out whether ncurses supports ABI 6?

if ( ABI 6 is supported ) {
    ...
}
else {
    ...
}
sid_com
  • 24,137
  • 26
  • 96
  • 187

1 Answers1

1

You can see this by comparing the header files. There are two features which can be checked at compile time:

  • the mouse version differs in the header files:
     /*                                                                             
      * Identify the mouse encoding version.                                        
      */                                                                            
    -#define NCURSES_MOUSE_VERSION 1                                                
    +#define NCURSES_MOUSE_VERSION 2
  • the extended-colors symbol is defined:
    @@ -374,9 +419,9 @@                                                             
     {                                                                              
         attr_t     attr;                                                           
         wchar_t    chars[CCHARW_MAX];                                              
    -#if 0                                                                          
    +#if 1                                                                          
     #undef NCURSES_EXT_COLORS                                                      
    -#define NCURSES_EXT_COLORS 20110404                                            
    +#define NCURSES_EXT_COLORS 20170729                                            
         int                ext_color;      /* color pair, must be more than 16-bits */
     #endif                                                                         
     }

That is, the latter is (in ABI 5) within an ifdef which prevents the NCURSES_EXT_COLORS symbol from being defined. The NCURSES_MOUSE_VERSION symbol is always defined, but its value changed.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • Can you give me some suggestions how I could find the right header file within `perl6` code? – sid_com Jul 28 '17 at 15:02
  • If you're talking about [this](https://github.com/azawawi/perl6-ncurses), it doesn't expose the extended mouse feature. For extended colors (256 versus 16), if the binding passes back errors, the ABI 5 should return an error if you asked for a color pair value past 255 in `init_pair`, or a color value past 15. – Thomas Dickey Jul 28 '17 at 16:56
  • Is it safe to use the return value of `mousemask` - it returns different numbers with the same mask when using the different ABI versions? `init_pair` return always an error when I use numbers higher than `init_pair(80,7,7)` independently from the ABI version. – sid_com Jul 29 '17 at 05:34
  • `init_pair` uses the terminal description; if that's `xterm-256color` then ABI 6 would allow larger pair- and color-values. If that's an 8-color description (use `infocmp` to see), you'd get errors in any case with ABI 5 or 6. The mouse interface in that code lacks the definitions for button 5 (doesn't support ABI 6). – Thomas Dickey Jul 29 '17 at 11:21
  • There is a `colors#8` in the output of `infocmp`. I added the required lacking definitions in my code. – sid_com Jul 29 '17 at 12:04