aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-07-14 19:06:52 +0400
committerDmitry Antipov2014-07-14 19:06:52 +0400
commitc299f850cd627f960192ff0f33989e9c22d82100 (patch)
treef15be23044c655daaede68467393b5f03238a5d4 /src
parent201b685783301c9acfda413d1860763f0e941601 (diff)
downloademacs-c299f850cd627f960192ff0f33989e9c22d82100.tar.gz
emacs-c299f850cd627f960192ff0f33989e9c22d82100.zip
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/term.c27
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 @@
7 * keymap.c (Fdefine_key, Flookup_key): 7 * keymap.c (Fdefine_key, Flookup_key):
8 * macros.c (Fstart_kbd_macro): Likewise. Avoid call to Flength. 8 * macros.c (Fstart_kbd_macro): Likewise. Avoid call to Flength.
9 9
10 * term.c (tty_menu_add_pane, tty_menu_add_selection):
11 Use menu_item_width.
12 (tty_menu_show): Simplify because ty_menu_create never return NULL.
13
102014-07-13 Paul Eggert <eggert@cs.ucla.edu> 142014-07-13 Paul Eggert <eggert@cs.ucla.edu>
11 15
12 Improve behavior of 'bzr up; cd src; make -k'. 16 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
2942tty_menu_add_pane (tty_menu *menu, const char *txt) 2942tty_menu_add_pane (tty_menu *menu, const char *txt)
2943{ 2943{
2944 int len; 2944 int len;
2945 const unsigned char *p;
2946 2945
2947 tty_menu_make_room (menu); 2946 tty_menu_make_room (menu);
2948 menu->submenu[menu->count] = tty_menu_create (); 2947 menu->submenu[menu->count] = tty_menu_create ();
@@ -2952,15 +2951,7 @@ tty_menu_add_pane (tty_menu *menu, const char *txt)
2952 menu->count++; 2951 menu->count++;
2953 2952
2954 /* Update the menu width, if necessary. */ 2953 /* Update the menu width, if necessary. */
2955 for (len = 0, p = (unsigned char *) txt; *p; ) 2954 len = menu_item_width ((const unsigned char *) txt);
2956 {
2957 int ch_len;
2958 int ch = STRING_CHAR_AND_LENGTH (p, ch_len);
2959
2960 len += CHAR_WIDTH (ch);
2961 p += ch_len;
2962 }
2963
2964 if (len > menu->width) 2955 if (len > menu->width)
2965 menu->width = len; 2956 menu->width = len;
2966 2957
@@ -2974,7 +2965,6 @@ tty_menu_add_selection (tty_menu *menu, int pane,
2974 char *txt, bool enable, char const *help_text) 2965 char *txt, bool enable, char const *help_text)
2975{ 2966{
2976 int len; 2967 int len;
2977 unsigned char *p;
2978 2968
2979 if (pane) 2969 if (pane)
2980 { 2970 {
@@ -2990,15 +2980,7 @@ tty_menu_add_selection (tty_menu *menu, int pane,
2990 menu->count++; 2980 menu->count++;
2991 2981
2992 /* Update the menu width, if necessary. */ 2982 /* Update the menu width, if necessary. */
2993 for (len = 0, p = (unsigned char *) txt; *p; ) 2983 len = menu_item_width ((const unsigned char *) txt);
2994 {
2995 int ch_len;
2996 int ch = STRING_CHAR_AND_LENGTH (p, ch_len);
2997
2998 len += CHAR_WIDTH (ch);
2999 p += ch_len;
3000 }
3001
3002 if (len > menu->width) 2984 if (len > menu->width)
3003 menu->width = len; 2985 menu->width = len;
3004 2986
@@ -3609,11 +3591,6 @@ tty_menu_show (struct frame *f, int x, int y, int menuflags,
3609 3591
3610 /* Make the menu on that window. */ 3592 /* Make the menu on that window. */
3611 menu = tty_menu_create (); 3593 menu = tty_menu_create ();
3612 if (menu == NULL)
3613 {
3614 *error_name = "Can't create menu";
3615 return Qnil;
3616 }
3617 3594
3618 /* Don't GC while we prepare and show the menu, because we give the 3595 /* Don't GC while we prepare and show the menu, because we give the
3619 menu functions pointers to the contents of strings. */ 3596 menu functions pointers to the contents of strings. */