Mercurial > hg > xemacs-beta
annotate src/console-tty-impl.h @ 5398:5256fedd50e6
issue 757 - tty device metric for num-color-cells
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2011-03-28 Jeff Sparkes <jsparkes@gmail.com>
* console-tty-impl.h (struct tty_console): Add field for number of
displayable colors.
* device-tty.c (tty_device_system_metrics): Return metrics for
num-color-cells and num-bit-planes. Tracker issue 757.
* device.c: There are two required args for device-system-metric.
* redisplay-tty.c (init_tty_for_redisplay): Retrieve number of
colors from terminal description. Default to 2 if none found.
author | Jeff Sparkes <jsparkes@gmail.com> |
---|---|
date | Mon, 28 Mar 2011 09:25:15 -0400 |
parents | a9c41067dd88 |
children | 248176c74e6b |
rev | line source |
---|---|
872 | 1 /* Define TTY specific console, device, and frame object for XEmacs. |
2 Copyright (C) 1995 Board of Trustees, University of Illinois. | |
3 Copyright (C) 1996 Ben Wing. | |
4 | |
5 This file is part of XEmacs. | |
6 | |
7 XEmacs is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 2, or (at your option) any | |
10 later version. | |
11 | |
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with XEmacs; see the file COPYING. If not, write to | |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 Boston, MA 02111-1307, USA. */ | |
21 | |
22 /* Synched up with: Not in FSF. */ | |
23 | |
24 /* Written by Chuck Thompson and Ben Wing. */ | |
25 | |
26 /* NOTE: Currently each TTY console can have only one device. | |
27 Therefore, all stuff for both input and output is lumped into | |
28 the console structure. If it ever becomes meaningful to | |
29 have more than one device on a TTY console, the output stuff | |
30 will have to get separated out. */ | |
31 | |
32 #ifndef INCLUDED_console_tty_impl_h_ | |
33 #define INCLUDED_console_tty_impl_h_ | |
34 | |
35 #include "console-impl.h" | |
36 #include "console-tty.h" | |
37 | |
38 DECLARE_CONSOLE_TYPE (tty); | |
39 | |
40 struct tty_console | |
41 { | |
3092 | 42 #ifdef NEW_GC |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
43 NORMAL_LISP_OBJECT_HEADER header; |
3092 | 44 #endif /* NEW_GC */ |
872 | 45 int infd, outfd; |
46 Lisp_Object instream, outstream; | |
47 Lisp_Object terminal_type; | |
48 Lisp_Object controlling_process; | |
49 char *term_entry_buffer; | |
50 | |
51 /* Physical location of cursor on this console. */ | |
52 int cursor_x; | |
53 int cursor_y; | |
54 | |
55 /* The real location of the cursor. The above physical location may | |
56 be ahead of where we really are. */ | |
57 int real_cursor_x; | |
58 int real_cursor_y; | |
59 | |
60 int final_cursor_x; | |
61 int final_cursor_y; | |
62 | |
63 int height; | |
64 int width; | |
65 | |
5398
5256fedd50e6
issue 757 - tty device metric for num-color-cells
Jeff Sparkes <jsparkes@gmail.com>
parents:
5127
diff
changeset
|
66 int colors; |
5256fedd50e6
issue 757 - tty device metric for num-color-cells
Jeff Sparkes <jsparkes@gmail.com>
parents:
5127
diff
changeset
|
67 |
872 | 68 /* The count of frame number. */ |
69 int frame_count; | |
70 | |
71 /* flags indicating presence, absence or value of various features */ | |
72 struct | |
73 { | |
74 unsigned int must_write_spaces :1; /* terminal inserts nulls, not | |
75 spaces to fill whitespace on | |
76 screen */ | |
77 unsigned int insert_mode_motion :1; /* cursor movement commands | |
78 work while in insert mode */ | |
79 unsigned int standout_motion :1; /* cursor movement is graceful | |
80 in standout or underline mode */ | |
81 unsigned int memory_above_frame :1; /* display retained above screen */ | |
82 unsigned int memory_below_frame :1; /* display retained below screen */ | |
83 unsigned int meta_key :2; /* 0 == mask off top bit; | |
84 1 == top bit is meta; | |
85 2 == top bit is useful as | |
86 character info */ | |
87 unsigned int flow_control :1; /* Nonzero means use ^S/^Q as | |
88 cretinous flow control. */ | |
89 int standout_width; /* # of spaces printed when | |
90 change to standout mode */ | |
91 int underline_width; /* # of spaces printed when | |
92 change to underline mode */ | |
93 } flags; | |
94 | |
95 /* cursor motion entries - each entry is commented with the terminfo | |
96 and the termcap entry */ | |
97 struct | |
98 { | |
99 /* local cursor movement */ | |
100 const char *up; /* cuu1, up */ | |
101 const char *down; /* cud1, do */ | |
102 const char *left; /* cub1, le */ | |
103 const char *right; /* cuf1, nd */ | |
104 const char *home; /* home, ho */ | |
105 const char *low_left; /* ll, ll */ | |
106 const char *car_return; /* cr, cr */ | |
107 | |
108 /* parameterized local cursor movement */ | |
109 const char *multi_up; /* cuu, UP */ | |
110 const char *multi_down; /* cud, DO */ | |
111 const char *multi_left; /* cub, LE */ | |
112 const char *multi_right; /* cuf, RI */ | |
113 | |
114 /* absolute cursor motion */ | |
115 const char *abs; /* cup, cm */ | |
116 const char *hor_abs; /* hpa, ch */ | |
117 const char *ver_abs; /* vpa, cv */ | |
118 | |
119 /* scrolling */ | |
120 const char *scroll_forw; /* ind, sf */ | |
121 const char *scroll_back; /* ri, sr */ | |
122 const char *multi_scroll_forw; /* indn, SF */ | |
123 const char *multi_scroll_back; /* rin, SR */ | |
124 const char *set_scroll_region; /* csr, cs */ | |
125 } cm; | |
126 | |
127 /* screen editing entries - each entry is commented with the | |
128 terminfo and the termcap entry */ | |
129 struct | |
130 { | |
131 /* adding to the screen */ | |
132 const char *ins_line; /* il1, al */ | |
133 const char *multi_ins_line; /* il, AL */ | |
134 const char *repeat; /* rep, rp */ | |
135 const char *begin_ins_mode; /* smir, im */ | |
136 const char *end_ins_mode; /* rmir, ei */ | |
137 const char *ins_char; /* ich1, ic */ | |
138 const char *multi_ins_char; /* ich, IC */ | |
139 const char *insert_pad; /* ip, ip */ | |
140 | |
141 /* deleting from the screen */ | |
142 const char *clr_frame; /* clear, cl */ | |
143 const char *clr_from_cursor; /* ed, cd */ | |
144 const char *clr_to_eol; /* el, ce */ | |
145 const char *del_line; /* dl1, dl */ | |
146 const char *multi_del_line; /* dl, DL */ | |
147 const char *del_char; /* dch1, dc */ | |
148 const char *multi_del_char; /* dch, DC */ | |
149 const char *begin_del_mode; /* smdc, dm */ | |
150 const char *end_del_mode; /* rmdc, ed */ | |
151 const char *erase_at_cursor; /* ech, ec */ | |
152 } se; | |
153 | |
154 /* screen display entries - each entry is commented with the | |
155 terminfo and termcap entry */ | |
156 struct | |
157 { | |
158 const char *begin_standout; /* smso, so */ | |
159 const char *end_standout; /* rmso, se */ | |
160 const char *begin_underline; /* smul, us */ | |
161 const char *end_underline; /* rmul, ue */ | |
162 const char *begin_alternate; /* smacs, as */ | |
163 const char *end_alternate; /* rmacs, ae */ | |
164 | |
165 const char *turn_on_reverse; /* rev, mr */ | |
166 const char *turn_on_blinking; /* blink, mb */ | |
167 const char *turn_on_bold; /* bold, md */ | |
168 const char *turn_on_dim; /* dim, mh */ | |
169 const char *turn_off_attributes; /* sgr0, me */ | |
170 | |
171 const char *visual_bell; /* flash, vb */ | |
172 const char *audio_bell; /* bel, bl */ | |
173 | |
174 const char *cursor_visible; /* cvvis, vs */ | |
175 const char *cursor_normal; /* cnorm, ve */ | |
176 const char *init_motion; /* smcup, ti */ | |
177 const char *end_motion; /* rmcup, te */ | |
178 const char *keypad_on; /* smkx, ks */ | |
179 const char *keypad_off; /* rmkx, ke */ | |
180 | |
181 const char *orig_pair; /* op, op */ | |
182 } sd; | |
183 | |
184 /* costs of various operations */ | |
185 struct | |
186 { | |
187 int cm_up; | |
188 int cm_down; | |
189 int cm_left; | |
190 int cm_right; | |
191 int cm_home; | |
192 int cm_low_left; | |
193 int cm_car_return; | |
194 int cm_abs; | |
195 int cm_hor_abs; | |
196 int cm_ver_abs; | |
197 } cost; | |
198 | |
199 /* The initial tty mode bits */ | |
200 struct emacs_tty old_tty; | |
201 | |
202 /* Is this TTY our controlling terminal? */ | |
203 unsigned int controlling_terminal :1; | |
204 unsigned int is_stdio :1; | |
3571 | 205 /* Do East Asian chars take up two columns? */ |
206 unsigned int multiple_width :1; | |
872 | 207 }; |
208 | |
3092 | 209 #ifdef NEW_GC |
210 typedef struct tty_console Lisp_Tty_Console; | |
211 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
3571
diff
changeset
|
212 DECLARE_LISP_OBJECT (tty_console, Lisp_Tty_Console); |
3092 | 213 |
214 #define XTTY_CONSOLE(x) \ | |
215 XRECORD (x, tty_console, Lisp_Tty_Console) | |
216 #define wrap_tty_console(p) wrap_record (p, tty_console) | |
217 #define TTY_CONSOLE_P(x) RECORDP (x, tty_console) | |
218 #endif /* NEW_GC */ | |
219 | |
872 | 220 #define CONSOLE_TTY_DATA(c) CONSOLE_TYPE_DATA (c, tty) |
221 #define CONSOLE_TTY_CURSOR_X(c) (CONSOLE_TTY_DATA (c)->cursor_x) | |
222 #define CONSOLE_TTY_CURSOR_Y(c) (CONSOLE_TTY_DATA (c)->cursor_y) | |
223 #define CONSOLE_TTY_REAL_CURSOR_X(c) (CONSOLE_TTY_DATA (c)->real_cursor_x) | |
224 #define CONSOLE_TTY_REAL_CURSOR_Y(c) (CONSOLE_TTY_DATA (c)->real_cursor_y) | |
225 #define CONSOLE_TTY_FINAL_CURSOR_X(c) (CONSOLE_TTY_DATA (c)->final_cursor_x) | |
226 #define CONSOLE_TTY_FINAL_CURSOR_Y(c) (CONSOLE_TTY_DATA (c)->final_cursor_y) | |
227 | |
3571 | 228 /* In a more ideal world where available terminfo files actually included |
229 information on whether a given TTY supports double-width characters or | |
230 not, oh, and where Mule was not conditional, SUPPORTS_MULTIPLE_WIDTH | |
231 would be as console-specific as its syntax implies. | |
232 | |
233 In this world, this is overengineering more than it is anything. */ | |
234 #define CONSOLE_TTY_SUPPORTS_MULTIPLE_WIDTH(c) (1 != MAX_ICHAR_LEN) | |
235 #define CONSOLE_TTY_MULTIPLE_WIDTH(c) \ | |
236 (CONSOLE_TTY_SUPPORTS_MULTIPLE_WIDTH(c) ? \ | |
237 CONSOLE_TTY_DATA (c)->multiple_width : (0)) | |
238 | |
872 | 239 #define TTY_CM(c) (CONSOLE_TTY_DATA (c)->cm) |
240 #define TTY_SE(c) (CONSOLE_TTY_DATA (c)->se) | |
241 #define TTY_SD(c) (CONSOLE_TTY_DATA (c)->sd) | |
242 #define TTY_FLAGS(c) (CONSOLE_TTY_DATA (c)->flags) | |
243 #define TTY_COST(c) (CONSOLE_TTY_DATA (c)->cost) | |
244 | |
245 #define TTY_INC_CURSOR_X(c, n) do { \ | |
246 int TICX_n = (n); \ | |
247 assert (CONSOLE_TTY_CURSOR_X (c) == CONSOLE_TTY_REAL_CURSOR_X (c)); \ | |
248 CONSOLE_TTY_CURSOR_X (c) += TICX_n; \ | |
249 CONSOLE_TTY_REAL_CURSOR_X (c) += TICX_n; \ | |
250 } while (0) | |
251 | |
252 #define TTY_INC_CURSOR_Y(c, n) do { \ | |
253 int TICY_n = (n); \ | |
254 CONSOLE_TTY_CURSOR_Y (c) += TICY_n; \ | |
255 CONSOLE_TTY_REAL_CURSOR_Y (c) += TICY_n; \ | |
256 } while (0) | |
257 | |
258 struct tty_device | |
259 { | |
3092 | 260 #ifdef NEW_GC |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
261 NORMAL_LISP_OBJECT_HEADER header; |
3092 | 262 #endif /* NEW_GC */ |
872 | 263 #ifdef HAVE_TERMIOS |
264 speed_t ospeed; /* Output speed (from sg_ospeed) */ | |
265 #else | |
266 short ospeed; /* Output speed (from sg_ospeed) */ | |
267 #endif | |
268 }; | |
269 | |
3092 | 270 #ifdef NEW_GC |
271 typedef struct tty_device Lisp_Tty_Device; | |
272 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
3571
diff
changeset
|
273 DECLARE_LISP_OBJECT (tty_device, Lisp_Tty_Device); |
3092 | 274 |
275 #define XTTY_DEVICE(x) \ | |
276 XRECORD (x, tty_device, Lisp_Tty_Device) | |
277 #define wrap_tty_device(p) wrap_record (p, tty_device) | |
278 #define TTY_DEVICE_P(x) RECORDP (x, tty_device) | |
279 #endif /* NEW_GC */ | |
280 | |
872 | 281 #define DEVICE_TTY_DATA(d) DEVICE_TYPE_DATA (d, tty) |
282 | |
283 /* termcap requires this to be global */ | |
284 #ifndef HAVE_TERMIOS | |
285 extern short ospeed; /* Output speed (from sg_ospeed) */ | |
286 #endif | |
287 | |
288 #endif /* INCLUDED_console_tty_impl_h_ */ |