unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Cc: reiner.steib@gmx.de, emacs-devel@gnu.org
Subject: Re: All platforms fail with Unicode in menus.
Date: Thu, 26 Aug 2004 17:13:02 +0900	[thread overview]
Message-ID: <wlfz6atj01.wl@church.math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <x5isb6q47s.fsf@lola.goethe.zz>

>>>>> On 25 Aug 2004 23:48:23 +0200, David Kastrup <dak@gnu.org> 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
				mituharu@math.s.chiba-u.ac.jp

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	other threads:[~2004-08-26  8:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-25 21:48 All platforms fail with Unicode in menus David Kastrup
2004-08-26  8:13 ` YAMAMOTO Mitsuharu [this message]
2004-08-26 18:30 ` Jan D.
2004-08-28  7:11   ` David Kastrup
2004-08-28  7:42     ` Jan D.
2004-08-28  8:08       ` David Kastrup
2004-08-28  8:24         ` Andreas Schwab
2004-08-28 21:38     ` Stefan
2004-08-28 22:18       ` Jan D.
2004-08-28 22:38         ` Stefan
2004-08-30  7:52   ` YAMAMOTO Mitsuharu
2004-08-30 10:28     ` Jan D.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=wlfz6atj01.wl@church.math.s.chiba-u.ac.jp \
    --to=mituharu@math.s.chiba-u.ac.jp \
    --cc=emacs-devel@gnu.org \
    --cc=reiner.steib@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).