1/* 2 * This file is part of ncurses, designed to be appended after curses.h.in 3 * (see that file for the relevant copyright). 4 */ 5/* $Id: curses.tail,v 1.14 2006/05/27 16:28:29 tom Exp $ */ 6 7/* mouse interface */ 8 9#if NCURSES_MOUSE_VERSION > 1 10#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5)) 11#else 12#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6)) 13#endif 14 15#define NCURSES_BUTTON_RELEASED 001L 16#define NCURSES_BUTTON_PRESSED 002L 17#define NCURSES_BUTTON_CLICKED 004L 18#define NCURSES_DOUBLE_CLICKED 010L 19#define NCURSES_TRIPLE_CLICKED 020L 20#define NCURSES_RESERVED_EVENT 040L 21 22/* event masks */ 23#define BUTTON1_RELEASED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED) 24#define BUTTON1_PRESSED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED) 25#define BUTTON1_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED) 26#define BUTTON1_DOUBLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED) 27#define BUTTON1_TRIPLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED) 28 29#define BUTTON2_RELEASED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED) 30#define BUTTON2_PRESSED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED) 31#define BUTTON2_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED) 32#define BUTTON2_DOUBLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED) 33#define BUTTON2_TRIPLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED) 34 35#define BUTTON3_RELEASED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED) 36#define BUTTON3_PRESSED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED) 37#define BUTTON3_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED) 38#define BUTTON3_DOUBLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED) 39#define BUTTON3_TRIPLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED) 40 41#define BUTTON4_RELEASED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED) 42#define BUTTON4_PRESSED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED) 43#define BUTTON4_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED) 44#define BUTTON4_DOUBLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED) 45#define BUTTON4_TRIPLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED) 46 47/* 48 * In 32 bits the version-1 scheme does not provide enough space for a 5th 49 * button, unless we choose to change the ABI by omitting the reserved-events. 50 */ 51#if NCURSES_MOUSE_VERSION > 1 52 53#define BUTTON5_RELEASED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED) 54#define BUTTON5_PRESSED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED) 55#define BUTTON5_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED) 56#define BUTTON5_DOUBLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED) 57#define BUTTON5_TRIPLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED) 58 59#define BUTTON_CTRL NCURSES_MOUSE_MASK(6, 0001L) 60#define BUTTON_SHIFT NCURSES_MOUSE_MASK(6, 0002L) 61#define BUTTON_ALT NCURSES_MOUSE_MASK(6, 0004L) 62#define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(6, 0010L) 63 64#else 65 66#define BUTTON1_RESERVED_EVENT NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT) 67#define BUTTON2_RESERVED_EVENT NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT) 68#define BUTTON3_RESERVED_EVENT NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT) 69#define BUTTON4_RESERVED_EVENT NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT) 70 71#define BUTTON_CTRL NCURSES_MOUSE_MASK(5, 0001L) 72#define BUTTON_SHIFT NCURSES_MOUSE_MASK(5, 0002L) 73#define BUTTON_ALT NCURSES_MOUSE_MASK(5, 0004L) 74#define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(5, 0010L) 75 76#endif 77 78#define ALL_MOUSE_EVENTS (REPORT_MOUSE_POSITION - 1) 79 80/* macros to extract single event-bits from masks */ 81#define BUTTON_RELEASE(e, x) ((e) & (001 << (6 * ((x) - 1)))) 82#define BUTTON_PRESS(e, x) ((e) & (002 << (6 * ((x) - 1)))) 83#define BUTTON_CLICK(e, x) ((e) & (004 << (6 * ((x) - 1)))) 84#define BUTTON_DOUBLE_CLICK(e, x) ((e) & (010 << (6 * ((x) - 1)))) 85#define BUTTON_TRIPLE_CLICK(e, x) ((e) & (020 << (6 * ((x) - 1)))) 86#define BUTTON_RESERVED_EVENT(e, x) ((e) & (040 << (6 * ((x) - 1)))) 87 88typedef struct 89{ 90 short id; /* ID to distinguish multiple devices */ 91 int x, y, z; /* event coordinates (character-cell) */ 92 mmask_t bstate; /* button state bits */ 93} 94MEVENT; 95 96extern NCURSES_EXPORT(int) getmouse (MEVENT *); 97extern NCURSES_EXPORT(int) ungetmouse (MEVENT *); 98extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *); 99extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int); 100extern NCURSES_EXPORT(int) mouseinterval (int); 101extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool); 102extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* generated */ 103 104#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen) 105 106/* other non-XSI functions */ 107 108extern NCURSES_EXPORT(int) mcprint (char *, int); /* direct data to printer */ 109extern NCURSES_EXPORT(int) has_key (int); /* do we have given key? */ 110 111/* Debugging : use with libncurses_g.a */ 112 113extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2); 114extern NCURSES_EXPORT(void) _tracedump (const char *, WINDOW *); 115extern NCURSES_EXPORT(char *) _traceattr (attr_t); 116extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype); 117extern NCURSES_EXPORT(char *) _nc_tracebits (void); 118extern NCURSES_EXPORT(char *) _tracechar (int); 119extern NCURSES_EXPORT(char *) _tracechtype (chtype); 120extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype); 121#ifdef _XOPEN_SOURCE_EXTENDED 122#define _tracech_t _tracecchar_t 123extern NCURSES_EXPORT(char *) _tracecchar_t (const cchar_t *); 124#define _tracech_t2 _tracecchar_t2 125extern NCURSES_EXPORT(char *) _tracecchar_t2 (int, const cchar_t *); 126#else 127#define _tracech_t _tracechtype 128#define _tracech_t2 _tracechtype2 129#endif 130extern NCURSES_EXPORT(char *) _tracemouse (const MEVENT *); 131extern NCURSES_EXPORT(void) trace (const unsigned int); 132 133/* trace masks */ 134#define TRACE_DISABLE 0x0000 /* turn off tracing */ 135#define TRACE_TIMES 0x0001 /* trace user and system times of updates */ 136#define TRACE_TPUTS 0x0002 /* trace tputs calls */ 137#define TRACE_UPDATE 0x0004 /* trace update actions, old & new screens */ 138#define TRACE_MOVE 0x0008 /* trace cursor moves and scrolls */ 139#define TRACE_CHARPUT 0x0010 /* trace all character outputs */ 140#define TRACE_ORDINARY 0x001F /* trace all update actions */ 141#define TRACE_CALLS 0x0020 /* trace all curses calls */ 142#define TRACE_VIRTPUT 0x0040 /* trace virtual character puts */ 143#define TRACE_IEVENT 0x0080 /* trace low-level input processing */ 144#define TRACE_BITS 0x0100 /* trace state of TTY control bits */ 145#define TRACE_ICALLS 0x0200 /* trace internal/nested calls */ 146#define TRACE_CCALLS 0x0400 /* trace per-character calls */ 147#define TRACE_DATABASE 0x0800 /* trace read/write of terminfo/termcap data */ 148#define TRACE_ATTRS 0x1000 /* trace attribute updates */ 149 150#define TRACE_SHIFT 13 /* number of bits in the trace masks */ 151#define TRACE_MAXIMUM ((1 << TRACE_SHIFT) - 1) /* maximum trace level */ 152 153#if defined(TRACE) || defined(NCURSES_TEST) 154extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable; /* enable optimizations */ 155extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *); 156#define OPTIMIZE_MVCUR 0x01 /* cursor movement optimization */ 157#define OPTIMIZE_HASHMAP 0x02 /* diff hashing to detect scrolls */ 158#define OPTIMIZE_SCROLL 0x04 /* scroll optimization */ 159#define OPTIMIZE_ALL 0xff /* enable all optimizations (dflt) */ 160#endif 161 162#ifdef __cplusplus 163 164#ifndef NCURSES_NOMACROS 165 166/* these names conflict with STL */ 167#undef box 168#undef clear 169#undef erase 170#undef move 171#undef refresh 172 173#endif /* NCURSES_NOMACROS */ 174 175} 176#endif 177 178#endif /* __NCURSES_H */ 179