1 /* m-x.c -- Meta-x minibuffer reader.
2 $Id: m-x.c,v 1.9 2001/11/16 23:14:33 karl Exp $
4 Copyright (C) 1993, 97, 98, 2001 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 Written by Brian Fox (bfox@ai.mit.edu). */
25 /* **************************************************************** */
27 /* Reading Named Commands */
29 /* **************************************************************** */
31 /* Read the name of an Info function in the echo area and return the
32 name. A return value of NULL indicates that no function name could
35 read_function_name (prompt, window)
41 REFERENCE **array = (REFERENCE **)NULL;
42 int array_index = 0, array_slots = 0;
44 /* Make an array of REFERENCE which actually contains the names of
45 the functions available in Info. */
46 for (i = 0; function_doc_array[i].func; i++)
50 entry = (REFERENCE *)xmalloc (sizeof (REFERENCE));
51 entry->label = xstrdup (function_doc_array[i].func_name);
52 entry->nodename = (char *)NULL;
53 entry->filename = (char *)NULL;
56 (entry, array_index, array, array_slots, 200, REFERENCE *);
59 line = info_read_completing_in_echo_area (window, prompt, array);
61 info_free_references (array);
63 if (!echo_area_is_active)
64 window_clear_echo_area ();
69 DECLARE_INFO_COMMAND (describe_command,
70 _("Read the name of an Info command and describe it"))
74 line = read_function_name (_("Describe command: "), window);
78 info_abort_key (active_window, count, key);
82 /* Describe the function named in "LINE". */
85 InfoCommand *cmd = named_function (line);
90 window_message_in_echo_area ("%s: %s.",
91 line, function_documentation (cmd));
96 DECLARE_INFO_COMMAND (info_execute_command,
97 _("Read a command name in the echo area and execute it"))
103 prompt = (char *)xmalloc (20);
105 keys = where_is (info_keymap, InfoCmd(info_execute_command));
106 /* If the where_is () function thinks that this command doesn't exist,
107 there's something very wrong! */
111 if (info_explicit_arg || count != 1)
112 sprintf (prompt, "%d %s ", count, keys);
114 sprintf (prompt, "%s ", keys);
116 /* Ask the completer to read a reference for us. */
117 line = read_function_name (prompt, window);
122 info_abort_key (active_window, count, key);
126 /* User accepted "default"? (There is none.) */
133 /* User wants to execute a named command. Do it. */
135 InfoCommand *command;
137 if ((active_window != the_echo_area) &&
138 (strncmp (line, "echo-area-", 10) == 0))
141 info_error (_("Cannot execute an `echo-area' command here."));
145 command = named_function (line);
151 (*InfoFunction(command)) (active_window, count, 0);
155 /* Okay, now that we have M-x, let the user set the screen height. */
156 DECLARE_INFO_COMMAND (set_screen_height,
157 _("Set the height of the displayed window"))
159 int new_height, old_height = screenheight;
161 if (info_explicit_arg || count != 1)
168 new_height = screenheight;
170 sprintf (prompt, _("Set screen height to (%d): "), new_height);
172 line = info_read_in_echo_area (window, prompt);
174 /* If the user aborted, do that now. */
177 info_abort_key (active_window, count, 0);
181 /* Find out what the new height is supposed to be. */
183 new_height = atoi (line);
185 /* Clear the echo area if it isn't active. */
186 if (!echo_area_is_active)
187 window_clear_echo_area ();
192 terminal_clear_screen ();
193 display_clear_display (the_display);
194 screenheight = new_height;
195 #ifdef SET_SCREEN_SIZE_HELPER
196 SET_SCREEN_SIZE_HELPER;
198 if (screenheight == old_height)
200 /* Display dimensions didn't actually change, so
201 window_new_screen_size won't do anything, but we've
202 already cleared the display above. Undo the damage. */
203 window_mark_chain (windows, W_UpdateWindow);
204 display_update_display (windows);
208 display_initialize_display (screenwidth, screenheight);
209 window_new_screen_size (screenwidth, screenheight);