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 Copyright (C) 2007 Nelson Ferreira
6 This file is part of SXEmacs
8 SXEmacs is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 SXEmacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 /* Synched up with: Not in FSF. */
24 /* Written by Chuck Thompson, Ben Wing and Nelson Ferreira */
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. */
32 #ifndef INCLUDED_console_tty_h_
33 #define INCLUDED_console_tty_h_
35 #include "ui/console.h"
36 #include "syssignal.h" /* Always include before systty.h */
37 #include "ui/systty.h"
39 DECLARE_CONSOLE_TYPE(tty);
43 Lisp_Object instream, outstream;
44 Lisp_Object terminal_type;
45 Lisp_Object controlling_process;
46 Lisp_Object term_cmap;
47 Lisp_Object term_crgb;
49 char *term_entry_buffer;
51 /* Physical location of cursor on this console. */
55 /* The real location of the cursor. The above physical location may
56 be ahead of where we really are. */
69 /* The count of frame number. */
72 /* flags indicating presence, absence or value of various features */
74 /* terminal inserts nulls, not
75 spaces to fill whitespace on
78 unsigned int must_write_spaces:1;
80 /* cursor movement commands
81 work while in insert mode
83 unsigned int insert_mode_motion:1;
85 /* cursor movement is graceful
86 in standout or underline mode */
87 unsigned int standout_motion:1;
89 /* display retained above screen */
90 unsigned int memory_above_frame:1;
92 /* display retained below screen */
93 unsigned int memory_below_frame:1;
94 unsigned int meta_key:2; /* 0 == mask off top bit;
96 2 == top bit is useful as
98 unsigned int flow_control:1; /* Nonzero means use ^S/^Q as
99 cretinous flow control. */
100 int standout_width; /* # of spaces printed when
101 change to standout mode */
102 int underline_width; /* # of spaces printed when
103 change to underline mode */
106 /* cursor motion entries - each entry is commented with the terminfo
107 and the termcap entry */
109 /* local cursor movement */
110 const char *up; /* cuu1, up */
111 const char *down; /* cud1, do */
112 const char *left; /* cub1, le */
113 const char *right; /* cuf1, nd */
114 const char *home; /* home, ho */
115 const char *low_left; /* ll, ll */
116 const char *car_return; /* cr, cr */
118 /* parameterized local cursor movement */
119 const char *multi_up; /* cuu, UP */
120 const char *multi_down; /* cud, DO */
121 const char *multi_left; /* cub, LE */
122 const char *multi_right; /* cuf, RI */
124 /* absolute cursor motion */
125 const char *abs; /* cup, cm */
126 const char *hor_abs; /* hpa, ch */
127 const char *ver_abs; /* vpa, cv */
130 const char *scroll_forw; /* ind, sf */
131 const char *scroll_back; /* ri, sr */
132 const char *multi_scroll_forw; /* indn, SF */
133 const char *multi_scroll_back; /* rin, SR */
134 const char *set_scroll_region; /* csr, cs */
138 /* screen editing entries - each entry is commented with the
139 terminfo and the termcap entry */
141 /* adding to the screen */
142 const char *ins_line; /* il1, al */
143 const char *multi_ins_line; /* il, AL */
144 const char *repeat; /* rep, rp */
145 const char *begin_ins_mode; /* smir, im */
146 const char *end_ins_mode; /* rmir, ei */
147 const char *ins_char; /* ich1, ic */
148 const char *multi_ins_char; /* ich, IC */
149 const char *insert_pad; /* ip, ip */
151 /* deleting from the screen */
152 const char *clr_frame; /* clear, cl */
153 const char *clr_from_cursor; /* ed, cd */
154 const char *clr_to_eol; /* el, ce */
155 const char *del_line; /* dl1, dl */
156 const char *multi_del_line; /* dl, DL */
157 const char *del_char; /* dch1, dc */
158 const char *multi_del_char; /* dch, DC */
159 const char *begin_del_mode; /* smdc, dm */
160 const char *end_del_mode; /* rmdc, ed */
161 const char *erase_at_cursor; /* ech, ec */
164 /* screen display entries - each entry is commented with the
165 terminfo and termcap entry */
167 const char *begin_standout_; /* smso, so */
168 const char *end_standout_; /* rmso, se */
169 const char *begin_underline_; /* smul, us */
170 const char *end_underline_; /* rmul, ue */
171 const char *begin_alternate_; /* smacs, as */
172 const char *end_alternate_; /* rmacs, ae */
174 const char *turn_on_reverse_; /* rev, mr */
175 const char *turn_on_blinking_; /* blink, mb */
176 const char *turn_on_bold_; /* bold, md */
177 const char *turn_on_dim_; /* dim, mh */
178 const char *turn_off_attributes_; /* sgr0, me */
181 const char *visual_bell_; /* flash, vb */
182 const char *audio_bell_; /* bel, bl */
184 const char *cursor_visible_; /* cvvis, vs */
185 const char *cursor_normal_; /* cnorm, ve */
186 const char *init_motion_; /* smcup, ti */
187 const char *end_motion_; /* rmcup, te */
188 const char *keypad_on_; /* smkx, ks */
189 const char *keypad_off_; /* rmkx, ke */
192 const char *set_fore_; /* setf, Sf */
193 const char *set_back_; /* setb, Sb */
194 /* tparm doesnt want these constant */
195 char *set_afore_; /* setaf, AF */
196 char *set_aback_; /* setab, AB */
197 const char *orig_pair_; /* op, op */
200 /* costs of various operations */
214 /* The initial tty mode bits */
215 struct emacs_tty old_tty;
217 /* Is this TTY our controlling terminal? */
218 unsigned int controlling_terminal:1;
219 unsigned int is_stdio:1;
221 /* Some flags relating to expanding the colors */
222 unsigned int is_bold_brighter :1;
223 unsigned int is_reverse_brighter :1;
224 unsigned int nearest_color :1;
227 #define CONSOLE_TTY_DATA(c) CONSOLE_TYPE_DATA (c, tty)
228 #define CONSOLE_TTY_CURSOR_X(c) (CONSOLE_TTY_DATA (c)->cursor_x)
229 #define CONSOLE_TTY_CURSOR_Y(c) (CONSOLE_TTY_DATA (c)->cursor_y)
230 #define CONSOLE_TTY_REAL_CURSOR_X(c) (CONSOLE_TTY_DATA (c)->real_cursor_x)
231 #define CONSOLE_TTY_REAL_CURSOR_Y(c) (CONSOLE_TTY_DATA (c)->real_cursor_y)
232 #define CONSOLE_TTY_FINAL_CURSOR_X(c) (CONSOLE_TTY_DATA (c)->final_cursor_x)
233 #define CONSOLE_TTY_FINAL_CURSOR_Y(c) (CONSOLE_TTY_DATA (c)->final_cursor_y)
235 #define TTY_CM(c) (CONSOLE_TTY_DATA (c)->cm)
236 #define TTY_SE(c) (CONSOLE_TTY_DATA (c)->se)
237 #define TTY_SD(c) (CONSOLE_TTY_DATA (c)->sd)
238 #define TTY_FLAGS(c) (CONSOLE_TTY_DATA (c)->flags)
239 #define TTY_COST(c) (CONSOLE_TTY_DATA (c)->cost)
241 #define TTY_INC_CURSOR_X(c, n) do { \
243 assert (CONSOLE_TTY_CURSOR_X (c) == CONSOLE_TTY_REAL_CURSOR_X (c)); \
244 CONSOLE_TTY_CURSOR_X (c) += TICX_n; \
245 CONSOLE_TTY_REAL_CURSOR_X (c) += TICX_n; \
248 #define TTY_INC_CURSOR_Y(c, n) do { \
250 CONSOLE_TTY_CURSOR_Y (c) += TICY_n; \
251 CONSOLE_TTY_REAL_CURSOR_Y (c) += TICY_n; \
256 speed_t ospeed; /* Output speed (from sg_ospeed) */
258 short ospeed; /* Output speed (from sg_ospeed) */
262 #define DEVICE_TTY_DATA(d) DEVICE_TYPE_DATA (d, tty)
264 /* termcap requires this to be global */
266 extern short ospeed; /* Output speed (from sg_ospeed) */
269 extern FILE *termscript;
271 EXFUN(Fconsole_tty_controlling_process, 1);
273 /****************** Prototypes from cm.c *******************/
275 /* #### Verify that all of these are still needed. */
277 void cm_cost_init(struct console *c);
279 void cmgoto(struct frame *f, int row, int col);
280 extern struct console *cmputc_console;
281 void send_string_to_tty_console(struct console *c, unsigned char *str, int len);
283 /*************** Prototypes from redisplay-tty.c ****************/
285 enum term_init_status {
286 TTY_UNABLE_OPEN_DATABASE,
288 TTY_TYPE_INSUFFICIENT,
289 TTY_SIZE_UNSPECIFIED,
293 int init_tty_for_redisplay(struct device *d, char *terminal_type);
294 /* #### These should probably be methods. */
295 void set_tty_modes(struct console *c);
296 void reset_tty_modes(struct console *c);
298 /* Used in sysdep.c to properly clear and position the cursor when exiting. */
299 void tty_redisplay_shutdown(struct console *c);
301 /* called from console-stream.c */
302 Lisp_Object tty_semi_canonicalize_console_connection(Lisp_Object connection,
303 Error_behavior errb);
304 Lisp_Object tty_canonicalize_console_connection(Lisp_Object connection,
305 Error_behavior errb);
306 Lisp_Object tty_semi_canonicalize_device_connection(Lisp_Object connection,
307 Error_behavior errb);
308 Lisp_Object tty_canonicalize_device_connection(Lisp_Object connection,
309 Error_behavior errb);
310 struct console *tty_find_console_from_fd(int fd);
312 /* called from redisplay-tty.c */
313 EXFUN(find_tty_color,3);
315 #endif /* INCLUDED_console_tty_h_ */