annotate src/console-stream.c @ 78:c7528f8e288d r20-0b34

Import from CVS: tag r20-0b34
author cvs
date Mon, 13 Aug 2007 09:05:42 +0200
parents 131b0175ea99
children fe104dbd9147
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Stream device functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 /* This file has been Mule-ized. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 /* Written by Ben Wing. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include "console-stream.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include "console-tty.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "events.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include "frame.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include "redisplay.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include "sysdep.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "window.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 DEFINE_CONSOLE_TYPE (stream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 Lisp_Object Vterminal_console;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 Lisp_Object Vterminal_device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 Lisp_Object Vterminal_frame;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
45 Lisp_Object Vstdio_str;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 allocate_stream_console_struct (struct console *con)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 con->console_data =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (struct stream_console *) xmalloc (sizeof (struct stream_console));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 /* zero out all slots. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 memset (con->console_data, 0, sizeof (struct stream_console));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 stream_init_console (struct console *con, Lisp_Object params)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 Lisp_Object tty = CONSOLE_CONNECTION (con);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 FILE *infd, *outfd, *errfd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 /* Open the specified console */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 if (NILP (tty) || !NILP (Fequal (tty, Vstdio_str)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 infd = stdin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 outfd = stdout;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 errfd = stderr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 CHECK_STRING (tty);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 infd = outfd = errfd =
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 12
diff changeset
75 fopen ((char *) XSTRING_DATA (tty), "r+");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 if (!infd)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 12
diff changeset
77 error ("Unable to open tty %s", XSTRING_DATA (tty));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 allocate_stream_console_struct (con);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 CONSOLE_STREAM_DATA (con)->infd = infd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 CONSOLE_STREAM_DATA (con)->outfd = outfd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 CONSOLE_STREAM_DATA (con)->errfd = errfd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 stream_init_device (struct device *d, Lisp_Object params)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 struct console *con = XCONSOLE (DEVICE_CONSOLE (d));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 DEVICE_INFD (d) = fileno (CONSOLE_STREAM_DATA (con)->infd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 DEVICE_OUTFD (d) = fileno (CONSOLE_STREAM_DATA (con)->outfd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 init_baud_rate (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 init_one_device (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 stream_initially_selected_for_input (struct console *con)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 return noninteractive && initialized;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 free_stream_console_struct (struct console *con)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 struct stream_console *tcon = (struct stream_console *) con->console_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 if (tcon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 xfree (tcon);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 extern int stdout_needs_newline;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 stream_delete_console (struct console *con)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 if (/* CONSOLE_STREAM_DATA (con)->needs_newline */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 stdout_needs_newline) /* #### clean this up */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 fputc ('\n', CONSOLE_STREAM_DATA (con)->outfd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 fflush (CONSOLE_STREAM_DATA (con)->outfd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 if (CONSOLE_STREAM_DATA (con)->infd != stdin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 fclose (CONSOLE_STREAM_DATA (con)->infd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 free_stream_console_struct (con);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
127 Lisp_Object
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 stream_semi_canonicalize_console_connection (Lisp_Object connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
131 if (NILP (connection))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
132 return Vstdio_str;
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
133
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
134 return connection;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
137 Lisp_Object
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 stream_canonicalize_console_connection (Lisp_Object connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
141 if (NILP (connection) || !NILP (Fequal (connection, Vstdio_str)))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
142 return Vstdio_str;
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
143
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
144 if (!ERRB_EQ (errb, ERROR_ME))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
145 {
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
146 if (!STRINGP (connection))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
147 return Qunbound;
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
148 }
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
149 else
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
150 CHECK_STRING (connection);
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
151
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
152 return Ffile_truename (connection, Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
155 Lisp_Object
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 stream_semi_canonicalize_device_connection (Lisp_Object connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
159 return stream_semi_canonicalize_console_connection (connection, errb);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
162 Lisp_Object
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 stream_canonicalize_device_connection (Lisp_Object connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
166 return stream_canonicalize_console_connection (connection, errb);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 stream_init_frame_1 (struct frame *f, Lisp_Object props)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 struct device *d = XDEVICE (FRAME_DEVICE (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 if (!NILP (DEVICE_FRAME_LIST (d)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 error ("Only one frame allowed on stream devices");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 f->name = build_string ("stream");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 f->height = 80;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 f->width = 24;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 f->visible = 0; /* so redisplay doesn't try to do anything */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 stream_text_width (struct face_cachel *cachel, CONST Emchar *str,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 Charcount len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 return len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 stream_left_margin_width (struct window *w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 stream_right_margin_width (struct window *w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 stream_divider_width (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 stream_divider_height (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 stream_eol_cursor_width (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 stream_output_begin (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 stream_output_end (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 stream_output_display_block (struct window *w, struct display_line *dl,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 int block, int start, int end,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 int start_pixpos, int cursor_start,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 int cursor_width, int cursor_height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 stream_output_vertical_divider (struct window *w, int clear)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 stream_clear_to_window_end (struct window *w, int ypos1, int ypos2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 stream_clear_region (Lisp_Object locale, face_index findex, int x, int y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 int width, int height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 stream_clear_frame (struct frame *f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 stream_flash (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 return 0; /* sorry can't do it */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 stream_ring_bell (struct device *d, int volume, int pitch, int duration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 struct console *c = XCONSOLE (DEVICE_CONSOLE (d));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 fputc (07, CONSOLE_STREAM_DATA (c)->outfd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 fflush (CONSOLE_STREAM_DATA (c)->outfd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 console_type_create_stream (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 INITIALIZE_CONSOLE_TYPE (stream, "stream", "console-stream-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 /* console methods */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 CONSOLE_HAS_METHOD (stream, init_console);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 CONSOLE_HAS_METHOD (stream, initially_selected_for_input);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 CONSOLE_HAS_METHOD (stream, delete_console);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 CONSOLE_HAS_METHOD (stream, canonicalize_console_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 CONSOLE_HAS_METHOD (stream, canonicalize_device_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 CONSOLE_HAS_METHOD (stream, semi_canonicalize_console_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 CONSOLE_HAS_METHOD (stream, semi_canonicalize_device_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 /* device methods */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 CONSOLE_HAS_METHOD (stream, init_device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 /* frame methods */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 CONSOLE_HAS_METHOD (stream, init_frame_1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 /* redisplay methods */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 CONSOLE_HAS_METHOD (stream, left_margin_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 CONSOLE_HAS_METHOD (stream, right_margin_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 CONSOLE_HAS_METHOD (stream, text_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 CONSOLE_HAS_METHOD (stream, output_display_block);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 CONSOLE_HAS_METHOD (stream, output_vertical_divider);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 CONSOLE_HAS_METHOD (stream, divider_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 CONSOLE_HAS_METHOD (stream, divider_height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 CONSOLE_HAS_METHOD (stream, eol_cursor_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 CONSOLE_HAS_METHOD (stream, clear_to_window_end);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 CONSOLE_HAS_METHOD (stream, clear_region);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 CONSOLE_HAS_METHOD (stream, clear_frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 CONSOLE_HAS_METHOD (stream, output_begin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 CONSOLE_HAS_METHOD (stream, output_end);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 CONSOLE_HAS_METHOD (stream, flash);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 CONSOLE_HAS_METHOD (stream, ring_bell);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 vars_of_console_stream (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 DEFVAR_LISP ("terminal-console", &Vterminal_console /*
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
321 The initial console-object, which represent's Emacs's stdout.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 Vterminal_console = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 DEFVAR_LISP ("terminal-device", &Vterminal_device /*
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
326 The initial device-object, which represent's Emacs's stdout.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 Vterminal_device = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 DEFVAR_LISP ("terminal-frame", &Vterminal_frame /*
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
331 The initial frame-object, which represents Emacs's stdout.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 Vterminal_frame = Qnil;
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
334
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
335 /* Moved from console-tty.c */
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
336 Vstdio_str = build_string ("stdio");
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
337 staticpro (&Vstdio_str);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 init_console_stream (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 if (!initialized)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 Vterminal_device = Fmake_device (Qstream, Qnil, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 Vterminal_console = Fdevice_console (Vterminal_device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 Vterminal_frame = Fmake_frame (Qnil, Vterminal_device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 minibuf_window = XFRAME (Vterminal_frame)->minibuffer_window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 else if (noninteractive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 event_stream_select_console (XCONSOLE (Vterminal_console));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 }