Mercurial > hg > xemacs-beta
annotate src/console-tty.c @ 4976:16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-02-04 Ben Wing <ben@xemacs.org>
* alloc.c (release_breathing_space):
* alloc.c (resize_string):
* alloc.c (sweep_lcrecords_1):
* alloc.c (SWEEP_FIXED_TYPE_BLOCK_1):
* alloc.c (ADDITIONAL_FREE_compiled_function):
* alloc.c (compact_string_chars):
* alloc.c (ADDITIONAL_FREE_string):
* alloc.c (sweep_strings):
* alloca.c (xemacs_c_alloca):
* alsaplay.c (alsa_play_sound_file):
* buffer.c (init_initial_directory):
* buffer.h:
* buffer.h (BUFFER_FREE):
* console-stream.c (stream_delete_console):
* console-tty.c (free_tty_console_struct):
* data.c (Fnumber_to_string):
* device-gtk.c (gtk_init_device):
* device-gtk.c (free_gtk_device_struct):
* device-gtk.c (gtk_delete_device):
* device-msw.c (mswindows_delete_device):
* device-msw.c (msprinter_delete_device):
* device-tty.c (free_tty_device_struct):
* device-tty.c (tty_delete_device):
* device-x.c (x_init_device):
* device-x.c (free_x_device_struct):
* device-x.c (x_delete_device):
* dialog-msw.c (handle_directory_dialog_box):
* dialog-x.c (dbox_descriptor_to_widget_value):
* dired-msw.c (Fmswindows_insert_directory):
* dired.c (free_user_cache):
* dired.c (user_name_completion_unwind):
* doc.c (unparesseuxify_doc_string):
* doc.c (Fsubstitute_command_keys):
* doprnt.c (emacs_doprnt_1):
* dumper.c (pdump_load_finish):
* dumper.c (pdump_file_free):
* dumper.c (pdump_file_unmap):
* dynarr.c:
* dynarr.c (Dynarr_free):
* editfns.c (uncache_home_directory):
* editfns.c (Fset_time_zone_rule):
* elhash.c:
* elhash.c (pdump_reorganize_hash_table):
* elhash.c (maphash_unwind):
* emacs.c (make_arg_list_1):
* emacs.c (free_argc_argv):
* emacs.c (sort_args):
* emacs.c (Frunning_temacs_p):
* emodules.c (attempt_module_delete):
* eval.c (free_pointer):
* event-Xt.c (unselect_filedesc):
* event-Xt.c (emacs_Xt_select_process):
* event-gtk.c (unselect_filedesc):
* event-gtk.c (dragndrop_data_received):
* event-msw.c (winsock_closer):
* event-msw.c (mswindows_dde_callback):
* event-msw.c (mswindows_wnd_proc):
* event-stream.c (finalize_command_builder):
* event-stream.c (free_command_builder):
* extents.c (free_gap_array):
* extents.c (free_extent_list):
* extents.c (free_soe):
* extents.c (extent_fragment_delete):
* extents.c (extent_priority_sort_function):
* file-coding.c (make_coding_system_1):
* file-coding.c (coding_finalizer):
* file-coding.c (set_coding_stream_coding_system):
* file-coding.c (chain_finalize_coding_stream_1):
* file-coding.c (chain_finalize):
* file-coding.c (free_detection_state):
* file-coding.c (coding_category_symbol_to_id):
* fileio.c:
* fileio.c (Ffile_name_directory):
* fileio.c (if):
* fileio.c (Ffile_symlink_p):
* filelock.c (FREE_LOCK_INFO):
* filelock.c (current_lock_owner):
* font-mgr.c (Ffc_name_unparse):
* font-mgr.c (Ffc_pattern_duplicate):
* frame-gtk.c (gtk_delete_frame):
* frame-msw.c (mswindows_delete_frame):
* frame-msw.c (msprinter_delete_frame):
* frame-x.c (x_cde_destroy_callback):
* frame-x.c (Fcde_start_drag_internal):
* frame-x.c (x_cde_transfer_callback):
* frame-x.c (x_delete_frame):
* frame.c (update_frame_title):
* frame.c (Fset_frame_pointer):
* gc.c (register_for_finalization):
* gccache-gtk.c (free_gc_cache):
* gccache-gtk.c (gc_cache_lookup):
* gccache-x.c (free_gc_cache):
* gccache-x.c (gc_cache_lookup):
* glyphs-eimage.c:
* glyphs-eimage.c (jpeg_instantiate_unwind):
* glyphs-eimage.c (gif_instantiate_unwind):
* glyphs-eimage.c (png_instantiate_unwind):
* glyphs-eimage.c (png_instantiate):
* glyphs-eimage.c (tiff_instantiate_unwind):
* glyphs-gtk.c (convert_EImage_to_GDKImage):
* glyphs-gtk.c (gtk_finalize_image_instance):
* glyphs-gtk.c (gtk_init_image_instance_from_eimage):
* glyphs-gtk.c (gtk_xpm_instantiate):
* glyphs-msw.c (convert_EImage_to_DIBitmap):
* glyphs-msw.c (mswindows_init_image_instance_from_eimage):
* glyphs-msw.c (mswindows_initialize_image_instance_mask):
* glyphs-msw.c (xpm_to_eimage):
* glyphs-msw.c (mswindows_xpm_instantiate):
* glyphs-msw.c (xbm_create_bitmap_from_data):
* glyphs-msw.c (mswindows_finalize_image_instance):
* glyphs-x.c (convert_EImage_to_XImage):
* glyphs-x.c (x_finalize_image_instance):
* glyphs-x.c (x_init_image_instance_from_eimage):
* glyphs-x.c (x_xpm_instantiate):
* gui-x.c (free_popup_widget_value_tree):
* hash.c (free_hash_table):
* hash.c (grow_hash_table):
* hash.c (pregrow_hash_table_if_necessary):
* imgproc.c (build_EImage_quantable):
* insdel.c (uninit_buffer_text):
* intl-win32.c (convert_multibyte_to_internal_malloc):
* intl.c:
* intl.c (Fset_current_locale):
* keymap.c:
* keymap.c (where_is_recursive_mapper):
* keymap.c (where_is_internal):
* lisp.h:
* lisp.h (xfree):
* lstream.c (Lstream_close):
* lstream.c (resizing_buffer_closer):
* mule-coding.c:
* mule-coding.c (iso2022_finalize_detection_state):
* nt.c:
* nt.c (mswindows_get_long_filename):
* nt.c (nt_get_resource):
* nt.c (init_mswindows_environment):
* nt.c (get_cached_volume_information):
* nt.c (mswindows_opendir):
* nt.c (mswindows_closedir):
* nt.c (mswindows_readdir):
* nt.c (mswindows_stat):
* nt.c (mswindows_getdcwd):
* nt.c (Fmswindows_long_file_name):
* ntplay.c (nt_play_sound_file):
* ntplay.c (play_sound_data_1):
* number-gmp.c (gmp_free):
* number-gmp.c (init_number_gmp):
* number-mp.c (bignum_to_string):
* number-mp.c (BIGNUM_TO_TYPE):
* number.c (bignum_print):
* number.c (bignum_convfree):
* number.c (ratio_print):
* number.c (bigfloat_print):
* number.c (bigfloat_finalize):
* objects-gtk.c (gtk_finalize_color_instance):
* objects-gtk.c (gtk_finalize_font_instance):
* objects-msw.c (mswindows_finalize_color_instance):
* objects-msw.c (mswindows_finalize_font_instance):
* objects-tty.c (tty_finalize_color_instance):
* objects-tty.c (tty_finalize_font_instance):
* objects-tty.c (tty_font_list):
* objects-x.c (x_finalize_color_instance):
* objects-x.c (x_finalize_font_instance):
* process.c:
* process.c (finalize_process):
* realpath.c:
* redisplay.c (add_propagation_runes):
* regex.c:
* regex.c (xfree):
* regex.c (REGEX_FREE_STACK):
* regex.c (FREE_STACK_RETURN):
* regex.c (regex_compile):
* regex.c (regexec):
* regex.c (regfree):
* scrollbar-gtk.c (gtk_free_scrollbar_instance):
* scrollbar-gtk.c (gtk_release_scrollbar_instance):
* scrollbar-msw.c (mswindows_free_scrollbar_instance):
* scrollbar-msw.c (unshow_that_mofo):
* scrollbar-x.c (x_free_scrollbar_instance):
* scrollbar-x.c (x_release_scrollbar_instance):
* select-gtk.c (emacs_gtk_selection_handle):
* select-msw.c (mswindows_own_selection):
* select-x.c:
* select-x.c (x_handle_selection_request):
* select-x.c (unexpect_property_change):
* select-x.c (x_handle_property_notify):
* select-x.c (receive_incremental_selection):
* select-x.c (x_get_window_property_as_lisp_data):
* select-x.c (Fx_get_cutbuffer_internal):
* specifier.c (finalize_specifier):
* syntax.c (uninit_buffer_syntax_cache):
* sysdep.c (qxe_allocating_getcwd):
* sysdep.c (qxe_lstat):
* sysdep.c (copy_in_passwd):
* sysdep.c (qxe_ctime):
* sysdep.c (closedir):
* sysdep.c (DIRSIZ):
* termcap.c (tgetent):
* termcap.c (tprint):
* tests.c (Ftest_data_format_conversion):
* text.c (new_dfc_convert_copy_data):
* text.h (eifree):
* text.h (eito_alloca):
* text.h (eito_external):
* toolbar-msw.c (mswindows_output_toolbar):
* ui-gtk.c (CONVERT_RETVAL):
* ui-gtk.c (__allocate_object_storage):
* unicode.c (free_from_unicode_table):
* unicode.c (free_to_unicode_table):
* unicode.c (free_charset_unicode_tables):
* win32.c (mswindows_read_link_1):
Rename: xfree(VAL, TYPE)->xfree(VAL)
Command used:
gr 'xfree *\((.*),.*\);' 'xfree (\1);' *.[ch]
Followed by grepping for 'xfree.*,' and fixing anything left.
Rationale: Having to specify the TYPE argument is annoying and
error-prone. It was originally put in to work around warnings
due to strict aliasing but years and years ago I rewrote it
in a way that doesn't use the TYPE argument at all and no one
has complained since then. (And anyway, XEmacs is far from
ever being in compliance with strict aliasing and would require
far-reaching changes to get that way.)
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Thu, 04 Feb 2010 07:28:14 -0600 |
parents | 304aebb79cd3 |
children | b5df3737028a |
rev | line source |
---|---|
428 | 1 /* TTY console functions. |
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | |
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc. | |
800 | 4 Copyright (C) 1996, 2001, 2002 Ben Wing. |
428 | 5 |
6 This file is part of XEmacs. | |
7 | |
8 XEmacs is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
10 Free Software Foundation; either version 2, or (at your option) any | |
11 later version. | |
12 | |
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with XEmacs; see the file COPYING. If not, write to | |
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. */ | |
22 | |
23 /* Synched up with: Not in FSF. */ | |
24 | |
25 /* Authors: Ben Wing and Chuck Thompson. */ | |
26 | |
27 #include <config.h> | |
28 #include "lisp.h" | |
29 | |
872 | 30 #include "console-tty-impl.h" |
428 | 31 #include "console-stream.h" |
872 | 32 |
2828 | 33 #include "elhash.h" |
428 | 34 #include "faces.h" |
872 | 35 #include "file-coding.h" |
428 | 36 #include "frame.h" |
872 | 37 #include "glyphs.h" |
428 | 38 #include "lstream.h" |
872 | 39 #include "process.h" |
40 | |
428 | 41 #include "sysdep.h" |
42 #include "sysfile.h" | |
43 | |
44 DEFINE_CONSOLE_TYPE (tty); | |
45 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing); | |
46 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string); | |
47 DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string); | |
48 DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit); | |
49 | |
50 Lisp_Object Qterminal_type; | |
51 Lisp_Object Qcontrolling_process; | |
52 | |
2850 | 53 Lisp_Object Vtty_seen_characters; |
2828 | 54 |
1204 | 55 static const struct memory_description tty_console_data_description_1 [] = { |
56 { XD_LISP_OBJECT, offsetof (struct tty_console, terminal_type) }, | |
57 { XD_LISP_OBJECT, offsetof (struct tty_console, instream) }, | |
58 { XD_LISP_OBJECT, offsetof (struct tty_console, outstream) }, | |
59 { XD_END } | |
60 }; | |
61 | |
3092 | 62 #ifdef NEW_GC |
63 DEFINE_LRECORD_IMPLEMENTATION ("tty-console", tty_console, | |
64 1, /*dumpable-flag*/ | |
65 0, 0, 0, 0, 0, | |
66 tty_console_data_description_1, | |
67 Lisp_Tty_Console); | |
68 #else /* not NEW_GC */ | |
1204 | 69 const struct sized_memory_description tty_console_data_description = { |
70 sizeof (struct tty_console), tty_console_data_description_1 | |
71 }; | |
3092 | 72 #endif /* not NEW_GC */ |
1204 | 73 |
428 | 74 |
75 static void | |
76 allocate_tty_console_struct (struct console *con) | |
77 { | |
78 /* zero out all slots except the lisp ones ... */ | |
3092 | 79 #ifdef NEW_GC |
80 CONSOLE_TTY_DATA (con) = alloc_lrecord_type (struct tty_console, | |
81 &lrecord_tty_console); | |
82 #else /* not NEW_GC */ | |
428 | 83 CONSOLE_TTY_DATA (con) = xnew_and_zero (struct tty_console); |
3092 | 84 #endif /* not NEW_GC */ |
428 | 85 CONSOLE_TTY_DATA (con)->terminal_type = Qnil; |
86 CONSOLE_TTY_DATA (con)->instream = Qnil; | |
87 CONSOLE_TTY_DATA (con)->outstream = Qnil; | |
88 } | |
89 | |
90 static void | |
91 tty_init_console (struct console *con, Lisp_Object props) | |
92 { | |
93 Lisp_Object tty = CONSOLE_CONNECTION (con); | |
94 Lisp_Object terminal_type = Qnil; | |
95 Lisp_Object controlling_process = Qnil; | |
96 struct tty_console *tty_con; | |
97 struct gcpro gcpro1, gcpro2; | |
98 | |
99 GCPRO2 (terminal_type, controlling_process); | |
100 | |
101 terminal_type = Fplist_get (props, Qterminal_type, Qnil); | |
102 controlling_process = Fplist_get (props, Qcontrolling_process, Qnil); | |
103 | |
104 /* Determine the terminal type */ | |
105 | |
106 if (!NILP (terminal_type)) | |
107 CHECK_STRING (terminal_type); | |
108 else | |
109 { | |
867 | 110 Ibyte *temp_type = egetenv ("TERM"); |
428 | 111 |
112 if (!temp_type) | |
113 { | |
563 | 114 invalid_state ("Cannot determine terminal type", Qunbound); |
428 | 115 } |
116 else | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4117
diff
changeset
|
117 terminal_type = build_istring (temp_type); |
428 | 118 } |
119 | |
120 /* Determine the controlling process */ | |
121 if (!NILP (controlling_process)) | |
122 CHECK_INT (controlling_process); | |
123 | |
124 /* Open the specified console */ | |
125 | |
126 allocate_tty_console_struct (con); | |
127 tty_con = CONSOLE_TTY_DATA (con); | |
128 | |
129 if (internal_equal (tty, Vstdio_str, 0)) | |
130 { | |
131 tty_con->infd = fileno (stdin); | |
132 tty_con->outfd = fileno (stdout); | |
133 tty_con->is_stdio = 1; | |
134 } | |
135 else | |
136 { | |
137 tty_con->infd = tty_con->outfd = | |
771 | 138 qxe_open (XSTRING_DATA (tty), O_RDWR); |
428 | 139 if (tty_con->infd < 0) |
563 | 140 signal_error (Qio_error, "Unable to open tty", tty); |
428 | 141 tty_con->is_stdio = 0; |
142 } | |
143 | |
802 | 144 /* set_descriptor_non_blocking (tty_con->infd); */ |
428 | 145 tty_con->instream = make_filedesc_input_stream (tty_con->infd, 0, -1, 0); |
771 | 146 Lstream_set_buffering (XLSTREAM (tty_con->instream), LSTREAM_UNBUFFERED, 0); |
428 | 147 tty_con->instream = |
771 | 148 make_coding_input_stream (XLSTREAM (tty_con->instream), |
149 get_coding_system_for_text_file (Qkeyboard, 0), | |
814 | 150 CODING_DECODE, |
151 LSTREAM_FL_READ_ONE_BYTE_AT_A_TIME); | |
771 | 152 Lstream_set_buffering (XLSTREAM (tty_con->instream), LSTREAM_UNBUFFERED, 0); |
153 tty_con->outstream = make_filedesc_output_stream (tty_con->outfd, 0, -1, 0); | |
428 | 154 tty_con->outstream = |
771 | 155 make_coding_output_stream (XLSTREAM (tty_con->outstream), |
156 get_coding_system_for_text_file (Qterminal, 0), | |
800 | 157 CODING_ENCODE, 0); |
428 | 158 tty_con->terminal_type = terminal_type; |
159 tty_con->controlling_process = controlling_process; | |
160 | |
3571 | 161 /* Defaults to 1 with Mule, 0 without. In the latter case the attribute is |
162 read-only from Lisp. */ | |
163 tty_con->multiple_width = CONSOLE_TTY_SUPPORTS_MULTIPLE_WIDTH(c); | |
164 | |
428 | 165 if (NILP (CONSOLE_NAME (con))) |
166 CONSOLE_NAME (con) = Ffile_name_nondirectory (tty); | |
167 { | |
442 | 168 pid_t tty_pg; |
169 pid_t controlling_tty_pg; | |
428 | 170 int cfd; |
171 | |
172 /* OK, the only sure-fire way I can think of to determine | |
173 whether a particular TTY is our controlling TTY is to check | |
174 if it has the same foreground process group as our controlling | |
175 TTY. This is OK because a process group can never simultaneously | |
176 be the foreground process group of two TTY's (in that case it | |
177 would have two controlling TTY's, which is not allowed). */ | |
178 | |
179 EMACS_GET_TTY_PROCESS_GROUP (tty_con->infd, &tty_pg); | |
867 | 180 cfd = qxe_open ((Ibyte *) "/dev/tty", O_RDWR, 0); |
428 | 181 EMACS_GET_TTY_PROCESS_GROUP (cfd, &controlling_tty_pg); |
771 | 182 retry_close (cfd); |
428 | 183 if (tty_pg == controlling_tty_pg) |
184 { | |
185 tty_con->controlling_terminal = 1; | |
793 | 186 Vcontrolling_terminal = wrap_console (con); |
428 | 187 munge_tty_process_group (); |
188 } | |
189 else | |
190 tty_con->controlling_terminal = 0; | |
191 } | |
192 | |
193 UNGCPRO; | |
194 } | |
195 | |
196 static void | |
197 tty_mark_console (struct console *con) | |
198 { | |
199 struct tty_console *tty_con = CONSOLE_TTY_DATA (con); | |
200 mark_object (tty_con->terminal_type); | |
201 mark_object (tty_con->instream); | |
202 mark_object (tty_con->outstream); | |
203 } | |
204 | |
205 static int | |
2286 | 206 tty_initially_selected_for_input (struct console *UNUSED (con)) |
428 | 207 { |
208 return 1; | |
209 } | |
210 | |
211 static void | |
212 free_tty_console_struct (struct console *con) | |
213 { | |
214 struct tty_console *tty_con = CONSOLE_TTY_DATA (con); | |
215 if (tty_con) | |
216 { | |
217 if (tty_con->term_entry_buffer) /* allocated in term_init () */ | |
218 { | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
219 xfree (tty_con->term_entry_buffer); |
428 | 220 tty_con->term_entry_buffer = NULL; |
221 } | |
4117 | 222 #ifndef NEW_GC |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
223 xfree (tty_con); |
3092 | 224 #endif /* not NEW_GC */ |
428 | 225 CONSOLE_TTY_DATA (con) = NULL; |
226 } | |
227 } | |
228 | |
229 static void | |
230 tty_delete_console (struct console *con) | |
231 { | |
232 Lstream_close (XLSTREAM (CONSOLE_TTY_DATA (con)->instream)); | |
233 Lstream_close (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream)); | |
234 if (!CONSOLE_TTY_DATA (con)->is_stdio) | |
771 | 235 retry_close (CONSOLE_TTY_DATA (con)->infd); |
428 | 236 if (CONSOLE_TTY_DATA (con)->controlling_terminal) |
237 { | |
238 Vcontrolling_terminal = Qnil; | |
239 unmunge_tty_process_group (); | |
240 } | |
241 free_tty_console_struct (con); | |
242 } | |
243 | |
244 | |
245 static struct console * | |
246 decode_tty_console (Lisp_Object console) | |
247 { | |
793 | 248 console = wrap_console (decode_console (console)); |
428 | 249 CHECK_TTY_CONSOLE (console); |
250 return XCONSOLE (console); | |
251 } | |
252 | |
253 DEFUN ("console-tty-terminal-type", Fconsole_tty_terminal_type, | |
254 0, 1, 0, /* | |
255 Return the terminal type of TTY console CONSOLE. | |
256 */ | |
257 (console)) | |
258 { | |
259 return CONSOLE_TTY_DATA (decode_tty_console (console))->terminal_type; | |
260 } | |
261 | |
262 DEFUN ("console-tty-controlling-process", Fconsole_tty_controlling_process, | |
263 0, 1, 0, /* | |
264 Return the controlling process of tty console CONSOLE. | |
265 */ | |
266 (console)) | |
267 { | |
268 return CONSOLE_TTY_DATA (decode_tty_console (console))->controlling_process; | |
269 } | |
270 | |
271 | |
272 DEFUN ("console-tty-input-coding-system", Fconsole_tty_input_coding_system, | |
273 0, 1, 0, /* | |
274 Return the input coding system of tty console CONSOLE. | |
275 */ | |
276 (console)) | |
277 { | |
771 | 278 return coding_stream_detected_coding_system |
428 | 279 (XLSTREAM (CONSOLE_TTY_DATA (decode_tty_console (console))->instream)); |
280 } | |
281 | |
282 DEFUN ("set-console-tty-input-coding-system", Fset_console_tty_input_coding_system, | |
283 0, 2, 0, /* | |
284 Set the input coding system of tty console CONSOLE to CODESYS. | |
285 CONSOLE defaults to the selected console. | |
286 CODESYS defaults to the value of `keyboard-coding-system'. | |
287 */ | |
288 (console, codesys)) | |
289 { | |
771 | 290 set_coding_stream_coding_system |
428 | 291 (XLSTREAM (CONSOLE_TTY_DATA (decode_tty_console (console))->instream), |
771 | 292 get_coding_system_for_text_file (NILP (codesys) ? Qkeyboard : codesys, |
293 0)); | |
428 | 294 return Qnil; |
295 } | |
296 | |
297 DEFUN ("console-tty-output-coding-system", Fconsole_tty_output_coding_system, | |
298 0, 1, 0, /* | |
299 Return TTY CONSOLE's output coding system. | |
300 */ | |
301 (console)) | |
302 { | |
771 | 303 return coding_stream_coding_system |
428 | 304 (XLSTREAM (CONSOLE_TTY_DATA (decode_tty_console (console))->outstream)); |
305 } | |
306 | |
307 DEFUN ("set-console-tty-output-coding-system", Fset_console_tty_output_coding_system, | |
308 0, 2, 0, /* | |
309 Set the coding system of tty output of console CONSOLE to CODESYS. | |
310 CONSOLE defaults to the selected console. | |
311 CODESYS defaults to the value of `terminal-coding-system'. | |
312 */ | |
313 (console, codesys)) | |
314 { | |
771 | 315 set_coding_stream_coding_system |
428 | 316 (XLSTREAM (CONSOLE_TTY_DATA (decode_tty_console (console))->outstream), |
771 | 317 get_coding_system_for_text_file (NILP (codesys) ? Qterminal : codesys, |
318 0)); | |
438 | 319 /* Redraw tty */ |
320 face_property_was_changed (Vdefault_face, Qfont, Qtty); | |
428 | 321 return Qnil; |
322 } | |
323 | |
3571 | 324 DEFUN ("console-tty-multiple-width", Fconsole_tty_multiple_width, |
325 0, 1, 0, /* | |
326 Return whether CONSOLE treats East Asian double-width chars as such. | |
327 | |
328 CONSOLE defaults to the selected console. Without XEmacs support for | |
329 double-width characters, this always gives nil. | |
330 */ | |
331 (console)) | |
332 { | |
333 return CONSOLE_TTY_MULTIPLE_WIDTH (decode_tty_console(console)) | |
334 ? Qt : Qnil; | |
335 } | |
336 | |
337 DEFUN ("set-console-tty-multiple-width", Fset_console_tty_multiple_width, | |
338 0, 2, 0, /* | |
339 Set whether CONSOLE treats East Asian double-width characters as such. | |
340 | |
341 CONSOLE defaults to the selected console, and VALUE defaults to nil. | |
342 Without XEmacs support for double-width characters, this throws an error if | |
343 VALUE is non-nil. | |
344 */ | |
345 (console, value)) | |
346 { | |
347 struct console *c = decode_tty_console (console); | |
348 | |
349 /* So people outside of East Asia can put (set-console-tty-multiple-width | |
350 (selected-console) nil) in their init files, independent of whether | |
351 Mule is enabled. */ | |
352 if (!CONSOLE_TTY_MULTIPLE_WIDTH (c) && NILP(value)) | |
353 { | |
354 return Qnil; | |
355 } | |
356 | |
357 if (!CONSOLE_TTY_SUPPORTS_MULTIPLE_WIDTH (c)) | |
358 { | |
359 invalid_change | |
360 ("No console support for double-width chars", | |
361 Fmake_symbol(CONSOLE_NAME(c))); | |
362 } | |
363 | |
364 CONSOLE_TTY_DATA(c)->multiple_width = NILP(value) ? 0 : 1; | |
365 | |
366 return Qnil; | |
367 } | |
368 | |
440 | 369 /* #### Move this function to lisp */ |
428 | 370 DEFUN ("set-console-tty-coding-system", Fset_console_tty_coding_system, |
371 0, 2, 0, /* | |
372 Set the input and output coding systems of tty console CONSOLE to CODESYS. | |
373 CONSOLE defaults to the selected console. | |
374 If CODESYS is nil, the values of `keyboard-coding-system' and | |
375 `terminal-coding-system' will be used for the input and | |
376 output coding systems of CONSOLE. | |
377 */ | |
378 (console, codesys)) | |
379 { | |
380 Fset_console_tty_input_coding_system (console, codesys); | |
381 Fset_console_tty_output_coding_system (console, codesys); | |
382 return Qnil; | |
383 } | |
384 | |
385 | |
386 Lisp_Object | |
387 tty_semi_canonicalize_console_connection (Lisp_Object connection, | |
578 | 388 Error_Behavior errb) |
428 | 389 { |
390 return stream_semi_canonicalize_console_connection (connection, errb); | |
391 } | |
392 | |
393 Lisp_Object | |
394 tty_canonicalize_console_connection (Lisp_Object connection, | |
578 | 395 Error_Behavior errb) |
428 | 396 { |
397 return stream_canonicalize_console_connection (connection, errb); | |
398 } | |
399 | |
400 Lisp_Object | |
401 tty_semi_canonicalize_device_connection (Lisp_Object connection, | |
578 | 402 Error_Behavior errb) |
428 | 403 { |
404 return stream_semi_canonicalize_console_connection (connection, errb); | |
405 } | |
406 | |
407 Lisp_Object | |
408 tty_canonicalize_device_connection (Lisp_Object connection, | |
578 | 409 Error_Behavior errb) |
428 | 410 { |
411 return stream_canonicalize_console_connection (connection, errb); | |
412 } | |
413 | |
2828 | 414 static Lisp_Object |
415 tty_perhaps_init_unseen_key_defaults (struct console *UNUSED(con), | |
416 Lisp_Object key) | |
417 { | |
418 Ichar val; | |
419 extern Lisp_Object Vcurrent_global_map; | |
420 | |
421 if (SYMBOLP(key)) | |
422 { | |
423 /* We've no idea what to default an unknown symbol to on the TTY. */ | |
424 return Qnil; | |
425 } | |
426 | |
427 CHECK_CHAR(key); | |
428 | |
2850 | 429 if (!(HASH_TABLEP(Vtty_seen_characters))) |
2828 | 430 { |
431 /* All the keysyms we deal with are character objects; therefore, we | |
432 can use eq as the test without worrying. */ | |
2850 | 433 Vtty_seen_characters = make_lisp_hash_table (128, HASH_TABLE_NON_WEAK, |
2828 | 434 HASH_TABLE_EQ); |
435 } | |
436 | |
437 /* Might give the user an opaque error if make_lisp_hash_table fails, | |
438 but it won't crash. */ | |
2850 | 439 CHECK_HASH_TABLE(Vtty_seen_characters); |
2828 | 440 |
441 val = XCHAR(key); | |
442 | |
443 /* Same logic as in x_has_keysym; I'm not convinced it's always sane. */ | |
444 if (val < 0x80) | |
445 { | |
446 return Qnil; | |
447 } | |
448 | |
2850 | 449 if (!NILP(Fgethash(key, Vtty_seen_characters, Qnil))) |
2828 | 450 { |
451 return Qnil; | |
452 } | |
453 | |
454 if (NILP (Flookup_key (Vcurrent_global_map, key, Qnil))) | |
455 { | |
2850 | 456 Fputhash(key, Qt, Vtty_seen_characters); |
2828 | 457 Fdefine_key (Vcurrent_global_map, key, Qself_insert_command); |
458 return Qt; | |
459 } | |
460 | |
461 return Qnil; | |
462 } | |
463 | |
428 | 464 |
465 /************************************************************************/ | |
466 /* initialization */ | |
467 /************************************************************************/ | |
468 | |
469 void | |
470 syms_of_console_tty (void) | |
471 { | |
472 DEFSUBR (Fconsole_tty_terminal_type); | |
473 DEFSUBR (Fconsole_tty_controlling_process); | |
563 | 474 DEFSYMBOL (Qterminal_type); |
475 DEFSYMBOL (Qcontrolling_process); | |
428 | 476 DEFSUBR (Fconsole_tty_output_coding_system); |
477 DEFSUBR (Fset_console_tty_output_coding_system); | |
478 DEFSUBR (Fconsole_tty_input_coding_system); | |
479 DEFSUBR (Fset_console_tty_input_coding_system); | |
480 DEFSUBR (Fset_console_tty_coding_system); | |
3571 | 481 DEFSUBR (Fconsole_tty_multiple_width); |
482 DEFSUBR (Fset_console_tty_multiple_width); | |
428 | 483 } |
484 | |
485 void | |
486 console_type_create_tty (void) | |
487 { | |
488 INITIALIZE_CONSOLE_TYPE (tty, "tty", "console-tty-p"); | |
489 | |
490 /* console methods */ | |
491 CONSOLE_HAS_METHOD (tty, init_console); | |
492 CONSOLE_HAS_METHOD (tty, mark_console); | |
493 CONSOLE_HAS_METHOD (tty, initially_selected_for_input); | |
494 CONSOLE_HAS_METHOD (tty, delete_console); | |
495 CONSOLE_HAS_METHOD (tty, canonicalize_console_connection); | |
496 CONSOLE_HAS_METHOD (tty, canonicalize_device_connection); | |
497 CONSOLE_HAS_METHOD (tty, semi_canonicalize_console_connection); | |
498 CONSOLE_HAS_METHOD (tty, semi_canonicalize_device_connection); | |
2828 | 499 CONSOLE_HAS_METHOD (tty, perhaps_init_unseen_key_defaults); |
428 | 500 } |
501 | |
502 void | |
503 reinit_console_type_create_tty (void) | |
504 { | |
505 REINITIALIZE_CONSOLE_TYPE (tty); | |
506 } | |
507 | |
508 void | |
509 image_instantiator_format_create_glyphs_tty (void) | |
510 { | |
511 IIFORMAT_VALID_CONSOLE (tty, nothing); | |
512 IIFORMAT_VALID_CONSOLE (tty, string); | |
513 IIFORMAT_VALID_CONSOLE (tty, formatted_string); | |
514 IIFORMAT_VALID_CONSOLE (tty, inherit); | |
515 } | |
516 | |
517 void | |
518 vars_of_console_tty (void) | |
519 { | |
2850 | 520 DEFVAR_LISP ("tty-seen-characters", &Vtty_seen_characters /* |
521 Hash table of non-ASCII characters the TTY subsystem has seen. | |
522 */ ); | |
523 Vtty_seen_characters = Qnil; | |
428 | 524 Fprovide (Qtty); |
525 } |