aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2004-01-01 17:55:53 +0000
committerKaroly Lorentey2004-01-01 17:55:53 +0000
commit28d7d09f841801cd052bb4ba0df92016b9245870 (patch)
treeeed006b0a32c39edb7a37d893bb2b192c63b69a5 /src
parent819b8f00ed7b8a9a2190efaa02376ed332ecf763 (diff)
downloademacs-28d7d09f841801cd052bb4ba0df92016b9245870.tar.gz
emacs-28d7d09f841801cd052bb4ba0df92016b9245870.zip
Separate frame-local, tty-dependent parameters from tty-local parameters.
src/termchar.h (struct tty_output): Redefined to contain frame-local tty-dependent parameters. (Currently there are no such parameters, so it consists of the tty_display_info pointer.) (struct tty_display_info): New structure, with reference_count. (FRAME_TTY): Updated to reflect new termcap frame structure. src/term.c: Update prototypes. Use tty_display_info instead of tty_output. src/cm.c (current_tty, cmcheckmagic, cmcostinit, calccost, cmgoto, Wcm_clear) (Wcm_init): Use tty_display_info instead of tty_output. src/cm.h: Update prototypes. src/dispextern.h: Ditto. src/dispnew.c (window_change_signal, init_display, make_terminal_frame): Use tty_display_info instead of tty_output. src/frame.c (Fdelete_frame): Use tty_display_info instead of tty_output. Fix delete_tty check. (make_terminal_frame): Allocate f->output_data.tty. Increase reference count of tty device. (delete_frame): Free f->output_data.tty. Use reference count to decide if the tty should be closed. src/frame.h (FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL): New, unconditional definitions. (struct device): New declaration (at the moment, it is defined as empty in termhooks.h). (struct frame): Added display, background_pixel, foreground_pixel member. src/keyboard.c (read_avail_input): Use tty_display_info instead of tty_output. src/lisp.h: Declare struct display. Update prototypes. src/sysdep.c: Update prototypes. (discard_tty_input, init_all_sys_modes, init_sys_modes, reset_all_sys_modes) (reset_sys_modes, hft_init, hft_reset): Use tty_display_info instead of tty_output. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-29
Diffstat (limited to 'src')
-rw-r--r--src/cm.c15
-rw-r--r--src/cm.h12
-rw-r--r--src/dispextern.h16
-rw-r--r--src/dispnew.c4
-rw-r--r--src/frame.c38
-rw-r--r--src/frame.h39
-rw-r--r--src/keyboard.c2
-rw-r--r--src/lisp.h9
-rw-r--r--src/sysdep.c20
-rw-r--r--src/term.c145
-rw-r--r--src/termchar.h52
-rw-r--r--src/termhooks.h6
12 files changed, 171 insertions, 187 deletions
diff --git a/src/cm.c b/src/cm.c
index 1094e3047d6..74f119d9b68 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -62,7 +62,7 @@ evalcost (c)
62} 62}
63 63
64/* The terminal to use for low-level output. */ 64/* The terminal to use for low-level output. */
65struct tty_output * current_tty; 65struct tty_display_info *current_tty;
66 66
67int 67int
68cmputc (c) 68cmputc (c)
@@ -135,7 +135,7 @@ addcol (tty, n) {
135 * after we reach the last column; this takes us to a known state. 135 * after we reach the last column; this takes us to a known state.
136 */ 136 */
137void 137void
138cmcheckmagic (struct tty_output *tty) 138cmcheckmagic (struct tty_display_info *tty)
139{ 139{
140 if (curX (tty) == FrameCols (tty)) 140 if (curX (tty) == FrameCols (tty))
141 { 141 {
@@ -160,7 +160,7 @@ cmcheckmagic (struct tty_output *tty)
160 */ 160 */
161 161
162void 162void
163cmcostinit (struct tty_output *tty) 163cmcostinit (struct tty_display_info *tty)
164{ 164{
165 char *p; 165 char *p;
166 166
@@ -200,7 +200,8 @@ cmcostinit (struct tty_output *tty)
200 */ 200 */
201 201
202static int 202static int
203calccost (struct tty_output *tty, int srcy, int srcx, int dsty, int dstx, int doit) 203calccost (struct tty_display_info *tty,
204 int srcy, int srcx, int dsty, int dstx, int doit)
204{ 205{
205 register int deltay, 206 register int deltay,
206 deltax, 207 deltax,
@@ -336,7 +337,7 @@ losecursor ()
336 337
337void 338void
338cmgoto (tty, row, col) 339cmgoto (tty, row, col)
339 struct tty_output *tty; 340 struct tty_display_info *tty;
340 int row, col; 341 int row, col;
341{ 342{
342 int homecost, 343 int homecost,
@@ -441,7 +442,7 @@ cmgoto (tty, row, col)
441 */ 442 */
442 443
443void 444void
444Wcm_clear (struct tty_output *tty) 445Wcm_clear (struct tty_display_info *tty)
445{ 446{
446 bzero (tty->Wcm, sizeof (struct cm)); 447 bzero (tty->Wcm, sizeof (struct cm));
447 UP = 0; 448 UP = 0;
@@ -456,7 +457,7 @@ Wcm_clear (struct tty_output *tty)
456 */ 457 */
457 458
458int 459int
459Wcm_init (struct tty_output *tty) 460Wcm_init (struct tty_display_info *tty)
460{ 461{
461#if 0 462#if 0
462 if (tty->Wcm->cm_abs && !tty->Wcm->cm_ds) 463 if (tty->Wcm->cm_abs && !tty->Wcm->cm_ds)
diff --git a/src/cm.h b/src/cm.h
index e71859c1a64..1b6c9522bbe 100644
--- a/src/cm.h
+++ b/src/cm.h
@@ -163,13 +163,13 @@ extern int evalcost ();
163 163
164#define emacs_tputs(tty, str, affcnt, putc) (current_tty = (tty), tputs (str, affcnt, putc)) 164#define emacs_tputs(tty, str, affcnt, putc) (current_tty = (tty), tputs (str, affcnt, putc))
165 165
166extern struct tty_output *current_tty; 166extern struct tty_display_info *current_tty;
167extern void cmcheckmagic P_ ((struct tty_output *)); 167extern void cmcheckmagic P_ ((struct tty_display_info *));
168extern int cmputc P_ ((int)); 168extern int cmputc P_ ((int));
169extern void cmcostinit P_ ((struct tty_output *)); 169extern void cmcostinit P_ ((struct tty_display_info *));
170extern void cmgoto P_ ((struct tty_output *, int, int)); 170extern void cmgoto P_ ((struct tty_display_info *, int, int));
171extern void Wcm_clear P_ ((struct tty_output *)); 171extern void Wcm_clear P_ ((struct tty_display_info *));
172extern int Wcm_init P_ ((struct tty_output *)); 172extern int Wcm_init P_ ((struct tty_display_info *));
173 173
174/* arch-tag: acc1535a-7136-49d6-b22d-9bc85702251b 174/* arch-tag: acc1535a-7136-49d6-b22d-9bc85702251b
175 (do not change this comment) */ 175 (do not change this comment) */
diff --git a/src/dispextern.h b/src/dispextern.h
index a4864068eda..4b47aaf7188 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2738,25 +2738,25 @@ extern void update_begin P_ ((struct frame *));
2738extern void update_end P_ ((struct frame *)); 2738extern void update_end P_ ((struct frame *));
2739extern void set_terminal_window P_ ((int)); 2739extern void set_terminal_window P_ ((int));
2740extern void set_scroll_region P_ ((int, int)); 2740extern void set_scroll_region P_ ((int, int));
2741extern void turn_off_insert P_ ((struct tty_output *)); 2741extern void turn_off_insert P_ ((struct tty_display_info *));
2742extern void turn_off_highlight P_ ((struct tty_output *)); 2742extern void turn_off_highlight P_ ((struct tty_display_info *));
2743extern void background_highlight P_ ((struct tty_output *)); 2743extern void background_highlight P_ ((struct tty_display_info *));
2744extern void clear_frame P_ ((void)); 2744extern void clear_frame P_ ((void));
2745extern void clear_end_of_line P_ ((int)); 2745extern void clear_end_of_line P_ ((int));
2746extern void clear_end_of_line_raw P_ ((int)); 2746extern void clear_end_of_line_raw P_ ((int));
2747extern void tty_clear_end_of_line P_ ((struct tty_output *, int)); 2747extern void tty_clear_end_of_line P_ ((struct tty_display_info *, int));
2748extern void delete_glyphs P_ ((int)); 2748extern void delete_glyphs P_ ((int));
2749extern void ins_del_lines P_ ((int, int)); 2749extern void ins_del_lines P_ ((int, int));
2750extern int string_cost P_ ((char *)); 2750extern int string_cost P_ ((char *));
2751extern int per_line_cost P_ ((char *)); 2751extern int per_line_cost P_ ((char *));
2752extern void calculate_costs P_ ((struct frame *)); 2752extern void calculate_costs P_ ((struct frame *));
2753extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object)); 2753extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object));
2754extern void tty_setup_colors P_ ((struct tty_output *, int)); 2754extern void tty_setup_colors P_ ((struct tty_display_info *, int));
2755extern struct tty_output *term_init P_ ((Lisp_Object, char *, char *)); 2755extern struct tty_display_info *term_init P_ ((Lisp_Object, char *, char *));
2756extern struct tty_output *term_dummy_init P_ ((void)); 2756extern struct tty_display_info *term_dummy_init P_ ((void));
2757extern void fatal P_ ((/* char *, ... */)); 2757extern void fatal P_ ((/* char *, ... */));
2758void cursor_to P_ ((int, int)); 2758void cursor_to P_ ((int, int));
2759extern int tty_capable_p P_ ((struct tty_output *, unsigned, unsigned long, unsigned long)); 2759extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long));
2760 2760
2761/* Defined in scroll.c */ 2761/* Defined in scroll.c */
2762 2762
diff --git a/src/dispnew.c b/src/dispnew.c
index 593067eae92..4401e2d2d56 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5916,7 +5916,7 @@ window_change_signal (signalnum) /* If we don't have an argument, */
5916#endif 5916#endif
5917 int old_errno = errno; 5917 int old_errno = errno;
5918 5918
5919 struct tty_output *tty; 5919 struct tty_display_info *tty;
5920 5920
5921 /* The frame size change obviously applies to a single 5921 /* The frame size change obviously applies to a single
5922 termcap-controlled terminal, but we can't decide which. 5922 termcap-controlled terminal, but we can't decide which.
@@ -6625,7 +6625,7 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\
6625#endif /* VMS */ 6625#endif /* VMS */
6626 6626
6627 { 6627 {
6628 struct tty_output *tty; 6628 struct tty_display_info *tty;
6629 6629
6630 tty = term_init (selected_frame, 0, terminal_type); 6630 tty = term_init (selected_frame, 0, terminal_type);
6631 change_frame_size (XFRAME (selected_frame), FrameRows (tty), FrameCols (tty), 0, 0, 0); 6631 change_frame_size (XFRAME (selected_frame), FrameRows (tty), FrameCols (tty), 0, 0, 0);
diff --git a/src/frame.c b/src/frame.c
index f26bf9ae9ca..af2cd20c514 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -544,20 +544,27 @@ make_terminal_frame (tty_name, tty_type)
544 make_mac_terminal_frame (f); 544 make_mac_terminal_frame (f);
545#else 545#else
546 { 546 {
547 struct tty_output *tty; 547 struct tty_display_info *tty;
548 f->output_method = output_termcap; 548 f->output_method = output_termcap;
549
550 f->output_data.tty = (struct tty_output *) xmalloc (sizeof (struct tty_output));
551 bzero (f->output_data.tty, sizeof (struct tty_output));
552
553 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
554 FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
549 555
550 if (initialized) 556 if (initialized)
551 { 557 {
552 /* Note that term_init may signal an error, but then it is its 558 /* Note that term_init may signal an error, but then it is its
553 responsibility to make sure this frame is deleted. */ 559 responsibility to make sure this frame is deleted. */
554 f->output_data.tty = term_init (frame, tty_name, tty_type); 560 f->output_data.tty->display_info = term_init (frame, tty_name, tty_type);
555 } 561 }
556 else 562 else
557 { 563 {
558 /* init_display() will reinitialize the terminal with correct values after dump. */ 564 /* init_display() will reinitialize the terminal with correct values after dump. */
559 f->output_data.tty = term_dummy_init (); 565 f->output_data.tty->display_info = term_dummy_init ();
560 } 566 }
567 FRAME_TTY (f)->reference_count++;
561 } 568 }
562 569
563#ifdef CANNOT_DUMP 570#ifdef CANNOT_DUMP
@@ -1390,28 +1397,17 @@ The functions are run with one arg, the frame to be deleted. */)
1390 1397
1391 if (FRAME_TERMCAP_P (f)) 1398 if (FRAME_TERMCAP_P (f))
1392 { 1399 {
1393 Lisp_Object tail, frame1;
1394 int delete = 1; 1400 int delete = 1;
1395 struct tty_output *tty = FRAME_TTY (f); 1401 struct tty_display_info *tty = FRAME_TTY (f);
1396 1402
1397 /* delete_tty will call us recursively, so better kill the 1403 if (! --tty->reference_count)
1398 frame now. */
1399 f->output_data.nothing = 0;
1400
1401 /* See if the terminal needs to be closed. */
1402 FOR_EACH_FRAME (tail, frame1)
1403 { 1404 {
1404 if (frame1 != frame 1405 /* delete_tty would call us recursively if we don't kill the
1405 && FRAME_LIVE_P (XFRAME (frame1)) 1406 frame now. */
1406 && FRAME_TERMCAP_P (XFRAME (frame1)) 1407 xfree (f->output_data.tty);
1407 && FRAME_TTY (XFRAME (frame1)) == FRAME_TTY (f)) 1408 f->output_data.nothing = 0;
1408 { 1409 delete_tty (tty);
1409 delete = 0;
1410 break;
1411 }
1412 } 1410 }
1413 if (delete)
1414 delete_tty (tty);
1415 } 1411 }
1416 else 1412 else
1417 { 1413 {
diff --git a/src/frame.h b/src/frame.h
index 06af557f3ee..5c4654632e1 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -65,34 +65,10 @@ enum text_cursor_kinds
65 HBAR_CURSOR 65 HBAR_CURSOR
66}; 66};
67 67
68#if !defined(MSDOS) && !defined(WINDOWSNT) && !defined(MAC_OS) 68#define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
69#define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
69 70
70#if !defined(HAVE_X_WINDOWS) 71struct device;
71
72#define PIX_TYPE unsigned long
73
74/* A (mostly empty) x_output structure definition for building Emacs
75 on Unix and GNU/Linux without X support. */
76struct x_output
77{
78 PIX_TYPE background_pixel;
79 PIX_TYPE foreground_pixel;
80};
81
82#endif /* ! HAVE_X_WINDOWS */
83
84
85#define FRAME_FOREGROUND_PIXEL(f) \
86 (((f)->output_method == output_termcap) \
87 ? ((f)->output_data.tty->foreground_pixel) \
88 : ((f)->output_data.x->foreground_pixel))
89
90#define FRAME_BACKGROUND_PIXEL(f) \
91 (((f)->output_method == output_termcap) \
92 ? ((f)->output_data.tty->background_pixel) \
93 : ((f)->output_data.x->background_pixel))
94
95#endif /* ! MSDOS && ! WINDOWSNT && ! MAC_OS */
96 72
97struct frame 73struct frame
98{ 74{
@@ -280,12 +256,15 @@ struct frame
280 /* Canonical Y unit. Height of a line, in pixels. */ 256 /* Canonical Y unit. Height of a line, in pixels. */
281 int line_height; 257 int line_height;
282 258
259 /* The display hooks to use with this frame. */
260 struct display *display;
261
283 /* The output method says how the contents of this frame 262 /* The output method says how the contents of this frame
284 are displayed. It could be using termcap, or using an X window. */ 263 are displayed. It could be using termcap, or using an X window. */
285 enum output_method output_method; 264 enum output_method output_method;
286 265
287 /* A structure of auxiliary data used for displaying the contents. 266 /* A structure of auxiliary data used for displaying the contents.
288 struct tty_output is used for terminal frames; 267 struct tty_output is used for termcap frames;
289 it is defined in term.h. 268 it is defined in term.h.
290 struct x_output is used for X window frames; 269 struct x_output is used for X window frames;
291 it is defined in xterm.h. 270 it is defined in xterm.h.
@@ -457,6 +436,10 @@ struct frame
457 Clear the frame in clear_garbaged_frames if set. */ 436 Clear the frame in clear_garbaged_frames if set. */
458 unsigned resized_p : 1; 437 unsigned resized_p : 1;
459 438
439 /* All display backends seem to need these two pixel values. */
440 unsigned long background_pixel;
441 unsigned long foreground_pixel;
442
460 /* Set to non-zero if the default face for the frame has been 443 /* Set to non-zero if the default face for the frame has been
461 realized. Reset to zero whenever the default face changes. 444 realized. Reset to zero whenever the default face changes.
462 Used to see the difference between a font change and face change. */ 445 Used to see the difference between a font change and face change. */
diff --git a/src/keyboard.c b/src/keyboard.c
index c9124f0f594..1751df6a735 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -6612,7 +6612,7 @@ read_avail_input (expected)
6612 of characters on some systems when input is stuffed at us. */ 6612 of characters on some systems when input is stuffed at us. */
6613 unsigned char cbuf[KBD_BUFFER_SIZE - 1]; 6613 unsigned char cbuf[KBD_BUFFER_SIZE - 1];
6614 int n_to_read; 6614 int n_to_read;
6615 struct tty_output *tty; 6615 struct tty_display_info *tty;
6616 Lisp_Object frame; 6616 Lisp_Object frame;
6617 6617
6618#ifdef WINDOWSNT 6618#ifdef WINDOWSNT
diff --git a/src/lisp.h b/src/lisp.h
index 412c7d25e46..8c6374e6004 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2937,7 +2937,10 @@ EXFUN (Fx_popup_dialog, 2);
2937extern void syms_of_xmenu P_ ((void)); 2937extern void syms_of_xmenu P_ ((void));
2938 2938
2939/* defined in termchar.h */ 2939/* defined in termchar.h */
2940struct tty_output; 2940struct tty_display_info;
2941
2942/* defined in termhooks.h */
2943struct display;
2941 2944
2942/* defined in sysdep.c */ 2945/* defined in sysdep.c */
2943extern void stuff_char P_ ((char c)); 2946extern void stuff_char P_ ((char c));
@@ -2945,8 +2948,8 @@ extern void init_sigio P_ ((int));
2945extern void sys_subshell P_ ((void)); 2948extern void sys_subshell P_ ((void));
2946extern void sys_suspend P_ ((void)); 2949extern void sys_suspend P_ ((void));
2947extern void discard_tty_input P_ ((void)); 2950extern void discard_tty_input P_ ((void));
2948extern void init_sys_modes P_ ((struct tty_output *)); 2951extern void init_sys_modes P_ ((struct tty_display_info *));
2949extern void reset_sys_modes P_ ((struct tty_output *)); 2952extern void reset_sys_modes P_ ((struct tty_display_info *));
2950extern void init_all_sys_modes P_ ((void)); 2953extern void init_all_sys_modes P_ ((void));
2951extern void reset_all_sys_modes P_ ((void)); 2954extern void reset_all_sys_modes P_ ((void));
2952extern void wait_for_termination P_ ((int)); 2955extern void wait_for_termination P_ ((int));
diff --git a/src/sysdep.c b/src/sysdep.c
index 98a671ddbdc..7710c2ad8ce 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -252,8 +252,8 @@ int emacs_ospeed;
252void croak P_ ((char *)); 252void croak P_ ((char *));
253 253
254#ifdef AIXHFT 254#ifdef AIXHFT
255void hft_init P_ ((struct tty_output *)); 255void hft_init P_ ((struct tty_display_info *));
256void hft_reset P_ ((struct tty_output *)); 256void hft_reset P_ ((struct tty_display_info *));
257#endif 257#endif
258 258
259/* Temporary used by `sigblock' when defined in terms of signprocmask. */ 259/* Temporary used by `sigblock' when defined in terms of signprocmask. */
@@ -285,7 +285,7 @@ discard_tty_input ()
285#else /* not VMS */ 285#else /* not VMS */
286#ifdef APOLLO 286#ifdef APOLLO
287 { 287 {
288 struct tty_output *tty; 288 struct tty_display_info *tty;
289 for (tty = tty_list; tty; tty = tty->next) 289 for (tty = tty_list; tty; tty = tty->next)
290 { 290 {
291 int zero = 0; 291 int zero = 0;
@@ -298,7 +298,7 @@ discard_tty_input ()
298 ; 298 ;
299#else /* not MSDOS */ 299#else /* not MSDOS */
300 { 300 {
301 struct tty_output *tty; 301 struct tty_display_info *tty;
302 for (tty = tty_list; tty; tty = tty->next) 302 for (tty = tty_list; tty; tty = tty->next)
303 { 303 {
304 EMACS_GET_TTY (fileno (TTY_INPUT (tty)), &buf); 304 EMACS_GET_TTY (fileno (TTY_INPUT (tty)), &buf);
@@ -1295,14 +1295,14 @@ static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1};
1295void 1295void
1296init_all_sys_modes (void) 1296init_all_sys_modes (void)
1297{ 1297{
1298 struct tty_output *tty; 1298 struct tty_display_info *tty;
1299 for (tty = tty_list; tty; tty = tty->next) 1299 for (tty = tty_list; tty; tty = tty->next)
1300 init_sys_modes (tty); 1300 init_sys_modes (tty);
1301} 1301}
1302 1302
1303void 1303void
1304init_sys_modes (tty_out) 1304init_sys_modes (tty_out)
1305 struct tty_output *tty_out; 1305 struct tty_display_info *tty_out;
1306{ 1306{
1307 struct emacs_tty tty; 1307 struct emacs_tty tty;
1308 1308
@@ -1796,7 +1796,7 @@ set_window_size (fd, height, width)
1796void 1796void
1797reset_all_sys_modes (void) 1797reset_all_sys_modes (void)
1798{ 1798{
1799 struct tty_output *tty; 1799 struct tty_display_info *tty;
1800 for (tty = tty_list; tty; tty = tty->next) 1800 for (tty = tty_list; tty; tty = tty->next)
1801 reset_sys_modes (tty); 1801 reset_sys_modes (tty);
1802} 1802}
@@ -1805,7 +1805,7 @@ reset_all_sys_modes (void)
1805 bottom of the frame, turn off interrupt-driven I/O, etc. */ 1805 bottom of the frame, turn off interrupt-driven I/O, etc. */
1806void 1806void
1807reset_sys_modes (tty_out) 1807reset_sys_modes (tty_out)
1808 struct tty_output *tty_out; 1808 struct tty_display_info *tty_out;
1809{ 1809{
1810 if (noninteractive) 1810 if (noninteractive)
1811 { 1811 {
@@ -5110,7 +5110,7 @@ srandom (seed)
5110 5110
5111/* Called from init_sys_modes. */ 5111/* Called from init_sys_modes. */
5112void 5112void
5113hft_init (struct tty_output *tty_out) 5113hft_init (struct tty_display_info *tty_out)
5114{ 5114{
5115 int junk; 5115 int junk;
5116 5116
@@ -5165,7 +5165,7 @@ hft_init (struct tty_output *tty_out)
5165/* Reset the rubout key to backspace. */ 5165/* Reset the rubout key to backspace. */
5166 5166
5167void 5167void
5168hft_reset (struct tty_output *tty_out) 5168hft_reset (struct tty_display_info *tty_out)
5169{ 5169{
5170 struct hfbuf buf; 5170 struct hfbuf buf;
5171 struct hfkeymap keymap; 5171 struct hfkeymap keymap;
diff --git a/src/term.c b/src/term.c
index 25f26e3c6e2..cce411debe7 100644
--- a/src/term.c
+++ b/src/term.c
@@ -69,11 +69,11 @@ extern int tgetnum P_ ((char *id));
69 69
70static void turn_on_face P_ ((struct frame *, int face_id)); 70static void turn_on_face P_ ((struct frame *, int face_id));
71static void turn_off_face P_ ((struct frame *, int face_id)); 71static void turn_off_face P_ ((struct frame *, int face_id));
72static void tty_show_cursor P_ ((struct tty_output *)); 72static void tty_show_cursor P_ ((struct tty_display_info *));
73static void tty_hide_cursor P_ ((struct tty_output *)); 73static void tty_hide_cursor P_ ((struct tty_display_info *));
74 74
75void delete_tty P_ ((struct tty_output *)); 75void delete_tty P_ ((struct tty_display_info *));
76static void delete_tty_1 P_ ((struct tty_output *)); 76static void delete_tty_1 P_ ((struct tty_display_info *));
77 77
78 78
79#define OUTPUT(tty, a) \ 79#define OUTPUT(tty, a) \
@@ -102,7 +102,7 @@ Lisp_Object Vring_bell_function;
102 102
103/* Terminal characteristics that higher levels want to look at. */ 103/* Terminal characteristics that higher levels want to look at. */
104 104
105struct tty_output *tty_list; 105struct tty_display_info *tty_list;
106 106
107/* Nonzero means no need to redraw the entire frame on resuming a 107/* Nonzero means no need to redraw the entire frame on resuming a
108 suspended Emacs. This is useful on terminals with multiple 108 suspended Emacs. This is useful on terminals with multiple
@@ -319,12 +319,12 @@ ring_bell ()
319 else if (!FRAME_TERMCAP_P (f)) 319 else if (!FRAME_TERMCAP_P (f))
320 (*ring_bell_hook) (); 320 (*ring_bell_hook) ();
321 else { 321 else {
322 struct tty_output *tty = FRAME_TTY (f); 322 struct tty_display_info *tty = FRAME_TTY (f);
323 OUTPUT (tty, tty->TS_visible_bell && visible_bell ? tty->TS_visible_bell : tty->TS_bell); 323 OUTPUT (tty, tty->TS_visible_bell && visible_bell ? tty->TS_visible_bell : tty->TS_bell);
324 } 324 }
325} 325}
326 326
327void tty_set_terminal_modes (struct tty_output *tty) 327void tty_set_terminal_modes (struct tty_display_info *tty)
328{ 328{
329 OUTPUT_IF (tty, tty->TS_termcap_modes); 329 OUTPUT_IF (tty, tty->TS_termcap_modes);
330 OUTPUT_IF (tty, tty->TS_cursor_visible); 330 OUTPUT_IF (tty, tty->TS_cursor_visible);
@@ -342,7 +342,7 @@ set_terminal_modes ()
342 (*set_terminal_modes_hook) (); 342 (*set_terminal_modes_hook) ();
343} 343}
344 344
345void tty_reset_terminal_modes (struct tty_output *tty) 345void tty_reset_terminal_modes (struct tty_display_info *tty)
346{ 346{
347 turn_off_highlight (tty); 347 turn_off_highlight (tty);
348 turn_off_insert (tty); 348 turn_off_insert (tty);
@@ -380,7 +380,7 @@ update_end (f)
380{ 380{
381 if (FRAME_TERMCAP_P (f)) 381 if (FRAME_TERMCAP_P (f))
382 { 382 {
383 struct tty_output *tty = FRAME_TTY (f); 383 struct tty_display_info *tty = FRAME_TTY (f);
384 if (!XWINDOW (selected_window)->cursor_off_p) 384 if (!XWINDOW (selected_window)->cursor_off_p)
385 tty_show_cursor (tty); 385 tty_show_cursor (tty);
386 turn_off_insert (tty); 386 turn_off_insert (tty);
@@ -399,7 +399,7 @@ set_terminal_window (size)
399 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 399 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
400 if (FRAME_TERMCAP_P (f)) 400 if (FRAME_TERMCAP_P (f))
401 { 401 {
402 struct tty_output *tty = FRAME_TTY (f); 402 struct tty_display_info *tty = FRAME_TTY (f);
403 tty->specified_window = size ? size : FRAME_LINES (f); 403 tty->specified_window = size ? size : FRAME_LINES (f);
404 if (TTY_SCROLL_REGION_OK (tty)) 404 if (TTY_SCROLL_REGION_OK (tty))
405 set_scroll_region (0, tty->specified_window); 405 set_scroll_region (0, tty->specified_window);
@@ -414,7 +414,7 @@ set_scroll_region (start, stop)
414{ 414{
415 char *buf; 415 char *buf;
416 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 416 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
417 struct tty_output *tty = FRAME_TTY (f); 417 struct tty_display_info *tty = FRAME_TTY (f);
418 418
419 if (tty->TS_set_scroll_region) 419 if (tty->TS_set_scroll_region)
420 buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1); 420 buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1);
@@ -433,7 +433,7 @@ set_scroll_region (start, stop)
433 433
434 434
435static void 435static void
436turn_on_insert (struct tty_output *tty) 436turn_on_insert (struct tty_display_info *tty)
437{ 437{
438 if (!tty->insert_mode) 438 if (!tty->insert_mode)
439 OUTPUT (tty, tty->TS_insert_mode); 439 OUTPUT (tty, tty->TS_insert_mode);
@@ -441,7 +441,7 @@ turn_on_insert (struct tty_output *tty)
441} 441}
442 442
443void 443void
444turn_off_insert (struct tty_output *tty) 444turn_off_insert (struct tty_display_info *tty)
445{ 445{
446 if (tty->insert_mode) 446 if (tty->insert_mode)
447 OUTPUT (tty, tty->TS_end_insert_mode); 447 OUTPUT (tty, tty->TS_end_insert_mode);
@@ -451,7 +451,7 @@ turn_off_insert (struct tty_output *tty)
451/* Handle highlighting. */ 451/* Handle highlighting. */
452 452
453void 453void
454turn_off_highlight (struct tty_output *tty) 454turn_off_highlight (struct tty_display_info *tty)
455{ 455{
456 if (tty->standout_mode) 456 if (tty->standout_mode)
457 OUTPUT_IF (tty, tty->TS_end_standout_mode); 457 OUTPUT_IF (tty, tty->TS_end_standout_mode);
@@ -459,7 +459,7 @@ turn_off_highlight (struct tty_output *tty)
459} 459}
460 460
461static void 461static void
462turn_on_highlight (struct tty_output *tty) 462turn_on_highlight (struct tty_display_info *tty)
463{ 463{
464 if (!tty->standout_mode) 464 if (!tty->standout_mode)
465 OUTPUT_IF (tty, tty->TS_standout_mode); 465 OUTPUT_IF (tty, tty->TS_standout_mode);
@@ -467,7 +467,7 @@ turn_on_highlight (struct tty_output *tty)
467} 467}
468 468
469static void 469static void
470toggle_highlight (struct tty_output *tty) 470toggle_highlight (struct tty_display_info *tty)
471{ 471{
472 if (tty->standout_mode) 472 if (tty->standout_mode)
473 turn_off_highlight (tty); 473 turn_off_highlight (tty);
@@ -479,7 +479,7 @@ toggle_highlight (struct tty_output *tty)
479/* Make cursor invisible. */ 479/* Make cursor invisible. */
480 480
481static void 481static void
482tty_hide_cursor (struct tty_output *tty) 482tty_hide_cursor (struct tty_display_info *tty)
483{ 483{
484 if (tty->cursor_hidden == 0) 484 if (tty->cursor_hidden == 0)
485 { 485 {
@@ -492,7 +492,7 @@ tty_hide_cursor (struct tty_output *tty)
492/* Ensure that cursor is visible. */ 492/* Ensure that cursor is visible. */
493 493
494static void 494static void
495tty_show_cursor (struct tty_output *tty) 495tty_show_cursor (struct tty_display_info *tty)
496{ 496{
497 if (tty->cursor_hidden) 497 if (tty->cursor_hidden)
498 { 498 {
@@ -508,7 +508,7 @@ tty_show_cursor (struct tty_output *tty)
508 depends on the user option inverse-video. */ 508 depends on the user option inverse-video. */
509 509
510void 510void
511background_highlight (struct tty_output *tty) 511background_highlight (struct tty_display_info *tty)
512{ 512{
513 if (inverse_video) 513 if (inverse_video)
514 turn_on_highlight (tty); 514 turn_on_highlight (tty);
@@ -519,7 +519,7 @@ background_highlight (struct tty_output *tty)
519/* Set standout mode to the mode specified for the text to be output. */ 519/* Set standout mode to the mode specified for the text to be output. */
520 520
521static void 521static void
522highlight_if_desired (struct tty_output *tty) 522highlight_if_desired (struct tty_display_info *tty)
523{ 523{
524 if (inverse_video) 524 if (inverse_video)
525 turn_on_highlight (tty); 525 turn_on_highlight (tty);
@@ -536,7 +536,7 @@ cursor_to (vpos, hpos)
536 int vpos, hpos; 536 int vpos, hpos;
537{ 537{
538 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 538 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
539 struct tty_output *tty; 539 struct tty_display_info *tty;
540 540
541 if (! FRAME_TERMCAP_P (f) && cursor_to_hook) 541 if (! FRAME_TERMCAP_P (f) && cursor_to_hook)
542 { 542 {
@@ -568,7 +568,7 @@ raw_cursor_to (row, col)
568 int row, col; 568 int row, col;
569{ 569{
570 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); 570 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame);
571 struct tty_output *tty; 571 struct tty_display_info *tty;
572 if (! FRAME_TERMCAP_P (f)) 572 if (! FRAME_TERMCAP_P (f))
573 { 573 {
574 (*raw_cursor_to_hook) (row, col); 574 (*raw_cursor_to_hook) (row, col);
@@ -594,7 +594,7 @@ clear_to_end ()
594 register int i; 594 register int i;
595 595
596 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 596 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
597 struct tty_output *tty; 597 struct tty_display_info *tty;
598 598
599 if (clear_to_end_hook && ! FRAME_TERMCAP_P (f)) 599 if (clear_to_end_hook && ! FRAME_TERMCAP_P (f))
600 { 600 {
@@ -623,7 +623,7 @@ void
623clear_frame () 623clear_frame ()
624{ 624{
625 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 625 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
626 struct tty_output *tty; 626 struct tty_display_info *tty;
627 627
628 if (clear_frame_hook && ! FRAME_TERMCAP_P (f)) 628 if (clear_frame_hook && ! FRAME_TERMCAP_P (f))
629 { 629 {
@@ -654,7 +654,7 @@ clear_end_of_line (first_unused_hpos)
654 int first_unused_hpos; 654 int first_unused_hpos;
655{ 655{
656 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 656 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
657 struct tty_output *tty; 657 struct tty_display_info *tty;
658 658
659 if (clear_end_of_line_hook 659 if (clear_end_of_line_hook
660 && ! FRAME_TERMCAP_P (f)) 660 && ! FRAME_TERMCAP_P (f))
@@ -667,7 +667,7 @@ clear_end_of_line (first_unused_hpos)
667} 667}
668 668
669void 669void
670tty_clear_end_of_line (struct tty_output *tty, int first_unused_hpos) 670tty_clear_end_of_line (struct tty_display_info *tty, int first_unused_hpos)
671{ 671{
672 register int i; 672 register int i;
673 /* Detect the case where we are called from reset_sys_modes 673 /* Detect the case where we are called from reset_sys_modes
@@ -818,7 +818,7 @@ write_glyphs (string, len)
818{ 818{
819 int produced, consumed; 819 int produced, consumed;
820 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); 820 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame);
821 struct tty_output *tty; 821 struct tty_display_info *tty;
822 unsigned char conversion_buffer[1024]; 822 unsigned char conversion_buffer[1024];
823 int conversion_buffer_size = sizeof conversion_buffer; 823 int conversion_buffer_size = sizeof conversion_buffer;
824 824
@@ -923,7 +923,7 @@ insert_glyphs (start, len)
923 char *buf; 923 char *buf;
924 struct glyph *glyph = NULL; 924 struct glyph *glyph = NULL;
925 struct frame *f; 925 struct frame *f;
926 struct tty_output *tty; 926 struct tty_display_info *tty;
927 927
928 if (len <= 0) 928 if (len <= 0)
929 return; 929 return;
@@ -1016,7 +1016,7 @@ delete_glyphs (n)
1016 char *buf; 1016 char *buf;
1017 register int i; 1017 register int i;
1018 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 1018 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
1019 struct tty_output *tty = FRAME_TTY (f); 1019 struct tty_display_info *tty = FRAME_TTY (f);
1020 1020
1021 if (delete_glyphs_hook && ! FRAME_TERMCAP_P (f)) 1021 if (delete_glyphs_hook && ! FRAME_TERMCAP_P (f))
1022 { 1022 {
@@ -1062,7 +1062,7 @@ ins_del_lines (vpos, n)
1062 } 1062 }
1063 else 1063 else
1064 { 1064 {
1065 struct tty_output *tty = FRAME_TTY (f); 1065 struct tty_display_info *tty = FRAME_TTY (f);
1066 char *multi = n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines; 1066 char *multi = n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines;
1067 char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; 1067 char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line;
1068 char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; 1068 char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll;
@@ -1181,7 +1181,7 @@ static void
1181calculate_ins_del_char_costs (f) 1181calculate_ins_del_char_costs (f)
1182 FRAME_PTR f; 1182 FRAME_PTR f;
1183{ 1183{
1184 struct tty_output *tty = FRAME_TTY (f); 1184 struct tty_display_info *tty = FRAME_TTY (f);
1185 int ins_startup_cost, del_startup_cost; 1185 int ins_startup_cost, del_startup_cost;
1186 int ins_cost_per_char, del_cost_per_char; 1186 int ins_cost_per_char, del_cost_per_char;
1187 register int i; 1187 register int i;
@@ -1243,7 +1243,7 @@ void
1243calculate_costs (frame) 1243calculate_costs (frame)
1244 FRAME_PTR frame; 1244 FRAME_PTR frame;
1245{ 1245{
1246 struct tty_output *tty = FRAME_TTY (frame); 1246 struct tty_display_info *tty = FRAME_TTY (frame);
1247 register char *f = (tty->TS_set_scroll_region 1247 register char *f = (tty->TS_set_scroll_region
1248 ? tty->TS_set_scroll_region 1248 ? tty->TS_set_scroll_region
1249 : tty->TS_set_scroll_region_1); 1249 : tty->TS_set_scroll_region_1);
@@ -1251,7 +1251,7 @@ calculate_costs (frame)
1251 FRAME_COST_BAUD_RATE (frame) = baud_rate; 1251 FRAME_COST_BAUD_RATE (frame) = baud_rate;
1252 1252
1253 if (FRAME_TERMCAP_P (frame)) 1253 if (FRAME_TERMCAP_P (frame))
1254 TTY_SCROLL_REGION_COST (frame->output_data.tty) = string_cost (f); 1254 TTY_SCROLL_REGION_COST (FRAME_TTY (frame)) = string_cost (f);
1255 1255
1256 /* These variables are only used for terminal stuff. They are allocated 1256 /* These variables are only used for terminal stuff. They are allocated
1257 once for the terminal frame of X-windows emacs, but not used afterwards. 1257 once for the terminal frame of X-windows emacs, but not used afterwards.
@@ -1761,7 +1761,7 @@ turn_on_face (f, face_id)
1761 struct face *face = FACE_FROM_ID (f, face_id); 1761 struct face *face = FACE_FROM_ID (f, face_id);
1762 long fg = face->foreground; 1762 long fg = face->foreground;
1763 long bg = face->background; 1763 long bg = face->background;
1764 struct tty_output *tty = FRAME_TTY (f); 1764 struct tty_display_info *tty = FRAME_TTY (f);
1765 1765
1766 /* Do this first because TS_end_standout_mode may be the same 1766 /* Do this first because TS_end_standout_mode may be the same
1767 as TS_exit_attribute_mode, which turns all appearances off. */ 1767 as TS_exit_attribute_mode, which turns all appearances off. */
@@ -1859,7 +1859,7 @@ turn_off_face (f, face_id)
1859 int face_id; 1859 int face_id;
1860{ 1860{
1861 struct face *face = FACE_FROM_ID (f, face_id); 1861 struct face *face = FACE_FROM_ID (f, face_id);
1862 struct tty_output *tty = FRAME_TTY (f); 1862 struct tty_display_info *tty = FRAME_TTY (f);
1863 1863
1864 xassert (face != NULL); 1864 xassert (face != NULL);
1865 1865
@@ -1910,7 +1910,7 @@ turn_off_face (f, face_id)
1910 1910
1911int 1911int
1912tty_capable_p (tty, caps, fg, bg) 1912tty_capable_p (tty, caps, fg, bg)
1913 struct tty_output *tty; 1913 struct tty_display_info *tty;
1914 unsigned caps; 1914 unsigned caps;
1915 unsigned long fg, bg; 1915 unsigned long fg, bg;
1916{ 1916{
@@ -1938,7 +1938,7 @@ DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p,
1938 (display) 1938 (display)
1939 Lisp_Object display; 1939 Lisp_Object display;
1940{ 1940{
1941 struct tty_output *tty = FRAME_TTY (SELECTED_FRAME ()); 1941 struct tty_display_info *tty = FRAME_TTY (SELECTED_FRAME ());
1942 return tty->TN_max_colors > 0 ? Qt : Qnil; 1942 return tty->TN_max_colors > 0 ? Qt : Qnil;
1943} 1943}
1944 1944
@@ -1949,7 +1949,7 @@ DEFUN ("tty-display-color-cells", Ftty_display_color_cells,
1949 (display) 1949 (display)
1950 Lisp_Object display; 1950 Lisp_Object display;
1951{ 1951{
1952 struct tty_output *tty = FRAME_TTY (SELECTED_FRAME ()); 1952 struct tty_display_info *tty = FRAME_TTY (SELECTED_FRAME ());
1953 return make_number (tty->TN_max_colors); 1953 return make_number (tty->TN_max_colors);
1954} 1954}
1955 1955
@@ -1958,7 +1958,7 @@ DEFUN ("tty-display-color-cells", Ftty_display_color_cells,
1958/* Save or restore the default color-related capabilities of this 1958/* Save or restore the default color-related capabilities of this
1959 terminal. */ 1959 terminal. */
1960static void 1960static void
1961tty_default_color_capabilities (struct tty_output *tty, int save) 1961tty_default_color_capabilities (struct tty_display_info *tty, int save)
1962{ 1962{
1963 static char 1963 static char
1964 *default_orig_pair, *default_set_foreground, *default_set_background; 1964 *default_orig_pair, *default_set_foreground, *default_set_background;
@@ -2000,7 +2000,7 @@ tty_default_color_capabilities (struct tty_output *tty, int save)
2000 support; zero means set up for the default capabilities, the ones 2000 support; zero means set up for the default capabilities, the ones
2001 we saw at term_init time; -1 means turn off color support. */ 2001 we saw at term_init time; -1 means turn off color support. */
2002void 2002void
2003tty_setup_colors (struct tty_output *tty, int mode) 2003tty_setup_colors (struct tty_display_info *tty, int mode)
2004{ 2004{
2005 /* Canonicalize all negative values of MODE. */ 2005 /* Canonicalize all negative values of MODE. */
2006 if (mode < -1) 2006 if (mode < -1)
@@ -2092,11 +2092,11 @@ set_tty_color_mode (f, val)
2092 2092
2093 2093
2094 2094
2095struct tty_output * 2095struct tty_display_info *
2096get_named_tty (name) 2096get_named_tty (name)
2097 char *name; 2097 char *name;
2098{ 2098{
2099 struct tty_output *tty = tty_list; 2099 struct tty_display_info *tty = tty_list;
2100 2100
2101 while (tty) { 2101 while (tty) {
2102 if ((tty->name == 0 && name == 0) 2102 if ((tty->name == 0 && name == 0)
@@ -2130,8 +2130,8 @@ DEFUN ("frame-tty-name", Fframe_tty_name, Sframe_tty_name, 0, 1, 0,
2130 if (f->output_method != output_termcap) 2130 if (f->output_method != output_termcap)
2131 wrong_type_argument (Qframe_tty_name, frame); 2131 wrong_type_argument (Qframe_tty_name, frame);
2132 2132
2133 if (f->output_data.tty->name) 2133 if (FRAME_TTY (f)->name)
2134 return build_string (f->output_data.tty->name); 2134 return build_string (FRAME_TTY (f)->name);
2135 else 2135 else
2136 return Qnil; 2136 return Qnil;
2137} 2137}
@@ -2156,8 +2156,8 @@ DEFUN ("frame-tty-type", Fframe_tty_type, Sframe_tty_type, 0, 1, 0,
2156 if (f->output_method != output_termcap) 2156 if (f->output_method != output_termcap)
2157 wrong_type_argument (Qframe_tty_type, frame); 2157 wrong_type_argument (Qframe_tty_type, frame);
2158 2158
2159 if (f->output_data.tty->type) 2159 if (FRAME_TTY (f)->type)
2160 return build_string (f->output_data.tty->type); 2160 return build_string (FRAME_TTY (f)->type);
2161 else 2161 else
2162 return Qnil; 2162 return Qnil;
2163} 2163}
@@ -2167,22 +2167,22 @@ DEFUN ("frame-tty-type", Fframe_tty_type, Sframe_tty_type, 0, 1, 0,
2167 Initialization 2167 Initialization
2168 ***********************************************************************/ 2168 ***********************************************************************/
2169 2169
2170struct tty_output * 2170struct tty_display_info *
2171term_dummy_init (void) 2171term_dummy_init (void)
2172{ 2172{
2173 if (initialized || tty_list) 2173 if (initialized || tty_list)
2174 error ("tty already initialized"); 2174 error ("tty already initialized");
2175 2175
2176 tty_list = xmalloc (sizeof (struct tty_output)); 2176 tty_list = xmalloc (sizeof (struct tty_display_info));
2177 bzero (tty_list, sizeof (struct tty_output)); 2177 bzero (tty_list, sizeof (struct tty_display_info));
2178 TTY_NAME (tty_list) = 0; 2178 tty_list->name = 0;
2179 TTY_INPUT (tty_list) = stdin; 2179 tty_list->input = stdin;
2180 TTY_OUTPUT (tty_list) = stdout; 2180 tty_list->input = stdout;
2181 return tty_list; 2181 return tty_list;
2182} 2182}
2183 2183
2184 2184
2185struct tty_output * 2185struct tty_display_info *
2186term_init (Lisp_Object frame, char *name, char *terminal_type) 2186term_init (Lisp_Object frame, char *name, char *terminal_type)
2187{ 2187{
2188 char *area; 2188 char *area;
@@ -2192,7 +2192,7 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
2192 register char *p; 2192 register char *p;
2193 int status; 2193 int status;
2194 struct frame *f = XFRAME (frame); 2194 struct frame *f = XFRAME (frame);
2195 struct tty_output *tty; 2195 struct tty_display_info *tty;
2196 2196
2197 tty = get_named_tty (name); 2197 tty = get_named_tty (name);
2198 if (tty) 2198 if (tty)
@@ -2204,8 +2204,8 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
2204 } 2204 }
2205 else 2205 else
2206 { 2206 {
2207 tty = (struct tty_output *) xmalloc (sizeof (struct tty_output)); 2207 tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info));
2208 bzero (tty, sizeof (struct tty_output)); 2208 bzero (tty, sizeof (struct tty_display_info));
2209 tty->next = tty_list; 2209 tty->next = tty_list;
2210 tty_list = tty; 2210 tty_list = tty;
2211 } 2211 }
@@ -2216,7 +2216,9 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
2216 /* Make sure the frame is live; if an error happens, it must be 2216 /* Make sure the frame is live; if an error happens, it must be
2217 deleted. */ 2217 deleted. */
2218 f->output_method = output_termcap; 2218 f->output_method = output_termcap;
2219 f->output_data.tty = tty; 2219 if (! f->output_data.tty)
2220 abort ();
2221 f->output_data.tty->display_info = tty;
2220 2222
2221 if (name) 2223 if (name)
2222 { 2224 {
@@ -2229,18 +2231,18 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
2229 error ("Could not open file: %s", name); 2231 error ("Could not open file: %s", name);
2230 } 2232 }
2231 file = fdopen (fd, "w+"); 2233 file = fdopen (fd, "w+");
2232 TTY_NAME (tty) = xstrdup (name); 2234 tty->name = xstrdup (name);
2233 TTY_INPUT (tty) = file; 2235 tty->input = file;
2234 TTY_OUTPUT (tty) = file; 2236 tty->output = file;
2235 } 2237 }
2236 else 2238 else
2237 { 2239 {
2238 TTY_NAME (tty) = 0; 2240 tty->name = 0;
2239 TTY_INPUT (tty) = stdin; 2241 tty->input = stdin;
2240 TTY_OUTPUT (tty) = stdout; 2242 tty->output = stdout;
2241 } 2243 }
2242 2244
2243 TTY_TYPE (tty) = xstrdup (terminal_type); 2245 tty->type = xstrdup (terminal_type);
2244 2246
2245 add_keyboard_wait_descriptor (fileno (tty->input)); 2247 add_keyboard_wait_descriptor (fileno (tty->input));
2246 2248
@@ -2699,9 +2701,6 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2699 2701
2700 tty->top_frame = frame; 2702 tty->top_frame = frame;
2701 2703
2702 tty->foreground_pixel = FACE_TTY_DEFAULT_FG_COLOR;
2703 tty->background_pixel = FACE_TTY_DEFAULT_BG_COLOR;
2704
2705 /* Init system terminal modes (RAW or CBREAK, etc.). */ 2704 /* Init system terminal modes (RAW or CBREAK, etc.). */
2706 init_sys_modes (tty); 2705 init_sys_modes (tty);
2707 2706
@@ -2730,7 +2729,7 @@ DEFUN ("delete-tty", Fdelete_tty, Sdelete_tty, 0, 1, 0,
2730 (tty) 2729 (tty)
2731 Lisp_Object tty; 2730 Lisp_Object tty;
2732{ 2731{
2733 struct tty_output *t; 2732 struct tty_display_info *t;
2734 char *name = 0; 2733 char *name = 0;
2735 2734
2736 CHECK_STRING (tty); 2735 CHECK_STRING (tty);
@@ -2753,7 +2752,7 @@ DEFUN ("delete-tty", Fdelete_tty, Sdelete_tty, 0, 1, 0,
2753static int deleting_tty = 0; 2752static int deleting_tty = 0;
2754 2753
2755void 2754void
2756delete_tty (struct tty_output *tty) 2755delete_tty (struct tty_display_info *tty)
2757{ 2756{
2758 Lisp_Object tail, frame; 2757 Lisp_Object tail, frame;
2759 2758
@@ -2768,7 +2767,7 @@ delete_tty (struct tty_output *tty)
2768 tty_list = tty->next; 2767 tty_list = tty->next;
2769 else 2768 else
2770 { 2769 {
2771 struct tty_output *p; 2770 struct tty_display_info *p;
2772 for (p = tty_list; p && p->next != tty; p = p->next) 2771 for (p = tty_list; p && p->next != tty; p = p->next)
2773 ; 2772 ;
2774 2773
@@ -2814,7 +2813,7 @@ delete_tty (struct tty_output *tty)
2814 if (tty->Wcm) 2813 if (tty->Wcm)
2815 xfree (tty->Wcm); 2814 xfree (tty->Wcm);
2816 2815
2817 bzero (tty, sizeof (struct tty_output)); 2816 bzero (tty, sizeof (struct tty_display_info));
2818 xfree (tty); 2817 xfree (tty);
2819 deleting_tty = 0; 2818 deleting_tty = 0;
2820} 2819}
@@ -2822,12 +2821,12 @@ delete_tty (struct tty_output *tty)
2822 2821
2823 2822
2824 2823
2825/* Mark the pointers in the tty_output objects. 2824/* Mark the pointers in the tty_display_info objects.
2826 Called by the Fgarbage_collector. */ 2825 Called by the Fgarbage_collector. */
2827void 2826void
2828mark_ttys () 2827mark_ttys ()
2829{ 2828{
2830 struct tty_output *tty; 2829 struct tty_display_info *tty;
2831 Lisp_Object *p; 2830 Lisp_Object *p;
2832 for (tty = tty_list; tty; tty = tty->next) 2831 for (tty = tty_list; tty; tty = tty->next)
2833 { 2832 {
diff --git a/src/termchar.h b/src/termchar.h
index a9a74dd5b05..49b1be87bea 100644
--- a/src/termchar.h
+++ b/src/termchar.h
@@ -18,11 +18,22 @@ along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */ 19Boston, MA 02111-1307, USA. */
20 20
21/* Each termcap frame points to its own struct tty_output object in the 21/* Each termcap frame points to its own struct tty_output object in
22 output_data.tty field. The tty_output structure contains the information 22 the output_data.tty field. The tty_output structure contains the
23 that is specific to terminals. */ 23 information that is specific to termcap frames. */
24struct tty_output 24struct tty_output
25{ 25{
26 /* The Emacs structure for the tty device this frame is on. */
27 struct tty_display_info *display_info;
28
29 /* There is nothing else here at the moment... */
30};
31
32/* Parameters that are shared between frames on the same tty device. */
33struct tty_display_info
34{
35 struct tty_display_info *next; /* Chain of all tty devices. */
36
26 char *name; /* The name of the device file or 0 if 37 char *name; /* The name of the device file or 0 if
27 stdin/stdout. */ 38 stdin/stdout. */
28 char *type; /* The type of the tty. */ 39 char *type; /* The type of the tty. */
@@ -40,8 +51,9 @@ struct tty_output
40 int term_initted; /* 1 if we have been through init_sys_modes. */ 51 int term_initted; /* 1 if we have been through init_sys_modes. */
41 52
42 53
43 /* Structure for info on cursor positioning. */ 54 int reference_count; /* Number of frames that are on this display. */
44 55
56 /* Info on cursor positioning. */
45 struct cm *Wcm; 57 struct cm *Wcm;
46 58
47 /* Redisplay. */ 59 /* Redisplay. */
@@ -52,12 +64,6 @@ struct tty_output
52 /* The previous terminal frame we displayed on this tty. */ 64 /* The previous terminal frame we displayed on this tty. */
53 struct frame *previous_terminal_frame; 65 struct frame *previous_terminal_frame;
54 66
55 /* Pixel values.
56 XXX What are these used for? */
57
58 unsigned long background_pixel;
59 unsigned long foreground_pixel;
60
61 /* Terminal characteristics. */ 67 /* Terminal characteristics. */
62 68
63 int must_write_spaces; /* Nonzero means spaces in the text must 69 int must_write_spaces; /* Nonzero means spaces in the text must
@@ -192,22 +198,18 @@ struct tty_output
192 /* Flag used in tty_show/hide_cursor. */ 198 /* Flag used in tty_show/hide_cursor. */
193 199
194 int cursor_hidden; 200 int cursor_hidden;
195
196
197 struct tty_output *next;
198}; 201};
199 202
200extern struct tty_output *tty_list; 203/* A chain of structures for all tty devices currently in use. */
204extern struct tty_display_info *tty_list;
201 205
202 206
203#define FRAME_TTY(f) \ 207#define FRAME_TTY(f) \
204 ((f)->output_method == output_termcap \ 208 ((f)->output_method == output_termcap \
205 ? (f)->output_data.tty : (abort(), (struct tty_output *) 0)) 209 ? (f)->output_data.tty->display_info \
206 210 : (abort(), (struct tty_display_info *) 0))
207#define CURTTY() FRAME_TTY (SELECTED_FRAME())
208 211
209#define TTY_NAME(t) ((t)->name) 212#define CURTTY() FRAME_TTY (SELECTED_FRAME())
210#define TTY_TYPE(t) ((t)->type)
211 213
212#define TTY_INPUT(t) ((t)->input) 214#define TTY_INPUT(t) ((t)->input)
213#define TTY_OUTPUT(t) ((t)->output) 215#define TTY_OUTPUT(t) ((t)->output)
@@ -221,11 +223,5 @@ extern struct tty_output *tty_list;
221#define TTY_SCROLL_REGION_COST(t) ((t)->scroll_region_cost) 223#define TTY_SCROLL_REGION_COST(t) ((t)->scroll_region_cost)
222#define TTY_MEMORY_BELOW_FRAME(t) ((t)->memory_below_frame) 224#define TTY_MEMORY_BELOW_FRAME(t) ((t)->memory_below_frame)
223 225
224#if 0
225/* These are not used anywhere. */
226#define TTY_MIN_PADDING_SPEED(t) ((t)->min_padding_speed)
227#define TTY_DONT_CALCULATE_COSTS(t) ((t)->dont_calculate_costs)
228#endif
229
230/* arch-tag: bf9f0d49-842b-42fb-9348-ec8759b27193 226/* arch-tag: bf9f0d49-842b-42fb-9348-ec8759b27193
231 (do not change this comment) */ 227 (do not change this comment) */
diff --git a/src/termhooks.h b/src/termhooks.h
index 0fc48a883e8..0802ec50d95 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -30,6 +30,12 @@ struct frame;
30#define P_(X) () 30#define P_(X) ()
31#endif 31#endif
32 32
33/* Device-local parameters. */
34struct device
35{
36 /* XXX Display hooks will go here. */
37};
38
33/* Text display hooks. */ 39/* Text display hooks. */
34 40
35extern void (*cursor_to_hook) P_ ((int vpos, int hpos)); 41extern void (*cursor_to_hook) P_ ((int vpos, int hpos));