Mercurial > hg > xemacs-beta
comparison src/menubar.c @ 2545:9caf26dd924f
[xemacs-hg @ 2005-02-03 05:03:36 by ben]
behavior ws #2: menu-related changes
menubar.c: New fun to compare menu itext as if the two were normalized.
menubar.c: Rename; there are no external callers of this function.
Remove unneeded BUFFER argument. Don't downcase.
(This will be done in compare-menu-text.)
Document that return value may be same string.
easymenu.el, map-ynp.el: Use normalize-menu-text not normalize-menu-item-name.
menubar-items.el, menubar.el: Move to menubar.el and rewrite for cleanliness.
menubar-items.el: Use menu-split-long-menu-and-sort.
menubar-items.el, menubar.el: Move to menubar.el.
menubar.el: New funs.
menubar.el: Split up find-menu-item w/find-menu-item-1, since PARENT is not
an external item.
Rewrite to use compare-menu-text.
menubar.el: Don't normalize items as find-menu-item does not need it.
menubar-items.el: Delete old Behavior menu defn, replaced by behavior-menu-filter.
Planning to [[Delete many menus from Tools menu -- they have been
integrated as part of the behavior system.]] Currently the new
Tools menu (very short, just a call to the behavior-menu-filter)
is commented out, and the old Toold menu defn remains. Once the
new packages are in place (c. 1 or 2 weeks), I'll make the
switchover.
Use menu-split-long-menu-and-sort.
author | ben |
---|---|
date | Thu, 03 Feb 2005 05:03:45 +0000 |
parents | ecf1ebac70d8 |
children | facf3239ba30 |
comparison
equal
deleted
inserted
replaced
2544:b4a8cd0dd8df | 2545:9caf26dd924f |
---|---|
1 /* Implements an elisp-programmable menubar. | 1 /* Implements an elisp-programmable menubar. |
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc. | 2 Copyright (C) 1993, 1994 Free Software Foundation, Inc. |
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp. | 3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp. |
4 Copyright (C) 2001, 2002 Ben Wing. | 4 Copyright (C) 2001, 2002, 2003 Ben Wing. |
5 | 5 |
6 This file is part of XEmacs. | 6 This file is part of XEmacs. |
7 | 7 |
8 XEmacs is free software; you can redistribute it and/or modify it | 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 | 9 under the terms of the GNU General Public License as published by the |
324 struct frame *f = decode_frame (Qnil); | 324 struct frame *f = decode_frame (Qnil); |
325 MAYBE_FRAMEMETH (f, popup_menu, (menu_description, event)); | 325 MAYBE_FRAMEMETH (f, popup_menu, (menu_description, event)); |
326 return Qnil; | 326 return Qnil; |
327 } | 327 } |
328 | 328 |
329 DEFUN ("normalize-menu-item-name", Fnormalize_menu_item_name, 1, 2, 0, /* | 329 DEFUN ("compare-menu-text", Fcompare_menu_text, 2, 2, 0, /* |
330 Compare the text of two menu items, ignoring accelerator specs and case. | |
331 Also treat %% as a single %. Return < 0 if STRING1 is less than STRING2, | |
332 0 if equal, > 0 if STRING1 is greater than STRING2. | |
333 */ | |
334 (string1, string2)) | |
335 { | |
336 Ibyte *p; | |
337 Ibyte *q; | |
338 | |
339 CHECK_STRING (string1); | |
340 CHECK_STRING (string2); | |
341 | |
342 p = XSTRING_DATA (string1); | |
343 q = XSTRING_DATA (string2); | |
344 | |
345 for (;;) | |
346 { | |
347 Ichar val; | |
348 if (*p == '%' && *(p + 1) == '%') | |
349 p++; | |
350 else if (*p == '%' && *(p + 1) == '_') | |
351 p += 2; | |
352 if (*q == '%' && *(q + 1) == '%') | |
353 q++; | |
354 else if (*q == '%' && *(q + 1) == '_') | |
355 q += 2; | |
356 if (!*p || !*q) | |
357 return make_int (*p - *q); | |
358 val = DOWNCASE (0, itext_ichar (p)) - DOWNCASE (0, itext_ichar (q)); | |
359 if (val) | |
360 return make_int (val); | |
361 INC_IBYTEPTR (p); | |
362 INC_IBYTEPTR (q); | |
363 } | |
364 } | |
365 | |
366 DEFUN ("normalize-menu-text", Fnormalize_menu_text, 1, 1, 0, /* | |
330 Convert a menu item name string into normal form, and return the new string. | 367 Convert a menu item name string into normal form, and return the new string. |
331 Menu item names should be converted to normal form before being compared. | 368 Menu item names should be converted to normal form before being compared. |
332 This removes %_'s (accelerator indications) and converts %% to %. | 369 This removes %_'s (accelerator indications) and converts %% to %. |
370 The returned string may be the same string as the original. | |
333 */ | 371 */ |
334 (name, buffer)) | 372 (name)) |
335 { | 373 { |
336 struct buffer *buf = decode_buffer (buffer, 0); | |
337 Charcount end; | 374 Charcount end; |
338 int i; | 375 int i; |
339 Ibyte *name_data; | 376 Ibyte *name_data; |
340 Ibyte *string_result; | 377 Ibyte *string_result; |
341 Ibyte *string_result_ptr; | 378 Ibyte *string_result_ptr; |
350 string_result = alloca_ibytes (end * MAX_ICHAR_LEN); | 387 string_result = alloca_ibytes (end * MAX_ICHAR_LEN); |
351 string_result_ptr = string_result; | 388 string_result_ptr = string_result; |
352 for (i = 0; i < end; i++) | 389 for (i = 0; i < end; i++) |
353 { | 390 { |
354 elt = itext_ichar (name_data); | 391 elt = itext_ichar (name_data); |
355 elt = DOWNCASE (buf, elt); | |
356 if (expecting_underscore) | 392 if (expecting_underscore) |
357 { | 393 { |
358 expecting_underscore = 0; | 394 expecting_underscore = 0; |
359 switch (elt) | 395 switch (elt) |
360 { | 396 { |
398 DEFSYMBOL (Qmenu_right); | 434 DEFSYMBOL (Qmenu_right); |
399 DEFSYMBOL (Qmenu_select); | 435 DEFSYMBOL (Qmenu_select); |
400 DEFSYMBOL (Qmenu_escape); | 436 DEFSYMBOL (Qmenu_escape); |
401 | 437 |
402 DEFSUBR (Fpopup_menu); | 438 DEFSUBR (Fpopup_menu); |
403 DEFSUBR (Fnormalize_menu_item_name); | 439 DEFSUBR (Fcompare_menu_text); |
440 DEFSUBR (Fnormalize_menu_text); | |
404 DEFSUBR (Fmenu_find_real_submenu); | 441 DEFSUBR (Fmenu_find_real_submenu); |
405 } | 442 } |
406 | 443 |
407 void | 444 void |
408 vars_of_menubar (void) | 445 vars_of_menubar (void) |