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