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