comparison src/xmenu.c @ 90119:8395880305fe

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-25 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 173-179) - Update from CVS
author Miles Bader <miles@gnu.org>
date Mon, 14 Mar 2005 05:27:53 +0000
parents 72cf6261961e 44c9c79a2c7a
children 30ad2795fdab
comparison
equal deleted inserted replaced
90118:e330fedc9152 90119:8395880305fe
1 /* X Communication module for terminals which understand the X protocol. 1 /* X Communication module for terminals which understand the X protocol.
2 Copyright (C) 1986, 1988, 1993, 1994, 1996, 1999, 2000, 2001, 2003, 2004 2 Copyright (C) 1986, 1988, 1993, 1994, 1996, 1999, 2000, 2001, 2003, 2004,
3 Free Software Foundation, Inc. 3 2005 Free Software Foundation, Inc.
4 4
5 This file is part of GNU Emacs. 5 This file is part of GNU Emacs.
6 6
7 GNU Emacs is free software; you can redistribute it and/or modify 7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
136 using it unconditionally. */ 136 using it unconditionally. */
137 #ifdef USE_GTK 137 #ifdef USE_GTK
138 /* gtk just uses utf-8. */ 138 /* gtk just uses utf-8. */
139 # define ENCODE_MENU_STRING(str) ENCODE_UTF_8 (str) 139 # define ENCODE_MENU_STRING(str) ENCODE_UTF_8 (str)
140 #else 140 #else
141 /* I'm not convinced ENCODE_SYSTEM is defined correctly, or maybe 141 # define ENCODE_MENU_STRING(str) string_make_unibyte (str)
142 something else should be used here. Except under MS-Windows it
143 just converts to unibyte, but encoding with `locale-coding-system'
144 seems better -- X may actually display the result correctly, and
145 it's not necessarily equivalent to the unibyte text. -- fx */
146 # define ENCODE_MENU_STRING(str) ENCODE_SYSTEM (str)
147 #endif 142 #endif
148 143
149 static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, 144 static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
150 Lisp_Object, Lisp_Object, Lisp_Object, 145 Lisp_Object, Lisp_Object, Lisp_Object,
151 Lisp_Object, Lisp_Object)); 146 Lisp_Object, Lisp_Object));
643 { 638 {
644 Lisp_Object tail; 639 Lisp_Object tail;
645 640
646 init_menu_items (); 641 init_menu_items ();
647 642
648 for (tail = menu; !NILP (tail); tail = Fcdr (tail)) 643 for (tail = menu; CONSP (tail); tail = XCDR (tail))
649 { 644 {
650 Lisp_Object elt, pane_name, pane_data; 645 Lisp_Object elt, pane_name, pane_data;
651 elt = Fcar (tail); 646 elt = XCAR (tail);
652 pane_name = Fcar (elt); 647 pane_name = Fcar (elt);
653 CHECK_STRING (pane_name); 648 CHECK_STRING (pane_name);
654 push_menu_pane (ENCODE_MENU_STRING (pane_name), Qnil); 649 push_menu_pane (ENCODE_MENU_STRING (pane_name), Qnil);
655 pane_data = Fcdr (elt); 650 pane_data = Fcdr (elt);
656 CHECK_CONS (pane_data); 651 CHECK_CONS (pane_data);
666 list_of_items (pane) 661 list_of_items (pane)
667 Lisp_Object pane; 662 Lisp_Object pane;
668 { 663 {
669 Lisp_Object tail, item, item1; 664 Lisp_Object tail, item, item1;
670 665
671 for (tail = pane; !NILP (tail); tail = Fcdr (tail)) 666 for (tail = pane; CONSP (tail); tail = XCDR (tail))
672 { 667 {
673 item = Fcar (tail); 668 item = XCAR (tail);
674 if (STRINGP (item)) 669 if (STRINGP (item))
675 push_menu_item (ENCODE_MENU_STRING (item), Qnil, Qnil, Qt, 670 push_menu_item (ENCODE_MENU_STRING (item), Qnil, Qnil, Qt,
676 Qnil, Qnil, Qnil, Qnil); 671 Qnil, Qnil, Qnil, Qnil);
677 else if (NILP (item)) 672 else if (CONSP (item))
678 push_left_right_boundary ();
679 else
680 { 673 {
681 CHECK_CONS (item); 674 item1 = XCAR (item);
682 item1 = Fcar (item);
683 CHECK_STRING (item1); 675 CHECK_STRING (item1);
684 push_menu_item (ENCODE_MENU_STRING (item1), Qt, Fcdr (item), 676 push_menu_item (ENCODE_MENU_STRING (item1), Qt, XCDR (item),
685 Qt, Qnil, Qnil, Qnil, Qnil); 677 Qt, Qnil, Qnil, Qnil, Qnil);
686 } 678 }
679 else
680 push_left_right_boundary ();
681
687 } 682 }
688 } 683 }
689 684
690 #ifdef HAVE_X_WINDOWS 685 #ifdef HAVE_X_WINDOWS
691 /* Return the mouse position in *X and *Y. The coordinates are window 686 /* Return the mouse position in *X and *Y. The coordinates are window
800 { 795 {
801 tem = Fcar (position); 796 tem = Fcar (position);
802 if (CONSP (tem)) 797 if (CONSP (tem))
803 { 798 {
804 window = Fcar (Fcdr (position)); 799 window = Fcar (Fcdr (position));
805 x = Fcar (tem); 800 x = XCAR (tem);
806 y = Fcar (Fcdr (tem)); 801 y = Fcar (XCDR (tem));
807 } 802 }
808 else 803 else
809 { 804 {
810 for_click = 1; 805 for_click = 1;
811 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ 806 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
929 924
930 title = Qnil; 925 title = Qnil;
931 926
932 /* The first keymap that has a prompt string 927 /* The first keymap that has a prompt string
933 supplies the menu title. */ 928 supplies the menu title. */
934 for (tem = menu, i = 0; CONSP (tem); tem = Fcdr (tem)) 929 for (tem = menu, i = 0; CONSP (tem); tem = XCDR (tem))
935 { 930 {
936 Lisp_Object prompt; 931 Lisp_Object prompt;
937 932
938 maps[i++] = keymap = get_keymap (Fcar (tem), 1, 0); 933 maps[i++] = keymap = get_keymap (XCAR (tem), 1, 0);
939 934
940 prompt = Fkeymap_prompt (keymap); 935 prompt = Fkeymap_prompt (keymap);
941 if (NILP (title) && !NILP (prompt)) 936 if (NILP (title) && !NILP (prompt))
942 title = prompt; 937 title = prompt;
943 } 938 }
1748 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; 1743 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
1749 1744
1750 #ifndef HAVE_MULTILINGUAL_MENU 1745 #ifndef HAVE_MULTILINGUAL_MENU
1751 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name)) 1746 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
1752 { 1747 {
1753 pane_name = ENCODE_SYSTEM (pane_name); 1748 pane_name = ENCODE_MENU_STRING (pane_name);
1754 AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name; 1749 AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name;
1755 } 1750 }
1756 #endif 1751 #endif
1757 pane_string = (NILP (pane_name) 1752 pane_string = (NILP (pane_name)
1758 ? "" : (char *) SDATA (pane_name)); 1753 ? "" : (char *) SDATA (pane_name));
2693 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); 2688 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
2694 2689
2695 #ifndef HAVE_MULTILINGUAL_MENU 2690 #ifndef HAVE_MULTILINGUAL_MENU
2696 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name)) 2691 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
2697 { 2692 {
2698 pane_name = ENCODE_SYSTEM (pane_name); 2693 pane_name = ENCODE_MENU_STRING (pane_name);
2699 AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name; 2694 AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name;
2700 } 2695 }
2701 #endif 2696 #endif
2702 pane_string = (NILP (pane_name) 2697 pane_string = (NILP (pane_name)
2703 ? "" : (char *) SDATA (pane_name)); 2698 ? "" : (char *) SDATA (pane_name));