libt3window
|
00001 /* Copyright (C) 2011-2012 G.P. Halkes 00002 This program is free software: you can redistribute it and/or modify 00003 it under the terms of the GNU General Public License version 3, as 00004 published by the Free Software Foundation. 00005 00006 This program is distributed in the hope that it will be useful, 00007 but WITHOUT ANY WARRANTY; without even the implied warranty of 00008 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00009 GNU General Public License for more details. 00010 00011 You should have received a copy of the GNU General Public License 00012 along with this program. If not, see <http://www.gnu.org/licenses/>. 00013 */ 00014 #ifndef T3_INTERNAL_H 00015 #define T3_INTERNAL_H 00016 00017 #include <limits.h> 00018 #ifdef HAS_SELECT_H 00019 #include <sys/select.h> 00020 #else 00021 #include <sys/time.h> 00022 #include <sys/types.h> 00023 #endif 00024 #include <stdint.h> 00025 00026 #include "window_api.h" 00027 00028 #define WIDTH_TO_META(_w) (((_w) & 3) << CHAR_BIT) 00029 00030 #define WIDTH_MASK (3 << CHAR_BIT) 00031 #define META_MASK (~((1 << CHAR_BIT) - 1)) 00032 00033 #define BASIC_ATTRS (T3_ATTR_UNDERLINE | T3_ATTR_BOLD | T3_ATTR_REVERSE | T3_ATTR_BLINK | T3_ATTR_DIM | T3_ATTR_ACS) 00034 00035 #define INITIAL_ALLOC 80 00036 00037 #define _T3_BLOCK_SIZE_TO_WIDTH(x) ((int)((x & 1) + 1)) 00038 00039 typedef struct { 00040 char *data; /* Data bytes. */ 00041 int start; /* Offset of data bytes in screen cells from the edge of the t3_window_t. */ 00042 int width; /* Width in cells of the the data. */ 00043 int length; /* Length in bytes. */ 00044 int allocated; /* Allocated number of bytes. */ 00045 } line_data_t; 00046 00047 struct t3_window_t { 00048 int x, y; /* X and Y coordinates of the t3_window_t. These may be relative to parent, depending on relation. */ 00049 int paint_x, paint_y; /* Drawing cursor */ 00050 int width, height; /* Height and width of the t3_window_t */ 00051 int depth; /* Depth in stack. Higher values are deeper and thus obscured by Windows with lower depth. */ 00052 int relation; /* Relation of this t3_window_t to parent. See window.h for values. */ 00053 int cached_pos_line; 00054 int cached_pos; 00055 int cached_pos_width; 00056 t3_attr_t default_attrs; /* Default attributes to be combined with drawing attributes. 00057 Mostly useful for background specification. */ 00058 t3_bool shown; /* Indicates whether this t3_window_t is visible. */ 00059 line_data_t *lines; /* The contents of the t3_window_t. */ 00060 t3_window_t *parent; /* t3_window_t used for clipping. */ 00061 t3_window_t *anchor; /* t3_window_t for relative placment. */ 00062 t3_window_t *restrictw; /* t3_window_t for restricting the placement of the window. [restrict is seen as keyword by clang :-(]*/ 00063 00064 /* Pointers for linking into depth sorted list. */ 00065 t3_window_t *next; 00066 t3_window_t *prev; 00067 00068 t3_window_t *head; 00069 t3_window_t *tail; 00070 }; 00071 00072 T3_WINDOW_LOCAL t3_bool _t3_win_refresh_term_line(int line); 00073 T3_WINDOW_LOCAL int _t3_term_get_default_acs(int idx); 00074 T3_WINDOW_LOCAL void _t3_remove_window(t3_window_t *win); 00075 00076 T3_WINDOW_LOCAL extern t3_window_t *_t3_terminal_window; 00077 00078 enum { 00079 _T3_TERM_UNKNOWN, 00080 _T3_TERM_UTF8, 00081 _T3_TERM_GB18030, 00082 _T3_TERM_SINGLE_BYTE, /* Generic single byte encoding. Pray that LC_CTYPE has been set correctly. */ 00083 _T3_TERM_CJK, /* One of the CJK encodings has been detected. More detection required. */ 00084 _T3_TERM_CJK_SHIFT_JIS, 00085 _T3_TERM_GBK 00086 }; 00087 00088 enum { 00089 _T3_MODHACK_NONE, 00090 _T3_MODHACK_LINUX 00091 }; 00092 00093 typedef enum { 00094 _T3_ACS_AUTO, 00095 _T3_ACS_ASCII, 00096 _T3_ACS_UTF8 00097 } t3_acs_override_t; 00098 00099 T3_WINDOW_LOCAL extern int _t3_term_encoding, _t3_term_combining, _t3_term_double_width; 00100 T3_WINDOW_LOCAL extern char _t3_current_charset[80]; 00101 T3_WINDOW_LOCAL extern long _t3_detection_needs_finishing; 00102 T3_WINDOW_LOCAL extern int _t3_terminal_in_fd; 00103 T3_WINDOW_LOCAL extern int _t3_terminal_out_fd; 00104 T3_WINDOW_LOCAL extern fd_set _t3_inset; 00105 00106 T3_WINDOW_LOCAL extern char *_t3_cup, 00107 *_t3_sc, 00108 *_t3_rc, 00109 *_t3_clear, 00110 *_t3_home, 00111 *_t3_vpa, 00112 *_t3_hpa, 00113 *_t3_cud, 00114 *_t3_cud1, 00115 *_t3_cuf, 00116 *_t3_cuf1, 00117 *_t3_civis, 00118 *_t3_cnorm, 00119 *_t3_sgr, 00120 *_t3_setaf, 00121 *_t3_setab, 00122 *_t3_op, 00123 *_t3_smacs, 00124 *_t3_rmacs, 00125 *_t3_sgr0, 00126 *_t3_smul, 00127 *_t3_rmul, 00128 *_t3_rev, 00129 *_t3_bold, 00130 *_t3_blink, 00131 *_t3_dim, 00132 *_t3_setf, 00133 *_t3_setb, 00134 *_t3_el, 00135 *_t3_scp; 00136 T3_WINDOW_LOCAL extern int _t3_lines, _t3_columns; 00137 T3_WINDOW_LOCAL extern const char *_t3_default_alternate_chars[256]; 00138 T3_WINDOW_LOCAL extern t3_attr_t _t3_attrs, _t3_ansi_attrs, _t3_reset_required_mask; 00139 T3_WINDOW_LOCAL extern t3_attr_t _t3_ncv; 00140 T3_WINDOW_LOCAL extern t3_bool _t3_bce; 00141 T3_WINDOW_LOCAL extern int _t3_colors, _t3_pairs; 00142 T3_WINDOW_LOCAL extern char _t3_alternate_chars[256]; 00143 T3_WINDOW_LOCAL extern line_data_t _t3_old_data; 00144 T3_WINDOW_LOCAL extern t3_bool _t3_show_cursor; 00145 T3_WINDOW_LOCAL extern int _t3_cursor_y, _t3_cursor_x; 00146 T3_WINDOW_LOCAL extern t3_acs_override_t _t3_acs_override; 00147 00148 T3_WINDOW_LOCAL void _t3_do_cup(int line, int col); 00149 T3_WINDOW_LOCAL void _t3_set_alternate_chars_defaults(void); 00150 T3_WINDOW_LOCAL void _t3_set_attrs(t3_attr_t new_attrs); 00151 00152 T3_WINDOW_LOCAL extern t3_window_t *_t3_head, *_t3_tail; 00153 T3_WINDOW_LOCAL t3_bool _t3_win_is_shown(t3_window_t *win); 00154 T3_WINDOW_LOCAL t3_attr_t _t3_term_sanitize_attrs(t3_attr_t attrs); 00155 00156 T3_WINDOW_LOCAL int _t3_map_attr(t3_attr_t attr); 00157 T3_WINDOW_LOCAL t3_attr_t _t3_get_attr(int idx); 00158 T3_WINDOW_LOCAL void _t3_init_attr_map(void); 00159 T3_WINDOW_LOCAL void _t3_free_attr_map(void); 00160 00161 #define _t3_get_value(s, size) (((s)[0] & 0x80) ? _t3_get_value_int(s, size) : (*(size) = 1, (s)[0])) 00162 T3_WINDOW_LOCAL uint32_t _t3_get_value_int(const char *s, size_t *size); 00163 T3_WINDOW_LOCAL size_t _t3_put_value(uint32_t c, char *dst); 00164 T3_WINDOW_LOCAL int _t3_modifier_hack; 00165 #endif