diff options
| author | Richard M. Stallman | 1996-02-04 20:25:10 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-02-04 20:25:10 +0000 |
| commit | 68e0de82384fab6372cb7119b50679cf6885e604 (patch) | |
| tree | e08affd75b074ed0ce2b776a8ec50734f7ba9fbb /src | |
| parent | 6186a4a01534ffd748f1c4a85e5a8cb6eeb16f1e (diff) | |
| download | emacs-68e0de82384fab6372cb7119b50679cf6885e604.tar.gz emacs-68e0de82384fab6372cb7119b50679cf6885e604.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 997020c50af..585561c4076 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -5130,6 +5130,12 @@ read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu) | |||
| 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 ; |
| @@ -5140,14 +5146,28 @@ read_char_minibuf_menu_prompt (commandflag, nmaps, maps) | |||
| 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; |
| 5150 | 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; | ||
| 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 | { |