comparison src/xmenu.c @ 2191:12480fa04422

(list_of_items): Allow strings among the alist items; they make nonselectable lines. (single_keymap_panes): When storing in ENABLES, check def before enabled.
author Richard M. Stallman <rms@gnu.org>
date Mon, 15 Mar 1993 06:00:04 +0000
parents 0639c52f017c
children 7b95f29936cb
comparison
equal deleted inserted replaced
2190:482c7827b968 2191:12480fa04422
99 \(STRING . REAL-DEFINITION). To give the menu a title, put a string into\n\ 99 \(STRING . REAL-DEFINITION). To give the menu a title, put a string into\n\
100 the keymap as a top-level element.\n\n\ 100 the keymap as a top-level element.\n\n\
101 You can also use a list of keymaps as MENU.\n\ 101 You can also use a list of keymaps as MENU.\n\
102 Then each keymap makes a separate pane.\n\n\ 102 Then each keymap makes a separate pane.\n\n\
103 Alternatively, you can specify a menu of multiple panes\n\ 103 Alternatively, you can specify a menu of multiple panes\n\
104 with a list of the form\n\ 104 with a list of the form (TITLE PANE1 PANE2...),\n\
105 \(TITLE PANE1 PANE2...), where each pane is a list of form\n\ 105 where each pane is a list of form (TITLE ITEM1 ITEM2...).\n\
106 \(TITLE (LINE ITEM)...). Each line should be a string, and item should\n\ 106 Each ITEM is normally a cons cell (STRING . VALUE);\n\
107 be the return value for that line (i.e. if it is selected).") 107 but a string can appear as an item--that makes a nonselectable line\n\
108 in the menu.")
108 (position, menu) 109 (position, menu)
109 Lisp_Object position, menu; 110 Lisp_Object position, menu;
110 { 111 {
111 int number_of_panes; 112 int number_of_panes;
112 Lisp_Object XMenu_return, keymap, tem; 113 Lisp_Object XMenu_return, keymap, tem;
565 { 566 {
566 (*names)[*p_ptr][i] = (char *) XSTRING (item2)->data; 567 (*names)[*p_ptr][i] = (char *) XSTRING (item2)->data;
567 /* The menu item "value" is the key bound here. */ 568 /* The menu item "value" is the key bound here. */
568 (*vector)[*p_ptr][i] = XCONS (item)->car; 569 (*vector)[*p_ptr][i] = XCONS (item)->car;
569 (*enables)[*p_ptr][i] 570 (*enables)[*p_ptr][i]
570 = (!NILP (enabled) ? 1 571 = (NILP (def) ? -1 : !NILP (enabled) ? 1 : 0);
571 : NILP (def) ? -1 : 0);
572 i++; 572 i++;
573 } 573 }
574 } 574 }
575 } 575 }
576 } 576 }
612 { 612 {
613 (*names)[*p_ptr][i] = (char *) XSTRING (item2)->data; 613 (*names)[*p_ptr][i] = (char *) XSTRING (item2)->data;
614 /* The menu item "value" is the key bound here. */ 614 /* The menu item "value" is the key bound here. */
615 (*vector)[*p_ptr][i] = character; 615 (*vector)[*p_ptr][i] = character;
616 (*enables)[*p_ptr][i] 616 (*enables)[*p_ptr][i]
617 = (!NILP (enabled) ? 1 617 = (NILP (def) ? -1 : !NILP (enabled) ? 1 : 0);
618 : NILP (def) ? -1 : 0);
619 i++; 618 i++;
620 } 619 }
621 } 620 }
622 } 621 }
623 } 622 }
724 *enables = (int *) xmalloc (i * sizeof (int)); 723 *enables = (int *) xmalloc (i * sizeof (int));
725 724
726 for (i = 0, tail = pane; !NILP (tail); tail = Fcdr (tail), i++) 725 for (i = 0, tail = pane; !NILP (tail); tail = Fcdr (tail), i++)
727 { 726 {
728 item = Fcar (tail); 727 item = Fcar (tail);
729 if (XTYPE (item) != Lisp_Cons) (void) wrong_type_argument (Qlistp, item); 728 if (STRINGP (item))
730 #ifdef XDEBUG 729 {
731 fprintf (stderr, "list_of_items check tail, i=%d\n", i); 730 (*vector)[i] = Qnil;
732 #endif 731 (*names)[i] = (char *) XSTRING (item)->data;
733 (*vector)[i] = Fcdr (item); 732 (*enables)[i] = -1;
734 item1 = Fcar (item); 733 }
735 CHECK_STRING (item1, 1); 734 else
736 #ifdef XDEBUG 735 {
737 fprintf (stderr, "list_of_items check item, i=%d%s\n", i, 736 CHECK_CONS (item, 0);
738 XSTRING (item1)->data); 737 (*vector)[i] = Fcdr (item);
739 #endif 738 item1 = Fcar (item);
740 (*names)[i] = (char *) XSTRING (item1)->data; 739 CHECK_STRING (item1, 1);
741 (*enables)[i] = 1; 740 (*names)[i] = (char *) XSTRING (item1)->data;
741 (*enables)[i] = 1;
742 }
742 } 743 }
743 return i; 744 return i;
744 } 745 }