diff options
| author | Eli Zaretskii | 2013-09-05 11:01:04 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-09-05 11:01:04 +0300 |
| commit | 41306318777a942420bc4feadbfacf662ea179dc (patch) | |
| tree | 669e5cca02f95d6064ce73c0d3fbbf91b8c8b563 /src/menu.c | |
| parent | 141f1ff7a40cda10f0558e891dd196a943a5082e (diff) | |
| parent | 257b3b03cb1cff917e0b3b7832ad3eab5b59f257 (diff) | |
| download | emacs-41306318777a942420bc4feadbfacf662ea179dc.tar.gz emacs-41306318777a942420bc4feadbfacf662ea179dc.zip | |
Merge from trunk after a lot of time.
Diffstat (limited to 'src/menu.c')
| -rw-r--r-- | src/menu.c | 207 |
1 files changed, 99 insertions, 108 deletions
diff --git a/src/menu.c b/src/menu.c index 7a7db9f07ff..2b199ffdf09 100644 --- a/src/menu.c +++ b/src/menu.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* Platform-independent code for terminal communications. | 1 | /* Platform-independent code for terminal communications. |
| 2 | 2 | ||
| 3 | Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2012 | 3 | Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2013 Free Software |
| 4 | Free Software Foundation, Inc. | 4 | Foundation, Inc. |
| 5 | 5 | ||
| 6 | This file is part of GNU Emacs. | 6 | This file is part of GNU Emacs. |
| 7 | 7 | ||
| @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 20 | 20 | ||
| 21 | #include <config.h> | 21 | #include <config.h> |
| 22 | #include <stdio.h> | 22 | #include <stdio.h> |
| 23 | #include <setjmp.h> | ||
| 24 | #include <limits.h> /* for INT_MAX */ | 23 | #include <limits.h> /* for INT_MAX */ |
| 25 | 24 | ||
| 26 | #include "lisp.h" | 25 | #include "lisp.h" |
| @@ -36,24 +35,17 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 36 | #include "../lwlib/lwlib.h" | 35 | #include "../lwlib/lwlib.h" |
| 37 | #endif | 36 | #endif |
| 38 | 37 | ||
| 39 | #ifdef HAVE_X_WINDOWS | 38 | #ifdef HAVE_WINDOW_SYSTEM |
| 40 | #include "xterm.h" | 39 | #include TERM_HEADER |
| 41 | #endif | 40 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 42 | |||
| 43 | #ifdef HAVE_NS | ||
| 44 | #include "nsterm.h" | ||
| 45 | #endif | ||
| 46 | |||
| 47 | #ifdef USE_GTK | ||
| 48 | #include "gtkutil.h" | ||
| 49 | #endif | ||
| 50 | 41 | ||
| 51 | #ifdef HAVE_NTGUI | 42 | #ifdef HAVE_NTGUI |
| 52 | #include "w32term.h" | 43 | # ifdef NTGUI_UNICODE |
| 53 | 44 | # define unicode_append_menu AppendMenuW | |
| 45 | # else /* !NTGUI_UNICODE */ | ||
| 54 | extern AppendMenuW_Proc unicode_append_menu; | 46 | extern AppendMenuW_Proc unicode_append_menu; |
| 47 | # endif /* NTGUI_UNICODE */ | ||
| 55 | extern HMENU current_popup_menu; | 48 | extern HMENU current_popup_menu; |
| 56 | |||
| 57 | #endif /* HAVE_NTGUI */ | 49 | #endif /* HAVE_NTGUI */ |
| 58 | 50 | ||
| 59 | #include "menu.h" | 51 | #include "menu.h" |
| @@ -110,10 +102,10 @@ finish_menu_items (void) | |||
| 110 | { | 102 | { |
| 111 | } | 103 | } |
| 112 | 104 | ||
| 113 | Lisp_Object | 105 | void |
| 114 | unuse_menu_items (Lisp_Object dummy) | 106 | unuse_menu_items (void) |
| 115 | { | 107 | { |
| 116 | return menu_items_inuse = Qnil; | 108 | menu_items_inuse = Qnil; |
| 117 | } | 109 | } |
| 118 | 110 | ||
| 119 | /* Call when finished using the data for the current menu | 111 | /* Call when finished using the data for the current menu |
| @@ -129,22 +121,13 @@ discard_menu_items (void) | |||
| 129 | menu_items = Qnil; | 121 | menu_items = Qnil; |
| 130 | menu_items_allocated = 0; | 122 | menu_items_allocated = 0; |
| 131 | } | 123 | } |
| 132 | xassert (NILP (menu_items_inuse)); | 124 | eassert (NILP (menu_items_inuse)); |
| 133 | } | 125 | } |
| 134 | 126 | ||
| 135 | #ifdef HAVE_NS | ||
| 136 | static Lisp_Object | ||
| 137 | cleanup_popup_menu (Lisp_Object arg) | ||
| 138 | { | ||
| 139 | discard_menu_items (); | ||
| 140 | return Qnil; | ||
| 141 | } | ||
| 142 | #endif | ||
| 143 | |||
| 144 | /* This undoes save_menu_items, and it is called by the specpdl unwind | 127 | /* This undoes save_menu_items, and it is called by the specpdl unwind |
| 145 | mechanism. */ | 128 | mechanism. */ |
| 146 | 129 | ||
| 147 | static Lisp_Object | 130 | static void |
| 148 | restore_menu_items (Lisp_Object saved) | 131 | restore_menu_items (Lisp_Object saved) |
| 149 | { | 132 | { |
| 150 | menu_items = XCAR (saved); | 133 | menu_items = XCAR (saved); |
| @@ -156,7 +139,6 @@ restore_menu_items (Lisp_Object saved) | |||
| 156 | menu_items_n_panes = XINT (XCAR (saved)); | 139 | menu_items_n_panes = XINT (XCAR (saved)); |
| 157 | saved = XCDR (saved); | 140 | saved = XCDR (saved); |
| 158 | menu_items_submenu_depth = XINT (XCAR (saved)); | 141 | menu_items_submenu_depth = XINT (XCAR (saved)); |
| 159 | return Qnil; | ||
| 160 | } | 142 | } |
| 161 | 143 | ||
| 162 | /* Push the whole state of menu_items processing onto the specpdl. | 144 | /* Push the whole state of menu_items processing onto the specpdl. |
| @@ -181,7 +163,7 @@ static void | |||
| 181 | ensure_menu_items (int items) | 163 | ensure_menu_items (int items) |
| 182 | { | 164 | { |
| 183 | int incr = items - (menu_items_allocated - menu_items_used); | 165 | int incr = items - (menu_items_allocated - menu_items_used); |
| 184 | if (0 < incr) | 166 | if (incr > 0) |
| 185 | { | 167 | { |
| 186 | menu_items = larger_vector (menu_items, incr, INT_MAX); | 168 | menu_items = larger_vector (menu_items, incr, INT_MAX); |
| 187 | menu_items_allocated = ASIZE (menu_items); | 169 | menu_items_allocated = ASIZE (menu_items); |
| @@ -197,7 +179,8 @@ static void | |||
| 197 | push_submenu_start (void) | 179 | push_submenu_start (void) |
| 198 | { | 180 | { |
| 199 | ensure_menu_items (1); | 181 | ensure_menu_items (1); |
| 200 | XVECTOR (menu_items)->contents[menu_items_used++] = Qnil; | 182 | ASET (menu_items, menu_items_used, Qnil); |
| 183 | menu_items_used++; | ||
| 201 | menu_items_submenu_depth++; | 184 | menu_items_submenu_depth++; |
| 202 | } | 185 | } |
| 203 | 186 | ||
| @@ -207,7 +190,8 @@ static void | |||
| 207 | push_submenu_end (void) | 190 | push_submenu_end (void) |
| 208 | { | 191 | { |
| 209 | ensure_menu_items (1); | 192 | ensure_menu_items (1); |
| 210 | XVECTOR (menu_items)->contents[menu_items_used++] = Qlambda; | 193 | ASET (menu_items, menu_items_used, Qlambda); |
| 194 | menu_items_used++; | ||
| 211 | menu_items_submenu_depth--; | 195 | menu_items_submenu_depth--; |
| 212 | } | 196 | } |
| 213 | 197 | ||
| @@ -219,7 +203,8 @@ static void | |||
| 219 | push_left_right_boundary (void) | 203 | push_left_right_boundary (void) |
| 220 | { | 204 | { |
| 221 | ensure_menu_items (1); | 205 | ensure_menu_items (1); |
| 222 | XVECTOR (menu_items)->contents[menu_items_used++] = Qquote; | 206 | ASET (menu_items, menu_items_used, Qquote); |
| 207 | menu_items_used++; | ||
| 223 | } | 208 | } |
| 224 | 209 | ||
| 225 | /* Start a new menu pane in menu_items. | 210 | /* Start a new menu pane in menu_items. |
| @@ -231,9 +216,12 @@ push_menu_pane (Lisp_Object name, Lisp_Object prefix_vec) | |||
| 231 | ensure_menu_items (MENU_ITEMS_PANE_LENGTH); | 216 | ensure_menu_items (MENU_ITEMS_PANE_LENGTH); |
| 232 | if (menu_items_submenu_depth == 0) | 217 | if (menu_items_submenu_depth == 0) |
| 233 | menu_items_n_panes++; | 218 | menu_items_n_panes++; |
| 234 | XVECTOR (menu_items)->contents[menu_items_used++] = Qt; | 219 | ASET (menu_items, menu_items_used, Qt); |
| 235 | XVECTOR (menu_items)->contents[menu_items_used++] = name; | 220 | menu_items_used++; |
| 236 | XVECTOR (menu_items)->contents[menu_items_used++] = prefix_vec; | 221 | ASET (menu_items, menu_items_used, name); |
| 222 | menu_items_used++; | ||
| 223 | ASET (menu_items, menu_items_used, prefix_vec); | ||
| 224 | menu_items_used++; | ||
| 237 | } | 225 | } |
| 238 | 226 | ||
| 239 | /* Push one menu item into the current pane. NAME is the string to | 227 | /* Push one menu item into the current pane. NAME is the string to |
| @@ -333,7 +321,7 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk | |||
| 333 | { | 321 | { |
| 334 | Lisp_Object map, item_string, enabled; | 322 | Lisp_Object map, item_string, enabled; |
| 335 | struct gcpro gcpro1, gcpro2; | 323 | struct gcpro gcpro1, gcpro2; |
| 336 | int res; | 324 | bool res; |
| 337 | struct skp *skp = skp_v; | 325 | struct skp *skp = skp_v; |
| 338 | 326 | ||
| 339 | /* Parse the menu item and leave the result in item_properties. */ | 327 | /* Parse the menu item and leave the result in item_properties. */ |
| @@ -343,10 +331,10 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk | |||
| 343 | if (!res) | 331 | if (!res) |
| 344 | return; /* Not a menu item. */ | 332 | return; /* Not a menu item. */ |
| 345 | 333 | ||
| 346 | map = XVECTOR (item_properties)->contents[ITEM_PROPERTY_MAP]; | 334 | map = AREF (item_properties, ITEM_PROPERTY_MAP); |
| 347 | 335 | ||
| 348 | enabled = XVECTOR (item_properties)->contents[ITEM_PROPERTY_ENABLE]; | 336 | enabled = AREF (item_properties, ITEM_PROPERTY_ENABLE); |
| 349 | item_string = XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME]; | 337 | item_string = AREF (item_properties, ITEM_PROPERTY_NAME); |
| 350 | 338 | ||
| 351 | if (!NILP (map) && SREF (item_string, 0) == '@') | 339 | if (!NILP (map) && SREF (item_string, 0) == '@') |
| 352 | { | 340 | { |
| @@ -363,11 +351,11 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk | |||
| 363 | front of them. */ | 351 | front of them. */ |
| 364 | { | 352 | { |
| 365 | Lisp_Object prefix = Qnil; | 353 | Lisp_Object prefix = Qnil; |
| 366 | Lisp_Object type = XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE]; | 354 | Lisp_Object type = AREF (item_properties, ITEM_PROPERTY_TYPE); |
| 367 | if (!NILP (type)) | 355 | if (!NILP (type)) |
| 368 | { | 356 | { |
| 369 | Lisp_Object selected | 357 | Lisp_Object selected |
| 370 | = XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED]; | 358 | = AREF (item_properties, ITEM_PROPERTY_SELECTED); |
| 371 | 359 | ||
| 372 | if (skp->notbuttons) | 360 | if (skp->notbuttons) |
| 373 | /* The first button. Line up previous items in this menu. */ | 361 | /* The first button. Line up previous items in this menu. */ |
| @@ -378,7 +366,7 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk | |||
| 378 | while (idx < menu_items_used) | 366 | while (idx < menu_items_used) |
| 379 | { | 367 | { |
| 380 | tem | 368 | tem |
| 381 | = XVECTOR (menu_items)->contents[idx + MENU_ITEMS_ITEM_NAME]; | 369 | = AREF (menu_items, idx + MENU_ITEMS_ITEM_NAME); |
| 382 | if (NILP (tem)) | 370 | if (NILP (tem)) |
| 383 | { | 371 | { |
| 384 | idx++; | 372 | idx++; |
| @@ -397,8 +385,8 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk | |||
| 397 | { | 385 | { |
| 398 | if (!submenu && SREF (tem, 0) != '\0' | 386 | if (!submenu && SREF (tem, 0) != '\0' |
| 399 | && SREF (tem, 0) != '-') | 387 | && SREF (tem, 0) != '-') |
| 400 | XVECTOR (menu_items)->contents[idx + MENU_ITEMS_ITEM_NAME] | 388 | ASET (menu_items, idx + MENU_ITEMS_ITEM_NAME, |
| 401 | = concat2 (build_string (" "), tem); | 389 | concat2 (build_string (" "), tem)); |
| 402 | idx += MENU_ITEMS_ITEM_LENGTH; | 390 | idx += MENU_ITEMS_ITEM_LENGTH; |
| 403 | } | 391 | } |
| 404 | } | 392 | } |
| @@ -430,11 +418,11 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk | |||
| 430 | #endif /* HAVE_X_WINDOWS || MSDOS */ | 418 | #endif /* HAVE_X_WINDOWS || MSDOS */ |
| 431 | 419 | ||
| 432 | push_menu_item (item_string, enabled, key, | 420 | push_menu_item (item_string, enabled, key, |
| 433 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF], | 421 | AREF (item_properties, ITEM_PROPERTY_DEF), |
| 434 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ], | 422 | AREF (item_properties, ITEM_PROPERTY_KEYEQ), |
| 435 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE], | 423 | AREF (item_properties, ITEM_PROPERTY_TYPE), |
| 436 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED], | 424 | AREF (item_properties, ITEM_PROPERTY_SELECTED), |
| 437 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]); | 425 | AREF (item_properties, ITEM_PROPERTY_HELP)); |
| 438 | 426 | ||
| 439 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || defined (HAVE_NTGUI) | 427 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || defined (HAVE_NTGUI) |
| 440 | /* Display a submenu using the toolkit. */ | 428 | /* Display a submenu using the toolkit. */ |
| @@ -521,14 +509,15 @@ list_of_panes (Lisp_Object menu) | |||
| 521 | /* Set up data in menu_items for a menu bar item | 509 | /* Set up data in menu_items for a menu bar item |
| 522 | whose event type is ITEM_KEY (with string ITEM_NAME) | 510 | whose event type is ITEM_KEY (with string ITEM_NAME) |
| 523 | and whose contents come from the list of keymaps MAPS. */ | 511 | and whose contents come from the list of keymaps MAPS. */ |
| 524 | int | 512 | bool |
| 525 | parse_single_submenu (Lisp_Object item_key, Lisp_Object item_name, Lisp_Object maps) | 513 | parse_single_submenu (Lisp_Object item_key, Lisp_Object item_name, |
| 514 | Lisp_Object maps) | ||
| 526 | { | 515 | { |
| 527 | Lisp_Object length; | 516 | Lisp_Object length; |
| 528 | EMACS_INT len; | 517 | EMACS_INT len; |
| 529 | Lisp_Object *mapvec; | 518 | Lisp_Object *mapvec; |
| 530 | ptrdiff_t i; | 519 | ptrdiff_t i; |
| 531 | int top_level_items = 0; | 520 | bool top_level_items = 0; |
| 532 | USE_SAFE_ALLOCA; | 521 | USE_SAFE_ALLOCA; |
| 533 | 522 | ||
| 534 | length = Flength (maps); | 523 | length = Flength (maps); |
| @@ -579,9 +568,9 @@ xmalloc_widget_value (void) | |||
| 579 | { | 568 | { |
| 580 | widget_value *value; | 569 | widget_value *value; |
| 581 | 570 | ||
| 582 | BLOCK_INPUT; | 571 | block_input (); |
| 583 | value = malloc_widget_value (); | 572 | value = malloc_widget_value (); |
| 584 | UNBLOCK_INPUT; | 573 | unblock_input (); |
| 585 | 574 | ||
| 586 | return value; | 575 | return value; |
| 587 | } | 576 | } |
| @@ -608,9 +597,9 @@ free_menubar_widget_value_tree (widget_value *wv) | |||
| 608 | free_menubar_widget_value_tree (wv->next); | 597 | free_menubar_widget_value_tree (wv->next); |
| 609 | wv->next = (widget_value *) 0xDEADBEEF; | 598 | wv->next = (widget_value *) 0xDEADBEEF; |
| 610 | } | 599 | } |
| 611 | BLOCK_INPUT; | 600 | block_input (); |
| 612 | free_widget_value (wv); | 601 | free_widget_value (wv); |
| 613 | UNBLOCK_INPUT; | 602 | unblock_input (); |
| 614 | } | 603 | } |
| 615 | 604 | ||
| 616 | /* Create a tree of widget_value objects | 605 | /* Create a tree of widget_value objects |
| @@ -618,16 +607,15 @@ free_menubar_widget_value_tree (widget_value *wv) | |||
| 618 | in menu_items starting at index START, up to index END. */ | 607 | in menu_items starting at index START, up to index END. */ |
| 619 | 608 | ||
| 620 | widget_value * | 609 | widget_value * |
| 621 | digest_single_submenu (int start, int end, int top_level_items) | 610 | digest_single_submenu (int start, int end, bool top_level_items) |
| 622 | { | 611 | { |
| 623 | widget_value *wv, *prev_wv, *save_wv, *first_wv; | 612 | widget_value *wv, *prev_wv, *save_wv, *first_wv; |
| 624 | int i; | 613 | int i; |
| 625 | int submenu_depth = 0; | 614 | int submenu_depth = 0; |
| 626 | widget_value **submenu_stack; | 615 | widget_value **submenu_stack; |
| 627 | int panes_seen = 0; | 616 | bool panes_seen = 0; |
| 628 | 617 | ||
| 629 | submenu_stack | 618 | submenu_stack = alloca (menu_items_used * sizeof *submenu_stack); |
| 630 | = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); | ||
| 631 | wv = xmalloc_widget_value (); | 619 | wv = xmalloc_widget_value (); |
| 632 | wv->name = "menu"; | 620 | wv->name = "menu"; |
| 633 | wv->value = 0; | 621 | wv->value = 0; |
| @@ -645,35 +633,35 @@ digest_single_submenu (int start, int end, int top_level_items) | |||
| 645 | i = start; | 633 | i = start; |
| 646 | while (i < end) | 634 | while (i < end) |
| 647 | { | 635 | { |
| 648 | if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) | 636 | if (EQ (AREF (menu_items, i), Qnil)) |
| 649 | { | 637 | { |
| 650 | submenu_stack[submenu_depth++] = save_wv; | 638 | submenu_stack[submenu_depth++] = save_wv; |
| 651 | save_wv = prev_wv; | 639 | save_wv = prev_wv; |
| 652 | prev_wv = 0; | 640 | prev_wv = 0; |
| 653 | i++; | 641 | i++; |
| 654 | } | 642 | } |
| 655 | else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) | 643 | else if (EQ (AREF (menu_items, i), Qlambda)) |
| 656 | { | 644 | { |
| 657 | prev_wv = save_wv; | 645 | prev_wv = save_wv; |
| 658 | save_wv = submenu_stack[--submenu_depth]; | 646 | save_wv = submenu_stack[--submenu_depth]; |
| 659 | i++; | 647 | i++; |
| 660 | } | 648 | } |
| 661 | else if (EQ (XVECTOR (menu_items)->contents[i], Qt) | 649 | else if (EQ (AREF (menu_items, i), Qt) |
| 662 | && submenu_depth != 0) | 650 | && submenu_depth != 0) |
| 663 | i += MENU_ITEMS_PANE_LENGTH; | 651 | i += MENU_ITEMS_PANE_LENGTH; |
| 664 | /* Ignore a nil in the item list. | 652 | /* Ignore a nil in the item list. |
| 665 | It's meaningful only for dialog boxes. */ | 653 | It's meaningful only for dialog boxes. */ |
| 666 | else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) | 654 | else if (EQ (AREF (menu_items, i), Qquote)) |
| 667 | i += 1; | 655 | i += 1; |
| 668 | else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) | 656 | else if (EQ (AREF (menu_items, i), Qt)) |
| 669 | { | 657 | { |
| 670 | /* Create a new pane. */ | 658 | /* Create a new pane. */ |
| 671 | Lisp_Object pane_name; | 659 | Lisp_Object pane_name; |
| 672 | const char *pane_string; | 660 | const char *pane_string; |
| 673 | 661 | ||
| 674 | panes_seen++; | 662 | panes_seen = 1; |
| 675 | 663 | ||
| 676 | pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; | 664 | pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); |
| 677 | 665 | ||
| 678 | #ifdef HAVE_NTGUI | 666 | #ifdef HAVE_NTGUI |
| 679 | if (STRINGP (pane_name)) | 667 | if (STRINGP (pane_name)) |
| @@ -738,8 +726,8 @@ digest_single_submenu (int start, int end, int top_level_items) | |||
| 738 | Lisp_Object help; | 726 | Lisp_Object help; |
| 739 | 727 | ||
| 740 | /* All items should be contained in panes. */ | 728 | /* All items should be contained in panes. */ |
| 741 | if (panes_seen == 0) | 729 | if (! panes_seen) |
| 742 | abort (); | 730 | emacs_abort (); |
| 743 | 731 | ||
| 744 | item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); | 732 | item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); |
| 745 | enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE); | 733 | enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE); |
| @@ -813,7 +801,7 @@ digest_single_submenu (int start, int end, int top_level_items) | |||
| 813 | else if (EQ (type, QCtoggle)) | 801 | else if (EQ (type, QCtoggle)) |
| 814 | wv->button_type = BUTTON_TYPE_TOGGLE; | 802 | wv->button_type = BUTTON_TYPE_TOGGLE; |
| 815 | else | 803 | else |
| 816 | abort (); | 804 | emacs_abort (); |
| 817 | 805 | ||
| 818 | wv->selected = !NILP (selected); | 806 | wv->selected = !NILP (selected); |
| 819 | if (! STRINGP (help)) | 807 | if (! STRINGP (help)) |
| @@ -879,7 +867,8 @@ update_submenu_strings (widget_value *first_wv) | |||
| 879 | VECTOR is an array of menu events for the whole menu. */ | 867 | VECTOR is an array of menu events for the whole menu. */ |
| 880 | 868 | ||
| 881 | void | 869 | void |
| 882 | find_and_call_menu_selection (FRAME_PTR f, int menu_bar_items_used, Lisp_Object vector, void *client_data) | 870 | find_and_call_menu_selection (struct frame *f, int menu_bar_items_used, |
| 871 | Lisp_Object vector, void *client_data) | ||
| 883 | { | 872 | { |
| 884 | Lisp_Object prefix, entry; | 873 | Lisp_Object prefix, entry; |
| 885 | Lisp_Object *subprefix_stack; | 874 | Lisp_Object *subprefix_stack; |
| @@ -887,31 +876,31 @@ find_and_call_menu_selection (FRAME_PTR f, int menu_bar_items_used, Lisp_Object | |||
| 887 | int i; | 876 | int i; |
| 888 | 877 | ||
| 889 | entry = Qnil; | 878 | entry = Qnil; |
| 890 | subprefix_stack = (Lisp_Object *) alloca (menu_bar_items_used * sizeof (Lisp_Object)); | 879 | subprefix_stack = alloca (menu_bar_items_used * sizeof *subprefix_stack); |
| 891 | prefix = Qnil; | 880 | prefix = Qnil; |
| 892 | i = 0; | 881 | i = 0; |
| 893 | 882 | ||
| 894 | while (i < menu_bar_items_used) | 883 | while (i < menu_bar_items_used) |
| 895 | { | 884 | { |
| 896 | if (EQ (XVECTOR (vector)->contents[i], Qnil)) | 885 | if (EQ (AREF (vector, i), Qnil)) |
| 897 | { | 886 | { |
| 898 | subprefix_stack[submenu_depth++] = prefix; | 887 | subprefix_stack[submenu_depth++] = prefix; |
| 899 | prefix = entry; | 888 | prefix = entry; |
| 900 | i++; | 889 | i++; |
| 901 | } | 890 | } |
| 902 | else if (EQ (XVECTOR (vector)->contents[i], Qlambda)) | 891 | else if (EQ (AREF (vector, i), Qlambda)) |
| 903 | { | 892 | { |
| 904 | prefix = subprefix_stack[--submenu_depth]; | 893 | prefix = subprefix_stack[--submenu_depth]; |
| 905 | i++; | 894 | i++; |
| 906 | } | 895 | } |
| 907 | else if (EQ (XVECTOR (vector)->contents[i], Qt)) | 896 | else if (EQ (AREF (vector, i), Qt)) |
| 908 | { | 897 | { |
| 909 | prefix = XVECTOR (vector)->contents[i + MENU_ITEMS_PANE_PREFIX]; | 898 | prefix = AREF (vector, i + MENU_ITEMS_PANE_PREFIX); |
| 910 | i += MENU_ITEMS_PANE_LENGTH; | 899 | i += MENU_ITEMS_PANE_LENGTH; |
| 911 | } | 900 | } |
| 912 | else | 901 | else |
| 913 | { | 902 | { |
| 914 | entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE]; | 903 | entry = AREF (vector, i + MENU_ITEMS_ITEM_VALUE); |
| 915 | /* Treat the pointer as an integer. There's no problem | 904 | /* Treat the pointer as an integer. There's no problem |
| 916 | as long as pointers have enough bits to hold small integers. */ | 905 | as long as pointers have enough bits to hold small integers. */ |
| 917 | if ((intptr_t) client_data == i) | 906 | if ((intptr_t) client_data == i) |
| @@ -960,9 +949,9 @@ find_and_call_menu_selection (FRAME_PTR f, int menu_bar_items_used, Lisp_Object | |||
| 960 | 949 | ||
| 961 | #ifdef HAVE_NS | 950 | #ifdef HAVE_NS |
| 962 | /* As above, but return the menu selection instead of storing in kb buffer. | 951 | /* As above, but return the menu selection instead of storing in kb buffer. |
| 963 | If keymaps==1, return full prefixes to selection. */ | 952 | If KEYMAPS, return full prefixes to selection. */ |
| 964 | Lisp_Object | 953 | Lisp_Object |
| 965 | find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data) | 954 | find_and_return_menu_selection (struct frame *f, bool keymaps, void *client_data) |
| 966 | { | 955 | { |
| 967 | Lisp_Object prefix, entry; | 956 | Lisp_Object prefix, entry; |
| 968 | int i; | 957 | int i; |
| @@ -971,43 +960,42 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data) | |||
| 971 | 960 | ||
| 972 | prefix = entry = Qnil; | 961 | prefix = entry = Qnil; |
| 973 | i = 0; | 962 | i = 0; |
| 974 | subprefix_stack = | 963 | subprefix_stack = alloca (menu_items_used * word_size); |
| 975 | (Lisp_Object *)alloca (menu_items_used * sizeof (Lisp_Object)); | ||
| 976 | 964 | ||
| 977 | while (i < menu_items_used) | 965 | while (i < menu_items_used) |
| 978 | { | 966 | { |
| 979 | if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) | 967 | if (EQ (AREF (menu_items, i), Qnil)) |
| 980 | { | 968 | { |
| 981 | subprefix_stack[submenu_depth++] = prefix; | 969 | subprefix_stack[submenu_depth++] = prefix; |
| 982 | prefix = entry; | 970 | prefix = entry; |
| 983 | i++; | 971 | i++; |
| 984 | } | 972 | } |
| 985 | else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) | 973 | else if (EQ (AREF (menu_items, i), Qlambda)) |
| 986 | { | 974 | { |
| 987 | prefix = subprefix_stack[--submenu_depth]; | 975 | prefix = subprefix_stack[--submenu_depth]; |
| 988 | i++; | 976 | i++; |
| 989 | } | 977 | } |
| 990 | else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) | 978 | else if (EQ (AREF (menu_items, i), Qt)) |
| 991 | { | 979 | { |
| 992 | prefix | 980 | prefix |
| 993 | = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; | 981 | = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); |
| 994 | i += MENU_ITEMS_PANE_LENGTH; | 982 | i += MENU_ITEMS_PANE_LENGTH; |
| 995 | } | 983 | } |
| 996 | /* Ignore a nil in the item list. | 984 | /* Ignore a nil in the item list. |
| 997 | It's meaningful only for dialog boxes. */ | 985 | It's meaningful only for dialog boxes. */ |
| 998 | else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) | 986 | else if (EQ (AREF (menu_items, i), Qquote)) |
| 999 | i += 1; | 987 | i += 1; |
| 1000 | else | 988 | else |
| 1001 | { | 989 | { |
| 1002 | entry | 990 | entry |
| 1003 | = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; | 991 | = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE); |
| 1004 | if (&XVECTOR (menu_items)->contents[i] == client_data) | 992 | if (aref_addr (menu_items, i) == client_data) |
| 1005 | { | 993 | { |
| 1006 | if (keymaps != 0) | 994 | if (keymaps) |
| 1007 | { | 995 | { |
| 1008 | int j; | 996 | int j; |
| 1009 | 997 | ||
| 1010 | entry = Fcons (entry, Qnil); | 998 | entry = list1 (entry); |
| 1011 | if (!NILP (prefix)) | 999 | if (!NILP (prefix)) |
| 1012 | entry = Fcons (prefix, entry); | 1000 | entry = Fcons (prefix, entry); |
| 1013 | for (j = submenu_depth - 1; j >= 0; j--) | 1001 | for (j = submenu_depth - 1; j >= 0; j--) |
| @@ -1073,10 +1061,10 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1073 | Lisp_Object title; | 1061 | Lisp_Object title; |
| 1074 | const char *error_name = NULL; | 1062 | const char *error_name = NULL; |
| 1075 | Lisp_Object selection = Qnil; | 1063 | Lisp_Object selection = Qnil; |
| 1076 | FRAME_PTR f = NULL; | 1064 | struct frame *f = NULL; |
| 1077 | Lisp_Object x, y, window; | 1065 | Lisp_Object x, y, window; |
| 1078 | int keymaps = 0; | 1066 | bool keymaps = 0; |
| 1079 | int for_click = 0; | 1067 | bool for_click = 0; |
| 1080 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); | 1068 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); |
| 1081 | struct gcpro gcpro1; | 1069 | struct gcpro gcpro1; |
| 1082 | 1070 | ||
| @@ -1087,8 +1075,9 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1087 | 1075 | ||
| 1088 | #ifdef HAVE_MENUS | 1076 | #ifdef HAVE_MENUS |
| 1089 | { | 1077 | { |
| 1090 | int get_current_pos_p = 0; | 1078 | bool get_current_pos_p = 0; |
| 1091 | /* FIXME!! check_w32 (); or check_x (); or check_ns (); */ | 1079 | |
| 1080 | check_window_system (SELECTED_FRAME ()); | ||
| 1092 | 1081 | ||
| 1093 | /* Decode the first argument: find the window and the coordinates. */ | 1082 | /* Decode the first argument: find the window and the coordinates. */ |
| 1094 | if (EQ (position, Qt) | 1083 | if (EQ (position, Qt) |
| @@ -1128,7 +1117,7 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1128 | if (get_current_pos_p) | 1117 | if (get_current_pos_p) |
| 1129 | { | 1118 | { |
| 1130 | /* Use the mouse's current position. */ | 1119 | /* Use the mouse's current position. */ |
| 1131 | FRAME_PTR new_f = SELECTED_FRAME (); | 1120 | struct frame *new_f = SELECTED_FRAME (); |
| 1132 | #ifdef HAVE_X_WINDOWS | 1121 | #ifdef HAVE_X_WINDOWS |
| 1133 | /* Can't use mouse_position_hook for X since it returns | 1122 | /* Can't use mouse_position_hook for X since it returns |
| 1134 | coordinates relative to the window the mouse is in, | 1123 | coordinates relative to the window the mouse is in, |
| @@ -1192,14 +1181,16 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1192 | but I don't want to make one now. */ | 1181 | but I don't want to make one now. */ |
| 1193 | CHECK_WINDOW (window); | 1182 | CHECK_WINDOW (window); |
| 1194 | 1183 | ||
| 1195 | CHECK_RANGED_INTEGER ((xpos < INT_MIN - MOST_NEGATIVE_FIXNUM | 1184 | CHECK_RANGED_INTEGER (x, |
| 1185 | (xpos < INT_MIN - MOST_NEGATIVE_FIXNUM | ||
| 1196 | ? (EMACS_INT) INT_MIN - xpos | 1186 | ? (EMACS_INT) INT_MIN - xpos |
| 1197 | : MOST_NEGATIVE_FIXNUM), | 1187 | : MOST_NEGATIVE_FIXNUM), |
| 1198 | x, INT_MAX - xpos); | 1188 | INT_MAX - xpos); |
| 1199 | CHECK_RANGED_INTEGER ((ypos < INT_MIN - MOST_NEGATIVE_FIXNUM | 1189 | CHECK_RANGED_INTEGER (y, |
| 1190 | (ypos < INT_MIN - MOST_NEGATIVE_FIXNUM | ||
| 1200 | ? (EMACS_INT) INT_MIN - ypos | 1191 | ? (EMACS_INT) INT_MIN - ypos |
| 1201 | : MOST_NEGATIVE_FIXNUM), | 1192 | : MOST_NEGATIVE_FIXNUM), |
| 1202 | y, INT_MAX - ypos); | 1193 | INT_MAX - ypos); |
| 1203 | xpos += XINT (x); | 1194 | xpos += XINT (x); |
| 1204 | ypos += XINT (y); | 1195 | ypos += XINT (y); |
| 1205 | 1196 | ||
| @@ -1213,7 +1204,7 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1213 | #endif /* HAVE_MENUS */ | 1204 | #endif /* HAVE_MENUS */ |
| 1214 | 1205 | ||
| 1215 | /* Now parse the lisp menus. */ | 1206 | /* Now parse the lisp menus. */ |
| 1216 | record_unwind_protect (unuse_menu_items, Qnil); | 1207 | record_unwind_protect_void (unuse_menu_items); |
| 1217 | 1208 | ||
| 1218 | title = Qnil; | 1209 | title = Qnil; |
| 1219 | GCPRO1 (title); | 1210 | GCPRO1 (title); |
| @@ -1315,11 +1306,11 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1315 | #endif | 1306 | #endif |
| 1316 | 1307 | ||
| 1317 | #ifdef HAVE_NS /* FIXME: ns-specific, why? --Stef */ | 1308 | #ifdef HAVE_NS /* FIXME: ns-specific, why? --Stef */ |
| 1318 | record_unwind_protect (cleanup_popup_menu, Qnil); | 1309 | record_unwind_protect_void (discard_menu_items); |
| 1319 | #endif | 1310 | #endif |
| 1320 | 1311 | ||
| 1321 | /* Display them in a menu. */ | 1312 | /* Display them in a menu. */ |
| 1322 | BLOCK_INPUT; | 1313 | block_input (); |
| 1323 | 1314 | ||
| 1324 | /* FIXME: Use a terminal hook! */ | 1315 | /* FIXME: Use a terminal hook! */ |
| 1325 | #if defined HAVE_NTGUI | 1316 | #if defined HAVE_NTGUI |
| @@ -1349,7 +1340,7 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1349 | selection = tty_menu_show (f, xpos, ypos, for_click, | 1340 | selection = tty_menu_show (f, xpos, ypos, for_click, |
| 1350 | keymaps, title, &error_name); | 1341 | keymaps, title, &error_name); |
| 1351 | 1342 | ||
| 1352 | UNBLOCK_INPUT; | 1343 | unblock_input (); |
| 1353 | 1344 | ||
| 1354 | #ifdef HAVE_NS | 1345 | #ifdef HAVE_NS |
| 1355 | unbind_to (specpdl_count, Qnil); | 1346 | unbind_to (specpdl_count, Qnil); |