From c299f850cd627f960192ff0f33989e9c22d82100 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Mon, 14 Jul 2014 19:06:52 +0400 Subject: [PATCH] * 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. --- src/ChangeLog | 4 ++++ src/term.c | 27 ++------------------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 9fb23b2d825..d74e0ed270c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -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 Improve behavior of 'bzr up; cd src; make -k'. diff --git a/src/term.c b/src/term.c index d4bb7e1bd32..b608ebf0da9 100644 --- a/src/term.c +++ b/src/term.c @@ -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. */ -- 2.39.2