Remove spurious test of XScale and HARD_FLOAT floags
[official-gcc.git] / texinfo / info / m-x.c
blobc32a8899ff639f26e6448f97d347879b09bf355b
1 /* m-x.c -- Meta-X minibuffer reader.
2 $Id: m-x.c,v 1.1.1.2 1998/03/22 20:42:42 law Exp $
4 Copyright (C) 1993, 97 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)
9 any later version.
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). */
22 #include "info.h"
24 /* **************************************************************** */
25 /* */
26 /* Reading Named Commands */
27 /* */
28 /* **************************************************************** */
30 /* Read the name of an Info function in the echo area and return the
31 name. A return value of NULL indicates that no function name could
32 be read. */
33 char *
34 read_function_name (prompt, window)
35 char *prompt;
36 WINDOW *window;
38 register int i;
39 char *line;
40 REFERENCE **array = (REFERENCE **)NULL;
41 int array_index = 0, array_slots = 0;
43 /* Make an array of REFERENCE which actually contains the names of
44 the functions available in Info. */
45 for (i = 0; function_doc_array[i].func; i++)
47 REFERENCE *entry;
49 entry = (REFERENCE *)xmalloc (sizeof (REFERENCE));
50 entry->label = xstrdup (function_doc_array[i].func_name);
51 entry->nodename = (char *)NULL;
52 entry->filename = (char *)NULL;
54 add_pointer_to_array
55 (entry, array_index, array, array_slots, 200, REFERENCE *);
58 line = info_read_completing_in_echo_area (window, prompt, array);
60 info_free_references (array);
62 if (!echo_area_is_active)
63 window_clear_echo_area ();
65 return (line);
68 DECLARE_INFO_COMMAND (describe_command,
69 _("Read the name of an Info command and describe it"))
71 char *line;
73 line = read_function_name (_("Describe command: "), window);
75 if (!line)
77 info_abort_key (active_window, count, key);
78 return;
81 /* Describe the function named in "LINE". */
82 if (*line)
84 VFunction *fun = named_function (line);
86 if (!fun)
87 return;
89 window_message_in_echo_area ("%s: %s.",
90 line, function_documentation (fun));
92 free (line);
95 DECLARE_INFO_COMMAND (info_execute_command,
96 _("Read a command name in the echo area and execute it"))
98 char *line;
100 /* Ask the completer to read a reference for us. */
101 if (info_explicit_arg || count != 1)
103 char *prompt;
105 prompt = (char *)xmalloc (20);
106 sprintf (prompt, "%d M-x ", count);
107 line = read_function_name (prompt, window);
109 else
110 line = read_function_name ("M-x ", window);
112 /* User aborted? */
113 if (!line)
115 info_abort_key (active_window, count, key);
116 return;
119 /* User accepted "default"? (There is none.) */
120 if (!*line)
122 free (line);
123 return;
126 /* User wants to execute a named command. Do it. */
128 VFunction *function;
130 if ((active_window != the_echo_area) &&
131 (strncmp (line, "echo-area-", 10) == 0))
133 free (line);
134 info_error (_("Cannot execute an `echo-area' command here."));
135 return;
138 function = named_function (line);
139 free (line);
141 if (!function)
142 return;
144 (*function) (active_window, count, 0);
148 /* Okay, now that we have M-x, let the user set the screen height. */
149 DECLARE_INFO_COMMAND (set_screen_height,
150 _("Set the height of the displayed window"))
152 int new_height;
154 if (info_explicit_arg || count != 1)
155 new_height = count;
156 else
158 char prompt[80];
159 char *line;
161 new_height = screenheight;
163 sprintf (prompt, _("Set screen height to (%d): "), new_height);
165 line = info_read_in_echo_area (window, prompt);
167 /* If the user aborted, do that now. */
168 if (!line)
170 info_abort_key (active_window, count, 0);
171 return;
174 /* Find out what the new height is supposed to be. */
175 if (*line)
176 new_height = atoi (line);
178 /* Clear the echo area if it isn't active. */
179 if (!echo_area_is_active)
180 window_clear_echo_area ();
182 free (line);
185 terminal_clear_screen ();
186 display_clear_display (the_display);
187 screenheight = new_height;
188 display_initialize_display (screenwidth, screenheight);
189 window_new_screen_size (screenwidth, screenheight);