Non-zero is the mini-buffer is in use
Int_Type MINIBUFFER_ACTIVE
The MINIBUFFER_ACTIVE
variable will be non-zero if the
mini-buffer is in use.
read_mini
add_completion
Void _add_completion (String f1, String f2, ..., Integer n);
The _add_completion
function is like the add_completion
function
except that it takes n
names f1
, ... fn
.
For example,
_add_completion ("fun_a", "fun_b", 2);
is equivalent to
add_completion ("fun_a");
add_completion ("fun_b");
add_completion
add_completion
Void add_completion(String f);
The add_completion
function adds the user defined S-Lang function
with name specified by the string f
to the list of functions that
are eligible for mini-buffer completion. The function specified by
f
must be already defined before this function is called. The
S-Lang function is_defined
may be used to test whether or not the
function is defined.
read_with_completion, _add_completion
Prompt for a key
Int_Type get_mini_response (String_Type str)
The get_mini_response
function display the text str
at
the bottom of the screen and waits for the user to press a key. The
key is returned.
read_mini, getkey, flush
Prompt for a y or n response
Int_Type get_y_or_n (String_Type str)
The get_y_or_n
function forms a y/n question by
concatenating "? (y/n)"
to str
and displays the result
at the bottom of the display. It returns 1
if the user responds
with y
, 0
with n
, or -1
if the user cancelled
the prompt.
get_yes_no, get_mini_response
get_yes_no
Integer get_yes_no (String s);
This function may be used to get a yes or no response from the
user. The string parameter s
will be used to construct the prompt
by concating the string "? (yes/no)"
to s
.
It returns 1
if the answer is yes or 0
if the answer is no.
getkey, flush, message
read_mini
String read_mini (String prompt, String dflt, String init);
The read_mini
function reads a line of input from the user in the
mini-buffer. The first parameter, prompt
, is used to prompt the
user. The second parameter, dflt
, is what is returned as a default
value if the user simply presses the return key. The final parameter,
init
, is stuffed into the mini-buffer for editing by the user.
For example,
define search_whole_buffer ()
{
variable str;
str = read_mini ("Search for:", "", "");
!if (strlen (str)) return;
!if (fsearch (str))
{
push_mark (); bob ();
if (fsearch (str)) pop_mark (0);
else pop_mark (1);
{
pop_mark (1);
error ("Not found");
}
}
}
reads a string from the user and then searches forward for it and if
not found, it resumes the search from the beginning of the buffer.
Note: If the user aborts the function mini_read
by pressing the
keyboard quit character (e.g., Ctrl-G), an error is signaled. This
error can be caught by an ERROR_BLOCK
and the appropriate action
taken. Also if the mini-buffer is already in use, this function should
not be called. The variable MINIBUFFER_ACTIVE
may be checked to
determine if this is the case or not.
read_with_completion, getkey, input_pending
MINIBUFFER_ACTIVE
read_with_completion
Void read_with_completion (String prt, String dflt, String s, Integer type);
This function may be used to read one of the objects specified by the
last parameter type
. The first parameter, prt
, is used as a
prompt, the second parameter, dflt
, is used to specify a default,
and the third parameter, s
, is used to initialize the string to
be read.
type
is an integer with the following meanings:
'f' file name
'b' buffer name
'F' function name
'V' variable name.
Finally, if type
has the value 's'
, then the set of completions
will be defined by a zeroth parameter, list
, to the function call.
This parameter is simple a comma separated list of completions.
For example,
read_with_completion ("Larry,Curly,Moe", "Favorite Stooge:",
"Larry", "", 's');
provides completion over the set of three stooges.
The function returns the string read.
read_mini
set_expansion_hook
Void set_expansion_hook (String fname);
This function may be used to specify a function that will be called to
expand a filename upon TAB completion. The function fname
must
already be defined. When fname
is called, it is given a string to
be expanded. If it changes the string, it must return a non-zero value
and the modified string. If the string is not modified, it must simply
return zero.