comparison src/console-gtk.c @ 2828:a25c824ed558

[xemacs-hg @ 2005-06-26 18:04:49 by aidan] Rename the ascii-character property, support more keysyms.
author aidan
date Sun, 26 Jun 2005 18:05:05 +0000
parents 04bc9d2f42c7
children 461fdb92f3b6
comparison
equal deleted inserted replaced
2827:936a6576c655 2828:a25c824ed558
30 #include "lisp.h" 30 #include "lisp.h"
31 31
32 #include "process.h" /* canonicalize_host_name */ 32 #include "process.h" /* canonicalize_host_name */
33 #include "redisplay.h" /* for display_arg */ 33 #include "redisplay.h" /* for display_arg */
34 34
35 #include "charset.h"
36 #include "elhash.h"
37
35 #include "console-gtk-impl.h" 38 #include "console-gtk-impl.h"
36 39
37 DEFINE_CONSOLE_TYPE (gtk); 40 DEFINE_CONSOLE_TYPE (gtk);
38 41
39 static int 42 static int
108 111
109 GCPRO1 (connection); 112 GCPRO1 (connection);
110 connection = build_string("gtk"); 113 connection = build_string("gtk");
111 114
112 RETURN_UNGCPRO (connection); 115 RETURN_UNGCPRO (connection);
116 }
117
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;
113 } 190 }
114 191
115 void 192 void
116 console_type_create_gtk (void) 193 console_type_create_gtk (void)
117 { 194 {
121 CONSOLE_HAS_METHOD (gtk, canonicalize_console_connection); 198 CONSOLE_HAS_METHOD (gtk, canonicalize_console_connection);
122 CONSOLE_HAS_METHOD (gtk, semi_canonicalize_device_connection); 199 CONSOLE_HAS_METHOD (gtk, semi_canonicalize_device_connection);
123 CONSOLE_HAS_METHOD (gtk, canonicalize_device_connection); 200 CONSOLE_HAS_METHOD (gtk, canonicalize_device_connection);
124 CONSOLE_HAS_METHOD (gtk, device_to_console_connection); 201 CONSOLE_HAS_METHOD (gtk, device_to_console_connection);
125 CONSOLE_HAS_METHOD (gtk, initially_selected_for_input); 202 CONSOLE_HAS_METHOD (gtk, initially_selected_for_input);
203 CONSOLE_HAS_METHOD (gtk, perhaps_init_unseen_key_defaults);
126 /* CONSOLE_HAS_METHOD (gtk, delete_console); */ 204 /* CONSOLE_HAS_METHOD (gtk, delete_console); */
127 } 205 }
128 206
129 void 207 void
130 reinit_console_type_create_gtk (void) 208 reinit_console_type_create_gtk (void)