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)
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). */
24 /* **************************************************************** */
26 /* Reading Named Commands */
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
34 read_function_name (prompt
, window
)
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
++)
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
;
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 ();
68 DECLARE_INFO_COMMAND (describe_command
,
69 _("Read the name of an Info command and describe it"))
73 line
= read_function_name (_("Describe command: "), window
);
77 info_abort_key (active_window
, count
, key
);
81 /* Describe the function named in "LINE". */
84 VFunction
*fun
= named_function (line
);
89 window_message_in_echo_area ("%s: %s.",
90 line
, function_documentation (fun
));
95 DECLARE_INFO_COMMAND (info_execute_command
,
96 _("Read a command name in the echo area and execute it"))
100 /* Ask the completer to read a reference for us. */
101 if (info_explicit_arg
|| count
!= 1)
105 prompt
= (char *)xmalloc (20);
106 sprintf (prompt
, "%d M-x ", count
);
107 line
= read_function_name (prompt
, window
);
110 line
= read_function_name ("M-x ", window
);
115 info_abort_key (active_window
, count
, key
);
119 /* User accepted "default"? (There is none.) */
126 /* User wants to execute a named command. Do it. */
130 if ((active_window
!= the_echo_area
) &&
131 (strncmp (line
, "echo-area-", 10) == 0))
134 info_error (_("Cannot execute an `echo-area' command here."));
138 function
= named_function (line
);
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"))
154 if (info_explicit_arg
|| count
!= 1)
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. */
170 info_abort_key (active_window
, count
, 0);
174 /* Find out what the new height is supposed to be. */
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 ();
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
);