emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: All platforms fail with Unicode in menus.


From: YAMAMOTO Mitsuharu
Subject: Re: All platforms fail with Unicode in menus.
Date: Thu, 26 Aug 2004 17:13:02 +0900
User-agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.5 (Awara-Onsen) FLIM/1.14.5 (Demachiyanagi) APEL/10.6 Emacs/21.3.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On 25 Aug 2004 23:48:23 +0200, David Kastrup <address@hidden> said:

> Since those kind of menus make for quite a bit of attraction, I'd
> kindly ask the various platform programmer to consider accessing
> Unicode support of their operating system/toolkit, and I'd
> appreciate it if the GTK support of Unicode was made robust against
> garbage collection.

Here's a patch for Mac OS X, Carbon.  It also contains a fix for the
bug that the menu bar cannot be activated just after a pop-up menu is
used.

                                     YAMAMOTO Mitsuharu
                                address@hidden

Index: src/macmenu.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macmenu.c,v
retrieving revision 1.15
diff -c -r1.15 macmenu.c
*** src/macmenu.c       30 May 2004 00:18:41 -0000      1.15
--- src/macmenu.c       26 Aug 2004 05:37:37 -0000
***************
*** 163,168 ****
--- 163,174 ----
  
  extern Lisp_Object Qmenu_bar_update_hook;
  
+ #if TARGET_API_MAC_CARBON
+ #define ENCODE_MENU_STRING(str) ENCODE_UTF_8 (str)
+ #else
+ #define ENCODE_MENU_STRING(str) ENCODE_SYSTEM (str)
+ #endif
+ 
  void set_frame_menubar ();
  
  static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
***************
*** 1246,1258 ****
  #ifndef HAVE_MULTILINGUAL_MENU
          if (STRING_MULTIBYTE (item_name))
            {
!             item_name = ENCODE_SYSTEM (item_name);
              AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
            }
  
          if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
            {
!             descrip = ENCODE_SYSTEM (descrip);
              AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
            }
  #endif /* not HAVE_MULTILINGUAL_MENU */
--- 1252,1264 ----
  #ifndef HAVE_MULTILINGUAL_MENU
          if (STRING_MULTIBYTE (item_name))
            {
!             item_name = ENCODE_MENU_STRING (item_name);
              AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
            }
  
          if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
            {
!             descrip = ENCODE_MENU_STRING (descrip);
              AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
            }
  #endif /* not HAVE_MULTILINGUAL_MENU */
***************
*** 1705,1716 ****
  #ifndef HAVE_MULTILINGUAL_MENU
            if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
            {
!             item_name = ENCODE_SYSTEM (item_name);
              AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
            }
            if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
              {
!             descrip = ENCODE_SYSTEM (descrip);
              AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
            }
  #endif /* not HAVE_MULTILINGUAL_MENU */
--- 1711,1722 ----
  #ifndef HAVE_MULTILINGUAL_MENU
            if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
            {
!             item_name = ENCODE_MENU_STRING (item_name);
              AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
            }
            if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
              {
!             descrip = ENCODE_MENU_STRING (descrip);
              AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
            }
  #endif /* not HAVE_MULTILINGUAL_MENU */
***************
*** 1764,1770 ****
  
  #ifndef HAVE_MULTILINGUAL_MENU
        if (STRING_MULTIBYTE (title))
!       title = ENCODE_SYSTEM (title);
  #endif
        wv_title->name = (char *) SDATA (title);
        wv_title->enabled = TRUE;
--- 1770,1776 ----
  
  #ifndef HAVE_MULTILINGUAL_MENU
        if (STRING_MULTIBYTE (title))
!       title = ENCODE_MENU_STRING (title);
  #endif
        wv_title->name = (char *) SDATA (title);
        wv_title->enabled = TRUE;
***************
*** 1813,1818 ****
--- 1819,1828 ----
    discard_mouse_events ();
  #endif
  
+   /* Must reset this manually because the button release event is not
+      passed to Emacs event loop. */
+   FRAME_MAC_DISPLAY_INFO (f)->grabbed = 0;
+ 
    /* Free the widget_value objects we used to specify the
       contents.  */
    free_menubar_widget_value_tree (first_wv);
***************
*** 2219,2226 ****
--- 2229,2246 ----
          strncat (item_name, wv->key, 255);
        }
        item_name[255] = 0;
+ #if TARGET_API_MAC_CARBON
+       {
+       CFStringRef string =
+         CFStringCreateWithCString (NULL, item_name, kCFStringEncodingUTF8);
+ 
+       SetMenuItemTextWithCFString (menu, pos, string);
+       CFRelease (string);
+       }
+ #else
        c2pstr (item_name);
        SetMenuItemText (menu, pos, item_name);
+ #endif
  
        if (wv->enabled && !force_disable)
  #if TARGET_API_MAC_CARBON




reply via email to

[Prev in Thread] Current Thread [Next in Thread]