comparison src/xmenu.c @ 16752:6409ef81a2a8

(single_keymap_panes): New arg DEPTH. Cut off recursion at that depth. Callers changed.
author Richard M. Stallman <rms@gnu.org>
date Thu, 26 Dec 1996 21:06:19 +0000
parents d5e92ecd4595
children 573189779804
comparison
equal deleted inserted replaced
16751:d393cbcfb69c 16752:6409ef81a2a8
502 502
503 /* Loop over the given keymaps, making a pane for each map. 503 /* Loop over the given keymaps, making a pane for each map.
504 But don't make a pane that is empty--ignore that map instead. 504 But don't make a pane that is empty--ignore that map instead.
505 P is the number of panes we have made so far. */ 505 P is the number of panes we have made so far. */
506 for (mapno = 0; mapno < nmaps; mapno++) 506 for (mapno = 0; mapno < nmaps; mapno++)
507 single_keymap_panes (keymaps[mapno], Qnil, Qnil, notreal); 507 single_keymap_panes (keymaps[mapno], Qnil, Qnil, notreal, 10);
508 508
509 finish_menu_items (); 509 finish_menu_items ();
510 } 510 }
511 511
512 /* This is a recursive subroutine of keymap_panes. 512 /* This is a recursive subroutine of keymap_panes.
513 It handles one keymap, KEYMAP. 513 It handles one keymap, KEYMAP.
514 The other arguments are passed along 514 The other arguments are passed along
515 or point to local variables of the previous function. 515 or point to local variables of the previous function.
516 If NOTREAL is nonzero, 516 If NOTREAL is nonzero,
517 don't bother really computing whether an item is enabled. */ 517 don't bother really computing whether an item is enabled.
518
519 If we encounter submenus deeper than MAXDEPTH levels, ignore them. */
518 520
519 static void 521 static void
520 single_keymap_panes (keymap, pane_name, prefix, notreal) 522 single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth)
521 Lisp_Object keymap; 523 Lisp_Object keymap;
522 Lisp_Object pane_name; 524 Lisp_Object pane_name;
523 Lisp_Object prefix; 525 Lisp_Object prefix;
524 int notreal; 526 int notreal;
527 int maxdepth;
525 { 528 {
526 Lisp_Object pending_maps; 529 Lisp_Object pending_maps;
527 Lisp_Object tail, item, item1, item_string, table; 530 Lisp_Object tail, item, item1, item_string, table;
528 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 531 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
532
533 if (maxdepth <= 0)
534 return;
529 535
530 pending_maps = Qnil; 536 pending_maps = Qnil;
531 537
532 push_menu_pane (pane_name, prefix); 538 push_menu_pane (pane_name, prefix);
533 539
591 /* Display a submenu using the toolkit. */ 597 /* Display a submenu using the toolkit. */
592 if (! NILP (submap)) 598 if (! NILP (submap))
593 { 599 {
594 push_submenu_start (); 600 push_submenu_start ();
595 single_keymap_panes (submap, Qnil, 601 single_keymap_panes (submap, Qnil,
596 XCONS (item)->car, notreal); 602 XCONS (item)->car, notreal,
603 maxdepth - 1);
597 push_submenu_end (); 604 push_submenu_end ();
598 } 605 }
599 #endif 606 #endif
600 } 607 }
601 } 608 }
660 #ifdef USE_X_TOOLKIT 667 #ifdef USE_X_TOOLKIT
661 if (! NILP (submap)) 668 if (! NILP (submap))
662 { 669 {
663 push_submenu_start (); 670 push_submenu_start ();
664 single_keymap_panes (submap, Qnil, 671 single_keymap_panes (submap, Qnil,
665 character, notreal); 672 character, notreal,
673 maxdepth - 1);
666 push_submenu_end (); 674 push_submenu_end ();
667 } 675 }
668 #endif 676 #endif
669 } 677 }
670 } 678 }
681 eltcdr = XCONS (elt)->cdr; 689 eltcdr = XCONS (elt)->cdr;
682 string = XCONS (eltcdr)->car; 690 string = XCONS (eltcdr)->car;
683 /* We no longer discard the @ from the beginning of the string here. 691 /* We no longer discard the @ from the beginning of the string here.
684 Instead, we do this in xmenu_show. */ 692 Instead, we do this in xmenu_show. */
685 single_keymap_panes (Fcar (elt), string, 693 single_keymap_panes (Fcar (elt), string,
686 XCONS (eltcdr)->cdr, notreal); 694 XCONS (eltcdr)->cdr, notreal, maxdepth - 1);
687 pending_maps = Fcdr (pending_maps); 695 pending_maps = Fcdr (pending_maps);
688 } 696 }
689 } 697 }
690 698
691 /* Push all the panes and items of a menu described by the 699 /* Push all the panes and items of a menu described by the
1423 top_level_items = 1; 1431 top_level_items = 1;
1424 push_menu_pane (Qnil, Qnil); 1432 push_menu_pane (Qnil, Qnil);
1425 push_menu_item (item_name, Qt, item_key, mapvec[i], Qnil); 1433 push_menu_item (item_name, Qt, item_key, mapvec[i], Qnil);
1426 } 1434 }
1427 else 1435 else
1428 single_keymap_panes (mapvec[i], item_name, item_key, 0); 1436 single_keymap_panes (mapvec[i], item_name, item_key, 0, 10);
1429 } 1437 }
1430 1438
1431 /* Create a tree of widget_value objects 1439 /* Create a tree of widget_value objects
1432 representing the panes and their items. */ 1440 representing the panes and their items. */
1433 1441