Mercurial > emacs
comparison src/keyboard.c @ 14490:c463c25a6806
(read_char_minibuf_menu_prompt): Use malloc to allocate
the echo-area prompt buffer.
(read_char_minibuf_menu_text, read_char_minibuf_menu_width): New variables.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 04 Feb 1996 20:25:10 +0000 |
parents | e5414c274414 |
children | 60e0c134c055 |
comparison
equal
deleted
inserted
replaced
14489:9bc700f13f97 | 14490:c463c25a6806 |
---|---|
5128 } | 5128 } |
5129 #endif /* HAVE_MENUS */ | 5129 #endif /* HAVE_MENUS */ |
5130 return Qnil ; | 5130 return Qnil ; |
5131 } | 5131 } |
5132 | 5132 |
5133 /* Buffer in use so far for the minibuf prompts for menu keymaps. | |
5134 We make this bigger when necessary, and never free it. */ | |
5135 static char *read_char_minibuf_menu_text; | |
5136 /* Size of that buffer. */ | |
5137 static int read_char_minibuf_menu_width; | |
5138 | |
5133 static Lisp_Object | 5139 static Lisp_Object |
5134 read_char_minibuf_menu_prompt (commandflag, nmaps, maps) | 5140 read_char_minibuf_menu_prompt (commandflag, nmaps, maps) |
5135 int commandflag ; | 5141 int commandflag ; |
5136 int nmaps; | 5142 int nmaps; |
5137 Lisp_Object *maps; | 5143 Lisp_Object *maps; |
5138 { | 5144 { |
5139 int mapno; | 5145 int mapno; |
5140 register Lisp_Object name; | 5146 register Lisp_Object name; |
5141 int nlength; | 5147 int nlength; |
5142 int width = FRAME_WIDTH (selected_frame) - 4; | 5148 int width = FRAME_WIDTH (selected_frame) - 4; |
5143 char *menu = (char *) alloca (width + 4); | |
5144 int idx = -1; | 5149 int idx = -1; |
5145 int nobindings = 1; | 5150 int nobindings = 1; |
5146 Lisp_Object rest, vector; | 5151 Lisp_Object rest, vector; |
5152 char *menu; | |
5147 | 5153 |
5148 if (! menu_prompting) | 5154 if (! menu_prompting) |
5149 return Qnil; | 5155 return Qnil; |
5156 | |
5157 /* Make sure we have a big enough buffer for the menu text. */ | |
5158 if (read_char_minibuf_menu_text == 0) | |
5159 { | |
5160 read_char_minibuf_menu_width = width + 4; | |
5161 read_char_minibuf_menu_text = (char *) xmalloc (width + 4); | |
5162 } | |
5163 else if (width + 4 > read_char_minibuf_menu_width) | |
5164 { | |
5165 read_char_minibuf_menu_width = width + 4; | |
5166 read_char_minibuf_menu_text | |
5167 = (char *) xrealloc (read_char_minibuf_menu_text, width + 4); | |
5168 } | |
5169 menu = read_char_minibuf_menu_text; | |
5150 | 5170 |
5151 /* Get the menu name from the first map that has one (a prompt string). */ | 5171 /* Get the menu name from the first map that has one (a prompt string). */ |
5152 for (mapno = 0; mapno < nmaps; mapno++) | 5172 for (mapno = 0; mapno < nmaps; mapno++) |
5153 { | 5173 { |
5154 name = map_prompt (maps[mapno]); | 5174 name = map_prompt (maps[mapno]); |