1 /*======================================================================*\
2 |	Library to determine and enquire terminal properties
3 |	(developed as part of mined editor)
4 \*======================================================================*/
5 
6 #include "termprop.h"
7 
8 
9 /*======================================================================*\
10 |	Terminal properties to be determined
11 \*======================================================================*/
12 
13 /* basic terminal encoding modes */
14 FLAG ascii_screen = False;	/* screen driven in ASCII mode ? */
15 FLAG utf8_screen = False;	/* screen driven in UTF-8 mode ? */
16 FLAG utf8_input = False;	/* keyboard input in UTF-8 mode ? */
17 FLAG combining_screen = False;	/* combining character terminal ? */
18 FLAG bidi_screen = False;	/* UTF-8 bidi terminal ? */
19 FLAG joining_screen = False;	/* UTF-8 terminal with Arabic LAM/ALEF joining ? */
20 FLAG halfjoining_screen = False;	/* Putty/mintty joining + spare space ? */
21 
22 FLAG mapped_term = False;	/* terminal in mapped 8-bit mode ? */
23 
24 FLAG cjk_term = False;		/* terminal in CJK mode ? */
25 FLAG cjk_uni_term = False;	/* terminal in CJK mode with Unicode widths ? */
26 FLAG cjk_wide_latin1 = True;	/* wide CJK chars in Latin-1 range ? */
27 FLAG gb18030_term = True;	/* does CJK terminal support GB18030 ? */
28 FLAG euc3_term = True;		/* does CJK terminal support EUC 3 byte ? */
29 FLAG euc4_term = True;		/* does CJK terminal support EUC 4 byte ? */
30 FLAG cjklow_term = True;	/* does CJK terminal support 81-9F range ? */
31 int cjk_tab_width;		/* width of CJK TAB indicator */
32 int cjk_lineend_width;		/* width of CJK line end indicator */
33 int cjk_currency_width = 0;	/* width of CJK cent/pound/yen characters */
34 
35 /* basic data versions of Unicode; defaults overwritten by auto-detection */
36 #ifdef older_defaults
37 int width_data_version = U320;		/* Unicode 3.2 */
38 int combining_data_version = U320;	/* Unicode 3.2 */
39 #else
40 int width_data_version = U410;		/* Unicode 4.1 and later */
41 int combining_data_version = U500;	/* Unicode 5.0 */
42 #endif
43 
44 /* special modes */
45 int cjk_width_data_version = 0;	/* xterm CJK legacy width mode -cjk_width */
46 FLAG hangul_jamo_extended = False;	/* U+D7B0... combining Jamo ? */
47 
48 /* specific behaviour of specific terminals */
49 FLAG unassigned_single_width = False;	/* unassigned chars displayed single width? */
50 FLAG spacing_combining = False;		/* mlterm */
51 FLAG wide_Yijing_hexagrams = True;	/* wcwidth glitch */
52 FLAG printable_bidi_controls = False;	/* since xterm 230 */
53 
54 /* version indications of specific terminals */
55 int decterm_version = 0;
56 int xterm_version = 0;
57 int gnome_terminal_version = 0;
58 int rxvt_version = 0;
59 int konsole_version = 0;
60 int mintty_version = 0;
61 int mlterm_version = 0;
62 int poderosa_version = 0;
63 int screen_version = 0;
64 int tmux_version = 0;
65 
66 /* terminal features with respect to non-BMP characters (>= 0x10000) */
67 int nonbmp_width_data = 0x4;
68 
69 
70 /*======================================================================*\
71 |	Unicode version information
72 \*======================================================================*/
73 
74 static struct name_table {
75 	int mode;
76 	char * name;
77 } Unicode_version_names [] = {
78 	{U300beta, "Unicode < 3.0 (beta? - xterm)"},
79 	{U300, "Unicode 3.0"},
80 	{U320beta, "Unicode < 3.2 (beta? - xterm CJK)"},
81 	{U320, "Unicode 3.2"},
82 	{U400, "Unicode 4.0"},
83 	{U410, "Unicode 4.1"},
84 	{U500, "Unicode 5.0"},
85 	{U510, "Unicode 5.1"},
86 	{U520, "Unicode 5.2"},
87 	{U600, "Unicode 6.0"},
88 	{U620, "Unicode 6.1/6.2"},
89 	{U630, "Unicode 6.3"},
90 	{U700, "Unicode 7.0"},
91 	{0, 0}
92 };
93 
94 /* return name of Unicode version applied by terminal */
95 char *
term_Unicode_version_name(v)96 term_Unicode_version_name (v)
97   int v;
98 {
99   struct name_table * t = Unicode_version_names;
100   while (t->name) {
101 	if (v == t->mode) {
102 		return t->name;
103 	}
104 	t ++;
105   }
106   return "?";
107 }
108 
109 
110 /*======================================================================*\
111 |	End
112 \*======================================================================*/
113