comparison src/keyboard.c @ 12185:7a18efea682a

(read_char_minibuf_menu_prompt): If the char to type doesn't match the prompt string, show the char explicitly.
author Karl Heuer <kwzh@gnu.org>
date Sun, 11 Jun 1995 20:09:49 +0000
parents 3e14d94320f2
children 24328f2358a1
comparison
equal deleted inserted replaced
12184:629806145d36 12185:7a18efea682a
4773 idx = 0; 4773 idx = 0;
4774 } 4774 }
4775 else 4775 else
4776 { 4776 {
4777 /* An ordinary element. */ 4777 /* An ordinary element. */
4778 if ( idx < 0 ) 4778 Lisp_Object event;
4779 s = Fcar_safe (Fcdr_safe (elt)); /* alist */ 4779
4780 else 4780 if (idx < 0)
4781 s = Fcar_safe(elt); /* vector */
4782 if (!STRINGP (s))
4783 /* Ignore the element if it has no prompt string. */
4784 ;
4785 /* If we have room for the prompt string, add it to this line.
4786 If this is the first on the line, always add it. */
4787 else if (XSTRING (s)->size + i + 2 < width
4788 || !notfirst)
4789 { 4781 {
4790 int thiswidth; 4782 s = Fcar_safe (Fcdr_safe (elt)); /* alist */
4791 4783 event = Fcar_safe (elt);
4792 /* Punctuate between strings. */
4793 if (notfirst)
4794 {
4795 strcpy (menu + i, ", ");
4796 i += 2;
4797 }
4798 notfirst = 1;
4799 nobindings = 0 ;
4800
4801 /* Add as much of string as fits. */
4802 thiswidth = XSTRING (s)->size;
4803 if (thiswidth + i > width)
4804 thiswidth = width - i;
4805 bcopy (XSTRING (s)->data, menu + i, thiswidth);
4806 i += thiswidth;
4807 menu[i] = 0;
4808 } 4784 }
4809 else 4785 else
4810 { 4786 {
4811 /* If this element does not fit, end the line now, 4787 s = Fcar_safe (elt); /* vector */
4812 and save the element for the next line. */ 4788 XSETINT (event, idx);
4813 strcpy (menu + i, "..."); 4789 }
4814 break; 4790
4791 /* Ignore the element if it has no prompt string. */
4792 if (STRINGP (s) && INTEGERP (event))
4793 {
4794 /* 1 if the char to type matches the string. */
4795 int char_matches;
4796 Lisp_Object upcased_event, downcased_event;
4797 Lisp_Object desc;
4798
4799 upcased_event = Fupcase (event);
4800 downcased_event = Fdowncase (event);
4801 char_matches = (XINT (upcased_event) == XSTRING (s)->data[0]
4802 || XINT (downcased_event) == XSTRING (s)->data[0]);
4803 if (! char_matches)
4804 desc = Fsingle_key_description (event);
4805
4806 /* If we have room for the prompt string, add it to this line.
4807 If this is the first on the line, always add it. */
4808 if ((XSTRING (s)->size + i + 2
4809 + (char_matches ? 0 : XSTRING (desc)->size + 3))
4810 < width
4811 || !notfirst)
4812 {
4813 int thiswidth;
4814
4815 /* Punctuate between strings. */
4816 if (notfirst)
4817 {
4818 strcpy (menu + i, ", ");
4819 i += 2;
4820 }
4821 notfirst = 1;
4822 nobindings = 0 ;
4823
4824 /* If the char to type doesn't match the string's
4825 first char, explicitly show what char to type. */
4826 if (! char_matches)
4827 {
4828 /* Add as much of string as fits. */
4829 thiswidth = XSTRING (desc)->size;
4830 if (thiswidth + i > width)
4831 thiswidth = width - i;
4832 bcopy (XSTRING (desc)->data, menu + i, thiswidth);
4833 i += thiswidth;
4834 strcpy (menu + i, " = ");
4835 i += 3;
4836 }
4837
4838 /* Add as much of string as fits. */
4839 thiswidth = XSTRING (s)->size;
4840 if (thiswidth + i > width)
4841 thiswidth = width - i;
4842 bcopy (XSTRING (s)->data, menu + i, thiswidth);
4843 i += thiswidth;
4844 menu[i] = 0;
4845 }
4846 else
4847 {
4848 /* If this element does not fit, end the line now,
4849 and save the element for the next line. */
4850 strcpy (menu + i, "...");
4851 break;
4852 }
4815 } 4853 }
4816 4854
4817 /* Move past this element. */ 4855 /* Move past this element. */
4818 if (idx >= 0 && idx + 1 >= XVECTOR (vector)->size) 4856 if (idx >= 0 && idx + 1 >= XVECTOR (vector)->size)
4819 /* Handle reaching end of dense table. */ 4857 /* Handle reaching end of dense table. */