Mercurial > hg > xemacs-beta
annotate src/gui-msw.c @ 5655:b7ae5f44b950
Remove some redundant functions, change others to labels, lisp/
lisp/ChangeLog addition:
2012-05-05 Aidan Kehoe <kehoea@parhasard.net>
Remove some redundant functions; turn other utility functions into
labels, avoiding visibility in the global namespace, and reducing
the size of the dumped binary.
* auto-save.el (auto-save-unhex): Removed.
* auto-save.el (auto-save-unescape-name): Use #'string-to-number
instead of #'auto-save-unhex.
* files.el (save-some-buffers):
* files.el (save-some-buffers-1): Changed to a label.
* files.el (not-modified):
* gui.el (make-gui-button):
* gui.el (gui-button-action): Changed to a label.
* gui.el (insert-gui-button):
* indent.el (indent-for-tab-command):
* indent.el (insert-tab): Changed to a label.
* indent.el (indent-rigidly):
* isearch-mode.el:
* isearch-mode.el (isearch-ring-adjust):
* isearch-mode.el (isearch-ring-adjust1): Changed to a label.
* isearch-mode.el (isearch-pre-command-hook):
* isearch-mode.el (isearch-maybe-frob-keyboard-macros): Changed to
a label.
* isearch-mode.el (isearch-highlight):
* isearch-mode.el (isearch-make-extent): Changed to a label.
* itimer.el:
* itimer.el (itimer-decrement): Removed, replaced uses with decf.
* itimer.el (itimer-increment): Removed, replaced uses with incf.
* itimer.el (itimer-signum): Removed, replaced uses with minusp, plusp.
* itimer.el (itimer-name):
* itimer.el (check-itimer): Removed, replaced with #'check-type calls.
* itimer.el (itimer-value):
* itimer.el (check-itimer-coerce-string): Removed.
* itimer.el (itimer-restart):
* itimer.el (itimer-function):
* itimer.el (check-nonnegative-number): Removed.
* itimer.el (itimer-uses-arguments):
* itimer.el (check-string): Removed.
* itimer.el (itimer-function-arguments):
* itimer.el (itimer-recorded-run-time):
* itimer.el (set-itimer-name):
* itimer.el (set-itimer-value):
* itimer.el (set-itimer-value-internal):
* itimer.el (set-itimer-restart):
* itimer.el (set-itimer-function):
* itimer.el (set-itimer-is-idle):
* itimer.el (set-itimer-recorded-run-time):
* itimer.el (get-itimer):
* itimer.el (delete-itimer):
* itimer.el (start-itimer):
* itimer.el (activate-itimer):
* itimer.el (itimer-edit-set-field):
* itimer.el (itimer-edit-next-field):
* itimer.el (itimer-edit-previous-field):
Use incf, decf, plusp, minusp and the more general argument type
checking macros.
* lib-complete.el:
* lib-complete.el (lib-complete:better-root): Changed to a label.
* lib-complete.el (lib-complete:get-completion-table): Changed to
a label.
* lib-complete.el (read-library-internal): Include labels.
* lib-complete.el (lib-complete:cache-completions): Changed to a
label.
* minibuf.el (read-buffer): Use #'set-difference, don't reinvent it.
* newcomment.el (comment-padright): Use a label instead of
repeating a lambda expression.
* packages.el (package-get-key):
* packages.el (package-get-key-1): Removed, use #'getf instead.
* simple.el (kill-backward-chars): Removed; this isn't used.
* simple.el (what-cursor-position):
(lambda (arg) (format "%S" arg) -> #'prin1-to-string.
* simple.el (debug-print-1): Renamed to #'debug-print.
* simple.el (debug-print): Removed, #'debug-print-1 was equivalent.
* subr.el (integer-to-bit-vector): check-nonnegative-number no
longer available.
* widget.el (define-widget):
* widget.el (define-widget-keywords): Removed, this was long obsolete.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 05 May 2012 18:42:00 +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 } |