Mercurial > hg > xemacs-beta
comparison src/console-stream.c @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | 966663fcf606 |
children | 558f606b08ae |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
32 #include "console-tty.h" | 32 #include "console-tty.h" |
33 #include "events.h" | 33 #include "events.h" |
34 #include "frame.h" | 34 #include "frame.h" |
35 #include "redisplay.h" | 35 #include "redisplay.h" |
36 #include "sysdep.h" | 36 #include "sysdep.h" |
37 #include "sysfile.h" | |
37 #include "window.h" | 38 #include "window.h" |
38 | 39 |
39 DEFINE_CONSOLE_TYPE (stream); | 40 DEFINE_CONSOLE_TYPE (stream); |
40 | 41 |
41 Lisp_Object Vterminal_console; | 42 Lisp_Object Vterminal_console; |
45 Lisp_Object Vstdio_str; | 46 Lisp_Object Vstdio_str; |
46 | 47 |
47 static void | 48 static void |
48 allocate_stream_console_struct (struct console *con) | 49 allocate_stream_console_struct (struct console *con) |
49 { | 50 { |
50 if (!con->console_data) | 51 if (!CONSOLE_STREAM_DATA (con)) |
51 { | 52 CONSOLE_STREAM_DATA (con) = xnew_and_zero (struct stream_console); |
52 con->console_data = xnew_and_zero (struct stream_console); | |
53 } | |
54 else | 53 else |
55 { | 54 xzero (*CONSOLE_STREAM_DATA (con)); |
56 memset(con->console_data, 0, sizeof (struct stream_console)); | |
57 } | |
58 } | 55 } |
59 | 56 |
60 static void | 57 static void |
61 stream_init_console (struct console *con, Lisp_Object params) | 58 stream_init_console (struct console *con, Lisp_Object params) |
62 { | 59 { |
65 | 62 |
66 /* Open the specified console */ | 63 /* Open the specified console */ |
67 | 64 |
68 if (NILP (tty) || internal_equal (tty, Vstdio_str, 0)) | 65 if (NILP (tty) || internal_equal (tty, Vstdio_str, 0)) |
69 { | 66 { |
70 infd = stdin; | 67 infd = stdin; |
71 outfd = stdout; | 68 outfd = stdout; |
72 errfd = stderr; | 69 errfd = stderr; |
73 } | 70 } |
74 else | 71 else |
75 { | 72 { |
79 if (!infd) | 76 if (!infd) |
80 error ("Unable to open tty %s", XSTRING_DATA (tty)); | 77 error ("Unable to open tty %s", XSTRING_DATA (tty)); |
81 } | 78 } |
82 | 79 |
83 allocate_stream_console_struct (con); | 80 allocate_stream_console_struct (con); |
84 CONSOLE_STREAM_DATA (con)->infd = infd; | 81 CONSOLE_STREAM_DATA (con)->infd = infd; |
85 CONSOLE_STREAM_DATA (con)->outfd = outfd; | 82 CONSOLE_STREAM_DATA (con)->outfd = outfd; |
86 CONSOLE_STREAM_DATA (con)->errfd = errfd; | 83 CONSOLE_STREAM_DATA (con)->errfd = errfd; |
87 } | 84 } |
88 | 85 |
89 static void | 86 static void |
90 stream_init_device (struct device *d, Lisp_Object params) | 87 stream_init_device (struct device *d, Lisp_Object params) |
91 { | 88 { |
92 struct console *con = XCONSOLE (DEVICE_CONSOLE (d)); | 89 struct console *con = XCONSOLE (DEVICE_CONSOLE (d)); |
93 | 90 |
94 DEVICE_INFD (d) = fileno (CONSOLE_STREAM_DATA (con)->infd); | 91 DEVICE_INFD (d) = fileno (CONSOLE_STREAM_DATA (con)->infd); |
95 DEVICE_OUTFD (d) = fileno (CONSOLE_STREAM_DATA (con)->outfd); | 92 DEVICE_OUTFD (d) = fileno (CONSOLE_STREAM_DATA (con)->outfd); |
96 init_baud_rate (d); | 93 init_baud_rate (d); |
97 init_one_device (d); | 94 init_one_device (d); |
98 } | 95 } |
99 | 96 |
104 } | 101 } |
105 | 102 |
106 static void | 103 static void |
107 free_stream_console_struct (struct console *con) | 104 free_stream_console_struct (struct console *con) |
108 { | 105 { |
109 struct stream_console *tcon = (struct stream_console *) con->console_data; | 106 if (CONSOLE_STREAM_DATA (con)) |
110 if (tcon) | 107 { |
111 { | 108 xfree (CONSOLE_STREAM_DATA (con)); |
112 xfree (tcon); | 109 CONSOLE_STREAM_DATA (con) = NULL; |
113 con->console_data = NULL; | |
114 } | 110 } |
115 } | 111 } |
116 | 112 |
117 extern int stdout_needs_newline; | 113 extern int stdout_needs_newline; |
118 | 114 |
132 | 128 |
133 Lisp_Object | 129 Lisp_Object |
134 stream_semi_canonicalize_console_connection (Lisp_Object connection, | 130 stream_semi_canonicalize_console_connection (Lisp_Object connection, |
135 Error_behavior errb) | 131 Error_behavior errb) |
136 { | 132 { |
137 if (NILP (connection)) | 133 return NILP (connection) ? Vstdio_str : connection; |
138 return Vstdio_str; | |
139 | |
140 return connection; | |
141 } | 134 } |
142 | 135 |
143 Lisp_Object | 136 Lisp_Object |
144 stream_canonicalize_console_connection (Lisp_Object connection, | 137 stream_canonicalize_console_connection (Lisp_Object connection, |
145 Error_behavior errb) | 138 Error_behavior errb) |
174 | 167 |
175 | 168 |
176 static void | 169 static void |
177 stream_init_frame_1 (struct frame *f, Lisp_Object props) | 170 stream_init_frame_1 (struct frame *f, Lisp_Object props) |
178 { | 171 { |
172 #if 0 | |
179 struct device *d = XDEVICE (FRAME_DEVICE (f)); | 173 struct device *d = XDEVICE (FRAME_DEVICE (f)); |
180 #if 0 | |
181 if (!NILP (DEVICE_FRAME_LIST (d))) | 174 if (!NILP (DEVICE_FRAME_LIST (d))) |
182 error ("Only one frame allowed on stream devices"); | 175 error ("Only one frame allowed on stream devices"); |
183 #endif | 176 #endif |
184 f->name = build_string ("stream"); | 177 f->name = build_string ("stream"); |
185 f->height = 80; | 178 f->height = 80; |
353 Vterminal_device = Fmake_device (Qstream, Qnil, Qnil); | 346 Vterminal_device = Fmake_device (Qstream, Qnil, Qnil); |
354 Vterminal_console = Fdevice_console (Vterminal_device); | 347 Vterminal_console = Fdevice_console (Vterminal_device); |
355 Vterminal_frame = Fmake_frame (Qnil, Vterminal_device); | 348 Vterminal_frame = Fmake_frame (Qnil, Vterminal_device); |
356 minibuf_window = XFRAME (Vterminal_frame)->minibuffer_window; | 349 minibuf_window = XFRAME (Vterminal_frame)->minibuffer_window; |
357 } | 350 } |
358 else { | 351 else |
359 /* Re-initialize the FILE fields of the console. */ | 352 { |
360 stream_init_console (XCONSOLE (Vterminal_console), Qnil); | 353 /* Re-initialize the FILE fields of the console. */ |
361 if (noninteractive) | 354 stream_init_console (XCONSOLE (Vterminal_console), Qnil); |
362 event_stream_select_console (XCONSOLE (Vterminal_console)); | 355 if (noninteractive) |
363 } | 356 event_stream_select_console (XCONSOLE (Vterminal_console)); |
364 } | 357 } |
358 } |