]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - include/curses.tail
ncurses 6.0 - patch 20160813
[ncurses.git] / include / curses.tail
index d51abc2515f6ca042122d6f4cd268d869e4c16d2..831a8f4c26dea5458147b524dca582c22b1d5eb9 100644 (file)
@@ -1,48 +1,90 @@
-/* $Id: curses.tail,v 1.8 2002/11/02 20:26:26 tom Exp $ */
+/* $Id: curses.tail,v 1.23 2016/02/13 16:37:45 tom Exp $ */
+/*
+ * vile:cmode:
+ * This file is part of ncurses, designed to be appended after curses.h.in
+ * (see that file for the relevant copyright).
+ */
 
 /* mouse interface */
-#define NCURSES_MOUSE_VERSION  1
+
+#if NCURSES_MOUSE_VERSION > 1
+#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5))
+#else
+#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6))
+#endif
+
+#define        NCURSES_BUTTON_RELEASED 001L
+#define        NCURSES_BUTTON_PRESSED  002L
+#define        NCURSES_BUTTON_CLICKED  004L
+#define        NCURSES_DOUBLE_CLICKED  010L
+#define        NCURSES_TRIPLE_CLICKED  020L
+#define        NCURSES_RESERVED_EVENT  040L
 
 /* event masks */
-#define        BUTTON1_RELEASED        000000000001L
-#define        BUTTON1_PRESSED         000000000002L
-#define        BUTTON1_CLICKED         000000000004L
-#define        BUTTON1_DOUBLE_CLICKED  000000000010L
-#define        BUTTON1_TRIPLE_CLICKED  000000000020L
-#define BUTTON1_RESERVED_EVENT 000000000040L
-#define        BUTTON2_RELEASED        000000000100L
-#define        BUTTON2_PRESSED         000000000200L
-#define        BUTTON2_CLICKED         000000000400L
-#define        BUTTON2_DOUBLE_CLICKED  000000001000L
-#define        BUTTON2_TRIPLE_CLICKED  000000002000L
-#define BUTTON2_RESERVED_EVENT 000000004000L
-#define        BUTTON3_RELEASED        000000010000L
-#define        BUTTON3_PRESSED         000000020000L
-#define        BUTTON3_CLICKED         000000040000L
-#define        BUTTON3_DOUBLE_CLICKED  000000100000L
-#define        BUTTON3_TRIPLE_CLICKED  000000200000L
-#define BUTTON3_RESERVED_EVENT 000000400000L
-#define        BUTTON4_RELEASED        000001000000L
-#define        BUTTON4_PRESSED         000002000000L
-#define        BUTTON4_CLICKED         000004000000L
-#define        BUTTON4_DOUBLE_CLICKED  000010000000L
-#define        BUTTON4_TRIPLE_CLICKED  000020000000L
-#define BUTTON4_RESERVED_EVENT 000040000000L
-#define BUTTON_CTRL            000100000000L
-#define BUTTON_SHIFT           000200000000L
-#define BUTTON_ALT             000400000000L
-#define        ALL_MOUSE_EVENTS        000777777777L
-#define        REPORT_MOUSE_POSITION   001000000000L
+#define        BUTTON1_RELEASED        NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED)
+#define        BUTTON1_PRESSED         NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED)
+#define        BUTTON1_CLICKED         NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED)
+#define        BUTTON1_DOUBLE_CLICKED  NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED)
+#define        BUTTON1_TRIPLE_CLICKED  NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED)
+
+#define        BUTTON2_RELEASED        NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED)
+#define        BUTTON2_PRESSED         NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED)
+#define        BUTTON2_CLICKED         NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED)
+#define        BUTTON2_DOUBLE_CLICKED  NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED)
+#define        BUTTON2_TRIPLE_CLICKED  NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED)
+
+#define        BUTTON3_RELEASED        NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED)
+#define        BUTTON3_PRESSED         NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED)
+#define        BUTTON3_CLICKED         NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED)
+#define        BUTTON3_DOUBLE_CLICKED  NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED)
+#define        BUTTON3_TRIPLE_CLICKED  NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED)
+
+#define        BUTTON4_RELEASED        NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED)
+#define        BUTTON4_PRESSED         NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED)
+#define        BUTTON4_CLICKED         NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED)
+#define        BUTTON4_DOUBLE_CLICKED  NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED)
+#define        BUTTON4_TRIPLE_CLICKED  NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED)
+
+/*
+ * In 32 bits the version-1 scheme does not provide enough space for a 5th
+ * button, unless we choose to change the ABI by omitting the reserved-events.
+ */
+#if NCURSES_MOUSE_VERSION > 1
+
+#define        BUTTON5_RELEASED        NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED)
+#define        BUTTON5_PRESSED         NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED)
+#define        BUTTON5_CLICKED         NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED)
+#define        BUTTON5_DOUBLE_CLICKED  NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED)
+#define        BUTTON5_TRIPLE_CLICKED  NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED)
+
+#define        BUTTON_CTRL             NCURSES_MOUSE_MASK(6, 0001L)
+#define        BUTTON_SHIFT            NCURSES_MOUSE_MASK(6, 0002L)
+#define        BUTTON_ALT              NCURSES_MOUSE_MASK(6, 0004L)
+#define        REPORT_MOUSE_POSITION   NCURSES_MOUSE_MASK(6, 0010L)
 
-/* macros to extract single event-bits from masks */
-#define        BUTTON_RELEASE(e, x)            ((e) & (001 << (6 * ((x) - 1))))
-#define        BUTTON_PRESS(e, x)              ((e) & (002 << (6 * ((x) - 1))))
-#define        BUTTON_CLICK(e, x)              ((e) & (004 << (6 * ((x) - 1))))
-#define        BUTTON_DOUBLE_CLICK(e, x)       ((e) & (010 << (6 * ((x) - 1))))
-#define        BUTTON_TRIPLE_CLICK(e, x)       ((e) & (020 << (6 * ((x) - 1))))
-#define        BUTTON_RESERVED_EVENT(e, x)     ((e) & (040 << (6 * ((x) - 1))))
+#else
+
+#define        BUTTON1_RESERVED_EVENT  NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT)
+#define        BUTTON2_RESERVED_EVENT  NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT)
+#define        BUTTON3_RESERVED_EVENT  NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT)
+#define        BUTTON4_RESERVED_EVENT  NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT)
+
+#define        BUTTON_CTRL             NCURSES_MOUSE_MASK(5, 0001L)
+#define        BUTTON_SHIFT            NCURSES_MOUSE_MASK(5, 0002L)
+#define        BUTTON_ALT              NCURSES_MOUSE_MASK(5, 0004L)
+#define        REPORT_MOUSE_POSITION   NCURSES_MOUSE_MASK(5, 0010L)
+
+#endif
 
-typedef unsigned long mmask_t;
+#define        ALL_MOUSE_EVENTS        (REPORT_MOUSE_POSITION - 1)
+
+/* macros to extract single event-bits from masks */
+#define        BUTTON_RELEASE(e, x)            ((e) & NCURSES_MOUSE_MASK(x, 001))
+#define        BUTTON_PRESS(e, x)              ((e) & NCURSES_MOUSE_MASK(x, 002))
+#define        BUTTON_CLICK(e, x)              ((e) & NCURSES_MOUSE_MASK(x, 004))
+#define        BUTTON_DOUBLE_CLICK(e, x)       ((e) & NCURSES_MOUSE_MASK(x, 010))
+#define        BUTTON_TRIPLE_CLICK(e, x)       ((e) & NCURSES_MOUSE_MASK(x, 020))
+#define        BUTTON_RESERVED_EVENT(e, x)     ((e) & NCURSES_MOUSE_MASK(x, 040))
 
 typedef struct
 {
@@ -52,32 +94,46 @@ typedef struct
 }
 MEVENT;
 
-extern NCURSES_EXPORT(int) getmouse (MEVENT *);
-extern NCURSES_EXPORT(int) ungetmouse (MEVENT *);
+extern NCURSES_EXPORT(bool)    has_mouse(void);
+extern NCURSES_EXPORT(int)     getmouse (MEVENT *);
+extern NCURSES_EXPORT(int)     ungetmouse (MEVENT *);
 extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *);
-extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int);
-extern NCURSES_EXPORT(int) mouseinterval (int);
-extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW* win,int* y, int* x, bool to_screen);
-extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool);              /* generated */
+extern NCURSES_EXPORT(bool)    wenclose (const WINDOW *, int, int);
+extern NCURSES_EXPORT(int)     mouseinterval (int);
+extern NCURSES_EXPORT(bool)    wmouse_trafo (const WINDOW*, int*, int*, bool);
+extern NCURSES_EXPORT(bool)    mouse_trafo (int*, int*, bool);              /* generated */
+
+#if NCURSES_SP_FUNCS
+extern NCURSES_EXPORT(bool)    NCURSES_SP_NAME(has_mouse) (SCREEN*);
+extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *);
+extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *);
+extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, mmask_t *);
+extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(mouseinterval) (SCREEN*, int);
+#endif
 
+#ifndef NCURSES_NOMACROS
 #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
+#endif
 
 /* other non-XSI functions */
 
 extern NCURSES_EXPORT(int) mcprint (char *, int);      /* direct data to printer */
 extern NCURSES_EXPORT(int) has_key (int);              /* do we have given key? */
 
+#if NCURSES_SP_FUNCS
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (SCREEN*, int);    /* do we have given key? */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mcprint) (SCREEN*, char *, int);    /* direct data to printer */
+#endif
+
 /* Debugging : use with libncurses_g.a */
 
 extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2);
-extern NCURSES_EXPORT(void) _tracedump (const char *, WINDOW *);
 extern NCURSES_EXPORT(char *) _traceattr (attr_t);
 extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype);
-extern NCURSES_EXPORT(char *) _nc_tracebits (void);
 extern NCURSES_EXPORT(char *) _tracechar (int);
 extern NCURSES_EXPORT(char *) _tracechtype (chtype);
 extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype);
-#ifdef _XOPEN_SOURCE_EXTENDED
+#if NCURSES_WIDECHAR
 #define _tracech_t             _tracecchar_t
 extern NCURSES_EXPORT(char *) _tracecchar_t (const cchar_t *);
 #define _tracech_t2            _tracecchar_t2
@@ -86,7 +142,6 @@ extern NCURSES_EXPORT(char *) _tracecchar_t2 (int, const cchar_t *);
 #define _tracech_t             _tracechtype
 #define _tracech_t2            _tracechtype2
 #endif
-extern NCURSES_EXPORT(char *) _tracemouse (const MEVENT *);
 extern NCURSES_EXPORT(void) trace (const unsigned int);
 
 /* trace masks */
@@ -111,9 +166,6 @@ extern NCURSES_EXPORT(void) trace (const unsigned int);
 
 #if defined(TRACE) || defined(NCURSES_TEST)
 extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable;            /* enable optimizations */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *);
-#endif
 extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
 #define OPTIMIZE_MVCUR         0x01    /* cursor movement optimization */
 #define OPTIMIZE_HASHMAP       0x02    /* diff hashing to detect scrolls */
@@ -121,8 +173,12 @@ extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
 #define OPTIMIZE_ALL           0xff    /* enable all optimizations (dflt) */
 #endif
 
+#include <unctrl.h>
+
 #ifdef __cplusplus
 
+#ifndef NCURSES_NOMACROS
+
 /* these names conflict with STL */
 #undef box
 #undef clear
@@ -130,6 +186,8 @@ extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
 #undef move
 #undef refresh
 
+#endif /* NCURSES_NOMACROS */
+
 }
 #endif