]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/tty/tty_display.h
e7b447d8045dd776e8ccc96dbf8bdc1d76cb9292
[ncurses.git] / ncurses / tty / tty_display.h
1 /****************************************************************************
2  * Copyright (c) 1998 Free Software Foundation, Inc.                        *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ************************************************************************** */
28
29 #ifndef TTY_DISPLAY_H
30 #define TTY_DISPLAY_H 1
31
32 extern bool _nc_tty_beep(void);
33 extern bool _nc_tty_check_resize(void);
34 extern bool _nc_tty_cursor(int);
35 extern bool _nc_tty_flash(void);
36 extern bool _nc_tty_init_color(int,int,int,int);
37 extern bool _nc_tty_init_pair(int,int,int);
38 extern bool _nc_tty_slk_hide(bool);
39 extern bool _nc_tty_slk_update(int,const char *);
40 extern bool _nc_tty_start_color(void);
41 extern void _nc_tty_display_resume(void);
42 extern void _nc_tty_display_suspend(void);
43 extern void _nc_tty_dispose(void);      /* frees SP->_term */
44 extern void _nc_tty_switch_to(void);
45 extern void _nc_tty_update(void);
46
47 struct tty_display_data {
48         int             _fifohold;      /* set if breakout marked           */
49         unsigned long   _current_attr;  /* terminal attribute current set   */
50         int             _cursrow;       /* physical cursor row (-1=unknown) */
51         int             _curscol;       /* physical cursor column           */
52
53         /* cursor movement costs; units are 10ths of milliseconds */
54         int             _char_padding;  /* cost of character put            */
55         int             _cr_cost;       /* cost of (carriage_return)        */
56         int             _cup_cost;      /* cost of (cursor_address)         */
57         int             _home_cost;     /* cost of (cursor_home)            */
58         int             _ll_cost;       /* cost of (cursor_to_ll)           */
59 #if USE_HARD_TABS
60         int             _ht_cost;       /* cost of (tab)                    */
61         int             _cbt_cost;      /* cost of (backtab)                */
62 #endif /* USE_HARD_TABS */
63         int             _cub1_cost;     /* cost of (cursor_left)            */
64         int             _cuf1_cost;     /* cost of (cursor_right)           */
65         int             _cud1_cost;     /* cost of (cursor_down)            */
66         int             _cuu1_cost;     /* cost of (cursor_up)              */
67         int             _cub_cost;      /* cost of (parm_cursor_left)       */
68         int             _cuf_cost;      /* cost of (parm_cursor_right)      */
69         int             _cud_cost;      /* cost of (parm_cursor_down)       */
70         int             _cuu_cost;      /* cost of (parm_cursor_up)         */
71         int             _hpa_cost;      /* cost of (column_address)         */
72         int             _vpa_cost;      /* cost of (row_address)            */
73         /* used in lib_doupdate.c, must be chars */
74         int             _ed_cost;       /* cost of (clr_eos)                */
75         int             _el_cost;       /* cost of (clr_eol)                */
76         int             _el1_cost;      /* cost of (clr_bol)                */
77         int             _dch1_cost;     /* cost of (delete_character)       */
78         int             _ich1_cost;     /* cost of (insert_character)       */
79         int             _dch_cost;      /* cost of (parm_dch)               */
80         int             _ich_cost;      /* cost of (parm_ich)               */
81         int             _ech_cost;      /* cost of (erase_chars)            */
82         int             _rep_cost;      /* cost of (repeat_char)            */
83         int             _hpa_ch_cost;   /* cost of (column_address)         */
84         int             _cup_ch_cost;   /* cost of (cursor_address)         */
85         int             _smir_cost;     /* cost of (enter_insert_mode)      */
86         int             _rmir_cost;     /* cost of (exit_insert_mode)       */
87         int             _ip_cost;       /* cost of (insert_padding)         */
88         /* used in lib_mvcur.c */
89         char *          _address_cursor;
90         int             _carriage_return_length;
91         int             _cursor_home_length;
92         int             _cursor_to_ll_length;
93
94         chtype          _xmc_suppress;  /* attributes to suppress if xmc     */
95         chtype          _xmc_triggers;  /* attributes to process if xmc      */
96
97         bool            _sig_winch;
98 };
99
100
101 #define DelCharCost(count) \
102                 ((parm_dch != 0) \
103                 ? D->_dch_cost \
104                 : ((delete_character != 0) \
105                         ? (D->_dch1_cost * count) \
106                         : INFINITY))
107
108 #define InsCharCost(count) \
109                 ((parm_ich != 0) \
110                 ? D->_ich_cost \
111                 : ((enter_insert_mode && exit_insert_mode) \
112                   ? D->_smir_cost + D->_rmir_cost + (D->_ip_cost * count) \
113                   : ((insert_character != 0) \
114                     ? (D->_ich1_cost * count) \
115                     : INFINITY)))
116
117 #if USE_XMC_SUPPORT
118 #define UpdateAttrs(c)  if (D->_current_attr != AttrOf(c)) { \
119                                 attr_t chg = D->_current_attr; \
120                                 vidattr(AttrOf(c)); \
121                                 if (magic_cookie_glitch > 0 \
122                                  && XMC_CHANGES((chg ^ D->_current_attr))) { \
123                                         T(("%s @%d before glitch %d,%d", \
124                                                 __FILE__, __LINE__, \
125                                                 D->_cursrow, \
126                                                 D->_curscol)); \
127                                         _nc_do_xmc_glitch(chg); \
128                                 } \
129                         }
130 #else
131 #define UpdateAttrs(c)  if (D->_current_attr != AttrOf(c)) \
132                                 vidattr(AttrOf(c));
133 #endif
134
135 #define XMC_CHANGES(c) ((c) & D->_xmc_suppress)
136
137 #endif /* TTY_DISPLAY_H */