]> code.delx.au - gnu-emacs/commitdiff
* term.c (tty_menu_add_pane, tty_menu_add_selection):
authorDmitry Antipov <dmantipov@yandex.ru>
Mon, 14 Jul 2014 15:06:52 +0000 (19:06 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Mon, 14 Jul 2014 15:06:52 +0000 (19:06 +0400)
Use menu_item_width.
(tty_menu_show): Simplify because ty_menu_create never return NULL.

src/ChangeLog
src/term.c

index 9fb23b2d82575d550f667b30b7039f0498220047..d74e0ed270cd945e24d3edd20e14bf68b44f36f0 100644 (file)
@@ -7,6 +7,10 @@
        * keymap.c (Fdefine_key, Flookup_key):
        * macros.c (Fstart_kbd_macro): Likewise.  Avoid call to Flength.
 
+       * term.c (tty_menu_add_pane, tty_menu_add_selection):
+       Use menu_item_width.
+       (tty_menu_show): Simplify because ty_menu_create never return NULL.
+
 2014-07-13  Paul Eggert  <eggert@cs.ucla.edu>
 
        Improve behavior of 'bzr up; cd src; make -k'.
index d4bb7e1bd3228bb1dc45090b78c8c34dc4b4293e..b608ebf0da970a87f4f58d0b56ebcbe3f4736eef 100644 (file)
@@ -2942,7 +2942,6 @@ static int
 tty_menu_add_pane (tty_menu *menu, const char *txt)
 {
   int len;
-  const unsigned char *p;
 
   tty_menu_make_room (menu);
   menu->submenu[menu->count] = tty_menu_create ();
@@ -2952,15 +2951,7 @@ tty_menu_add_pane (tty_menu *menu, const char *txt)
   menu->count++;
 
   /* Update the menu width, if necessary.  */
-  for (len = 0, p = (unsigned char *) txt; *p; )
-    {
-      int ch_len;
-      int ch = STRING_CHAR_AND_LENGTH (p, ch_len);
-
-      len += CHAR_WIDTH (ch);
-      p += ch_len;
-    }
-
+  len = menu_item_width ((const unsigned char *) txt);
   if (len > menu->width)
     menu->width = len;
 
@@ -2974,7 +2965,6 @@ tty_menu_add_selection (tty_menu *menu, int pane,
                        char *txt, bool enable, char const *help_text)
 {
   int len;
-  unsigned char *p;
 
   if (pane)
     {
@@ -2990,15 +2980,7 @@ tty_menu_add_selection (tty_menu *menu, int pane,
   menu->count++;
 
   /* Update the menu width, if necessary.  */
-  for (len = 0, p = (unsigned char *) txt; *p; )
-    {
-      int ch_len;
-      int ch = STRING_CHAR_AND_LENGTH (p, ch_len);
-
-      len += CHAR_WIDTH (ch);
-      p += ch_len;
-    }
-
+  len = menu_item_width ((const unsigned char *) txt);
   if (len > menu->width)
     menu->width = len;
 
@@ -3609,11 +3591,6 @@ tty_menu_show (struct frame *f, int x, int y, int menuflags,
 
   /* Make the menu on that window.  */
   menu = tty_menu_create ();
-  if (menu == NULL)
-    {
-      *error_name = "Can't create menu";
-      return Qnil;
-    }
 
   /* Don't GC while we prepare and show the menu, because we give the
      menu functions pointers to the contents of strings.  */