curses.tail 7.4 KB

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