finish_menu_items ();
}
+/* Encode a menu string as appropriate for menu-updating-frame's type. */
+static Lisp_Object
+encode_menu_string (Lisp_Object str)
+{
+ /* TTY menu strings are encoded by write_glyphs, when they are
+ delivered to the glass, so no need to encode them here. */
+ if (FRAME_TERMCAP_P (XFRAME (Vmenu_updating_frame)))
+ return str;
+ return ENCODE_MENU_STRING (str);
+}
/* Push the items in a single pane defined by the alist PANE. */
static void
{
item = XCAR (tail);
if (STRINGP (item))
- push_menu_item (ENCODE_MENU_STRING (item), Qnil, Qnil, Qt,
+ push_menu_item (encode_menu_string (item), Qnil, Qnil, Qt,
Qnil, Qnil, Qnil, Qnil);
else if (CONSP (item))
{
item1 = XCAR (item);
CHECK_STRING (item1);
- push_menu_item (ENCODE_MENU_STRING (item1), Qt, XCDR (item),
+ push_menu_item (encode_menu_string (item1), Qt, XCDR (item),
Qt, Qnil, Qnil, Qnil, Qnil);
}
else
elt = XCAR (tail);
pane_name = Fcar (elt);
CHECK_STRING (pane_name);
- push_menu_pane (ENCODE_MENU_STRING (pane_name), Qnil);
+ push_menu_pane (encode_menu_string (pane_name), Qnil);
pane_data = Fcdr (elt);
CHECK_CONS (pane_data);
list_of_items (pane_data);
int submenu_depth = 0;
widget_value **submenu_stack;
bool panes_seen = 0;
+ struct frame *f = XFRAME (Vmenu_updating_frame);
submenu_stack = alloca (menu_items_used * sizeof *submenu_stack);
wv = xmalloc_widget_value ();
pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
-#ifdef HAVE_NTGUI
- if (STRINGP (pane_name))
+ /* TTY menus display menu items via tty_write_glyphs, which
+ will encode the strings as appropriate. */
+ if (!FRAME_TERMCAP_P (f))
{
- if (unicode_append_menu)
- /* Encode as UTF-8 for now. */
- pane_name = ENCODE_UTF_8 (pane_name);
- else if (STRING_MULTIBYTE (pane_name))
- pane_name = ENCODE_SYSTEM (pane_name);
+#ifdef HAVE_NTGUI
+ if (STRINGP (pane_name))
+ {
+ if (unicode_append_menu)
+ /* Encode as UTF-8 for now. */
+ pane_name = ENCODE_UTF_8 (pane_name);
+ else if (STRING_MULTIBYTE (pane_name))
+ pane_name = ENCODE_SYSTEM (pane_name);
- ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
- }
+ ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
+ }
#elif defined (USE_LUCID) && defined (HAVE_XFT)
- if (STRINGP (pane_name))
- {
- pane_name = ENCODE_UTF_8 (pane_name);
- ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
- }
+ if (STRINGP (pane_name))
+ {
+ pane_name = ENCODE_UTF_8 (pane_name);
+ ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
+ }
#elif !defined (HAVE_MULTILINGUAL_MENU)
- if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
- {
- pane_name = ENCODE_MENU_STRING (pane_name);
- ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
- }
+ if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
+ {
+ pane_name = ENCODE_MENU_STRING (pane_name);
+ ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
+ }
#endif
+ }
pane_string = (NILP (pane_name)
? "" : SSDATA (pane_name));
selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
-#ifdef HAVE_NTGUI
- if (STRINGP (item_name))
+ /* TTY menu items and their descriptions will be encoded by
+ tty_write_glyphs. */
+ if (!FRAME_TERMCAP_P (f))
{
- if (unicode_append_menu)
- item_name = ENCODE_UTF_8 (item_name);
- else if (STRING_MULTIBYTE (item_name))
- item_name = ENCODE_SYSTEM (item_name);
+#ifdef HAVE_NTGUI
+ if (STRINGP (item_name))
+ {
+ if (unicode_append_menu)
+ item_name = ENCODE_UTF_8 (item_name);
+ else if (STRING_MULTIBYTE (item_name))
+ item_name = ENCODE_SYSTEM (item_name);
- ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
- }
+ ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
+ }
- if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
- {
- descrip = ENCODE_SYSTEM (descrip);
- ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
- }
+ if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
+ {
+ descrip = ENCODE_SYSTEM (descrip);
+ ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
+ }
#elif USE_LUCID
- if (STRINGP (item_name))
- {
- item_name = ENCODE_UTF_8 (item_name);
- ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
- }
+ if (STRINGP (item_name))
+ {
+ item_name = ENCODE_UTF_8 (item_name);
+ ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
+ }
- if (STRINGP (descrip))
- {
- descrip = ENCODE_UTF_8 (descrip);
- ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
- }
+ if (STRINGP (descrip))
+ {
+ descrip = ENCODE_UTF_8 (descrip);
+ ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
+ }
#elif !defined (HAVE_MULTILINGUAL_MENU)
- if (STRING_MULTIBYTE (item_name))
- {
- item_name = ENCODE_MENU_STRING (item_name);
- ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
- }
+ if (STRING_MULTIBYTE (item_name))
+ {
+ item_name = ENCODE_MENU_STRING (item_name);
+ ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
+ }
- if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
- {
- descrip = ENCODE_MENU_STRING (descrip);
- ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
- }
+ if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
+ {
+ descrip = ENCODE_MENU_STRING (descrip);
+ ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
+ }
#endif
+ }
wv = xmalloc_widget_value ();
if (prev_wv)