1 /* Public Domain Curses */
2 
3 /* Private definitions and declarations for use within PDCurses.
4    These should generally not be referenced by applications. */
5 
6 #ifndef __CURSES_INTERNALS__
7 #define __CURSES_INTERNALS__ 1
8 
9 #define CURSES_LIBRARY
10 #include <curses.h>
11 
12 #if defined(__TURBOC__) || defined(__EMX__) || defined(__DJGPP__) || \
13     defined(__CYGWIN__) || defined(__MINGW32__) || \
14     defined(__WATCOMC__) || defined(__PACIFIC__)
15 # ifndef HAVE_VSSCANF
16 #  define HAVE_VSSCANF       /* have vsscanf() */
17 # endif
18 #endif
19 
20 #if defined(__CYGWIN__) || defined(__MINGW32__) || \
21     defined(__LCC__) || defined(__WATCOMC__)
22 # ifndef HAVE_VSNPRINTF
23 #  define HAVE_VSNPRINTF     /* have vsnprintf() */
24 # endif
25 #endif
26 
27 #if defined(_MSC_VER) && defined(_WIN32) && !defined(_CRT_SECURE_NO_DEPRECATE)
28 # define _CRT_SECURE_NO_DEPRECATE 1   /* kill nonsense warnings */
29 #endif
30 
31 /*----------------------------------------------------------------------*/
32 
33 typedef struct           /* structure for ripped off lines */
34 {
35     int line;
36     int (*init)(WINDOW *, int);
37 } RIPPEDOFFLINE;
38 
39 /* Window properties */
40 
41 #define _SUBWIN    0x01  /* window is a subwindow */
42 #define _PAD       0x10  /* X/Open Pad. */
43 #define _SUBPAD    0x20  /* X/Open subpad. */
44 
45 /* Miscellaneous */
46 
47 #define _NO_CHANGE -1    /* flags line edge unchanged */
48 
49 #define _ECHAR     0x08  /* Erase char       (^H) */
50 #define _DWCHAR    0x17  /* Delete Word char (^W) */
51 #define _DLCHAR    0x15  /* Delete Line char (^U) */
52 
53 extern WINDOW *pdc_lastscr;
54 extern bool pdc_trace_on;   /* tracing flag */
55 extern bool pdc_color_started;
56 extern unsigned long pdc_key_modifiers;
57 extern MOUSE_STATUS pdc_mouse_status;
58 
59 /*----------------------------------------------------------------------*/
60 
61 /* Platform implementation functions */
62 
63 void    PDC_beep(void);
64 bool    PDC_can_change_color(void);
65 int     PDC_color_content(short, short *, short *, short *);
66 bool    PDC_check_key(void);
67 int     PDC_curs_set(int);
68 void    PDC_flushinp(void);
69 int     PDC_get_columns(void);
70 int     PDC_get_cursor_mode(void);
71 int     PDC_get_key(void);
72 int     PDC_get_rows(void);
73 void    PDC_gotoyx(int, int);
74 int     PDC_init_color(short, short, short, short);
75 void    PDC_init_pair(short, short, short);
76 int     PDC_modifiers_set(void);
77 int     PDC_mouse_set(void);
78 void    PDC_napms(int);
79 int     PDC_pair_content(short, short *, short *);
80 void    PDC_reset_prog_mode(void);
81 void    PDC_reset_shell_mode(void);
82 int     PDC_resize_screen(int, int);
83 void    PDC_restore_screen_mode(int);
84 void    PDC_save_screen_mode(int);
85 void    PDC_scr_close(void);
86 void    PDC_scr_free(void);
87 int     PDC_scr_open(int, char **);
88 void    PDC_set_keyboard_binary(bool);
89 void    PDC_transform_line(int, int, int, const chtype *);
90 const char *PDC_sysname(void);
91 
92 /* Internal cross-module functions */
93 
94 void    PDC_init_atrtab(void);
95 WINDOW *PDC_makelines(WINDOW *);
96 WINDOW *PDC_makenew(int, int, int, int);
97 int     PDC_mouse_in_slk(int, int);
98 void    PDC_slk_free(void);
99 void    PDC_slk_initialize(void);
100 void    PDC_sync(WINDOW *);
101 
102 #ifdef PDC_WIDE
103 int     PDC_mbtowc(wchar_t *, const char *, size_t);
104 size_t  PDC_mbstowcs(wchar_t *, const char *, size_t);
105 size_t  PDC_wcstombs(char *, const wchar_t *, size_t);
106 #endif
107 
108 #ifdef PDCDEBUG
109 # define PDC_LOG(x) if (pdc_trace_on) PDC_debug x
110 #else
111 # define PDC_LOG(x)
112 #endif
113 
114 /* Internal macros for attributes */
115 
116 #ifdef CHTYPE_LONG
117 # define PDC_COLOR_PAIRS 256
118 #else
119 # define PDC_COLOR_PAIRS  32
120 #endif
121 
122 #ifndef max
123 # define max(a,b) (((a) > (b)) ? (a) : (b))
124 #endif
125 #ifndef min
126 # define min(a,b) (((a) < (b)) ? (a) : (b))
127 #endif
128 
129 #define DIVROUND(num, divisor) ((num) + ((divisor) >> 1)) / (divisor)
130 
131 #define PDC_CLICK_PERIOD 150  /* time to wait for a click, if
132                                  not set by mouseinterval() */
133 
134 #endif /* __CURSES_INTERNALS__*/
135