462
|
1 /* Console functions for X windows.
|
|
2 Copyright (C) 1996 Ben Wing.
|
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
6 XEmacs is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by the
|
|
8 Free Software Foundation; either version 2, or (at your option) any
|
|
9 later version.
|
|
10
|
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with XEmacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
|
20
|
|
21 /* Synched up with: Not in FSF. */
|
|
22
|
|
23 /* Authorship:
|
|
24
|
|
25 Ben Wing: January 1996, for 19.14.
|
|
26 William Perry: April 2000, for 21.1 (Gtk version)
|
|
27 */
|
|
28
|
|
29 #include <config.h>
|
|
30 #include "lisp.h"
|
|
31
|
|
32 #include "process.h" /* canonicalize_host_name */
|
|
33 #include "redisplay.h" /* for display_arg */
|
|
34
|
2828
|
35 #include "charset.h"
|
|
36 #include "elhash.h"
|
|
37
|
872
|
38 #include "console-gtk-impl.h"
|
|
39
|
462
|
40 DEFINE_CONSOLE_TYPE (gtk);
|
|
41
|
|
42 static int
|
2286
|
43 gtk_initially_selected_for_input (struct console *UNUSED (con))
|
462
|
44 {
|
|
45 return 1;
|
|
46 }
|
|
47
|
|
48 /* Remember, in all of the following functions, we have to verify
|
|
49 the integrity of our input, because the generic functions don't. */
|
|
50
|
|
51 static Lisp_Object
|
2286
|
52 gtk_device_to_console_connection (Lisp_Object connection,
|
|
53 Error_Behavior UNUSED (errb))
|
462
|
54 {
|
|
55 /* Strip the trailing .# off of the connection, if it's there. */
|
|
56
|
|
57 if (NILP (connection))
|
|
58 return Qnil;
|
|
59 else
|
|
60 {
|
|
61 connection = build_string ("gtk");
|
|
62 }
|
|
63 return connection;
|
|
64 }
|
|
65
|
|
66 static Lisp_Object
|
|
67 gtk_semi_canonicalize_console_connection (Lisp_Object connection,
|
2286
|
68 Error_Behavior UNUSED (errb))
|
462
|
69 {
|
|
70 struct gcpro gcpro1;
|
|
71
|
|
72 GCPRO1 (connection);
|
|
73
|
|
74 connection = build_string ("gtk");
|
|
75
|
|
76 RETURN_UNGCPRO (connection);
|
|
77 }
|
|
78
|
|
79 static Lisp_Object
|
2286
|
80 gtk_canonicalize_console_connection (Lisp_Object connection,
|
|
81 Error_Behavior UNUSED (errb))
|
462
|
82 {
|
|
83 Lisp_Object hostname = Qnil;
|
|
84 struct gcpro gcpro1, gcpro2;
|
|
85
|
|
86 GCPRO2 (connection, hostname);
|
|
87
|
|
88 connection = build_string ("gtk");
|
|
89
|
|
90 RETURN_UNGCPRO (connection);
|
|
91 }
|
|
92
|
|
93 static Lisp_Object
|
|
94 gtk_semi_canonicalize_device_connection (Lisp_Object connection,
|
2286
|
95 Error_Behavior UNUSED (errb))
|
462
|
96 {
|
|
97 struct gcpro gcpro1;
|
|
98
|
|
99 GCPRO1 (connection);
|
|
100
|
|
101 connection = build_string("gtk");
|
|
102
|
|
103 RETURN_UNGCPRO (connection);
|
|
104 }
|
|
105
|
|
106 static Lisp_Object
|
2286
|
107 gtk_canonicalize_device_connection (Lisp_Object connection,
|
|
108 Error_Behavior UNUSED (errb))
|
462
|
109 {
|
|
110 struct gcpro gcpro1;
|
|
111
|
|
112 GCPRO1 (connection);
|
|
113 connection = build_string("gtk");
|
|
114
|
|
115 RETURN_UNGCPRO (connection);
|
|
116 }
|
|
117
|
2828
|
118 extern Lisp_Object gtk_keysym_to_character(guint keysym);
|
|
119
|
|
120 static Lisp_Object
|
|
121 gtk_perhaps_init_unseen_key_defaults (struct console *UNUSED(con),
|
|
122 Lisp_Object key)
|
|
123 {
|
|
124 Lisp_Object char_to_associate = Qnil;
|
|
125 extern Lisp_Object Vcurrent_global_map, Qgtk_seen_characters,
|
|
126 Qcharacter_of_keysym;
|
|
127
|
|
128 if (SYMBOLP(key))
|
|
129 {
|
|
130 gchar *symbol_name;
|
|
131 guint keyval;
|
|
132 DECLARE_EISTRING(ei_symname);
|
|
133
|
|
134 eicpy_rawz(ei_symname, XSTRING_DATA(symbol_name(XSYMBOL(key))));
|
|
135
|
|
136 /* No information on the coding system of the string key names in GDK,
|
|
137 to my knowledge. Defaulting to binary, */
|
|
138 eito_external(ei_symname, Qbinary);
|
|
139 symbol_name = eiextdata(ei_symname);
|
|
140
|
|
141 /* GTK 2.0 has an API we can use, and makes this available in gdkkeys.h
|
|
142
|
|
143 This has yet to be compiled, because XEmacs' GTK support hasn't yet moved
|
|
144 to 2.0. So if you're porting XEmacs to GTK 2.0, bear that in mind. */
|
|
145 char_to_associate
|
|
146 #ifdef __GDK_KEYS_H__
|
|
147 = Funicode_to_char
|
|
148 (make_int(gdk_keyval_to_unicode
|
|
149 (gdk_keyval_from_name(symbol_name))), Qnil);
|
|
150 #else /* GTK 1.whatever doesn't. Use the X11 map. */
|
|
151 = gtk_keysym_to_character(gdk_keyval_from_name(symbol_name));
|
|
152 #endif
|
|
153 }
|
|
154 else
|
|
155 {
|
|
156 CHECK_CHAR(key);
|
|
157 }
|
|
158
|
|
159 if (!(HASH_TABLEP(Qgtk_seen_characters)))
|
|
160 {
|
|
161 Qgtk_seen_characters = make_lisp_hash_table (128, HASH_TABLE_NON_WEAK,
|
|
162 HASH_TABLE_EQUAL);
|
|
163 }
|
|
164
|
|
165 /* Might give the user an opaque error if make_lisp_hash_table fails,
|
|
166 but it shouldn't crash. */
|
|
167 CHECK_HASH_TABLE(Qgtk_seen_characters);
|
|
168
|
|
169 if (EQ(char_to_associate, Qnil) /* If there's no char to bind, */
|
|
170 || (XCHAR(char_to_associate) < 0x80) /* or it's ASCII */
|
|
171 || !NILP(Fgethash(key, Qgtk_seen_characters, Qnil))) /* Or we've seen
|
|
172 it already, */
|
|
173 {
|
|
174 /* then don't bind the key. */
|
|
175 return Qnil;
|
|
176 }
|
|
177
|
|
178 if (NILP (Flookup_key (Vcurrent_global_map, key, Qnil)))
|
|
179 {
|
|
180 Fputhash(key, Qt, Qgtk_seen_characters);
|
|
181 Fdefine_key (Vcurrent_global_map, key, Qself_insert_command);
|
|
182 if (SYMBOLP(key))
|
|
183 {
|
|
184 Fput (key, Qcharacter_of_keysym, char_to_associate);
|
|
185 }
|
|
186 return Qt;
|
|
187 }
|
|
188
|
|
189 return Qnil;
|
|
190 }
|
|
191
|
462
|
192 void
|
|
193 console_type_create_gtk (void)
|
|
194 {
|
|
195 INITIALIZE_CONSOLE_TYPE (gtk, "gtk", "console-gtk-p");
|
|
196
|
|
197 CONSOLE_HAS_METHOD (gtk, semi_canonicalize_console_connection);
|
|
198 CONSOLE_HAS_METHOD (gtk, canonicalize_console_connection);
|
|
199 CONSOLE_HAS_METHOD (gtk, semi_canonicalize_device_connection);
|
|
200 CONSOLE_HAS_METHOD (gtk, canonicalize_device_connection);
|
|
201 CONSOLE_HAS_METHOD (gtk, device_to_console_connection);
|
|
202 CONSOLE_HAS_METHOD (gtk, initially_selected_for_input);
|
2828
|
203 CONSOLE_HAS_METHOD (gtk, perhaps_init_unseen_key_defaults);
|
462
|
204 /* CONSOLE_HAS_METHOD (gtk, delete_console); */
|
|
205 }
|
|
206
|
|
207 void
|
|
208 reinit_console_type_create_gtk (void)
|
|
209 {
|
|
210 REINITIALIZE_CONSOLE_TYPE (gtk);
|
|
211 }
|