]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/tty/tty_display.h
ncurses 5.7 - patch 20091121
[ncurses.git] / ncurses / tty / tty_display.h
1 /****************************************************************************
2  * Copyright (c) 1998-2003,2004 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 /*
33  * $Id: tty_display.h,v 1.6 2005/01/01 23:41:12 tom Exp $
34  */
35 extern NCURSES_EXPORT(bool) _nc_tty_beep (void);
36 extern NCURSES_EXPORT(bool) _nc_tty_check_resize (void);
37 extern NCURSES_EXPORT(bool) _nc_tty_cursor (int);
38 extern NCURSES_EXPORT(bool) _nc_tty_flash (void);
39 extern NCURSES_EXPORT(bool) _nc_tty_init_color (int,int,int,int);
40 extern NCURSES_EXPORT(bool) _nc_tty_init_pair (int,int,int);
41 extern NCURSES_EXPORT(bool) _nc_tty_slk_hide (bool);
42 extern NCURSES_EXPORT(bool) _nc_tty_slk_update (int,const char *);
43 extern NCURSES_EXPORT(bool) _nc_tty_start_color (void);
44 extern NCURSES_EXPORT(void) _nc_tty_display_resume (void);
45 extern NCURSES_EXPORT(void) _nc_tty_display_suspend (void);
46 extern NCURSES_EXPORT(void) _nc_tty_dispose (void);     /* frees SP->_term */
47 extern NCURSES_EXPORT(void) _nc_tty_switch_to (void);
48 extern NCURSES_EXPORT(void) _nc_tty_update (void);
49
50 struct tty_display_data {
51         int             _fifohold;      /* set if breakout marked           */
52         unsigned long   _current_attr;  /* terminal attribute current set   */
53         int             _cursrow;       /* physical cursor row (-1=unknown) */
54         int             _curscol;       /* physical cursor column           */
55
56         /* cursor movement costs; units are 10ths of milliseconds */
57         int             _char_padding;  /* cost of character put            */
58         int             _cr_cost;       /* cost of (carriage_return)        */
59         int             _cup_cost;      /* cost of (cursor_address)         */
60         int             _home_cost;     /* cost of (cursor_home)            */
61         int             _ll_cost;       /* cost of (cursor_to_ll)           */
62 #if USE_HARD_TABS
63         int             _ht_cost;       /* cost of (tab)                    */
64         int             _cbt_cost;      /* cost of (backtab)                */
65 #endif /* USE_HARD_TABS */
66         int             _cub1_cost;     /* cost of (cursor_left)            */
67         int             _cuf1_cost;     /* cost of (cursor_right)           */
68         int             _cud1_cost;     /* cost of (cursor_down)            */
69         int             _cuu1_cost;     /* cost of (cursor_up)              */
70         int             _cub_cost;      /* cost of (parm_cursor_left)       */
71         int             _cuf_cost;      /* cost of (parm_cursor_right)      */
72         int             _cud_cost;      /* cost of (parm_cursor_down)       */
73         int             _cuu_cost;      /* cost of (parm_cursor_up)         */
74         int             _hpa_cost;      /* cost of (column_address)         */
75         int             _vpa_cost;      /* cost of (row_address)            */
76         /* used in lib_doupdate.c, must be chars */
77         int             _ed_cost;       /* cost of (clr_eos)                */
78         int             _el_cost;       /* cost of (clr_eol)                */
79         int             _el1_cost;      /* cost of (clr_bol)                */
80         int             _dch1_cost;     /* cost of (delete_character)       */
81         int             _ich1_cost;     /* cost of (insert_character)       */
82         int             _dch_cost;      /* cost of (parm_dch)               */
83         int             _ich_cost;      /* cost of (parm_ich)               */
84         int             _ech_cost;      /* cost of (erase_chars)            */
85         int             _rep_cost;      /* cost of (repeat_char)            */
86         int             _hpa_ch_cost;   /* cost of (column_address)         */
87         int             _cup_ch_cost;   /* cost of (cursor_address)         */
88         int             _smir_cost;     /* cost of (enter_insert_mode)      */
89         int             _rmir_cost;     /* cost of (exit_insert_mode)       */
90         int             _ip_cost;       /* cost of (insert_padding)         */
91         /* used in lib_mvcur.c */
92         char *          _address_cursor;
93         int             _carriage_return_length;
94         int             _cursor_home_length;
95         int             _cursor_to_ll_length;
96
97         chtype          _xmc_suppress;  /* attributes to suppress if xmc     */
98         chtype          _xmc_triggers;  /* attributes to process if xmc      */
99
100         bool            _sig_winch;
101 };
102
103
104 #define DelCharCost(count) \
105                 ((parm_dch != 0) \
106                 ? D->_dch_cost \
107                 : ((delete_character != 0) \
108                         ? (D->_dch1_cost * count) \
109                         : INFINITY))
110
111 #define InsCharCost(count) \
112                 ((parm_ich != 0) \
113                 ? D->_ich_cost \
114                 : ((enter_insert_mode && exit_insert_mode) \
115                   ? D->_smir_cost + D->_rmir_cost + (D->_ip_cost * count) \
116                   : ((insert_character != 0) \
117                     ? ((D->_ich1_cost + D->_ip_cost) * count) \
118                     : INFINITY)))
119
120 #if USE_XMC_SUPPORT
121 #define UpdateAttrs(c)  if (!SameAttrOf(D->_current_attr, AttrOf(c))) { \
122                                 attr_t chg = D->_current_attr; \
123                                 vidattr(AttrOf(c)); \
124                                 if (magic_cookie_glitch > 0 \
125                                  && XMC_CHANGES((chg ^ D->_current_attr))) { \
126                                         T(("%s @%d before glitch %d,%d", \
127                                                 __FILE__, __LINE__, \
128                                                 D->_cursrow, \
129                                                 D->_curscol)); \
130                                         _nc_do_xmc_glitch(chg); \
131                                 } \
132                         }
133 #else
134 #define UpdateAttrs(c)  if (!SameAttrOf(D->_current_attr, AttrOf(c))) \
135                                 vidattr(AttrOf(c));
136 #endif
137
138 #define XMC_CHANGES(c) ((c) & D->_xmc_suppress)
139
140 #endif /* TTY_DISPLAY_H */