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