Mercurial > hg > xemacs-beta
annotate src/gui-msw.c @ 5652:cc6f0266bc36
Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
lisp/ChangeLog addition:
2012-05-01 Aidan Kehoe <kehoea@parhasard.net>
Avoid #'delq in core code, for the sake of style and a (very
slightly) smaller binary.
* behavior.el (disable-behavior):
* behavior.el (compute-behavior-group-children):
* buff-menu.el (buffers-tab-items):
* byte-optimize.el (byte-optimize-delay-constants-math):
* byte-optimize.el (byte-optimize-logmumble):
* byte-optimize.el (byte-decompile-bytecode-1):
* byte-optimize.el (byte-optimize-lapcode):
* bytecomp.el:
* bytecomp.el (byte-compile-arglist-warn):
* bytecomp.el (byte-compile-warn-about-unresolved-functions):
* bytecomp.el (byte-compile-lambda):
* bytecomp.el (byte-compile-out-toplevel):
* bytecomp.el (byte-compile-insert):
* bytecomp.el (byte-compile-defalias-warn):
* cl-macs.el (cl-upcase-arg):
* cl-macs.el (cl-transform-lambda):
* cl-macs.el (cl-do-proclaim):
* cl-macs.el (defstruct):
* cl-macs.el (cl-make-type-test):
* cl-macs.el (define-compiler-macro):
* cl-macs.el (delete-duplicates):
* cus-edit.el (widget-face-value-delete):
* cus-edit.el (face-history):
* easymenu.el (easy-menu-remove):
* files.el (files-fetch-hook-value):
* files.el (file-expand-wildcards):
* font-lock.el (font-lock-update-removed-keyword-alist):
* font-lock.el (font-lock-remove-keywords):
* frame.el (frame-initialize):
* frame.el (frame-notice-user-settings):
* frame.el (set-frame-font):
* frame.el (delete-other-frames):
* frame.el (get-frame-for-buffer-noselect):
* gnuserv.el (gnuserv-kill-buffer-function):
* gnuserv.el (gnuserv-check-device):
* gnuserv.el (gnuserv-kill-client):
* gnuserv.el (gnuserv-buffer-done-1):
* gtk-font-menu.el (gtk-reset-device-font-menus):
* gutter-items.el (buffers-tab-items):
* gutter.el (set-gutter-element-visible-p):
* info.el (Info-find-file-node):
* info.el (Info-history-add):
* info.el (Info-build-annotation-completions):
* info.el (Info-index):
* info.el (Info-reannotate-node):
* itimer.el (delete-itimer):
* itimer.el (start-itimer):
* lib-complete.el (lib-complete:cache-completions):
* loadhist.el (unload-feature):
* menubar-items.el (build-buffers-menu-internal):
* menubar.el (delete-menu-item):
* menubar.el (relabel-menu-item):
* msw-font-menu.el (mswindows-reset-device-font-menus):
* mule/make-coding-system.el (fixed-width-generate-helper):
* next-error.el (next-error-find-buffer):
* obsolete.el:
* obsolete.el (find-non-ascii-charset-string):
* obsolete.el (find-non-ascii-charset-region):
* occur.el (multi-occur-by-filename-regexp):
* occur.el (occur-1):
* packages.el (packages-package-hierarchy-directory-names):
* packages.el (package-get-key-1):
* process.el (setenv):
* simple.el (undo):
* simple.el (handle-pre-motion-command-current-command-is-motion):
* sound.el (load-sound-file):
* wid-edit.el (widget-field-value-delete):
* wid-edit.el (widget-checklist-match-inline):
* wid-edit.el (widget-checklist-match-find):
* wid-edit.el (widget-editable-list-delete-at):
* wid-edit.el (widget-editable-list-entry-create):
* window.el (quit-window):
* x-font-menu.el (x-reset-device-font-menus-core):
1. Replace (delq nil (mapcar ....)) with analogous (mapcan ...)
forms; this is in non-dumped files, it was done previously in
dumped files.
2. Replace (delq FOO (copy-sequence BAR)) with (remove* FOO BAR),
where #'eq and #'eql are equivalent
3. Replace (delq FOO BAR) with (delete* FOO BAR), where FOO is not
a non-fixnum number. Saves a little space in the dumped file
(since the compiler macro adds :test #'eq to the delete* call if
it's not clear that FOO is not a non-fixnum number).
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Tue, 01 May 2012 16:17:42 +0100 |
parents | 56144c8593a8 |
children |
rev | line source |
---|---|
428 | 1 /* mswindows GUI code. (menubars, scrollbars, toolbars, dialogs) |
2 Copyright (C) 1998 Andy Piper. | |
1204 | 3 Copyright (C) 2002 Ben Wing. |
428 | 4 |
5 This file is part of XEmacs. | |
6 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2367
diff
changeset
|
7 XEmacs is free software: you can redistribute it and/or modify it |
428 | 8 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2367
diff
changeset
|
9 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2367
diff
changeset
|
10 option) any later version. |
428 | 11 |
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2367
diff
changeset
|
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 19 |
20 /* Synched up with: Not in FSF. */ | |
21 | |
771 | 22 /* This file essentially Mule-ized (except perhaps some Unicode splitting). |
23 5-2000. */ | |
24 | |
428 | 25 #include <config.h> |
26 #include "lisp.h" | |
872 | 27 #include "console-msw-impl.h" |
442 | 28 #include "redisplay.h" |
428 | 29 #include "gui.h" |
442 | 30 #include "glyphs.h" |
872 | 31 #include "frame-impl.h" |
428 | 32 #include "elhash.h" |
442 | 33 #include "events.h" |
440 | 34 #include "buffer.h" |
428 | 35 |
36 /* | |
37 * Return value is Qt if we have dispatched the command, | |
38 * or Qnil if id has not been mapped to a callback. | |
39 * Window procedure may try other targets to route the | |
40 * command if we return nil | |
41 */ | |
42 Lisp_Object | |
2286 | 43 mswindows_handle_gui_wm_command (struct frame *f, HWND UNUSED (ctrl), |
44 LPARAM id) | |
428 | 45 { |
46 /* Try to map the command id through the proper hash table */ | |
442 | 47 Lisp_Object callback, callback_ex, image_instance, frame, event; |
48 | |
793 | 49 frame = wrap_frame (f); |
428 | 50 |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
51 image_instance = Fgethash (make_fixnum_verify (id), |
442 | 52 FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f), Qnil); |
53 /* It is possible for a widget action to cause it to get out of sync | |
54 with its instantiator. Thus it is necessary to signal this | |
55 possibility. */ | |
56 if (IMAGE_INSTANCEP (image_instance)) | |
57 XIMAGE_INSTANCE_WIDGET_ACTION_OCCURRED (image_instance) = 1; | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
58 callback = Fgethash (make_fixnum (id), |
442 | 59 FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f), Qnil); |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
60 callback_ex = Fgethash (make_fixnum (id), |
442 | 61 FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f), Qnil); |
428 | 62 |
442 | 63 if (!NILP (callback_ex) && !UNBOUNDP (callback_ex)) |
64 { | |
65 event = Fmake_event (Qnil, Qnil); | |
440 | 66 |
964 | 67 XSET_EVENT_TYPE (event, misc_user_event); |
68 XSET_EVENT_CHANNEL (event, frame); | |
69 XSET_EVENT_TIMESTAMP (event, GetTickCount()); | |
1204 | 70 XSET_EVENT_MISC_USER_FUNCTION (event, Qeval); |
71 XSET_EVENT_MISC_USER_OBJECT (event, | |
964 | 72 list4 (Qfuncall, callback_ex, image_instance, event)); |
442 | 73 } |
74 else if (NILP (callback) || UNBOUNDP (callback)) | |
75 return Qnil; | |
76 else | |
77 { | |
78 Lisp_Object fn, arg; | |
440 | 79 |
442 | 80 event = Fmake_event (Qnil, Qnil); |
440 | 81 |
442 | 82 get_gui_callback (callback, &fn, &arg); |
964 | 83 XSET_EVENT_TYPE (event, misc_user_event); |
84 XSET_EVENT_CHANNEL (event, frame); | |
85 XSET_EVENT_TIMESTAMP (event, GetTickCount()); | |
1204 | 86 XSET_EVENT_MISC_USER_FUNCTION (event, fn); |
87 XSET_EVENT_MISC_USER_OBJECT (event, arg); | |
442 | 88 } |
89 | |
90 mswindows_enqueue_dispatch_event (event); | |
91 /* The result of this evaluation could cause other instances to change so | |
92 enqueue an update callback to check this. */ | |
93 enqueue_magic_eval_event (update_widget_instances, frame); | |
94 return Qt; | |
440 | 95 } |
96 | |
1204 | 97 /* |
98 * Translate X accelerator syntax to win32 accelerator syntax. | |
99 * accel = (Ichar*) to receive the accelerator character | |
100 * or NULL to suppress accelerators in the menu or dialog item. | |
101 * | |
102 * %% is replaced with % | |
103 * if accel is NULL: | |
104 * %_ is removed. | |
105 * if accel is non-NULL: | |
106 * %_ is replaced with &. | |
107 * The accelerator character is passed back in *accel. | |
108 * (If there is no accelerator, it will be added on the first character.) | |
109 * | |
110 */ | |
111 | |
112 Lisp_Object | |
113 mswindows_translate_menu_or_dialog_item (Lisp_Object item, Ichar *accel) | |
114 { | |
115 Bytecount len = XSTRING_LENGTH (item); | |
2367 | 116 Ibyte *it = alloca_ibytes (2 * len + 42), *ptr = it; |
1204 | 117 |
118 memcpy (ptr, XSTRING_DATA (item), len + 1); | |
119 if (accel) | |
120 *accel = '\0'; | |
121 | |
122 /* Escape '&' as '&&' */ | |
123 | |
124 while ((ptr = (Ibyte *) memchr (ptr, '&', len - (ptr - it))) != NULL) | |
125 { | |
126 memmove (ptr + 1, ptr, (len - (ptr - it)) + 1); | |
127 len++; | |
128 ptr += 2; | |
129 } | |
130 | |
131 /* Replace XEmacs accelerator '%_' with Windows accelerator '&' | |
132 and `%%' with `%'. */ | |
133 ptr = it; | |
134 while ((ptr = (Ibyte *) memchr (ptr, '%', len - (ptr - it))) != NULL) | |
135 { | |
136 if (*(ptr + 1) == '_') | |
137 { | |
138 if (accel) | |
139 { | |
140 *ptr = '&'; | |
141 if (!*accel) | |
142 *accel = DOWNCASE (0, itext_ichar (ptr + 2)); | |
143 memmove (ptr + 1, ptr + 2, len - (ptr - it + 2) + 1); | |
144 len--; | |
145 } | |
146 else /* Skip accelerator */ | |
147 { | |
148 memmove (ptr, ptr + 2, len - (ptr - it + 2) + 1); | |
149 len -= 2; | |
150 } | |
151 } | |
152 else if (*(ptr + 1) == '%') | |
153 { | |
154 memmove (ptr + 1, ptr + 2, len - (ptr - it + 2) + 1); | |
155 len--; | |
156 ptr++; | |
157 } | |
158 else /* % on its own - shouldn't happen */ | |
159 ptr++; | |
160 } | |
161 | |
162 if (accel && !*accel) | |
163 { | |
164 /* Force a default accelerator */ | |
165 ptr = it; | |
166 memmove (ptr + 1, ptr, len + 1); | |
167 *accel = DOWNCASE (0, itext_ichar (ptr + 1)); | |
168 *ptr = '&'; | |
169 | |
170 len++; | |
171 } | |
172 | |
173 return make_string (it, len); | |
174 } | |
175 | |
440 | 176 void |
177 syms_of_gui_mswindows (void) | |
178 { | |
179 } |