Merge local changes
This commit is contained in:
parent
3be056262b
commit
a39df769f3
@ -1,3 +1,5 @@
|
||||
# $FreeBSD$
|
||||
mv doc/readline.3 .
|
||||
mv doc/history.3 .
|
||||
rm doc/*.dvi doc/*.html doc/*.ps doc/*.0 doc/*.info doc/*.tex doc/texi2*
|
||||
rm savestring.c
|
||||
|
@ -50,18 +50,6 @@ extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
#include <pwd.h>
|
||||
#if !defined (HAVE_GETPW_DECLS)
|
||||
extern struct passwd *getpwent ();
|
||||
#endif /* USG && !HAVE_GETPW_DECLS */
|
||||
|
||||
/* ISC systems don't define getpwent() if _POSIX_SOURCE is defined. */
|
||||
#if defined (isc386) && defined (_POSIX_SOURCE)
|
||||
# if defined (__STDC__)
|
||||
extern struct passwd *getpwent (void);
|
||||
# else
|
||||
extern struct passwd *getpwent ();
|
||||
# endif /* !__STDC__ */
|
||||
#endif /* isc386 && _POSIX_SOURCE */
|
||||
|
||||
#include "posixdir.h"
|
||||
#include "posixstat.h"
|
||||
@ -80,6 +68,12 @@ typedef int QSFUNC (const void *, const void *);
|
||||
typedef int QSFUNC ();
|
||||
#endif
|
||||
|
||||
/* Most systems don't declare getpwent in <pwd.h> if _POSIX_SOURCE is
|
||||
defined. */
|
||||
#if !defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE)
|
||||
extern struct passwd *getpwent __P((void));
|
||||
#endif /* !HAVE_GETPW_DECLS || _POSIX_SOURCE */
|
||||
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing a word would normally display the list of possible matches.
|
||||
This function is called instead of actually doing the display.
|
||||
@ -87,11 +81,7 @@ typedef int QSFUNC ();
|
||||
where MATCHES is the array of strings that matched, NUM_MATCHES is the
|
||||
number of strings in that array, and MAX_LENGTH is the length of the
|
||||
longest string in that array. */
|
||||
VFunction *rl_completion_display_matches_hook = (VFunction *)NULL;
|
||||
|
||||
/* Forward declarations for functions defined and used in this file. */
|
||||
char *filename_completion_function __P((char *, int));
|
||||
char **completion_matches __P((char *, CPFunction *));
|
||||
rl_compdisp_func_t *rl_completion_display_matches_hook = (rl_compdisp_func_t *)NULL;
|
||||
|
||||
#if defined (VISIBLE_STATS)
|
||||
# if !defined (X_OK)
|
||||
@ -101,14 +91,13 @@ static int stat_char __P((char *));
|
||||
#endif
|
||||
|
||||
static char *rl_quote_filename __P((char *, int, char *));
|
||||
static char *rl_strpbrk __P((char *, char *));
|
||||
|
||||
static char **remove_duplicate_matches __P((char **));
|
||||
static void insert_match __P((char *, int, int, char *));
|
||||
static int append_to_match __P((char *, int, int));
|
||||
static void insert_all_matches __P((char **, int, char *));
|
||||
static void display_matches __P((char **));
|
||||
static int compute_lcd_of_matches __P((char **, int, char *));
|
||||
static int compute_lcd_of_matches __P((char **, int, const char *));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
@ -147,15 +136,17 @@ int rl_visible_stats = 0;
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing on a directory name. The function is called with
|
||||
the address of a string (the current directory name) as an arg. */
|
||||
Function *rl_directory_completion_hook = (Function *)NULL;
|
||||
rl_icppfunc_t *rl_directory_completion_hook = (rl_icppfunc_t *)NULL;
|
||||
|
||||
rl_icppfunc_t *rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
|
||||
|
||||
/* Non-zero means readline completion functions perform tilde expansion. */
|
||||
int rl_complete_with_tilde_expansion = 0;
|
||||
|
||||
/* Pointer to the generator function for completion_matches ().
|
||||
NULL means to use filename_completion_function (), the default filename
|
||||
NULL means to use rl_filename_completion_function (), the default filename
|
||||
completer. */
|
||||
Function *rl_completion_entry_function = (Function *)NULL;
|
||||
rl_compentry_func_t *rl_completion_entry_function = (rl_compentry_func_t *)NULL;
|
||||
|
||||
/* Pointer to alternative function to create matches.
|
||||
Function is called with TEXT, START, and END.
|
||||
@ -164,7 +155,7 @@ Function *rl_completion_entry_function = (Function *)NULL;
|
||||
If this function exists and returns NULL then call the value of
|
||||
rl_completion_entry_function to try to match, otherwise use the
|
||||
array of strings returned. */
|
||||
CPPFunction *rl_attempted_completion_function = (CPPFunction *)NULL;
|
||||
rl_completion_func_t *rl_attempted_completion_function = (rl_completion_func_t *)NULL;
|
||||
|
||||
/* Non-zero means to suppress normal filename completion after the
|
||||
user-specified completion function has been called. */
|
||||
@ -183,29 +174,29 @@ int rl_completion_query_items = 100;
|
||||
/* The basic list of characters that signal a break between words for the
|
||||
completer routine. The contents of this variable is what breaks words
|
||||
in the shell, i.e. " \t\n\"\\'`@$><=" */
|
||||
char *rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{(";
|
||||
const char *rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{(";
|
||||
|
||||
/* List of basic quoting characters. */
|
||||
char *rl_basic_quote_characters = "\"'";
|
||||
const char *rl_basic_quote_characters = "\"'";
|
||||
|
||||
/* The list of characters that signal a break between words for
|
||||
rl_complete_internal. The default list is the contents of
|
||||
rl_basic_word_break_characters. */
|
||||
char *rl_completer_word_break_characters = (char *)NULL;
|
||||
const char *rl_completer_word_break_characters = (const char *)NULL;
|
||||
|
||||
/* List of characters which can be used to quote a substring of the line.
|
||||
Completion occurs on the entire substring, and within the substring
|
||||
rl_completer_word_break_characters are treated as any other character,
|
||||
unless they also appear within this list. */
|
||||
char *rl_completer_quote_characters = (char *)NULL;
|
||||
const char *rl_completer_quote_characters = (const char *)NULL;
|
||||
|
||||
/* List of characters that should be quoted in filenames by the completer. */
|
||||
char *rl_filename_quote_characters = (char *)NULL;
|
||||
const char *rl_filename_quote_characters = (const char *)NULL;
|
||||
|
||||
/* List of characters that are word break characters, but should be left
|
||||
in TEXT when it is passed to the completion function. The shell uses
|
||||
this to help determine what kind of completing to do. */
|
||||
char *rl_special_prefixes = (char *)NULL;
|
||||
const char *rl_special_prefixes = (const char *)NULL;
|
||||
|
||||
/* If non-zero, then disallow duplicates in the matches. */
|
||||
int rl_ignore_completion_duplicates = 1;
|
||||
@ -231,24 +222,24 @@ int rl_filename_quoting_desired = 1;
|
||||
the list of matches as required, but all elements of the array must be
|
||||
free()'d if they are deleted. The main intent of this function is
|
||||
to implement FIGNORE a la SunOS csh. */
|
||||
Function *rl_ignore_some_completions_function = (Function *)NULL;
|
||||
rl_compignore_func_t *rl_ignore_some_completions_function = (rl_compignore_func_t *)NULL;
|
||||
|
||||
/* Set to a function to quote a filename in an application-specific fashion.
|
||||
Called with the text to quote, the type of match found (single or multiple)
|
||||
and a pointer to the quoting character to be used, which the function can
|
||||
reset if desired. */
|
||||
CPFunction *rl_filename_quoting_function = rl_quote_filename;
|
||||
rl_quote_func_t *rl_filename_quoting_function = rl_quote_filename;
|
||||
|
||||
/* Function to call to remove quoting characters from a filename. Called
|
||||
before completion is attempted, so the embedded quotes do not interfere
|
||||
with matching names in the file system. Readline doesn't do anything
|
||||
with this; it's set only by applications. */
|
||||
CPFunction *rl_filename_dequoting_function = (CPFunction *)NULL;
|
||||
rl_dequote_func_t *rl_filename_dequoting_function = (rl_dequote_func_t *)NULL;
|
||||
|
||||
/* Function to call to decide whether or not a word break character is
|
||||
quoted. If a character is quoted, it does not break words for the
|
||||
completer. */
|
||||
Function *rl_char_is_quoted_p = (Function *)NULL;
|
||||
rl_linebuf_func_t *rl_char_is_quoted_p = (rl_linebuf_func_t *)NULL;
|
||||
|
||||
/* Character appended to completed words when at the end of the line. The
|
||||
default is a space. */
|
||||
@ -270,7 +261,7 @@ static int completion_changed_buffer;
|
||||
|
||||
/* Complete the word at or before point. You have supplied the function
|
||||
that does the initial simple matching selection algorithm (see
|
||||
completion_matches ()). The default is to do filename completion. */
|
||||
rl_completion_matches ()). The default is to do filename completion. */
|
||||
int
|
||||
rl_complete (ignore, invoking_key)
|
||||
int ignore, invoking_key;
|
||||
@ -306,27 +297,6 @@ rl_insert_completions (ignore, invoking_key)
|
||||
/* */
|
||||
/************************************/
|
||||
|
||||
/* Find the first occurrence in STRING1 of any character from STRING2.
|
||||
Return a pointer to the character in STRING1. */
|
||||
static char *
|
||||
rl_strpbrk (string1, string2)
|
||||
char *string1, *string2;
|
||||
{
|
||||
register char *scan;
|
||||
|
||||
for (; *string1; string1++)
|
||||
{
|
||||
for (scan = string2; *scan; scan++)
|
||||
{
|
||||
if (*string1 == *scan)
|
||||
{
|
||||
return (string1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
/* The user must press "y" or "n". Non-zero return means "y" pressed. */
|
||||
static int
|
||||
get_y_or_n ()
|
||||
@ -335,14 +305,17 @@ get_y_or_n ()
|
||||
|
||||
for (;;)
|
||||
{
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
c = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
|
||||
if (c == 'y' || c == 'Y' || c == ' ')
|
||||
return (1);
|
||||
if (c == 'n' || c == 'N' || c == RUBOUT)
|
||||
return (0);
|
||||
if (c == ABORT_CHAR)
|
||||
_rl_abort_internal ();
|
||||
ding ();
|
||||
rl_ding ();
|
||||
}
|
||||
}
|
||||
|
||||
@ -572,7 +545,11 @@ find_completion_word (fp, dp)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rl_line_buffer[scan] == '\\')
|
||||
/* Shell-like semantics for single quotes -- don't allow backslash
|
||||
to quote anything in single quotes, especially not the closing
|
||||
quote. If you don't like this, take out the check on the value
|
||||
of quote_char. */
|
||||
if (quote_char != '\'' && rl_line_buffer[scan] == '\\')
|
||||
{
|
||||
pass_next = 1;
|
||||
found_quote |= RL_QF_BACKSLASH;
|
||||
@ -672,7 +649,7 @@ static char **
|
||||
gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
|
||||
char *text;
|
||||
int start, end;
|
||||
Function *our_func;
|
||||
rl_compentry_func_t *our_func;
|
||||
int found_quote, quote_char;
|
||||
{
|
||||
char **matches, *temp;
|
||||
@ -696,7 +673,7 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
|
||||
filename dequoting function. */
|
||||
temp = (char *)NULL;
|
||||
|
||||
if (found_quote && our_func == (Function *)filename_completion_function &&
|
||||
if (found_quote && our_func == rl_filename_completion_function &&
|
||||
rl_filename_dequoting_function)
|
||||
{
|
||||
/* delete single and double quotes */
|
||||
@ -704,7 +681,7 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
|
||||
text = temp; /* not freeing text is not a memory leak */
|
||||
}
|
||||
|
||||
matches = completion_matches (text, (CPFunction *)our_func);
|
||||
matches = rl_completion_matches (text, our_func);
|
||||
FREE (temp);
|
||||
return matches;
|
||||
}
|
||||
@ -776,7 +753,7 @@ static int
|
||||
compute_lcd_of_matches (match_list, matches, text)
|
||||
char **match_list;
|
||||
int matches;
|
||||
char *text;
|
||||
const char *text;
|
||||
{
|
||||
register int i, c1, c2, si;
|
||||
int low; /* Count of max-matched characters. */
|
||||
@ -902,11 +879,11 @@ rl_display_match_list (matches, len, max)
|
||||
|
||||
/* How many items of MAX length can we fit in the screen window? */
|
||||
max += 2;
|
||||
limit = screenwidth / max;
|
||||
if (limit != 1 && (limit * max == screenwidth))
|
||||
limit = _rl_screenwidth / max;
|
||||
if (limit != 1 && (limit * max == _rl_screenwidth))
|
||||
limit--;
|
||||
|
||||
/* Avoid a possible floating exception. If max > screenwidth,
|
||||
/* Avoid a possible floating exception. If max > _rl_screenwidth,
|
||||
limit will be 0 and a divide-by-zero fault will result. */
|
||||
if (limit == 0)
|
||||
limit = 1;
|
||||
@ -922,7 +899,7 @@ rl_display_match_list (matches, len, max)
|
||||
if (rl_ignore_completion_duplicates == 0)
|
||||
qsort (matches + 1, len, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
|
||||
|
||||
crlf ();
|
||||
rl_crlf ();
|
||||
|
||||
if (_rl_print_completions_horizontally == 0)
|
||||
{
|
||||
@ -944,7 +921,7 @@ rl_display_match_list (matches, len, max)
|
||||
}
|
||||
l += count;
|
||||
}
|
||||
crlf ();
|
||||
rl_crlf ();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -958,13 +935,13 @@ rl_display_match_list (matches, len, max)
|
||||
if (matches[i+1])
|
||||
{
|
||||
if (i && (limit > 1) && (i % limit) == 0)
|
||||
crlf ();
|
||||
rl_crlf ();
|
||||
else
|
||||
for (k = 0; k < max - printed_len; k++)
|
||||
putc (' ', rl_outstream);
|
||||
}
|
||||
}
|
||||
crlf ();
|
||||
rl_crlf ();
|
||||
}
|
||||
}
|
||||
|
||||
@ -993,9 +970,9 @@ display_matches (matches)
|
||||
if (matches[1] == 0)
|
||||
{
|
||||
temp = printable_part (matches[0]);
|
||||
crlf ();
|
||||
rl_crlf ();
|
||||
print_filename (temp, matches[0]);
|
||||
crlf ();
|
||||
rl_crlf ();
|
||||
|
||||
rl_forced_update_display ();
|
||||
rl_display_fixed = 1;
|
||||
@ -1027,12 +1004,12 @@ display_matches (matches)
|
||||
see them all. */
|
||||
if (len >= rl_completion_query_items)
|
||||
{
|
||||
crlf ();
|
||||
rl_crlf ();
|
||||
fprintf (rl_outstream, "Display all %d possibilities? (y or n)", len);
|
||||
fflush (rl_outstream);
|
||||
if (get_y_or_n () == 0)
|
||||
{
|
||||
crlf ();
|
||||
rl_crlf ();
|
||||
|
||||
rl_forced_update_display ();
|
||||
rl_display_fixed = 1;
|
||||
@ -1080,7 +1057,7 @@ make_quoted_replacement (match, mtype, qc)
|
||||
This also checks whether the common prefix of several
|
||||
matches needs to be quoted. */
|
||||
should_quote = rl_filename_quote_characters
|
||||
? (rl_strpbrk (match, rl_filename_quote_characters) != 0)
|
||||
? (_rl_strpbrk (match, rl_filename_quote_characters) != 0)
|
||||
: 0;
|
||||
|
||||
do_replace = should_quote ? mtype : NO_MATCH;
|
||||
@ -1233,11 +1210,12 @@ rl_complete_internal (what_to_do)
|
||||
int what_to_do;
|
||||
{
|
||||
char **matches;
|
||||
Function *our_func;
|
||||
rl_compentry_func_t *our_func;
|
||||
int start, end, delimiter, found_quote, i;
|
||||
char *text, *saved_line_buffer;
|
||||
char quote_char;
|
||||
|
||||
RL_SETSTATE(RL_STATE_COMPLETING);
|
||||
/* Only the completion entry function can change these. */
|
||||
rl_filename_completion_desired = 0;
|
||||
rl_filename_quoting_desired = 1;
|
||||
@ -1246,7 +1224,7 @@ rl_complete_internal (what_to_do)
|
||||
saved_line_buffer = rl_line_buffer ? savestring (rl_line_buffer) : (char *)NULL;
|
||||
our_func = rl_completion_entry_function
|
||||
? rl_completion_entry_function
|
||||
: (Function *)filename_completion_function;
|
||||
: rl_filename_completion_function;
|
||||
|
||||
/* We now look backwards for the start of a filename/variable word. */
|
||||
end = rl_point;
|
||||
@ -1267,27 +1245,23 @@ rl_complete_internal (what_to_do)
|
||||
|
||||
if (matches == 0)
|
||||
{
|
||||
ding ();
|
||||
rl_ding ();
|
||||
FREE (saved_line_buffer);
|
||||
RL_UNSETSTATE(RL_STATE_COMPLETING);
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* If we are matching filenames, our_func will have been set to
|
||||
filename_completion_function */
|
||||
i = our_func == (Function *)filename_completion_function;
|
||||
#else
|
||||
/* If we are matching filenames, the attempted completion function will
|
||||
have set rl_filename_completion_desired to a non-zero value. The basic
|
||||
filename_completion_function does this. */
|
||||
rl_filename_completion_function does this. */
|
||||
i = rl_filename_completion_desired;
|
||||
#endif
|
||||
|
||||
if (postprocess_matches (&matches, i) == 0)
|
||||
{
|
||||
ding ();
|
||||
rl_ding ();
|
||||
FREE (saved_line_buffer);
|
||||
completion_changed_buffer = 0;
|
||||
RL_UNSETSTATE(RL_STATE_COMPLETING);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -1315,7 +1289,7 @@ rl_complete_internal (what_to_do)
|
||||
break;
|
||||
}
|
||||
else if (rl_editing_mode != vi_mode)
|
||||
ding (); /* There are other matches remaining. */
|
||||
rl_ding (); /* There are other matches remaining. */
|
||||
}
|
||||
else
|
||||
append_to_match (matches[0], delimiter, quote_char);
|
||||
@ -1332,8 +1306,9 @@ rl_complete_internal (what_to_do)
|
||||
|
||||
default:
|
||||
fprintf (stderr, "\r\nreadline: bad value %d for what_to_do in rl_complete\n", what_to_do);
|
||||
ding ();
|
||||
rl_ding ();
|
||||
FREE (saved_line_buffer);
|
||||
RL_UNSETSTATE(RL_STATE_COMPLETING);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1346,6 +1321,7 @@ rl_complete_internal (what_to_do)
|
||||
free (saved_line_buffer);
|
||||
}
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_COMPLETING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1368,9 +1344,9 @@ rl_complete_internal (what_to_do)
|
||||
when there are no more matches.
|
||||
*/
|
||||
char **
|
||||
completion_matches (text, entry_function)
|
||||
char *text;
|
||||
CPFunction *entry_function;
|
||||
rl_completion_matches (text, entry_function)
|
||||
const char *text;
|
||||
rl_compentry_func_t *entry_function;
|
||||
{
|
||||
/* Number of slots in match_list. */
|
||||
int match_list_size;
|
||||
@ -1415,8 +1391,8 @@ completion_matches (text, entry_function)
|
||||
TEXT contains a partial username preceded by a random
|
||||
character (usually `~'). */
|
||||
char *
|
||||
username_completion_function (text, state)
|
||||
char *text;
|
||||
rl_username_completion_function (text, state)
|
||||
const char *text;
|
||||
int state;
|
||||
{
|
||||
#if defined (__WIN32__) || defined (__OPENNT)
|
||||
@ -1472,8 +1448,8 @@ username_completion_function (text, state)
|
||||
because of all the pathnames that must be followed when looking up the
|
||||
completion for a command. */
|
||||
char *
|
||||
filename_completion_function (text, state)
|
||||
char *text;
|
||||
rl_filename_completion_function (text, state)
|
||||
const char *text;
|
||||
int state;
|
||||
{
|
||||
static DIR *directory = (DIR *)NULL;
|
||||
@ -1543,6 +1519,9 @@ filename_completion_function (text, state)
|
||||
dirname = temp;
|
||||
}
|
||||
|
||||
if (rl_directory_rewrite_hook)
|
||||
(*rl_directory_rewrite_hook) (&dirname);
|
||||
|
||||
if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&dirname))
|
||||
{
|
||||
free (users_dirname);
|
||||
@ -1642,8 +1621,11 @@ filename_completion_function (text, state)
|
||||
else
|
||||
{
|
||||
dirlen = strlen (users_dirname);
|
||||
temp = xmalloc (1 + dirlen + D_NAMLEN (entry));
|
||||
temp = xmalloc (2 + dirlen + D_NAMLEN (entry));
|
||||
strcpy (temp, users_dirname);
|
||||
/* Make sure that temp has a trailing slash here. */
|
||||
if (users_dirname[dirlen - 1] != '/')
|
||||
temp[dirlen++] = '/';
|
||||
}
|
||||
|
||||
strcpy (temp + dirlen, entry->d_name);
|
||||
@ -1668,7 +1650,7 @@ int
|
||||
rl_menu_complete (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
Function *our_func;
|
||||
rl_compentry_func_t *our_func;
|
||||
int matching_filenames, found_quote;
|
||||
|
||||
static char *orig_text;
|
||||
@ -1698,7 +1680,7 @@ rl_menu_complete (count, ignore)
|
||||
|
||||
our_func = rl_completion_entry_function
|
||||
? rl_completion_entry_function
|
||||
: (Function *)filename_completion_function;
|
||||
: rl_filename_completion_function;
|
||||
|
||||
/* We now look backwards for the start of a filename/variable word. */
|
||||
orig_end = rl_point;
|
||||
@ -1717,19 +1699,14 @@ rl_menu_complete (count, ignore)
|
||||
matches = gen_completion_matches (orig_text, orig_start, orig_end,
|
||||
our_func, found_quote, quote_char);
|
||||
|
||||
#if 0
|
||||
/* If we are matching filenames, our_func will have been set to
|
||||
filename_completion_function */
|
||||
matching_filenames = our_func == (Function *)filename_completion_function;
|
||||
#else
|
||||
/* If we are matching filenames, the attempted completion function will
|
||||
have set rl_filename_completion_desired to a non-zero value. The basic
|
||||
filename_completion_function does this. */
|
||||
rl_filename_completion_function does this. */
|
||||
matching_filenames = rl_filename_completion_desired;
|
||||
#endif
|
||||
|
||||
if (matches == 0 || postprocess_matches (&matches, matching_filenames) == 0)
|
||||
{
|
||||
ding ();
|
||||
rl_ding ();
|
||||
FREE (matches);
|
||||
matches = (char **)0;
|
||||
FREE (orig_text);
|
||||
@ -1750,7 +1727,7 @@ rl_menu_complete (count, ignore)
|
||||
|
||||
if (matches == 0 || match_list_size == 0)
|
||||
{
|
||||
ding ();
|
||||
rl_ding ();
|
||||
FREE (matches);
|
||||
matches = (char **)0;
|
||||
completion_changed_buffer = 0;
|
||||
@ -1763,7 +1740,7 @@ rl_menu_complete (count, ignore)
|
||||
|
||||
if (match_list_index == 0 && match_list_size > 1)
|
||||
{
|
||||
ding ();
|
||||
rl_ding ();
|
||||
insert_match (orig_text, orig_start, MULT_MATCH, "e_char);
|
||||
}
|
||||
else
|
||||
|
@ -60,7 +60,7 @@ extern char *strchr (), *strrchr ();
|
||||
#endif /* !strchr && !__STDC__ */
|
||||
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
extern char *term_forward_char;
|
||||
extern char *_rl_term_forward_char;
|
||||
#endif
|
||||
|
||||
static void update_line __P((char *, char *, int, int, int, int));
|
||||
@ -104,7 +104,7 @@ static int inv_lbsize, vis_lbsize;
|
||||
RL_DISPLAY_FIXED variable. This is good for efficiency. */
|
||||
|
||||
/* Application-specific redisplay function. */
|
||||
VFunction *rl_redisplay_function = rl_redisplay;
|
||||
rl_voidfunc_t *rl_redisplay_function = rl_redisplay;
|
||||
|
||||
/* Global variables declared here. */
|
||||
/* What YOU turn on when you have handled all redisplay yourself. */
|
||||
@ -143,27 +143,40 @@ static int forced_display;
|
||||
/* Default and initial buffer size. Can grow. */
|
||||
static int line_size = 1024;
|
||||
|
||||
/* Variables to keep track of the expanded prompt string, which may
|
||||
include invisible characters. */
|
||||
|
||||
static char *local_prompt, *local_prompt_prefix;
|
||||
static int visible_length, prefix_length;
|
||||
static int prompt_visible_length, prompt_prefix_length;
|
||||
|
||||
/* The number of invisible characters in the line currently being
|
||||
displayed on the screen. */
|
||||
static int visible_wrap_offset;
|
||||
|
||||
/* static so it can be shared between rl_redisplay and update_line */
|
||||
/* The number of invisible characters in the prompt string. Static so it
|
||||
can be shared between rl_redisplay and update_line */
|
||||
static int wrap_offset;
|
||||
|
||||
/* The index of the last invisible_character in the prompt string. */
|
||||
static int last_invisible;
|
||||
/* The index of the last invisible character in the prompt string. */
|
||||
static int prompt_last_invisible;
|
||||
|
||||
/* The length (buffer offset) of the first line of the last (possibly
|
||||
multi-line) buffer displayed on the screen. */
|
||||
static int visible_first_line_len;
|
||||
|
||||
/* Number of invisible characters on the first physical line of the prompt.
|
||||
Only valid when the number of physical characters in the prompt exceeds
|
||||
(or is equal to) _rl_screenwidth. */
|
||||
static int prompt_invis_chars_first_line;
|
||||
|
||||
static int prompt_last_screen_line;
|
||||
|
||||
/* Expand the prompt string S and return the number of visible
|
||||
characters in *LP, if LP is not null. This is currently more-or-less
|
||||
a placeholder for expansion. LIP, if non-null is a place to store the
|
||||
index of the last invisible character in the returned string. */
|
||||
index of the last invisible character in the returned string. NIFLP,
|
||||
if non-zero, is a place to store the number of invisible characters in
|
||||
the first prompt line. */
|
||||
|
||||
/* Current implementation:
|
||||
\001 (^A) start non-visible characters
|
||||
@ -173,12 +186,12 @@ static int visible_first_line_len;
|
||||
\002 are assumed to be `visible'. */
|
||||
|
||||
static char *
|
||||
expand_prompt (pmt, lp, lip)
|
||||
expand_prompt (pmt, lp, lip, niflp)
|
||||
char *pmt;
|
||||
int *lp, *lip;
|
||||
int *lp, *lip, *niflp;
|
||||
{
|
||||
char *r, *ret, *p;
|
||||
int l, rl, last, ignoring;
|
||||
int l, rl, last, ignoring, ninvis, invfl;
|
||||
|
||||
/* Short-circuit if we can. */
|
||||
if (strchr (pmt, RL_PROMPT_START_IGNORE) == 0)
|
||||
@ -191,8 +204,10 @@ expand_prompt (pmt, lp, lip)
|
||||
|
||||
l = strlen (pmt);
|
||||
r = ret = xmalloc (l + 1);
|
||||
|
||||
for (rl = ignoring = last = 0, p = pmt; p && *p; p++)
|
||||
|
||||
invfl = 0; /* invisible chars in first line of prompt */
|
||||
|
||||
for (rl = ignoring = last = ninvis = 0, p = pmt; p && *p; p++)
|
||||
{
|
||||
/* This code strips the invisible character string markers
|
||||
RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */
|
||||
@ -212,14 +227,23 @@ expand_prompt (pmt, lp, lip)
|
||||
*r++ = *p;
|
||||
if (!ignoring)
|
||||
rl++;
|
||||
else
|
||||
ninvis++;
|
||||
if (rl == _rl_screenwidth)
|
||||
invfl = ninvis;
|
||||
}
|
||||
}
|
||||
|
||||
if (rl < _rl_screenwidth)
|
||||
invfl = ninvis;
|
||||
|
||||
*r = '\0';
|
||||
if (lp)
|
||||
*lp = rl;
|
||||
if (lip)
|
||||
*lip = last;
|
||||
if (niflp)
|
||||
*niflp = invfl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -231,7 +255,7 @@ _rl_strip_prompt (pmt)
|
||||
{
|
||||
char *ret;
|
||||
|
||||
ret = expand_prompt (pmt, (int *)NULL, (int *)NULL);
|
||||
ret = expand_prompt (pmt, (int *)NULL, (int *)NULL, (int *)NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -243,8 +267,8 @@ _rl_strip_prompt (pmt)
|
||||
* (portion after the final newline)
|
||||
* local_prompt_prefix = portion before last newline of rl_display_prompt,
|
||||
* expanded via expand_prompt
|
||||
* visible_length = number of visible characters in local_prompt
|
||||
* prefix_length = number of visible characters in local_prompt_prefix
|
||||
* prompt_visible_length = number of visible characters in local_prompt
|
||||
* prompt_prefix_length = number of visible characters in local_prompt_prefix
|
||||
*
|
||||
* This function is called once per call to readline(). It may also be
|
||||
* called arbitrarily to expand the primary prompt.
|
||||
@ -260,12 +284,11 @@ rl_expand_prompt (prompt)
|
||||
int c;
|
||||
|
||||
/* Clear out any saved values. */
|
||||
if (local_prompt)
|
||||
free (local_prompt);
|
||||
if (local_prompt_prefix)
|
||||
free (local_prompt_prefix);
|
||||
FREE (local_prompt);
|
||||
FREE (local_prompt_prefix);
|
||||
|
||||
local_prompt = local_prompt_prefix = (char *)0;
|
||||
last_invisible = visible_length = 0;
|
||||
prompt_last_invisible = prompt_visible_length = 0;
|
||||
|
||||
if (prompt == 0 || *prompt == 0)
|
||||
return (0);
|
||||
@ -273,22 +296,28 @@ rl_expand_prompt (prompt)
|
||||
p = strrchr (prompt, '\n');
|
||||
if (!p)
|
||||
{
|
||||
/* The prompt is only one line. */
|
||||
local_prompt = expand_prompt (prompt, &visible_length, &last_invisible);
|
||||
/* The prompt is only one logical line, though it might wrap. */
|
||||
local_prompt = expand_prompt (prompt, &prompt_visible_length,
|
||||
&prompt_last_invisible,
|
||||
&prompt_invis_chars_first_line);
|
||||
local_prompt_prefix = (char *)0;
|
||||
return (visible_length);
|
||||
return (prompt_visible_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The prompt spans multiple lines. */
|
||||
t = ++p;
|
||||
local_prompt = expand_prompt (p, &visible_length, &last_invisible);
|
||||
local_prompt = expand_prompt (p, &prompt_visible_length,
|
||||
&prompt_last_invisible,
|
||||
&prompt_invis_chars_first_line);
|
||||
c = *t; *t = '\0';
|
||||
/* The portion of the prompt string up to and including the
|
||||
final newline is now null-terminated. */
|
||||
local_prompt_prefix = expand_prompt (prompt, &prefix_length, (int *)NULL);
|
||||
local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length,
|
||||
(int *)NULL,
|
||||
&prompt_invis_chars_first_line);
|
||||
*t = c;
|
||||
return (prefix_length);
|
||||
return (prompt_prefix_length);
|
||||
}
|
||||
}
|
||||
|
||||
@ -400,7 +429,7 @@ rl_redisplay ()
|
||||
out += local_len;
|
||||
}
|
||||
line[out] = '\0';
|
||||
wrap_offset = local_len - visible_length;
|
||||
wrap_offset = local_len - prompt_visible_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -433,7 +462,7 @@ rl_redisplay ()
|
||||
strncpy (line + out, prompt_this_line, pmtlen);
|
||||
out += pmtlen;
|
||||
line[out] = '\0';
|
||||
wrap_offset = 0;
|
||||
wrap_offset = prompt_invis_chars_first_line = 0;
|
||||
}
|
||||
|
||||
#define CHECK_INV_LBREAKS() \
|
||||
@ -448,7 +477,7 @@ rl_redisplay ()
|
||||
#define CHECK_LPOS() \
|
||||
do { \
|
||||
lpos++; \
|
||||
if (lpos >= screenwidth) \
|
||||
if (lpos >= _rl_screenwidth) \
|
||||
{ \
|
||||
if (newlines >= (inv_lbsize - 2)) \
|
||||
{ \
|
||||
@ -464,21 +493,36 @@ rl_redisplay ()
|
||||
inv_lbreaks[newlines = 0] = 0;
|
||||
lpos = out - wrap_offset;
|
||||
|
||||
/* XXX - what if lpos is already >= screenwidth before we start drawing the
|
||||
/* prompt_invis_chars_first_line is the number of invisible characters in
|
||||
the first physical line of the prompt.
|
||||
wrap_offset - prompt_invis_chars_first_line is the number of invis
|
||||
chars on the second line. */
|
||||
|
||||
/* what if lpos is already >= _rl_screenwidth before we start drawing the
|
||||
contents of the command line? */
|
||||
while (lpos >= screenwidth)
|
||||
while (lpos >= _rl_screenwidth)
|
||||
{
|
||||
/* XXX - possible fix from Darin Johnson <darin@acuson.com> for prompt
|
||||
string with invisible characters that is longer than the screen
|
||||
width. XXX - this doesn't work right if invisible characters have
|
||||
to be put on the second screen line -- it adds too much (the number
|
||||
of invisible chars after the screenwidth). */
|
||||
temp = ((newlines + 1) * screenwidth) + ((newlines == 0) ? wrap_offset : 0);
|
||||
/* fix from Darin Johnson <darin@acuson.com> for prompt string with
|
||||
invisible characters that is longer than the screen width. The
|
||||
prompt_invis_chars_first_line variable could be made into an array
|
||||
saying how many invisible characters there are per line, but that's
|
||||
probably too much work for the benefit gained. How many people have
|
||||
prompts that exceed two physical lines? */
|
||||
temp = ((newlines + 1) * _rl_screenwidth) +
|
||||
((newlines == 0) ? prompt_invis_chars_first_line : 0) +
|
||||
((newlines == 1) ? wrap_offset : 0);
|
||||
|
||||
inv_lbreaks[++newlines] = temp;
|
||||
lpos -= screenwidth;
|
||||
lpos -= _rl_screenwidth;
|
||||
}
|
||||
|
||||
prompt_last_screen_line = newlines;
|
||||
|
||||
/* Draw the rest of the line (after the prompt) into invisible_line, keeping
|
||||
track of where the cursor is (c_pos), the number of the line containing
|
||||
the cursor (lb_linenum), the last line number (lb_botlin and inv_botlin).
|
||||
It maintains an array of line breaks for display (inv_lbreaks).
|
||||
This handles expanding tabs for display and displaying meta characters. */
|
||||
lb_linenum = 0;
|
||||
for (in = 0; in < rl_end; in++)
|
||||
{
|
||||
@ -504,9 +548,9 @@ rl_redisplay ()
|
||||
{
|
||||
sprintf (line + out, "\\%o", c);
|
||||
|
||||
if (lpos + 4 >= screenwidth)
|
||||
if (lpos + 4 >= _rl_screenwidth)
|
||||
{
|
||||
temp = screenwidth - lpos;
|
||||
temp = _rl_screenwidth - lpos;
|
||||
CHECK_INV_LBREAKS ();
|
||||
inv_lbreaks[++newlines] = out + temp;
|
||||
lpos = 4 - temp;
|
||||
@ -525,7 +569,7 @@ rl_redisplay ()
|
||||
#if defined (DISPLAY_TABS)
|
||||
else if (c == '\t')
|
||||
{
|
||||
register int temp, newout;
|
||||
register int newout;
|
||||
|
||||
#if 0
|
||||
newout = (out | (int)7) + 1;
|
||||
@ -533,10 +577,10 @@ rl_redisplay ()
|
||||
newout = out + 8 - lpos % 8;
|
||||
#endif
|
||||
temp = newout - out;
|
||||
if (lpos + temp >= screenwidth)
|
||||
if (lpos + temp >= _rl_screenwidth)
|
||||
{
|
||||
register int temp2;
|
||||
temp2 = screenwidth - lpos;
|
||||
temp2 = _rl_screenwidth - lpos;
|
||||
CHECK_INV_LBREAKS ();
|
||||
inv_lbreaks[++newlines] = out + temp2;
|
||||
lpos = temp - temp2;
|
||||
@ -551,7 +595,7 @@ rl_redisplay ()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && term_up && *term_up)
|
||||
else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
|
||||
{
|
||||
line[out++] = '\0'; /* XXX - sentinel */
|
||||
CHECK_INV_LBREAKS ();
|
||||
@ -583,7 +627,8 @@ rl_redisplay ()
|
||||
inv_lbreaks[newlines+1] = out;
|
||||
cursor_linenum = lb_linenum;
|
||||
|
||||
/* C_POS == position in buffer where cursor should be placed. */
|
||||
/* C_POS == position in buffer where cursor should be placed.
|
||||
CURSOR_LINENUM == line number where the cursor should be placed. */
|
||||
|
||||
/* PWP: now is when things get a bit hairy. The visible and invisible
|
||||
line buffers are really multiple lines, which would wrap every
|
||||
@ -594,7 +639,7 @@ rl_redisplay ()
|
||||
otherwise, let long lines display in a single terminal line, and
|
||||
horizontally scroll it. */
|
||||
|
||||
if (_rl_horizontal_scroll_mode == 0 && term_up && *term_up)
|
||||
if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
|
||||
{
|
||||
int nleft, pos, changed_screen_line;
|
||||
|
||||
@ -605,8 +650,8 @@ rl_redisplay ()
|
||||
/* If we have more than a screenful of material to display, then
|
||||
only display a screenful. We should display the last screen,
|
||||
not the first. */
|
||||
if (out >= screenchars)
|
||||
out = screenchars - 1;
|
||||
if (out >= _rl_screenchars)
|
||||
out = _rl_screenchars - 1;
|
||||
|
||||
/* The first line is at character position 0 in the buffer. The
|
||||
second and subsequent lines start at inv_lbreaks[N], offset by
|
||||
@ -636,7 +681,7 @@ rl_redisplay ()
|
||||
(wrap_offset > visible_wrap_offset) &&
|
||||
(_rl_last_c_pos < visible_first_line_len))
|
||||
{
|
||||
nleft = screenwidth + wrap_offset - _rl_last_c_pos;
|
||||
nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
|
||||
if (nleft)
|
||||
_rl_clear_to_eol (nleft);
|
||||
}
|
||||
@ -657,7 +702,7 @@ rl_redisplay ()
|
||||
_rl_move_vert (linenum);
|
||||
_rl_move_cursor_relative (0, tt);
|
||||
_rl_clear_to_eol
|
||||
((linenum == _rl_vis_botlin) ? strlen (tt) : screenwidth);
|
||||
((linenum == _rl_vis_botlin) ? strlen (tt) : _rl_screenwidth);
|
||||
}
|
||||
}
|
||||
_rl_vis_botlin = inv_botlin;
|
||||
@ -668,7 +713,7 @@ rl_redisplay ()
|
||||
if (changed_screen_line)
|
||||
{
|
||||
_rl_move_vert (cursor_linenum);
|
||||
/* If we moved up to the line with the prompt using term_up,
|
||||
/* If we moved up to the line with the prompt using _rl_term_up,
|
||||
the physical cursor position on the screen stays the same,
|
||||
but the buffer position needs to be adjusted to account
|
||||
for invisible characters. */
|
||||
@ -681,15 +726,15 @@ rl_redisplay ()
|
||||
the characters from the current cursor position. But we
|
||||
only need to reprint it if the cursor is before the last
|
||||
invisible character in the prompt string. */
|
||||
nleft = visible_length + wrap_offset;
|
||||
nleft = prompt_visible_length + wrap_offset;
|
||||
if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 &&
|
||||
_rl_last_c_pos <= last_invisible && local_prompt)
|
||||
_rl_last_c_pos <= prompt_last_invisible && local_prompt)
|
||||
{
|
||||
#if defined (__MSDOS__)
|
||||
putc ('\r', rl_outstream);
|
||||
#else
|
||||
if (term_cr)
|
||||
tputs (term_cr, 1, _rl_output_character_function);
|
||||
if (_rl_term_cr)
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif
|
||||
_rl_output_some_chars (local_prompt, nleft);
|
||||
_rl_last_c_pos = nleft;
|
||||
@ -728,11 +773,11 @@ rl_redisplay ()
|
||||
|
||||
/* The number of characters that will be displayed before the cursor. */
|
||||
ndisp = c_pos - wrap_offset;
|
||||
nleft = visible_length + wrap_offset;
|
||||
nleft = prompt_visible_length + wrap_offset;
|
||||
/* Where the new cursor position will be on the screen. This can be
|
||||
longer than SCREENWIDTH; if it is, lmargin will be adjusted. */
|
||||
phys_c_pos = c_pos - (last_lmargin ? last_lmargin : wrap_offset);
|
||||
t = screenwidth / 3;
|
||||
t = _rl_screenwidth / 3;
|
||||
|
||||
/* If the number of characters had already exceeded the screenwidth,
|
||||
last_lmargin will be > 0. */
|
||||
@ -740,7 +785,7 @@ rl_redisplay ()
|
||||
/* If the number of characters to be displayed is more than the screen
|
||||
width, compute the starting offset so that the cursor is about
|
||||
two-thirds of the way across the screen. */
|
||||
if (phys_c_pos > screenwidth - 2)
|
||||
if (phys_c_pos > _rl_screenwidth - 2)
|
||||
{
|
||||
lmargin = c_pos - (2 * t);
|
||||
if (lmargin < 0)
|
||||
@ -750,7 +795,7 @@ rl_redisplay ()
|
||||
if (wrap_offset && lmargin > 0 && lmargin < nleft)
|
||||
lmargin = nleft;
|
||||
}
|
||||
else if (ndisp < screenwidth - 2) /* XXX - was -1 */
|
||||
else if (ndisp < _rl_screenwidth - 2) /* XXX - was -1 */
|
||||
lmargin = 0;
|
||||
else if (phys_c_pos < 1)
|
||||
{
|
||||
@ -772,7 +817,7 @@ rl_redisplay ()
|
||||
the whole line, indicate that with a special character at the
|
||||
right edge of the screen. If LMARGIN is 0, we need to take the
|
||||
wrap offset into account. */
|
||||
t = lmargin + M_OFFSET (lmargin, wrap_offset) + screenwidth;
|
||||
t = lmargin + M_OFFSET (lmargin, wrap_offset) + _rl_screenwidth;
|
||||
if (t < out)
|
||||
line[t - 1] = '>';
|
||||
|
||||
@ -782,8 +827,8 @@ rl_redisplay ()
|
||||
update_line (&visible_line[last_lmargin],
|
||||
&invisible_line[lmargin],
|
||||
0,
|
||||
screenwidth + visible_wrap_offset,
|
||||
screenwidth + (lmargin ? 0 : wrap_offset),
|
||||
_rl_screenwidth + visible_wrap_offset,
|
||||
_rl_screenwidth + (lmargin ? 0 : wrap_offset),
|
||||
0);
|
||||
|
||||
/* If the visible new line is shorter than the old, but the number
|
||||
@ -794,12 +839,12 @@ rl_redisplay ()
|
||||
(_rl_last_c_pos == out) &&
|
||||
t < visible_first_line_len)
|
||||
{
|
||||
nleft = screenwidth - t;
|
||||
nleft = _rl_screenwidth - t;
|
||||
_rl_clear_to_eol (nleft);
|
||||
}
|
||||
visible_first_line_len = out - lmargin - M_OFFSET (lmargin, wrap_offset);
|
||||
if (visible_first_line_len > screenwidth)
|
||||
visible_first_line_len = screenwidth;
|
||||
if (visible_first_line_len > _rl_screenwidth)
|
||||
visible_first_line_len = _rl_screenwidth;
|
||||
|
||||
_rl_move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]);
|
||||
last_lmargin = lmargin;
|
||||
@ -809,11 +854,11 @@ rl_redisplay ()
|
||||
|
||||
/* Swap visible and non-visible lines. */
|
||||
{
|
||||
char *temp = visible_line;
|
||||
char *vtemp = visible_line;
|
||||
int *itemp = vis_lbreaks, ntemp = vis_lbsize;
|
||||
|
||||
visible_line = invisible_line;
|
||||
invisible_line = temp;
|
||||
invisible_line = vtemp;
|
||||
|
||||
vis_lbreaks = inv_lbreaks;
|
||||
inv_lbreaks = itemp;
|
||||
@ -863,7 +908,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
emulators. In this calculation, TEMP is the physical screen
|
||||
position of the cursor. */
|
||||
temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
|
||||
if (temp == screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
|
||||
if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
|
||||
&& _rl_last_v_pos == current_line - 1)
|
||||
{
|
||||
if (new[0])
|
||||
@ -940,13 +985,13 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
lendiff = local_prompt ? strlen (local_prompt) : 0;
|
||||
od = ofd - old; /* index of first difference in visible line */
|
||||
if (current_line == 0 && !_rl_horizontal_scroll_mode &&
|
||||
term_cr && lendiff > visible_length && _rl_last_c_pos > 0 &&
|
||||
od > lendiff && _rl_last_c_pos < last_invisible)
|
||||
_rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 &&
|
||||
od >= lendiff && _rl_last_c_pos <= prompt_last_invisible)
|
||||
{
|
||||
#if defined (__MSDOS__)
|
||||
putc ('\r', rl_outstream);
|
||||
#else
|
||||
tputs (term_cr, 1, _rl_output_character_function);
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif
|
||||
_rl_output_some_chars (local_prompt, lendiff);
|
||||
_rl_last_c_pos = lendiff;
|
||||
@ -974,14 +1019,14 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
use the terminal's capabilities. If we're growing the number
|
||||
of lines, make sure we actually cause the new line to wrap
|
||||
around on auto-wrapping terminals. */
|
||||
if (terminal_can_insert && ((2 * temp) >= lendiff || term_IC) && (!_rl_term_autowrap || !gl))
|
||||
if (_rl_terminal_can_insert && ((2 * temp) >= lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
|
||||
{
|
||||
/* If lendiff > visible_length and _rl_last_c_pos == 0 and
|
||||
/* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and
|
||||
_rl_horizontal_scroll_mode == 1, inserting the characters with
|
||||
term_IC or term_ic will screw up the screen because of the
|
||||
_rl_term_IC or _rl_term_ic will screw up the screen because of the
|
||||
invisible characters. We need to just draw them. */
|
||||
if (*ols && (!_rl_horizontal_scroll_mode || _rl_last_c_pos > 0 ||
|
||||
lendiff <= visible_length || !current_invis_chars))
|
||||
lendiff <= prompt_visible_length || !current_invis_chars))
|
||||
{
|
||||
insert_some_chars (nfd, lendiff);
|
||||
_rl_last_c_pos += lendiff;
|
||||
@ -1022,7 +1067,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
else /* Delete characters from line. */
|
||||
{
|
||||
/* If possible and inexpensive to use terminal deletion, then do so. */
|
||||
if (term_dc && (2 * temp) >= -lendiff)
|
||||
if (_rl_term_dc && (2 * temp) >= -lendiff)
|
||||
{
|
||||
/* If all we're doing is erasing the invisible characters in the
|
||||
prompt string, don't bother. It screws up the assumptions
|
||||
@ -1107,7 +1152,7 @@ rl_on_new_line_with_prompt ()
|
||||
/* Dissect prompt_last_line into screen lines. Note that here we have
|
||||
to use the real screenwidth. Readline's notion of screenwidth might be
|
||||
one less, see terminal.c. */
|
||||
real_screenwidth = screenwidth + (_rl_term_autowrap ? 0 : 1);
|
||||
real_screenwidth = _rl_screenwidth + (_rl_term_autowrap ? 0 : 1);
|
||||
_rl_last_v_pos = l / real_screenwidth;
|
||||
/* If the prompt length is a multiple of real_screenwidth, we don't know
|
||||
whether the cursor is at the end of the last line, or already at the
|
||||
@ -1152,7 +1197,7 @@ rl_forced_update_display ()
|
||||
void
|
||||
_rl_move_cursor_relative (new, data)
|
||||
int new;
|
||||
char *data;
|
||||
const char *data;
|
||||
{
|
||||
register int i;
|
||||
|
||||
@ -1164,12 +1209,12 @@ _rl_move_cursor_relative (new, data)
|
||||
/* i == current physical cursor position. */
|
||||
i = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
|
||||
if (new == 0 || CR_FASTER (new, _rl_last_c_pos) ||
|
||||
(_rl_term_autowrap && i == screenwidth))
|
||||
(_rl_term_autowrap && i == _rl_screenwidth))
|
||||
{
|
||||
#if defined (__MSDOS__)
|
||||
putc ('\r', rl_outstream);
|
||||
#else
|
||||
tputs (term_cr, 1, _rl_output_character_function);
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif /* !__MSDOS__ */
|
||||
_rl_last_c_pos = 0;
|
||||
}
|
||||
@ -1186,9 +1231,9 @@ _rl_move_cursor_relative (new, data)
|
||||
That kind of control is for people who don't know what the
|
||||
data is underneath the cursor. */
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
if (term_forward_char)
|
||||
if (_rl_term_forward_char)
|
||||
for (i = _rl_last_c_pos; i < new; i++)
|
||||
tputs (term_forward_char, 1, _rl_output_character_function);
|
||||
tputs (_rl_term_forward_char, 1, _rl_output_character_function);
|
||||
else
|
||||
for (i = _rl_last_c_pos; i < new; i++)
|
||||
putc (data[i], rl_outstream);
|
||||
@ -1209,7 +1254,7 @@ _rl_move_vert (to)
|
||||
{
|
||||
register int delta, i;
|
||||
|
||||
if (_rl_last_v_pos == to || to > screenheight)
|
||||
if (_rl_last_v_pos == to || to > _rl_screenheight)
|
||||
return;
|
||||
|
||||
if ((delta = to - _rl_last_v_pos) > 0)
|
||||
@ -1219,15 +1264,15 @@ _rl_move_vert (to)
|
||||
#if defined (__MSDOS__)
|
||||
putc ('\r', rl_outstream);
|
||||
#else
|
||||
tputs (term_cr, 1, _rl_output_character_function);
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif
|
||||
_rl_last_c_pos = 0;
|
||||
}
|
||||
else
|
||||
{ /* delta < 0 */
|
||||
if (term_up && *term_up)
|
||||
if (_rl_term_up && *_rl_term_up)
|
||||
for (i = 0; i < -delta; i++)
|
||||
tputs (term_up, 1, _rl_output_character_function);
|
||||
tputs (_rl_term_up, 1, _rl_output_character_function);
|
||||
}
|
||||
|
||||
_rl_last_v_pos = to; /* Now TO is here */
|
||||
@ -1361,25 +1406,23 @@ rl_save_prompt ()
|
||||
{
|
||||
saved_local_prompt = local_prompt;
|
||||
saved_local_prefix = local_prompt_prefix;
|
||||
saved_last_invisible = last_invisible;
|
||||
saved_visible_length = visible_length;
|
||||
saved_last_invisible = prompt_last_invisible;
|
||||
saved_visible_length = prompt_visible_length;
|
||||
|
||||
local_prompt = local_prompt_prefix = (char *)0;
|
||||
last_invisible = visible_length = 0;
|
||||
prompt_last_invisible = prompt_visible_length = 0;
|
||||
}
|
||||
|
||||
void
|
||||
rl_restore_prompt ()
|
||||
{
|
||||
if (local_prompt)
|
||||
free (local_prompt);
|
||||
if (local_prompt_prefix)
|
||||
free (local_prompt_prefix);
|
||||
FREE (local_prompt);
|
||||
FREE (local_prompt_prefix);
|
||||
|
||||
local_prompt = saved_local_prompt;
|
||||
local_prompt_prefix = saved_local_prefix;
|
||||
last_invisible = saved_last_invisible;
|
||||
visible_length = saved_visible_length;
|
||||
prompt_last_invisible = saved_last_invisible;
|
||||
prompt_visible_length = saved_visible_length;
|
||||
}
|
||||
|
||||
char *
|
||||
@ -1409,8 +1452,8 @@ _rl_make_prompt_for_search (pchar)
|
||||
pmt[len] = pchar;
|
||||
pmt[len+1] = '\0';
|
||||
local_prompt = savestring (pmt);
|
||||
last_invisible = saved_last_invisible;
|
||||
visible_length = saved_visible_length + 1;
|
||||
prompt_last_invisible = saved_last_invisible;
|
||||
prompt_visible_length = saved_visible_length + 1;
|
||||
}
|
||||
return pmt;
|
||||
}
|
||||
@ -1437,8 +1480,8 @@ void
|
||||
_rl_clear_to_eol (count)
|
||||
int count;
|
||||
{
|
||||
if (term_clreol)
|
||||
tputs (term_clreol, 1, _rl_output_character_function);
|
||||
if (_rl_term_clreol)
|
||||
tputs (_rl_term_clreol, 1, _rl_output_character_function);
|
||||
else if (count)
|
||||
space_to_eol (count);
|
||||
}
|
||||
@ -1460,10 +1503,10 @@ space_to_eol (count)
|
||||
void
|
||||
_rl_clear_screen ()
|
||||
{
|
||||
if (term_clrpag)
|
||||
tputs (term_clrpag, 1, _rl_output_character_function);
|
||||
if (_rl_term_clrpag)
|
||||
tputs (_rl_term_clrpag, 1, _rl_output_character_function);
|
||||
else
|
||||
crlf ();
|
||||
rl_crlf ();
|
||||
}
|
||||
|
||||
/* Insert COUNT characters from STRING to the output stream. */
|
||||
@ -1473,10 +1516,10 @@ insert_some_chars (string, count)
|
||||
int count;
|
||||
{
|
||||
/* If IC is defined, then we do not have to "enter" insert mode. */
|
||||
if (term_IC)
|
||||
if (_rl_term_IC)
|
||||
{
|
||||
char *buffer;
|
||||
buffer = tgoto (term_IC, 0, count);
|
||||
buffer = tgoto (_rl_term_IC, 0, count);
|
||||
tputs (buffer, 1, _rl_output_character_function);
|
||||
_rl_output_some_chars (string, count);
|
||||
}
|
||||
@ -1485,15 +1528,15 @@ insert_some_chars (string, count)
|
||||
register int i;
|
||||
|
||||
/* If we have to turn on insert-mode, then do so. */
|
||||
if (term_im && *term_im)
|
||||
tputs (term_im, 1, _rl_output_character_function);
|
||||
if (_rl_term_im && *_rl_term_im)
|
||||
tputs (_rl_term_im, 1, _rl_output_character_function);
|
||||
|
||||
/* If there is a special command for inserting characters, then
|
||||
use that first to open up the space. */
|
||||
if (term_ic && *term_ic)
|
||||
if (_rl_term_ic && *_rl_term_ic)
|
||||
{
|
||||
for (i = count; i--; )
|
||||
tputs (term_ic, 1, _rl_output_character_function);
|
||||
tputs (_rl_term_ic, 1, _rl_output_character_function);
|
||||
}
|
||||
|
||||
/* Print the text. */
|
||||
@ -1501,8 +1544,8 @@ insert_some_chars (string, count)
|
||||
|
||||
/* If there is a string to turn off insert mode, we had best use
|
||||
it now. */
|
||||
if (term_ei && *term_ei)
|
||||
tputs (term_ei, 1, _rl_output_character_function);
|
||||
if (_rl_term_ei && *_rl_term_ei)
|
||||
tputs (_rl_term_ei, 1, _rl_output_character_function);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1511,20 +1554,20 @@ static void
|
||||
delete_chars (count)
|
||||
int count;
|
||||
{
|
||||
if (count > screenwidth) /* XXX */
|
||||
if (count > _rl_screenwidth) /* XXX */
|
||||
return;
|
||||
|
||||
if (term_DC && *term_DC)
|
||||
if (_rl_term_DC && *_rl_term_DC)
|
||||
{
|
||||
char *buffer;
|
||||
buffer = tgoto (term_DC, count, count);
|
||||
buffer = tgoto (_rl_term_DC, count, count);
|
||||
tputs (buffer, count, _rl_output_character_function);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (term_dc && *term_dc)
|
||||
if (_rl_term_dc && *_rl_term_dc)
|
||||
while (count--)
|
||||
tputs (term_dc, 1, _rl_output_character_function);
|
||||
tputs (_rl_term_dc, 1, _rl_output_character_function);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1544,7 +1587,7 @@ _rl_update_final ()
|
||||
}
|
||||
_rl_move_vert (_rl_vis_botlin);
|
||||
/* If we've wrapped lines, remove the final xterm line-wrap flag. */
|
||||
if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == screenwidth))
|
||||
if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == _rl_screenwidth))
|
||||
{
|
||||
char *last_line;
|
||||
#if 0
|
||||
@ -1552,12 +1595,12 @@ _rl_update_final ()
|
||||
#else
|
||||
last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]];
|
||||
#endif
|
||||
_rl_move_cursor_relative (screenwidth - 1, last_line);
|
||||
_rl_move_cursor_relative (_rl_screenwidth - 1, last_line);
|
||||
_rl_clear_to_eol (0);
|
||||
putc (last_line[screenwidth - 1], rl_outstream);
|
||||
putc (last_line[_rl_screenwidth - 1], rl_outstream);
|
||||
}
|
||||
_rl_vis_botlin = 0;
|
||||
crlf ();
|
||||
rl_crlf ();
|
||||
fflush (rl_outstream);
|
||||
rl_display_fixed++;
|
||||
}
|
||||
@ -1566,12 +1609,12 @@ _rl_update_final ()
|
||||
static void
|
||||
cr ()
|
||||
{
|
||||
if (term_cr)
|
||||
if (_rl_term_cr)
|
||||
{
|
||||
#if defined (__MSDOS__)
|
||||
putc ('\r', rl_outstream);
|
||||
#else
|
||||
tputs (term_cr, 1, _rl_output_character_function);
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif
|
||||
_rl_last_c_pos = 0;
|
||||
}
|
||||
@ -1585,27 +1628,31 @@ redraw_prompt (t)
|
||||
char *t;
|
||||
{
|
||||
char *oldp, *oldl, *oldlprefix;
|
||||
int oldlen, oldlast, oldplen;
|
||||
int oldlen, oldlast, oldplen, oldninvis;
|
||||
|
||||
/* Geez, I should make this a struct. */
|
||||
oldp = rl_display_prompt;
|
||||
oldl = local_prompt;
|
||||
oldlprefix = local_prompt_prefix;
|
||||
oldlen = visible_length;
|
||||
oldplen = prefix_length;
|
||||
oldlast = last_invisible;
|
||||
oldlen = prompt_visible_length;
|
||||
oldplen = prompt_prefix_length;
|
||||
oldlast = prompt_last_invisible;
|
||||
oldninvis = prompt_invis_chars_first_line;
|
||||
|
||||
rl_display_prompt = t;
|
||||
local_prompt = expand_prompt (t, &visible_length, &last_invisible);
|
||||
local_prompt = expand_prompt (t, &prompt_visible_length,
|
||||
&prompt_last_invisible,
|
||||
&prompt_invis_chars_first_line);
|
||||
local_prompt_prefix = (char *)NULL;
|
||||
rl_forced_update_display ();
|
||||
|
||||
rl_display_prompt = oldp;
|
||||
local_prompt = oldl;
|
||||
local_prompt_prefix = oldlprefix;
|
||||
visible_length = oldlen;
|
||||
prefix_length = oldplen;
|
||||
last_invisible = oldlast;
|
||||
prompt_visible_length = oldlen;
|
||||
prompt_prefix_length = oldplen;
|
||||
prompt_last_invisible = oldlast;
|
||||
prompt_invis_chars_first_line = oldninvis;
|
||||
}
|
||||
|
||||
/* Redisplay the current line after a SIGWINCH is received. */
|
||||
@ -1616,31 +1663,31 @@ _rl_redisplay_after_sigwinch ()
|
||||
|
||||
/* Clear the current line and put the cursor at column 0. Make sure
|
||||
the right thing happens if we have wrapped to a new screen line. */
|
||||
if (term_cr)
|
||||
if (_rl_term_cr)
|
||||
{
|
||||
#if defined (__MSDOS__)
|
||||
putc ('\r', rl_outstream);
|
||||
#else
|
||||
tputs (term_cr, 1, _rl_output_character_function);
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif
|
||||
_rl_last_c_pos = 0;
|
||||
#if defined (__MSDOS__)
|
||||
space_to_eol (screenwidth);
|
||||
space_to_eol (_rl_screenwidth);
|
||||
putc ('\r', rl_outstream);
|
||||
#else
|
||||
if (term_clreol)
|
||||
tputs (term_clreol, 1, _rl_output_character_function);
|
||||
if (_rl_term_clreol)
|
||||
tputs (_rl_term_clreol, 1, _rl_output_character_function);
|
||||
else
|
||||
{
|
||||
space_to_eol (screenwidth);
|
||||
tputs (term_cr, 1, _rl_output_character_function);
|
||||
space_to_eol (_rl_screenwidth);
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
}
|
||||
#endif
|
||||
if (_rl_last_v_pos > 0)
|
||||
_rl_move_vert (0);
|
||||
}
|
||||
else
|
||||
crlf ();
|
||||
rl_crlf ();
|
||||
|
||||
/* Redraw only the last line of a multi-line prompt. */
|
||||
t = strrchr (rl_display_prompt, '\n');
|
||||
@ -1681,12 +1728,12 @@ _rl_current_display_line ()
|
||||
/* Find out whether or not there might be invisible characters in the
|
||||
editing buffer. */
|
||||
if (rl_display_prompt == rl_prompt)
|
||||
nleft = _rl_last_c_pos - screenwidth - rl_visible_prompt_length;
|
||||
nleft = _rl_last_c_pos - _rl_screenwidth - rl_visible_prompt_length;
|
||||
else
|
||||
nleft = _rl_last_c_pos - screenwidth;
|
||||
nleft = _rl_last_c_pos - _rl_screenwidth;
|
||||
|
||||
if (nleft > 0)
|
||||
ret = 1 + nleft / screenwidth;
|
||||
ret = 1 + nleft / _rl_screenwidth;
|
||||
else
|
||||
ret = 0;
|
||||
|
||||
|
@ -7,9 +7,9 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet@ins.CWRU.Edu
|
||||
.\"
|
||||
.\" Last Change: Tue Jun 1 13:28:03 EDT 1999
|
||||
.\" Last Change: Mon Mar 5 09:58:38 EST 2001
|
||||
.\"
|
||||
.TH READLINE 3 "1999 Jun 1" GNU
|
||||
.TH READLINE 3 "2001 Mar 5" "GNU Readline 4.2"
|
||||
.\"
|
||||
.\" File Name macro. This used to be `.PN', for Path Name,
|
||||
.\" but Sun doesn't seem to like that very much.
|
||||
@ -30,14 +30,13 @@ readline \- get a line from a user with editing
|
||||
.fi
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
char *readline (prompt)
|
||||
char *prompt;
|
||||
.ft
|
||||
\fIchar *\fP
|
||||
.br
|
||||
\fBreadline\fP (\fIconst char *prompt\fP);
|
||||
.fi
|
||||
.SH COPYRIGHT
|
||||
.if n Readline is Copyright (C) 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
|
||||
.if t Readline is Copyright \(co 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
|
||||
.if n Readline is Copyright (C) 1989\-2001 by the Free Software Foundation, Inc.
|
||||
.if t Readline is Copyright \(co 1989\-2001 by the Free Software Foundation, Inc.
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
.B readline
|
||||
@ -46,9 +45,10 @@ and return it, using
|
||||
.B prompt
|
||||
as a prompt. If
|
||||
.B prompt
|
||||
is null, no prompt is issued. The line returned is allocated with
|
||||
.IR malloc (3),
|
||||
so the caller must free it when finished. The line returned
|
||||
is \fBNULL\fP or the empty string, no prompt is issued.
|
||||
The line returned is allocated with
|
||||
.IR malloc (3);
|
||||
the caller must free it when finished. The line returned
|
||||
has the final newline removed, so only the text of the line
|
||||
remains.
|
||||
.LP
|
||||
@ -58,6 +58,11 @@ line.
|
||||
By default, the line editing commands
|
||||
are similar to those of emacs.
|
||||
A vi\-style line editing interface is also available.
|
||||
.LP
|
||||
This manual page describes only the most basic use of \fBreadline\fP.
|
||||
Much more functionality is available; see
|
||||
\fIThe GNU Readline Library\fP and \fIThe GNU History Library\fP
|
||||
for additional information.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
.B readline
|
||||
@ -131,6 +136,7 @@ or
|
||||
.RS
|
||||
C\-Meta\-u: universal\-argument
|
||||
.RE
|
||||
.sp
|
||||
into the
|
||||
.I inputrc
|
||||
would make M\-C\-u execute the readline command
|
||||
@ -138,15 +144,16 @@ would make M\-C\-u execute the readline command
|
||||
.PP
|
||||
The following symbolic character names are recognized while
|
||||
processing key bindings:
|
||||
.IR RUBOUT ,
|
||||
.IR DEL ,
|
||||
.IR ESC ,
|
||||
.IR ESCAPE ,
|
||||
.IR LFD ,
|
||||
.IR NEWLINE ,
|
||||
.IR RET ,
|
||||
.IR RETURN ,
|
||||
.IR SPC ,
|
||||
.IR RUBOUT ,
|
||||
.IR SPACE ,
|
||||
.IR SPC ,
|
||||
and
|
||||
.IR TAB .
|
||||
.PP
|
||||
@ -162,6 +169,7 @@ command or the text of a macro and a key sequence to which
|
||||
it should be bound. The name may be specified in one of two ways:
|
||||
as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
|
||||
prefixes, or as a key sequence.
|
||||
.PP
|
||||
When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP,
|
||||
.I keyname
|
||||
is the name of a key spelled out in English. For example:
|
||||
@ -171,7 +179,7 @@ Control\-u: universal\-argument
|
||||
.br
|
||||
Meta\-Rubout: backward\-kill\-word
|
||||
.br
|
||||
Control\-o: ">&output"
|
||||
Control\-o: "> output"
|
||||
.RE
|
||||
.LP
|
||||
In the above example,
|
||||
@ -185,7 +193,8 @@ and
|
||||
.I C\-o
|
||||
is bound to run the macro
|
||||
expressed on the right hand side (that is, to insert the text
|
||||
.I >&output
|
||||
.if t \f(CW> output\fP
|
||||
.if n ``> output''
|
||||
into the line).
|
||||
.PP
|
||||
In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
|
||||
@ -195,7 +204,8 @@ differs from
|
||||
above in that strings denoting
|
||||
an entire key sequence may be specified by placing the sequence
|
||||
within double quotes. Some GNU Emacs style key escapes can be
|
||||
used, as in the following example.
|
||||
used, as in the following example, but the symbolic character names
|
||||
are not recognized.
|
||||
.sp
|
||||
.RS
|
||||
"\eC\-u": universal\-argument
|
||||
@ -215,8 +225,11 @@ is bound to the function
|
||||
and
|
||||
.I "ESC [ 1 1 ~"
|
||||
is bound to insert the text
|
||||
.BR "Function Key 1" .
|
||||
The full set of GNU Emacs style escape sequences is
|
||||
.if t \f(CWFunction Key 1\fP.
|
||||
.if n ``Function Key 1''.
|
||||
.PP
|
||||
The full set of GNU Emacs style escape sequences available when specifying
|
||||
key sequences is
|
||||
.RS
|
||||
.PD 0
|
||||
.TP
|
||||
@ -233,10 +246,10 @@ an escape character
|
||||
backslash
|
||||
.TP
|
||||
.B \e"
|
||||
literal "
|
||||
literal ", a double quote
|
||||
.TP
|
||||
.B \e'
|
||||
literal '
|
||||
literal ', a single quote
|
||||
.RE
|
||||
.PD
|
||||
.PP
|
||||
@ -314,7 +327,8 @@ file with a statement of the form
|
||||
Except where noted, readline variables can take the values
|
||||
.B On
|
||||
or
|
||||
.BR Off .
|
||||
.B Off
|
||||
(without regard to case).
|
||||
The variables and their default values are:
|
||||
.PP
|
||||
.PD 0
|
||||
@ -352,7 +366,7 @@ on the terminal.
|
||||
.B convert\-meta (On)
|
||||
If set to \fBOn\fP, readline will convert characters with the
|
||||
eighth bit set to an ASCII key sequence
|
||||
by stripping the eighth bit and prepending an
|
||||
by stripping the eighth bit and prefixing it with an
|
||||
escape character (in effect, using escape as the \fImeta prefix\fP).
|
||||
.TP
|
||||
.B disable\-completion (Off)
|
||||
@ -362,7 +376,7 @@ mapped to \fBself-insert\fP.
|
||||
.TP
|
||||
.B editing\-mode (emacs)
|
||||
Controls whether readline begins with a set of key bindings similar
|
||||
to \fIemacs\fP or \fIvi\fP.
|
||||
to emacs or vi.
|
||||
.B editing\-mode
|
||||
can be set to either
|
||||
.B emacs
|
||||
@ -385,12 +399,12 @@ becomes longer than the screen width rather than wrapping to a new line.
|
||||
.TP
|
||||
.B input\-meta (Off)
|
||||
If set to \fBOn\fP, readline will enable eight-bit input (that is,
|
||||
it will not strip the high bit from the characters it reads),
|
||||
it will not clear the eighth bit in the characters it reads),
|
||||
regardless of what the terminal claims it can support. The name
|
||||
.B meta\-flag
|
||||
is a synonym for this variable.
|
||||
.TP
|
||||
.B isearch\-terminators (``C\-[C\-J'')
|
||||
.B isearch\-terminators (``C\-[ C\-J'')
|
||||
The string of characters that should terminate an incremental
|
||||
search without subsequently executing the character as a command.
|
||||
If this variable has not been given a value, the characters
|
||||
@ -403,13 +417,13 @@ vi-command\fP, and
|
||||
.IR vi-insert .
|
||||
\fIvi\fP is equivalent to \fIvi-command\fP; \fIemacs\fP is
|
||||
equivalent to \fIemacs-standard\fP. The default value is
|
||||
.IR emacs ;
|
||||
the value of
|
||||
.IR emacs .
|
||||
The value of
|
||||
.B editing\-mode
|
||||
also affects the default keymap.
|
||||
.TP
|
||||
.B mark\-directories (On)
|
||||
If set to \fBOn\fP, complete<d directory names have a slash
|
||||
If set to \fBOn\fP, completed directory names have a slash
|
||||
appended.
|
||||
.TP
|
||||
.B mark\-modified\-lines (Off)
|
||||
@ -434,7 +448,7 @@ matches to be listed immediately instead of ringing the bell.
|
||||
.TP
|
||||
.B visible\-stats (Off)
|
||||
If set to \fBOn\fP, a character denoting a file's type as reported
|
||||
by \fBstat\fP(2) is appended to the filename when listing possible
|
||||
by \fIstat\fP(2) is appended to the filename when listing possible
|
||||
completions.
|
||||
.PD
|
||||
.SS Conditional Constructs
|
||||
@ -482,7 +496,7 @@ key sequence that quotes the current or previous word in Bash:
|
||||
.sp 1
|
||||
.RS
|
||||
.nf
|
||||
\fB$if\fP bash
|
||||
\fB$if\fP Bash
|
||||
# Quote the current or previous word
|
||||
"\eC-xq": "\eeb\e"\eef\e""
|
||||
\fB$endif\fP
|
||||
@ -520,22 +534,27 @@ As each character of the search string is typed, readline displays
|
||||
the next entry from the history matching the string typed so far.
|
||||
An incremental search requires only as many characters as needed to
|
||||
find the desired history entry.
|
||||
The characters present in the value of the \fIisearch-terminators\fP
|
||||
To search backward in the history for a particular string, type
|
||||
\fBC\-r\fP. Typing \fBC\-s\fP searches forward through the history.
|
||||
The characters present in the value of the \fBisearch-terminators\fP
|
||||
variable are used to terminate an incremental search.
|
||||
If that variable has not been assigned a value the Escape and
|
||||
Control-J characters will terminate an incremental search.
|
||||
Control-G will abort an incremental search and restore the original
|
||||
If that variable has not been assigned a value the \fIEscape\fP and
|
||||
\fBC\-J\fP characters will terminate an incremental search.
|
||||
\fBC\-G\fP will abort an incremental search and restore the original
|
||||
line.
|
||||
When the search is terminated, the history entry containing the
|
||||
search string becomes the current line.
|
||||
To find other matching entries in the history list, type Control-S or
|
||||
Control-R as appropriate.
|
||||
.PP
|
||||
To find other matching entries in the history list, type \fBC\-s\fP or
|
||||
\fBC\-r\fP as appropriate.
|
||||
This will search backward or forward in the history for the next
|
||||
line matching the search string typed so far.
|
||||
Any other key sequence bound to a readline command will terminate
|
||||
the search and execute that command.
|
||||
For instance, a \fInewline\fP will terminate the search and accept
|
||||
For instance, a newline will terminate the search and accept
|
||||
the line, thereby executing the command from the history list.
|
||||
A movement command will terminate the search, make the last line found
|
||||
the current line, and begin editing.
|
||||
.PP
|
||||
Non-incremental searches read the entire search string before starting
|
||||
to search for matching history lines. The search string may be
|
||||
@ -545,6 +564,11 @@ typed by the user or be part of the contents of the current line.
|
||||
The following is a list of the names of the commands and the default
|
||||
key sequences to which they are bound.
|
||||
Command names without an accompanying key sequence are unbound by default.
|
||||
.PP
|
||||
In the following descriptions, \fIpoint\fP refers to the current cursor
|
||||
position, and \fImark\fP refers to a cursor position saved by the
|
||||
\fBset\-mark\fP command.
|
||||
The text between the point and mark is referred to as the \fIregion\fP.
|
||||
.SS Commands for Moving
|
||||
.PP
|
||||
.PD 0
|
||||
@ -582,9 +606,11 @@ Refresh the current line.
|
||||
.PD 0
|
||||
.TP
|
||||
.B accept\-line (Newline, Return)
|
||||
Accept the line regardless of where the cursor is. If this line is
|
||||
non-empty, add it to the history list. If the line is a modified
|
||||
history line, then restore the history line to its original state.
|
||||
Accept the line regardless of where the cursor is.
|
||||
If this line is
|
||||
non-empty, it may be added to the history list for future recall with
|
||||
\fBadd_history()\fP.
|
||||
If the line is a modified history line, the history line is restored to its original state.
|
||||
.TP
|
||||
.B previous\-history (C\-p)
|
||||
Fetch the previous command from the history list, moving back in
|
||||
@ -630,8 +656,8 @@ This is a non-incremental search.
|
||||
.TP
|
||||
.B yank\-nth\-arg (M\-C\-y)
|
||||
Insert the first argument to the previous command (usually
|
||||
the second word on the previous line) at point (the current
|
||||
cursor position). With an argument
|
||||
the second word on the previous line) at point.
|
||||
With an argument
|
||||
.IR n ,
|
||||
insert the \fIn\fPth word from the previous command (the words
|
||||
in the previous command begin with word 0). A negative argument
|
||||
@ -650,9 +676,9 @@ list, inserting the last argument of each line in turn.
|
||||
.PD 0
|
||||
.TP
|
||||
.B delete\-char (C\-d)
|
||||
Delete the character under the cursor. If point is at the
|
||||
Delete the character at point. If point is at the
|
||||
beginning of the line, there are no characters in the line, and
|
||||
the last character typed was not bound to \fBBdelete\-char\fP, then return
|
||||
the last character typed was not bound to \fBdelete\-char\fP, then return
|
||||
.SM
|
||||
.BR EOF .
|
||||
.TP
|
||||
@ -663,7 +689,7 @@ save the deleted text on the kill ring.
|
||||
.B forward\-backward\-delete\-char
|
||||
Delete the character under the cursor, unless the cursor is at the
|
||||
end of the line, in which case the character behind the cursor is
|
||||
deleted. By default, this is not bound to a key.
|
||||
deleted.
|
||||
.TP
|
||||
.B quoted\-insert (C\-q, C\-v)
|
||||
Add the next character that you type to the line verbatim. This is
|
||||
@ -676,13 +702,15 @@ Insert a tab character.
|
||||
Insert the character typed.
|
||||
.TP
|
||||
.B transpose\-chars (C\-t)
|
||||
Drag the character before point forward over the character at point.
|
||||
Point moves forward as well. If point is at the end of the line, then
|
||||
transpose the two characters before point. Negative arguments don't work.
|
||||
Drag the character before point forward over the character at point,
|
||||
moving point forward as well.
|
||||
If point is at the end of the line, then this transposes
|
||||
the two characters before point.
|
||||
Negative arguments have no effect.
|
||||
.TP
|
||||
.B transpose\-words (M\-t)
|
||||
Drag the word behind the cursor past the word in front of the cursor
|
||||
moving the cursor over that word as well.
|
||||
Drag the word before point past the word after point,
|
||||
moving point over that word as well.
|
||||
.TP
|
||||
.B upcase\-word (M\-u)
|
||||
Uppercase the current (or following) word. With a negative argument,
|
||||
@ -701,7 +729,7 @@ capitalize the previous word, but do not move point.
|
||||
.PD 0
|
||||
.TP
|
||||
.B kill\-line (C\-k)
|
||||
Kill the text from the current cursor position to the end of the line.
|
||||
Kill the text from point to the end of the line.
|
||||
.TP
|
||||
.B backward\-kill\-line (C\-x Rubout)
|
||||
Kill backward to the beginning of the line.
|
||||
@ -712,22 +740,20 @@ The killed text is saved on the kill-ring.
|
||||
.\" There is no real difference between this and backward-kill-line
|
||||
.TP
|
||||
.B kill\-whole\-line
|
||||
Kill all characters on the current line, no matter where the
|
||||
cursor is.
|
||||
Kill all characters on the current line, no matter where point is.
|
||||
.TP
|
||||
.B kill\-word (M\-d)
|
||||
Kill from the cursor to the end of the current word, or if between
|
||||
Kill from point the end of the current word, or if between
|
||||
words, to the end of the next word. Word boundaries are the same as
|
||||
those used by \fBforward\-word\fP.
|
||||
.TP
|
||||
.B backward\-kill\-word (M\-Rubout)
|
||||
Kill the word behind the cursor. Word boundaries are the same as
|
||||
those used by \fBbackward\-word\fP.
|
||||
Kill the word behind point.
|
||||
Word boundaries are the same as those used by \fBbackward\-word\fP.
|
||||
.TP
|
||||
.B unix\-word\-rubout (C\-w)
|
||||
Kill the word behind the cursor, using white space as a word boundary.
|
||||
The word boundaries are different from
|
||||
.BR backward\-kill\-word .
|
||||
Kill the word behind point, using white space as a word boundary.
|
||||
The killed text is saved on the kill-ring.
|
||||
.TP
|
||||
.B delete\-horizontal\-space (M\-\e)
|
||||
Delete all spaces and tabs around point.
|
||||
@ -748,7 +774,7 @@ Copy the word following point to the kill buffer.
|
||||
The word boundaries are the same as \fBforward\-word\fP.
|
||||
.TP
|
||||
.B yank (C\-y)
|
||||
Yank the top of the kill ring into the buffer at the cursor.
|
||||
Yank the top of the kill ring into the buffer at point.
|
||||
.TP
|
||||
.B yank\-pop (M\-y)
|
||||
Rotate the kill ring, and yank the new top. Only works following
|
||||
@ -809,8 +835,9 @@ Similar to \fBcomplete\fP, but replaces the word to be completed
|
||||
with a single match from the list of possible completions.
|
||||
Repeated execution of \fBmenu\-complete\fP steps through the list
|
||||
of possible completions, inserting each match in turn.
|
||||
At the end of the list of completions, the bell is rung and the
|
||||
original text is restored.
|
||||
At the end of the list of completions, the bell is rung
|
||||
(subject to the setting of \Bbell\-style\fP)
|
||||
and the original text is restored.
|
||||
An argument of \fIn\fP moves \fIn\fP positions forward in the list
|
||||
of matches; a negative argument may be used to move backward
|
||||
through the list.
|
||||
@ -822,7 +849,6 @@ Deletes the character under the cursor if not at the beginning or
|
||||
end of the line (like \fBdelete-char\fP).
|
||||
If at the end of the line, behaves identically to
|
||||
\fBpossible-completions\fP.
|
||||
This command is unbound by default.
|
||||
.PD
|
||||
.SS Keyboard Macros
|
||||
.PP
|
||||
@ -875,8 +901,8 @@ command enough times to return the line to its initial state.
|
||||
.B tilde\-expand (M\-&)
|
||||
Perform tilde expansion on the current word.
|
||||
.TP
|
||||
.B set\-mark (C\-@, M-<space>)
|
||||
Set the mark to the current point. If a
|
||||
.B set\-mark (C\-@, M\-<space>)
|
||||
Set the mark to the point. If a
|
||||
numeric argument is supplied, the mark is set to that position.
|
||||
.TP
|
||||
.B exchange\-point\-and\-mark (C\-x C\-x)
|
||||
@ -895,8 +921,9 @@ character. A negative count searches for subsequent occurrences.
|
||||
The value of the readline
|
||||
.B comment\-begin
|
||||
variable is inserted at the beginning of the current line, and the line
|
||||
is accepted as if a newline had been typed. This makes the current line
|
||||
a shell comment.
|
||||
is accepted as if a newline had been typed. The default value of
|
||||
.B comment\-begin
|
||||
makes the current line a shell comment.
|
||||
.TP
|
||||
.B dump\-functions
|
||||
Print all of the functions and their key bindings to the
|
||||
@ -933,25 +960,23 @@ editing mode.
|
||||
.SH DEFAULT KEY BINDINGS
|
||||
.LP
|
||||
The following is a list of the default emacs and vi bindings.
|
||||
Characters with the 8th bit set are written as M\-<character>, and
|
||||
Characters with the eighth bit set are written as M\-<character>, and
|
||||
are referred to as
|
||||
.I metafied
|
||||
characters.
|
||||
The printable ASCII characters not mentioned in the list of emacs
|
||||
standard bindings are bound to the
|
||||
.I self\-insert
|
||||
.B self\-insert
|
||||
function, which just inserts the given character into the input line.
|
||||
In vi insertion mode, all characters not specifically mentioned are
|
||||
bound to
|
||||
.IR self\-insert .
|
||||
.BR self\-insert .
|
||||
Characters assigned to signal generation by
|
||||
.IR stty (1)
|
||||
or the terminal driver, such as C-Z or C-C,
|
||||
retain that function.
|
||||
Upper and lower case
|
||||
.I metafied
|
||||
characters are bound to the same function in the emacs mode
|
||||
meta keymap.
|
||||
Upper and lower case metafied characters are bound to the same function in
|
||||
the emacs mode meta keymap.
|
||||
The remaining characters are unbound, which causes readline
|
||||
to ring the bell (subject to the setting of the
|
||||
.B bell\-style
|
||||
@ -1037,7 +1062,7 @@ Emacs Meta bindings
|
||||
"M-Y" yank-pop
|
||||
"M-\e" delete-horizontal-space
|
||||
"M-~" tilde-expand
|
||||
"M-C-?" backward-delete-word
|
||||
"M-C-?" backward-kill-word
|
||||
"M-_" yank-last-arg
|
||||
.PP
|
||||
Emacs Control-X bindings
|
||||
@ -1097,6 +1122,7 @@ VI Command Mode functions
|
||||
"C-V" quoted-insert
|
||||
"C-W" unix-word-rubout
|
||||
"C-Y" yank
|
||||
"C-_" vi-undo
|
||||
"\^ " forward-char
|
||||
"#" insert-comment
|
||||
"$" end-of-line
|
||||
@ -1151,7 +1177,7 @@ VI Command Mode functions
|
||||
"r" vi-change-char
|
||||
"s" vi-subst
|
||||
"t" vi-char-search
|
||||
"u" undo
|
||||
"u" vi-undo
|
||||
"w" vi-next-word
|
||||
"x" vi-delete
|
||||
"y" vi-yank-to
|
||||
|
@ -7,9 +7,9 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet@ins.CWRU.Edu
|
||||
.\"
|
||||
.\" Last Change: Tue Jun 1 13:28:03 EDT 1999
|
||||
.\" Last Change: Mon Mar 5 09:58:38 EST 2001
|
||||
.\"
|
||||
.TH READLINE 3 "1999 Jun 1" GNU
|
||||
.TH READLINE 3 "2001 Mar 5" "GNU Readline 4.2"
|
||||
.\"
|
||||
.\" File Name macro. This used to be `.PN', for Path Name,
|
||||
.\" but Sun doesn't seem to like that very much.
|
||||
@ -30,14 +30,13 @@ readline \- get a line from a user with editing
|
||||
.fi
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
char *readline (prompt)
|
||||
char *prompt;
|
||||
.ft
|
||||
\fIchar *\fP
|
||||
.br
|
||||
\fBreadline\fP (\fIconst char *prompt\fP);
|
||||
.fi
|
||||
.SH COPYRIGHT
|
||||
.if n Readline is Copyright (C) 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
|
||||
.if t Readline is Copyright \(co 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
|
||||
.if n Readline is Copyright (C) 1989\-2001 by the Free Software Foundation, Inc.
|
||||
.if t Readline is Copyright \(co 1989\-2001 by the Free Software Foundation, Inc.
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
.B readline
|
||||
@ -46,9 +45,10 @@ and return it, using
|
||||
.B prompt
|
||||
as a prompt. If
|
||||
.B prompt
|
||||
is null, no prompt is issued. The line returned is allocated with
|
||||
.IR malloc (3),
|
||||
so the caller must free it when finished. The line returned
|
||||
is \fBNULL\fP or the empty string, no prompt is issued.
|
||||
The line returned is allocated with
|
||||
.IR malloc (3);
|
||||
the caller must free it when finished. The line returned
|
||||
has the final newline removed, so only the text of the line
|
||||
remains.
|
||||
.LP
|
||||
@ -58,6 +58,11 @@ line.
|
||||
By default, the line editing commands
|
||||
are similar to those of emacs.
|
||||
A vi\-style line editing interface is also available.
|
||||
.LP
|
||||
This manual page describes only the most basic use of \fBreadline\fP.
|
||||
Much more functionality is available; see
|
||||
\fIThe GNU Readline Library\fP and \fIThe GNU History Library\fP
|
||||
for additional information.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
.B readline
|
||||
@ -131,6 +136,7 @@ or
|
||||
.RS
|
||||
C\-Meta\-u: universal\-argument
|
||||
.RE
|
||||
.sp
|
||||
into the
|
||||
.I inputrc
|
||||
would make M\-C\-u execute the readline command
|
||||
@ -138,15 +144,16 @@ would make M\-C\-u execute the readline command
|
||||
.PP
|
||||
The following symbolic character names are recognized while
|
||||
processing key bindings:
|
||||
.IR RUBOUT ,
|
||||
.IR DEL ,
|
||||
.IR ESC ,
|
||||
.IR ESCAPE ,
|
||||
.IR LFD ,
|
||||
.IR NEWLINE ,
|
||||
.IR RET ,
|
||||
.IR RETURN ,
|
||||
.IR SPC ,
|
||||
.IR RUBOUT ,
|
||||
.IR SPACE ,
|
||||
.IR SPC ,
|
||||
and
|
||||
.IR TAB .
|
||||
.PP
|
||||
@ -162,6 +169,7 @@ command or the text of a macro and a key sequence to which
|
||||
it should be bound. The name may be specified in one of two ways:
|
||||
as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
|
||||
prefixes, or as a key sequence.
|
||||
.PP
|
||||
When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP,
|
||||
.I keyname
|
||||
is the name of a key spelled out in English. For example:
|
||||
@ -171,7 +179,7 @@ Control\-u: universal\-argument
|
||||
.br
|
||||
Meta\-Rubout: backward\-kill\-word
|
||||
.br
|
||||
Control\-o: ">&output"
|
||||
Control\-o: "> output"
|
||||
.RE
|
||||
.LP
|
||||
In the above example,
|
||||
@ -185,7 +193,8 @@ and
|
||||
.I C\-o
|
||||
is bound to run the macro
|
||||
expressed on the right hand side (that is, to insert the text
|
||||
.I >&output
|
||||
.if t \f(CW> output\fP
|
||||
.if n ``> output''
|
||||
into the line).
|
||||
.PP
|
||||
In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
|
||||
@ -195,7 +204,8 @@ differs from
|
||||
above in that strings denoting
|
||||
an entire key sequence may be specified by placing the sequence
|
||||
within double quotes. Some GNU Emacs style key escapes can be
|
||||
used, as in the following example.
|
||||
used, as in the following example, but the symbolic character names
|
||||
are not recognized.
|
||||
.sp
|
||||
.RS
|
||||
"\eC\-u": universal\-argument
|
||||
@ -215,8 +225,11 @@ is bound to the function
|
||||
and
|
||||
.I "ESC [ 1 1 ~"
|
||||
is bound to insert the text
|
||||
.BR "Function Key 1" .
|
||||
The full set of GNU Emacs style escape sequences is
|
||||
.if t \f(CWFunction Key 1\fP.
|
||||
.if n ``Function Key 1''.
|
||||
.PP
|
||||
The full set of GNU Emacs style escape sequences available when specifying
|
||||
key sequences is
|
||||
.RS
|
||||
.PD 0
|
||||
.TP
|
||||
@ -233,10 +246,10 @@ an escape character
|
||||
backslash
|
||||
.TP
|
||||
.B \e"
|
||||
literal "
|
||||
literal ", a double quote
|
||||
.TP
|
||||
.B \e'
|
||||
literal '
|
||||
literal ', a single quote
|
||||
.RE
|
||||
.PD
|
||||
.PP
|
||||
@ -314,7 +327,8 @@ file with a statement of the form
|
||||
Except where noted, readline variables can take the values
|
||||
.B On
|
||||
or
|
||||
.BR Off .
|
||||
.B Off
|
||||
(without regard to case).
|
||||
The variables and their default values are:
|
||||
.PP
|
||||
.PD 0
|
||||
@ -352,7 +366,7 @@ on the terminal.
|
||||
.B convert\-meta (On)
|
||||
If set to \fBOn\fP, readline will convert characters with the
|
||||
eighth bit set to an ASCII key sequence
|
||||
by stripping the eighth bit and prepending an
|
||||
by stripping the eighth bit and prefixing it with an
|
||||
escape character (in effect, using escape as the \fImeta prefix\fP).
|
||||
.TP
|
||||
.B disable\-completion (Off)
|
||||
@ -362,7 +376,7 @@ mapped to \fBself-insert\fP.
|
||||
.TP
|
||||
.B editing\-mode (emacs)
|
||||
Controls whether readline begins with a set of key bindings similar
|
||||
to \fIemacs\fP or \fIvi\fP.
|
||||
to emacs or vi.
|
||||
.B editing\-mode
|
||||
can be set to either
|
||||
.B emacs
|
||||
@ -385,12 +399,12 @@ becomes longer than the screen width rather than wrapping to a new line.
|
||||
.TP
|
||||
.B input\-meta (Off)
|
||||
If set to \fBOn\fP, readline will enable eight-bit input (that is,
|
||||
it will not strip the high bit from the characters it reads),
|
||||
it will not clear the eighth bit in the characters it reads),
|
||||
regardless of what the terminal claims it can support. The name
|
||||
.B meta\-flag
|
||||
is a synonym for this variable.
|
||||
.TP
|
||||
.B isearch\-terminators (``C\-[C\-J'')
|
||||
.B isearch\-terminators (``C\-[ C\-J'')
|
||||
The string of characters that should terminate an incremental
|
||||
search without subsequently executing the character as a command.
|
||||
If this variable has not been given a value, the characters
|
||||
@ -403,13 +417,13 @@ vi-command\fP, and
|
||||
.IR vi-insert .
|
||||
\fIvi\fP is equivalent to \fIvi-command\fP; \fIemacs\fP is
|
||||
equivalent to \fIemacs-standard\fP. The default value is
|
||||
.IR emacs ;
|
||||
the value of
|
||||
.IR emacs .
|
||||
The value of
|
||||
.B editing\-mode
|
||||
also affects the default keymap.
|
||||
.TP
|
||||
.B mark\-directories (On)
|
||||
If set to \fBOn\fP, complete<d directory names have a slash
|
||||
If set to \fBOn\fP, completed directory names have a slash
|
||||
appended.
|
||||
.TP
|
||||
.B mark\-modified\-lines (Off)
|
||||
@ -434,7 +448,7 @@ matches to be listed immediately instead of ringing the bell.
|
||||
.TP
|
||||
.B visible\-stats (Off)
|
||||
If set to \fBOn\fP, a character denoting a file's type as reported
|
||||
by \fBstat\fP(2) is appended to the filename when listing possible
|
||||
by \fIstat\fP(2) is appended to the filename when listing possible
|
||||
completions.
|
||||
.PD
|
||||
.SS Conditional Constructs
|
||||
@ -482,7 +496,7 @@ key sequence that quotes the current or previous word in Bash:
|
||||
.sp 1
|
||||
.RS
|
||||
.nf
|
||||
\fB$if\fP bash
|
||||
\fB$if\fP Bash
|
||||
# Quote the current or previous word
|
||||
"\eC-xq": "\eeb\e"\eef\e""
|
||||
\fB$endif\fP
|
||||
@ -520,22 +534,27 @@ As each character of the search string is typed, readline displays
|
||||
the next entry from the history matching the string typed so far.
|
||||
An incremental search requires only as many characters as needed to
|
||||
find the desired history entry.
|
||||
The characters present in the value of the \fIisearch-terminators\fP
|
||||
To search backward in the history for a particular string, type
|
||||
\fBC\-r\fP. Typing \fBC\-s\fP searches forward through the history.
|
||||
The characters present in the value of the \fBisearch-terminators\fP
|
||||
variable are used to terminate an incremental search.
|
||||
If that variable has not been assigned a value the Escape and
|
||||
Control-J characters will terminate an incremental search.
|
||||
Control-G will abort an incremental search and restore the original
|
||||
If that variable has not been assigned a value the \fIEscape\fP and
|
||||
\fBC\-J\fP characters will terminate an incremental search.
|
||||
\fBC\-G\fP will abort an incremental search and restore the original
|
||||
line.
|
||||
When the search is terminated, the history entry containing the
|
||||
search string becomes the current line.
|
||||
To find other matching entries in the history list, type Control-S or
|
||||
Control-R as appropriate.
|
||||
.PP
|
||||
To find other matching entries in the history list, type \fBC\-s\fP or
|
||||
\fBC\-r\fP as appropriate.
|
||||
This will search backward or forward in the history for the next
|
||||
line matching the search string typed so far.
|
||||
Any other key sequence bound to a readline command will terminate
|
||||
the search and execute that command.
|
||||
For instance, a \fInewline\fP will terminate the search and accept
|
||||
For instance, a newline will terminate the search and accept
|
||||
the line, thereby executing the command from the history list.
|
||||
A movement command will terminate the search, make the last line found
|
||||
the current line, and begin editing.
|
||||
.PP
|
||||
Non-incremental searches read the entire search string before starting
|
||||
to search for matching history lines. The search string may be
|
||||
@ -545,6 +564,11 @@ typed by the user or be part of the contents of the current line.
|
||||
The following is a list of the names of the commands and the default
|
||||
key sequences to which they are bound.
|
||||
Command names without an accompanying key sequence are unbound by default.
|
||||
.PP
|
||||
In the following descriptions, \fIpoint\fP refers to the current cursor
|
||||
position, and \fImark\fP refers to a cursor position saved by the
|
||||
\fBset\-mark\fP command.
|
||||
The text between the point and mark is referred to as the \fIregion\fP.
|
||||
.SS Commands for Moving
|
||||
.PP
|
||||
.PD 0
|
||||
@ -582,9 +606,11 @@ Refresh the current line.
|
||||
.PD 0
|
||||
.TP
|
||||
.B accept\-line (Newline, Return)
|
||||
Accept the line regardless of where the cursor is. If this line is
|
||||
non-empty, add it to the history list. If the line is a modified
|
||||
history line, then restore the history line to its original state.
|
||||
Accept the line regardless of where the cursor is.
|
||||
If this line is
|
||||
non-empty, it may be added to the history list for future recall with
|
||||
\fBadd_history()\fP.
|
||||
If the line is a modified history line, the history line is restored to its original state.
|
||||
.TP
|
||||
.B previous\-history (C\-p)
|
||||
Fetch the previous command from the history list, moving back in
|
||||
@ -630,8 +656,8 @@ This is a non-incremental search.
|
||||
.TP
|
||||
.B yank\-nth\-arg (M\-C\-y)
|
||||
Insert the first argument to the previous command (usually
|
||||
the second word on the previous line) at point (the current
|
||||
cursor position). With an argument
|
||||
the second word on the previous line) at point.
|
||||
With an argument
|
||||
.IR n ,
|
||||
insert the \fIn\fPth word from the previous command (the words
|
||||
in the previous command begin with word 0). A negative argument
|
||||
@ -650,9 +676,9 @@ list, inserting the last argument of each line in turn.
|
||||
.PD 0
|
||||
.TP
|
||||
.B delete\-char (C\-d)
|
||||
Delete the character under the cursor. If point is at the
|
||||
Delete the character at point. If point is at the
|
||||
beginning of the line, there are no characters in the line, and
|
||||
the last character typed was not bound to \fBBdelete\-char\fP, then return
|
||||
the last character typed was not bound to \fBdelete\-char\fP, then return
|
||||
.SM
|
||||
.BR EOF .
|
||||
.TP
|
||||
@ -663,7 +689,7 @@ save the deleted text on the kill ring.
|
||||
.B forward\-backward\-delete\-char
|
||||
Delete the character under the cursor, unless the cursor is at the
|
||||
end of the line, in which case the character behind the cursor is
|
||||
deleted. By default, this is not bound to a key.
|
||||
deleted.
|
||||
.TP
|
||||
.B quoted\-insert (C\-q, C\-v)
|
||||
Add the next character that you type to the line verbatim. This is
|
||||
@ -676,13 +702,15 @@ Insert a tab character.
|
||||
Insert the character typed.
|
||||
.TP
|
||||
.B transpose\-chars (C\-t)
|
||||
Drag the character before point forward over the character at point.
|
||||
Point moves forward as well. If point is at the end of the line, then
|
||||
transpose the two characters before point. Negative arguments don't work.
|
||||
Drag the character before point forward over the character at point,
|
||||
moving point forward as well.
|
||||
If point is at the end of the line, then this transposes
|
||||
the two characters before point.
|
||||
Negative arguments have no effect.
|
||||
.TP
|
||||
.B transpose\-words (M\-t)
|
||||
Drag the word behind the cursor past the word in front of the cursor
|
||||
moving the cursor over that word as well.
|
||||
Drag the word before point past the word after point,
|
||||
moving point over that word as well.
|
||||
.TP
|
||||
.B upcase\-word (M\-u)
|
||||
Uppercase the current (or following) word. With a negative argument,
|
||||
@ -701,7 +729,7 @@ capitalize the previous word, but do not move point.
|
||||
.PD 0
|
||||
.TP
|
||||
.B kill\-line (C\-k)
|
||||
Kill the text from the current cursor position to the end of the line.
|
||||
Kill the text from point to the end of the line.
|
||||
.TP
|
||||
.B backward\-kill\-line (C\-x Rubout)
|
||||
Kill backward to the beginning of the line.
|
||||
@ -712,22 +740,20 @@ The killed text is saved on the kill-ring.
|
||||
.\" There is no real difference between this and backward-kill-line
|
||||
.TP
|
||||
.B kill\-whole\-line
|
||||
Kill all characters on the current line, no matter where the
|
||||
cursor is.
|
||||
Kill all characters on the current line, no matter where point is.
|
||||
.TP
|
||||
.B kill\-word (M\-d)
|
||||
Kill from the cursor to the end of the current word, or if between
|
||||
Kill from point the end of the current word, or if between
|
||||
words, to the end of the next word. Word boundaries are the same as
|
||||
those used by \fBforward\-word\fP.
|
||||
.TP
|
||||
.B backward\-kill\-word (M\-Rubout)
|
||||
Kill the word behind the cursor. Word boundaries are the same as
|
||||
those used by \fBbackward\-word\fP.
|
||||
Kill the word behind point.
|
||||
Word boundaries are the same as those used by \fBbackward\-word\fP.
|
||||
.TP
|
||||
.B unix\-word\-rubout (C\-w)
|
||||
Kill the word behind the cursor, using white space as a word boundary.
|
||||
The word boundaries are different from
|
||||
.BR backward\-kill\-word .
|
||||
Kill the word behind point, using white space as a word boundary.
|
||||
The killed text is saved on the kill-ring.
|
||||
.TP
|
||||
.B delete\-horizontal\-space (M\-\e)
|
||||
Delete all spaces and tabs around point.
|
||||
@ -748,7 +774,7 @@ Copy the word following point to the kill buffer.
|
||||
The word boundaries are the same as \fBforward\-word\fP.
|
||||
.TP
|
||||
.B yank (C\-y)
|
||||
Yank the top of the kill ring into the buffer at the cursor.
|
||||
Yank the top of the kill ring into the buffer at point.
|
||||
.TP
|
||||
.B yank\-pop (M\-y)
|
||||
Rotate the kill ring, and yank the new top. Only works following
|
||||
@ -809,8 +835,9 @@ Similar to \fBcomplete\fP, but replaces the word to be completed
|
||||
with a single match from the list of possible completions.
|
||||
Repeated execution of \fBmenu\-complete\fP steps through the list
|
||||
of possible completions, inserting each match in turn.
|
||||
At the end of the list of completions, the bell is rung and the
|
||||
original text is restored.
|
||||
At the end of the list of completions, the bell is rung
|
||||
(subject to the setting of \Bbell\-style\fP)
|
||||
and the original text is restored.
|
||||
An argument of \fIn\fP moves \fIn\fP positions forward in the list
|
||||
of matches; a negative argument may be used to move backward
|
||||
through the list.
|
||||
@ -822,7 +849,6 @@ Deletes the character under the cursor if not at the beginning or
|
||||
end of the line (like \fBdelete-char\fP).
|
||||
If at the end of the line, behaves identically to
|
||||
\fBpossible-completions\fP.
|
||||
This command is unbound by default.
|
||||
.PD
|
||||
.SS Keyboard Macros
|
||||
.PP
|
||||
@ -875,8 +901,8 @@ command enough times to return the line to its initial state.
|
||||
.B tilde\-expand (M\-&)
|
||||
Perform tilde expansion on the current word.
|
||||
.TP
|
||||
.B set\-mark (C\-@, M-<space>)
|
||||
Set the mark to the current point. If a
|
||||
.B set\-mark (C\-@, M\-<space>)
|
||||
Set the mark to the point. If a
|
||||
numeric argument is supplied, the mark is set to that position.
|
||||
.TP
|
||||
.B exchange\-point\-and\-mark (C\-x C\-x)
|
||||
@ -895,8 +921,9 @@ character. A negative count searches for subsequent occurrences.
|
||||
The value of the readline
|
||||
.B comment\-begin
|
||||
variable is inserted at the beginning of the current line, and the line
|
||||
is accepted as if a newline had been typed. This makes the current line
|
||||
a shell comment.
|
||||
is accepted as if a newline had been typed. The default value of
|
||||
.B comment\-begin
|
||||
makes the current line a shell comment.
|
||||
.TP
|
||||
.B dump\-functions
|
||||
Print all of the functions and their key bindings to the
|
||||
@ -933,25 +960,23 @@ editing mode.
|
||||
.SH DEFAULT KEY BINDINGS
|
||||
.LP
|
||||
The following is a list of the default emacs and vi bindings.
|
||||
Characters with the 8th bit set are written as M\-<character>, and
|
||||
Characters with the eighth bit set are written as M\-<character>, and
|
||||
are referred to as
|
||||
.I metafied
|
||||
characters.
|
||||
The printable ASCII characters not mentioned in the list of emacs
|
||||
standard bindings are bound to the
|
||||
.I self\-insert
|
||||
.B self\-insert
|
||||
function, which just inserts the given character into the input line.
|
||||
In vi insertion mode, all characters not specifically mentioned are
|
||||
bound to
|
||||
.IR self\-insert .
|
||||
.BR self\-insert .
|
||||
Characters assigned to signal generation by
|
||||
.IR stty (1)
|
||||
or the terminal driver, such as C-Z or C-C,
|
||||
retain that function.
|
||||
Upper and lower case
|
||||
.I metafied
|
||||
characters are bound to the same function in the emacs mode
|
||||
meta keymap.
|
||||
Upper and lower case metafied characters are bound to the same function in
|
||||
the emacs mode meta keymap.
|
||||
The remaining characters are unbound, which causes readline
|
||||
to ring the bell (subject to the setting of the
|
||||
.B bell\-style
|
||||
@ -1037,7 +1062,7 @@ Emacs Meta bindings
|
||||
"M-Y" yank-pop
|
||||
"M-\e" delete-horizontal-space
|
||||
"M-~" tilde-expand
|
||||
"M-C-?" backward-delete-word
|
||||
"M-C-?" backward-kill-word
|
||||
"M-_" yank-last-arg
|
||||
.PP
|
||||
Emacs Control-X bindings
|
||||
@ -1097,6 +1122,7 @@ VI Command Mode functions
|
||||
"C-V" quoted-insert
|
||||
"C-W" unix-word-rubout
|
||||
"C-Y" yank
|
||||
"C-_" vi-undo
|
||||
"\^ " forward-char
|
||||
"#" insert-comment
|
||||
"$" end-of-line
|
||||
@ -1151,7 +1177,7 @@ VI Command Mode functions
|
||||
"r" vi-change-char
|
||||
"s" vi-subst
|
||||
"t" vi-char-search
|
||||
"u" undo
|
||||
"u" vi-undo
|
||||
"w" vi-next-word
|
||||
"x" vi-delete
|
||||
"y" vi-yank-to
|
||||
|
@ -61,8 +61,8 @@ extern UNDO_LIST *rl_undo_list;
|
||||
|
||||
/* The data structure for mapping textual names to code addresses. */
|
||||
typedef struct _funmap {
|
||||
char *name;
|
||||
Function *function;
|
||||
const char *name;
|
||||
rl_command_func_t *function;
|
||||
} FUNMAP;
|
||||
|
||||
extern FUNMAP **funmap;
|
||||
@ -156,8 +156,8 @@ extern int rl_yank __P((int, int));
|
||||
extern int rl_yank_pop __P((int, int));
|
||||
extern int rl_yank_nth_arg __P((int, int));
|
||||
extern int rl_yank_last_arg __P((int, int));
|
||||
/* Not available unless __CYGWIN32__ is defined. */
|
||||
#ifdef __CYGWIN32__
|
||||
/* Not available unless __CYGWIN__ is defined. */
|
||||
#ifdef __CYGWIN__
|
||||
extern int rl_paste_from_clipboard __P((int, int));
|
||||
#endif
|
||||
|
||||
@ -197,7 +197,7 @@ extern int rl_noninc_reverse_search_again __P((int, int));
|
||||
extern int rl_insert_close __P((int, int));
|
||||
|
||||
/* Not available unless READLINE_CALLBACKS is defined. */
|
||||
extern void rl_callback_handler_install __P((char *, VFunction *));
|
||||
extern void rl_callback_handler_install __P((const char *, rl_vcpfunc_t *));
|
||||
extern void rl_callback_read_char __P((void));
|
||||
extern void rl_callback_handler_remove __P((void));
|
||||
|
||||
@ -261,69 +261,68 @@ extern int rl_vi_eword __P((int, int));
|
||||
|
||||
/* Readline functions. */
|
||||
/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */
|
||||
extern char *readline __P((char *));
|
||||
extern char *readline __P((const char *));
|
||||
|
||||
extern int rl_set_prompt __P((const char *));
|
||||
extern int rl_expand_prompt __P((char *));
|
||||
|
||||
extern int rl_initialize __P((void));
|
||||
|
||||
/* Undocumented; unused by readline */
|
||||
extern int rl_discard_argument __P((void));
|
||||
|
||||
/* Utility functions to bind keys to readline commands. */
|
||||
extern int rl_add_defun __P((char *, Function *, int));
|
||||
extern int rl_bind_key __P((int, Function *));
|
||||
extern int rl_bind_key_in_map __P((int, Function *, Keymap));
|
||||
extern int rl_add_defun __P((const char *, rl_command_func_t *, int));
|
||||
extern int rl_bind_key __P((int, rl_command_func_t *));
|
||||
extern int rl_bind_key_in_map __P((int, rl_command_func_t *, Keymap));
|
||||
extern int rl_unbind_key __P((int));
|
||||
extern int rl_unbind_key_in_map __P((int, Keymap));
|
||||
extern int rl_unbind_function_in_map __P((Function *, Keymap));
|
||||
extern int rl_unbind_command_in_map __P((char *, Keymap));
|
||||
extern int rl_set_key __P((char *, Function *, Keymap));
|
||||
extern int rl_generic_bind __P((int, char *, char *, Keymap));
|
||||
extern int rl_variable_bind __P((char *, char *));
|
||||
extern int rl_unbind_function_in_map __P((rl_command_func_t *, Keymap));
|
||||
extern int rl_unbind_command_in_map __P((const char *, Keymap));
|
||||
extern int rl_set_key __P((const char *, rl_command_func_t *, Keymap));
|
||||
extern int rl_generic_bind __P((int, const char *, char *, Keymap));
|
||||
extern int rl_variable_bind __P((const char *, const char *));
|
||||
|
||||
/* Backwards compatibility, use rl_generic_bind instead. */
|
||||
extern int rl_macro_bind __P((char *, char *, Keymap));
|
||||
extern int rl_macro_bind __P((const char *, const char *, Keymap));
|
||||
|
||||
/* Undocumented in the texinfo manual; not really useful to programs. */
|
||||
extern int rl_translate_keyseq __P((char *, char *, int *));
|
||||
extern int rl_translate_keyseq __P((const char *, char *, int *));
|
||||
extern char *rl_untranslate_keyseq __P((int));
|
||||
|
||||
extern Function *rl_named_function __P((char *));
|
||||
extern Function *rl_function_of_keyseq __P((char *, Keymap, int *));
|
||||
extern rl_command_func_t *rl_named_function __P((const char *));
|
||||
extern rl_command_func_t *rl_function_of_keyseq __P((const char *, Keymap, int *));
|
||||
|
||||
extern void rl_list_funmap_names __P((void));
|
||||
extern char **rl_invoking_keyseqs_in_map __P((Function *, Keymap));
|
||||
extern char **rl_invoking_keyseqs __P((Function *));
|
||||
extern char **rl_invoking_keyseqs_in_map __P((rl_command_func_t *, Keymap));
|
||||
extern char **rl_invoking_keyseqs __P((rl_command_func_t *));
|
||||
|
||||
extern void rl_function_dumper __P((int));
|
||||
extern void rl_macro_dumper __P((int));
|
||||
extern void rl_variable_dumper __P((int));
|
||||
|
||||
extern int rl_read_init_file __P((char *));
|
||||
extern int rl_read_init_file __P((const char *));
|
||||
extern int rl_parse_and_bind __P((char *));
|
||||
|
||||
/* Functions for manipulating keymaps. */
|
||||
extern Keymap rl_make_bare_keymap __P((void));
|
||||
extern Keymap rl_copy_keymap __P((Keymap));
|
||||
extern Keymap rl_make_keymap __P((void));
|
||||
extern void rl_discard_keymap __P((Keymap));
|
||||
|
||||
extern Keymap rl_get_keymap_by_name __P((char *));
|
||||
extern char *rl_get_keymap_name __P((Keymap));
|
||||
extern void rl_set_keymap __P((Keymap));
|
||||
extern Keymap rl_get_keymap __P((void));
|
||||
/* Undocumented; used internally only. */
|
||||
extern void rl_set_keymap_from_edit_mode __P((void));
|
||||
extern char *rl_get_keymap_name_from_edit_mode __P((void));
|
||||
|
||||
/* Functions for manipulating the funmap, which maps command names to functions. */
|
||||
extern int rl_add_funmap_entry __P((char *, Function *));
|
||||
extern int rl_add_funmap_entry __P((const char *, rl_command_func_t *));
|
||||
extern const char **rl_funmap_names __P((void));
|
||||
/* Undocumented, only used internally -- there is only one funmap, and this
|
||||
function may be called only once. */
|
||||
extern void rl_initialize_funmap __P((void));
|
||||
extern char **rl_funmap_names __P((void));
|
||||
|
||||
/* Utility functions for managing keyboard macros. */
|
||||
extern void rl_push_macro_input __P((char *));
|
||||
|
||||
/* Functions for undoing, from undo.c */
|
||||
extern void rl_add_undo __P((enum undo_code, int, int, char *));
|
||||
extern void free_undo_list __P((void));
|
||||
extern void rl_free_undo_list __P((void));
|
||||
extern int rl_do_undo __P((void));
|
||||
extern int rl_begin_undo_group __P((void));
|
||||
extern int rl_end_undo_group __P((void));
|
||||
@ -336,6 +335,7 @@ extern int rl_on_new_line_with_prompt __P((void));
|
||||
extern int rl_forced_update_display __P((void));
|
||||
extern int rl_clear_message __P((void));
|
||||
extern int rl_reset_line_state __P((void));
|
||||
extern int rl_crlf __P((void));
|
||||
|
||||
#if (defined (__STDC__) || defined (__cplusplus)) && defined (USE_VARARGS) && defined (PREFER_STDARG)
|
||||
extern int rl_message (const char *, ...);
|
||||
@ -343,17 +343,17 @@ extern int rl_message (const char *, ...);
|
||||
extern int rl_message ();
|
||||
#endif
|
||||
|
||||
/* Undocumented in texinfo manual. */
|
||||
extern int rl_show_char __P((int));
|
||||
|
||||
/* Undocumented in texinfo manual. */
|
||||
extern int rl_character_len __P((int, int));
|
||||
extern int crlf __P((void));
|
||||
|
||||
/* Save and restore internal prompt redisplay information. */
|
||||
extern void rl_save_prompt __P((void));
|
||||
extern void rl_restore_prompt __P((void));
|
||||
|
||||
/* Modifying text. */
|
||||
extern int rl_insert_text __P((char *));
|
||||
extern int rl_insert_text __P((const char *));
|
||||
extern int rl_delete_text __P((int, int));
|
||||
extern int rl_kill_text __P((int, int));
|
||||
extern char *rl_copy_text __P((int, int));
|
||||
@ -361,20 +361,25 @@ extern char *rl_copy_text __P((int, int));
|
||||
/* Terminal and tty mode management. */
|
||||
extern void rl_prep_terminal __P((int));
|
||||
extern void rl_deprep_terminal __P((void));
|
||||
extern void rltty_set_default_bindings __P((Keymap));
|
||||
extern void rl_tty_set_default_bindings __P((Keymap));
|
||||
|
||||
extern int rl_reset_terminal __P((char *));
|
||||
extern int rl_reset_terminal __P((const char *));
|
||||
extern void rl_resize_terminal __P((void));
|
||||
|
||||
/* `Public' utility functions . */
|
||||
extern void rl_extend_line_buffer __P((int));
|
||||
extern int ding __P((void));
|
||||
extern void rl_set_screen_size __P((int, int));
|
||||
extern void rl_get_screen_size __P((int *, int *));
|
||||
|
||||
/* Functions for character input. */
|
||||
extern int rl_stuff_char __P((int));
|
||||
extern int rl_execute_next __P((int));
|
||||
extern int rl_clear_pending_input __P((void));
|
||||
extern int rl_read_key __P((void));
|
||||
extern int rl_getc __P((FILE *));
|
||||
extern int rl_set_keyboard_input_timeout __P((int));
|
||||
|
||||
/* `Public' utility functions . */
|
||||
extern void rl_extend_line_buffer __P((int));
|
||||
extern int rl_ding __P((void));
|
||||
extern int rl_alphabetic __P((int));
|
||||
|
||||
/* Readline signal handling, from signals.c */
|
||||
extern int rl_set_signals __P((void));
|
||||
@ -384,19 +389,36 @@ extern void rl_reset_after_signal __P((void));
|
||||
extern void rl_free_line_state __P((void));
|
||||
|
||||
/* Undocumented. */
|
||||
extern int rl_expand_prompt __P((char *));
|
||||
extern int rl_set_paren_blink_timeout __P((int));
|
||||
|
||||
extern int maybe_save_line __P((void));
|
||||
extern int maybe_unsave_line __P((void));
|
||||
extern int maybe_replace_line __P((void));
|
||||
/* Undocumented. */
|
||||
extern int rl_maybe_save_line __P((void));
|
||||
extern int rl_maybe_unsave_line __P((void));
|
||||
extern int rl_maybe_replace_line __P((void));
|
||||
|
||||
/* Completion functions. */
|
||||
extern int rl_complete_internal __P((int));
|
||||
extern void rl_display_match_list __P((char **, int, int));
|
||||
|
||||
extern char **completion_matches __P((char *, CPFunction *));
|
||||
extern char *username_completion_function __P((char *, int));
|
||||
extern char *filename_completion_function __P((char *, int));
|
||||
extern char **rl_completion_matches __P((const char *, rl_compentry_func_t *));
|
||||
extern char *rl_username_completion_function __P((const char *, int));
|
||||
extern char *rl_filename_completion_function __P((const char *, int));
|
||||
|
||||
#if 0
|
||||
/* Backwards compatibility (compat.c). These will go away sometime. */
|
||||
extern void free_undo_list __P((void));
|
||||
extern int maybe_save_line __P((void));
|
||||
extern int maybe_unsave_line __P((void));
|
||||
extern int maybe_replace_line __P((void));
|
||||
|
||||
extern int ding __P((void));
|
||||
extern int alphabetic __P((int));
|
||||
extern int crlf __P((void));
|
||||
|
||||
extern char **completion_matches __P((char *, rl_compentry_func_t *));
|
||||
extern char *username_completion_function __P((const char *, int));
|
||||
extern char *filename_completion_function __P((const char *, int));
|
||||
#endif
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
@ -405,14 +427,21 @@ extern char *filename_completion_function __P((char *, int));
|
||||
/* **************************************************************** */
|
||||
|
||||
/* The version of this incarnation of the readline library. */
|
||||
extern char *rl_library_version;
|
||||
extern const char *rl_library_version;
|
||||
|
||||
/* True if this is real GNU readline. */
|
||||
extern int rl_gnu_readline_p;
|
||||
|
||||
/* Flags word encapsulating the current readline state. */
|
||||
extern int rl_readline_state;
|
||||
|
||||
/* Says which editing mode readline is currently using. 1 means emacs mode;
|
||||
0 means vi mode. */
|
||||
extern int rl_editing_mode;
|
||||
|
||||
/* The name of the calling program. You should initialize this to
|
||||
whatever was in argv[0]. It is used when parsing conditionals. */
|
||||
extern char *rl_readline_name;
|
||||
extern const char *rl_readline_name;
|
||||
|
||||
/* The prompt readline uses. This is set from the argument to
|
||||
readline (), and should not be assigned to directly. */
|
||||
@ -422,7 +451,8 @@ extern char *rl_prompt;
|
||||
extern char *rl_line_buffer;
|
||||
|
||||
/* The location of point, and end. */
|
||||
extern int rl_point, rl_end;
|
||||
extern int rl_point;
|
||||
extern int rl_end;
|
||||
|
||||
/* The mark, or saved cursor position. */
|
||||
extern int rl_mark;
|
||||
@ -439,29 +469,44 @@ extern int rl_pending_input;
|
||||
or directly from an application. */
|
||||
extern int rl_dispatching;
|
||||
|
||||
/* Non-zero if the user typed a numeric argument before executing the
|
||||
current function. */
|
||||
extern int rl_explicit_arg;
|
||||
|
||||
/* The current value of the numeric argument specified by the user. */
|
||||
extern int rl_numeric_arg;
|
||||
|
||||
/* The address of the last command function Readline executed. */
|
||||
extern rl_command_func_t *rl_last_func;
|
||||
|
||||
/* The name of the terminal to use. */
|
||||
extern char *rl_terminal_name;
|
||||
extern const char *rl_terminal_name;
|
||||
|
||||
/* The input and output streams. */
|
||||
extern FILE *rl_instream, *rl_outstream;
|
||||
extern FILE *rl_instream;
|
||||
extern FILE *rl_outstream;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call just
|
||||
before readline_internal () prints the first prompt. */
|
||||
extern Function *rl_startup_hook;
|
||||
extern rl_hook_func_t *rl_startup_hook;
|
||||
|
||||
/* If non-zero, this is the address of a function to call just before
|
||||
readline_internal_setup () returns and readline_internal starts
|
||||
reading input characters. */
|
||||
extern Function *rl_pre_input_hook;
|
||||
extern rl_hook_func_t *rl_pre_input_hook;
|
||||
|
||||
/* The address of a function to call periodically while Readline is
|
||||
awaiting character input, or NULL, for no event handling. */
|
||||
extern Function *rl_event_hook;
|
||||
extern rl_hook_func_t *rl_event_hook;
|
||||
|
||||
extern Function *rl_getc_function;
|
||||
extern VFunction *rl_redisplay_function;
|
||||
extern VFunction *rl_prep_term_function;
|
||||
extern VFunction *rl_deprep_term_function;
|
||||
/* The address of the function to call to fetch a character from the current
|
||||
Readline input stream */
|
||||
extern rl_getc_func_t *rl_getc_function;
|
||||
|
||||
extern rl_voidfunc_t *rl_redisplay_function;
|
||||
|
||||
extern rl_vintfunc_t *rl_prep_term_function;
|
||||
extern rl_voidfunc_t *rl_deprep_term_function;
|
||||
|
||||
/* Dispatch variables. */
|
||||
extern Keymap rl_executing_keymap;
|
||||
@ -482,6 +527,9 @@ extern int rl_already_prompted;
|
||||
up to a character bound to accept-line. */
|
||||
extern int rl_num_chars_to_read;
|
||||
|
||||
/* The text of a currently-executing keyboard macro. */
|
||||
extern char *rl_executing_macro;
|
||||
|
||||
/* Variables to control readline signal handling. */
|
||||
/* If non-zero, readline will install its own signal handlers for
|
||||
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
|
||||
@ -498,7 +546,7 @@ extern int rl_catch_sigwinch;
|
||||
/* Pointer to the generator function for completion_matches ().
|
||||
NULL means to use filename_entry_function (), the default filename
|
||||
completer. */
|
||||
extern Function *rl_completion_entry_function;
|
||||
extern rl_compentry_func_t *rl_completion_entry_function;
|
||||
|
||||
/* If rl_ignore_some_completions_function is non-NULL it is the address
|
||||
of a function to call after all of the possible matches have been
|
||||
@ -506,7 +554,7 @@ extern Function *rl_completion_entry_function;
|
||||
The function is called with one argument; a NULL terminated array
|
||||
of (char *). If your function removes any of the elements, they
|
||||
must be free()'ed. */
|
||||
extern Function *rl_ignore_some_completions_function;
|
||||
extern rl_compignore_func_t *rl_ignore_some_completions_function;
|
||||
|
||||
/* Pointer to alternative function to create matches.
|
||||
Function is called with TEXT, START, and END.
|
||||
@ -515,39 +563,50 @@ extern Function *rl_ignore_some_completions_function;
|
||||
If this function exists and returns NULL then call the value of
|
||||
rl_completion_entry_function to try to match, otherwise use the
|
||||
array of strings returned. */
|
||||
extern CPPFunction *rl_attempted_completion_function;
|
||||
extern rl_completion_func_t *rl_attempted_completion_function;
|
||||
|
||||
/* The basic list of characters that signal a break between words for the
|
||||
completer routine. The initial contents of this variable is what
|
||||
breaks words in the shell, i.e. "n\"\\'`@$>". */
|
||||
extern char *rl_basic_word_break_characters;
|
||||
extern const char *rl_basic_word_break_characters;
|
||||
|
||||
/* The list of characters that signal a break between words for
|
||||
rl_complete_internal. The default list is the contents of
|
||||
rl_basic_word_break_characters. */
|
||||
extern char *rl_completer_word_break_characters;
|
||||
extern const char *rl_completer_word_break_characters;
|
||||
|
||||
/* List of characters which can be used to quote a substring of the line.
|
||||
Completion occurs on the entire substring, and within the substring
|
||||
rl_completer_word_break_characters are treated as any other character,
|
||||
unless they also appear within this list. */
|
||||
extern char *rl_completer_quote_characters;
|
||||
extern const char *rl_completer_quote_characters;
|
||||
|
||||
/* List of quote characters which cause a word break. */
|
||||
extern char *rl_basic_quote_characters;
|
||||
extern const char *rl_basic_quote_characters;
|
||||
|
||||
/* List of characters that need to be quoted in filenames by the completer. */
|
||||
extern char *rl_filename_quote_characters;
|
||||
extern const char *rl_filename_quote_characters;
|
||||
|
||||
/* List of characters that are word break characters, but should be left
|
||||
in TEXT when it is passed to the completion function. The shell uses
|
||||
this to help determine what kind of completing to do. */
|
||||
extern char *rl_special_prefixes;
|
||||
extern const char *rl_special_prefixes;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing on a directory name. The function is called with
|
||||
the address of a string (the current directory name) as an arg. */
|
||||
extern Function *rl_directory_completion_hook;
|
||||
the address of a string (the current directory name) as an arg. It
|
||||
changes what is displayed when the possible completions are printed
|
||||
or inserted. */
|
||||
extern rl_icppfunc_t *rl_directory_completion_hook;
|
||||
|
||||
/* If non-zero, this is the address of a function to call when completing
|
||||
a directory name. This function takes the address of the directory name
|
||||
to be modified as an argument. Unlike rl_directory_completion_hook, it
|
||||
only modifies the directory name used in opendir(2), not what is displayed
|
||||
when the possible completions are printed or inserted. It is called
|
||||
before rl_directory_completion_hook. I'm not happy with how this works
|
||||
yet, so it's undocumented. */
|
||||
extern rl_icppfunc_t *rl_directory_rewrite_hook;
|
||||
|
||||
/* Backwards compatibility with previous versions of readline. */
|
||||
#define rl_symbolic_link_hook rl_directory_completion_hook
|
||||
@ -559,7 +618,7 @@ extern Function *rl_directory_completion_hook;
|
||||
where MATCHES is the array of strings that matched, NUM_MATCHES is the
|
||||
number of strings in that array, and MAX_LENGTH is the length of the
|
||||
longest string in that array. */
|
||||
extern VFunction *rl_completion_display_matches_hook;
|
||||
extern rl_compdisp_func_t *rl_completion_display_matches_hook;
|
||||
|
||||
/* Non-zero means that the results of the matches are to be treated
|
||||
as filenames. This is ALWAYS zero on entry, and can only be changed
|
||||
@ -577,17 +636,17 @@ extern int rl_filename_quoting_desired;
|
||||
Called with the text to quote, the type of match found (single or multiple)
|
||||
and a pointer to the quoting character to be used, which the function can
|
||||
reset if desired. */
|
||||
extern CPFunction *rl_filename_quoting_function;
|
||||
extern rl_quote_func_t *rl_filename_quoting_function;
|
||||
|
||||
/* Function to call to remove quoting characters from a filename. Called
|
||||
before completion is attempted, so the embedded quotes do not interfere
|
||||
with matching names in the file system. */
|
||||
extern CPFunction *rl_filename_dequoting_function;
|
||||
extern rl_dequote_func_t *rl_filename_dequoting_function;
|
||||
|
||||
/* Function to call to decide whether or not a word break character is
|
||||
quoted. If a character is quoted, it does not break words for the
|
||||
completer. */
|
||||
extern Function *rl_char_is_quoted_p;
|
||||
extern rl_linebuf_func_t *rl_char_is_quoted_p;
|
||||
|
||||
/* Non-zero means to suppress normal filename completion after the
|
||||
user-specified completion function has been called. */
|
||||
@ -624,9 +683,37 @@ extern int rl_inhibit_completion;
|
||||
#define SINGLE_MATCH 1
|
||||
#define MULT_MATCH 2
|
||||
|
||||
/* Possible state values for rl_readline_state */
|
||||
#define RL_STATE_NONE 0x00000 /* no state; before first call */
|
||||
|
||||
#define RL_STATE_INITIALIZING 0x00001 /* initializing */
|
||||
#define RL_STATE_INITIALIZED 0x00002 /* initialization done */
|
||||
#define RL_STATE_TERMPREPPED 0x00004 /* terminal is prepped */
|
||||
#define RL_STATE_READCMD 0x00008 /* reading a command key */
|
||||
#define RL_STATE_METANEXT 0x00010 /* reading input after ESC */
|
||||
#define RL_STATE_DISPATCHING 0x00020 /* dispatching to a command */
|
||||
#define RL_STATE_MOREINPUT 0x00040 /* reading more input in a command function */
|
||||
#define RL_STATE_ISEARCH 0x00080 /* doing incremental search */
|
||||
#define RL_STATE_NSEARCH 0x00100 /* doing non-inc search */
|
||||
#define RL_STATE_SEARCH 0x00200 /* doing a history search */
|
||||
#define RL_STATE_NUMERICARG 0x00400 /* reading numeric argument */
|
||||
#define RL_STATE_MACROINPUT 0x00800 /* getting input from a macro */
|
||||
#define RL_STATE_MACRODEF 0x01000 /* defining keyboard macro */
|
||||
#define RL_STATE_OVERWRITE 0x02000 /* overwrite mode */
|
||||
#define RL_STATE_COMPLETING 0x04000 /* doing completion */
|
||||
#define RL_STATE_SIGHANDLER 0x08000 /* in readline sighandler */
|
||||
#define RL_STATE_UNDOING 0x10000 /* doing an undo */
|
||||
#define RL_STATE_INPUTPENDING 0x20000 /* rl_execute_next called */
|
||||
|
||||
#define RL_STATE_DONE 0x80000 /* done; accepted line */
|
||||
|
||||
#define RL_SETSTATE(x) (rl_readline_state |= (x))
|
||||
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
|
||||
#define RL_ISSTATE(x) (rl_readline_state & (x))
|
||||
|
||||
#if !defined (savestring)
|
||||
#define savestring rl_savestring
|
||||
extern char *savestring __P((char *)); /* XXX backwards compatibility */
|
||||
extern char *savestring __P((char *)); /* XXX backwards compatibility */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -50,11 +50,12 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "rlstdc.h"
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
#if !defined (HAVE_GETPW_DECLS)
|
||||
extern struct passwd *getpwuid ();
|
||||
extern struct passwd *getpwuid __P((uid_t));
|
||||
#endif /* !HAVE_GETPW_DECLS */
|
||||
|
||||
#ifndef NULL
|
||||
@ -66,7 +67,7 @@ extern struct passwd *getpwuid ();
|
||||
|
||||
/* Does shell-like quoting using single quotes. */
|
||||
char *
|
||||
single_quote (string)
|
||||
sh_single_quote (string)
|
||||
char *string;
|
||||
{
|
||||
register int c;
|
||||
@ -97,7 +98,7 @@ single_quote (string)
|
||||
/* Set the environment variables LINES and COLUMNS to lines and cols,
|
||||
respectively. */
|
||||
void
|
||||
set_lines_and_columns (lines, cols)
|
||||
sh_set_lines_and_columns (lines, cols)
|
||||
int lines, cols;
|
||||
{
|
||||
char *b;
|
||||
@ -122,14 +123,14 @@ set_lines_and_columns (lines, cols)
|
||||
}
|
||||
|
||||
char *
|
||||
get_env_value (varname)
|
||||
char *varname;
|
||||
sh_get_env_value (varname)
|
||||
const char *varname;
|
||||
{
|
||||
return ((char *)getenv (varname));
|
||||
}
|
||||
|
||||
char *
|
||||
get_home_dir ()
|
||||
sh_get_home_dir ()
|
||||
{
|
||||
char *home_dir;
|
||||
struct passwd *entry;
|
||||
@ -148,7 +149,7 @@ get_home_dir ()
|
||||
#endif
|
||||
|
||||
int
|
||||
unset_nodelay_mode (fd)
|
||||
sh_unset_nodelay_mode (fd)
|
||||
int fd;
|
||||
{
|
||||
int flags, bflags;
|
||||
|
@ -77,9 +77,6 @@ static char *term_string_buffer = (char *)NULL;
|
||||
|
||||
static int tcap_initialized;
|
||||
|
||||
/* Non-zero means this terminal can't really do anything. */
|
||||
static int dumb_term;
|
||||
|
||||
#if !defined (__linux__)
|
||||
# if defined (__EMX__) || defined (NEED_EXTERN_PC)
|
||||
extern
|
||||
@ -88,27 +85,36 @@ char PC, *BC, *UP;
|
||||
#endif /* __linux__ */
|
||||
|
||||
/* Some strings to control terminal actions. These are output by tputs (). */
|
||||
char *term_goto, *term_clreol, *term_cr, *term_clrpag, *term_backspace;
|
||||
char *term_pc;
|
||||
char *_rl_term_clreol;
|
||||
char *_rl_term_clrpag;
|
||||
char *_rl_term_cr;
|
||||
char *_rl_term_backspace;
|
||||
char *_rl_term_goto;
|
||||
char *_rl_term_pc;
|
||||
|
||||
/* Non-zero if we determine that the terminal can do character insertion. */
|
||||
int terminal_can_insert = 0;
|
||||
int _rl_terminal_can_insert = 0;
|
||||
|
||||
/* How to insert characters. */
|
||||
char *term_im, *term_ei, *term_ic, *term_ip, *term_IC;
|
||||
char *_rl_term_im;
|
||||
char *_rl_term_ei;
|
||||
char *_rl_term_ic;
|
||||
char *_rl_term_ip;
|
||||
char *_rl_term_IC;
|
||||
|
||||
/* How to delete characters. */
|
||||
char *term_dc, *term_DC;
|
||||
char *_rl_term_dc;
|
||||
char *_rl_term_DC;
|
||||
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
char *term_forward_char;
|
||||
char *_rl_term_forward_char;
|
||||
#endif /* HACK_TERMCAP_MOTION */
|
||||
|
||||
/* How to go up a line. */
|
||||
char *term_up;
|
||||
char *_rl_term_up;
|
||||
|
||||
/* A visible bell, if the terminal can be made to flash the screen. */
|
||||
static char *visible_bell;
|
||||
/* A visible bell; char if the terminal can be made to flash the screen. */
|
||||
static char *_rl_visible_bell;
|
||||
|
||||
/* Non-zero means the terminal can auto-wrap lines. */
|
||||
int _rl_term_autowrap;
|
||||
@ -117,20 +123,26 @@ int _rl_term_autowrap;
|
||||
static int term_has_meta;
|
||||
|
||||
/* The sequences to write to turn on and off the meta key, if this
|
||||
terminal has one. */
|
||||
static char *term_mm, *term_mo;
|
||||
terminal has one. */
|
||||
static char *_rl_term_mm;
|
||||
static char *_rl_term_mo;
|
||||
|
||||
/* The key sequences output by the arrow keys, if this terminal has any. */
|
||||
static char *term_ku, *term_kd, *term_kr, *term_kl;
|
||||
static char *_rl_term_ku;
|
||||
static char *_rl_term_kd;
|
||||
static char *_rl_term_kr;
|
||||
static char *_rl_term_kl;
|
||||
|
||||
/* How to initialize and reset the arrow keys, if this terminal has any. */
|
||||
static char *term_ks, *term_ke;
|
||||
static char *_rl_term_ks;
|
||||
static char *_rl_term_ke;
|
||||
|
||||
/* The key sequences sent by the Home and End keys, if any. */
|
||||
static char *term_kh, *term_kH;
|
||||
static char *_rl_term_kh;
|
||||
static char *_rl_term_kH;
|
||||
|
||||
/* Variables that hold the screen dimensions, used by the display code. */
|
||||
int screenwidth, screenheight, screenchars;
|
||||
int _rl_screenwidth, _rl_screenheight, _rl_screenchars;
|
||||
|
||||
/* Non-zero means the user wants to enable the keypad. */
|
||||
int _rl_enable_keypad;
|
||||
@ -170,72 +182,92 @@ _rl_get_screen_size (tty, ignore_env)
|
||||
#if defined (TIOCGWINSZ)
|
||||
if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
|
||||
{
|
||||
screenwidth = (int) window_size.ws_col;
|
||||
screenheight = (int) window_size.ws_row;
|
||||
_rl_screenwidth = (int) window_size.ws_col;
|
||||
_rl_screenheight = (int) window_size.ws_row;
|
||||
}
|
||||
#endif /* TIOCGWINSZ */
|
||||
|
||||
#if defined (__EMX__)
|
||||
_emx_get_screensize (&screenwidth, &screenheight);
|
||||
_emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
|
||||
#endif
|
||||
|
||||
/* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV
|
||||
is unset. */
|
||||
if (screenwidth <= 0)
|
||||
if (_rl_screenwidth <= 0)
|
||||
{
|
||||
if (ignore_env == 0 && (ss = get_env_value ("COLUMNS")))
|
||||
screenwidth = atoi (ss);
|
||||
if (ignore_env == 0 && (ss = sh_get_env_value ("COLUMNS")))
|
||||
_rl_screenwidth = atoi (ss);
|
||||
|
||||
#if !defined (__DJGPP__)
|
||||
if (screenwidth <= 0 && term_string_buffer)
|
||||
screenwidth = tgetnum ("co");
|
||||
if (_rl_screenwidth <= 0 && term_string_buffer)
|
||||
_rl_screenwidth = tgetnum ("co");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Environment variable LINES overrides setting of "li" if IGNORE_ENV
|
||||
is unset. */
|
||||
if (screenheight <= 0)
|
||||
if (_rl_screenheight <= 0)
|
||||
{
|
||||
if (ignore_env == 0 && (ss = get_env_value ("LINES")))
|
||||
screenheight = atoi (ss);
|
||||
if (ignore_env == 0 && (ss = sh_get_env_value ("LINES")))
|
||||
_rl_screenheight = atoi (ss);
|
||||
|
||||
#if !defined (__DJGPP__)
|
||||
if (screenheight <= 0 && term_string_buffer)
|
||||
screenheight = tgetnum ("li");
|
||||
if (_rl_screenheight <= 0 && term_string_buffer)
|
||||
_rl_screenheight = tgetnum ("li");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* If all else fails, default to 80x24 terminal. */
|
||||
if (screenwidth <= 1)
|
||||
screenwidth = 80;
|
||||
if (_rl_screenwidth <= 1)
|
||||
_rl_screenwidth = 80;
|
||||
|
||||
if (screenheight <= 0)
|
||||
screenheight = 24;
|
||||
if (_rl_screenheight <= 0)
|
||||
_rl_screenheight = 24;
|
||||
|
||||
/* If we're being compiled as part of bash, set the environment
|
||||
variables $LINES and $COLUMNS to new values. Otherwise, just
|
||||
do a pair of putenv () or setenv () calls. */
|
||||
set_lines_and_columns (screenheight, screenwidth);
|
||||
sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
|
||||
|
||||
if (_rl_term_autowrap == 0)
|
||||
screenwidth--;
|
||||
_rl_screenwidth--;
|
||||
|
||||
screenchars = screenwidth * screenheight;
|
||||
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
|
||||
}
|
||||
|
||||
void
|
||||
_rl_set_screen_size (rows, cols)
|
||||
int rows, cols;
|
||||
{
|
||||
screenheight = rows;
|
||||
screenwidth = cols;
|
||||
if (rows == 0 || cols == 0)
|
||||
return;
|
||||
|
||||
_rl_screenheight = rows;
|
||||
_rl_screenwidth = cols;
|
||||
|
||||
if (_rl_term_autowrap == 0)
|
||||
screenwidth--;
|
||||
_rl_screenwidth--;
|
||||
|
||||
screenchars = screenwidth * screenheight;
|
||||
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
|
||||
}
|
||||
|
||||
void
|
||||
rl_set_screen_size (rows, cols)
|
||||
int rows, cols;
|
||||
{
|
||||
_rl_set_screen_size (rows, cols);
|
||||
}
|
||||
|
||||
void
|
||||
rl_get_screen_size (rows, cols)
|
||||
int *rows, *cols;
|
||||
{
|
||||
if (rows)
|
||||
*rows = _rl_screenheight;
|
||||
if (cols)
|
||||
*cols = _rl_screenwidth;
|
||||
}
|
||||
|
||||
void
|
||||
rl_resize_terminal ()
|
||||
{
|
||||
@ -247,7 +279,7 @@ rl_resize_terminal ()
|
||||
}
|
||||
|
||||
struct _tc_string {
|
||||
char *tc_var;
|
||||
const char *tc_var;
|
||||
char **tc_value;
|
||||
};
|
||||
|
||||
@ -255,32 +287,32 @@ struct _tc_string {
|
||||
search algorithm to something smarter. */
|
||||
static struct _tc_string tc_strings[] =
|
||||
{
|
||||
{ "DC", &term_DC },
|
||||
{ "IC", &term_IC },
|
||||
{ "ce", &term_clreol },
|
||||
{ "cl", &term_clrpag },
|
||||
{ "cr", &term_cr },
|
||||
{ "dc", &term_dc },
|
||||
{ "ei", &term_ei },
|
||||
{ "ic", &term_ic },
|
||||
{ "im", &term_im },
|
||||
{ "kd", &term_kd },
|
||||
{ "kh", &term_kh }, /* home */
|
||||
{ "@7", &term_kH }, /* end */
|
||||
{ "kl", &term_kl },
|
||||
{ "kr", &term_kr },
|
||||
{ "ku", &term_ku },
|
||||
{ "ks", &term_ks },
|
||||
{ "ke", &term_ke },
|
||||
{ "le", &term_backspace },
|
||||
{ "mm", &term_mm },
|
||||
{ "mo", &term_mo },
|
||||
{ "DC", &_rl_term_DC },
|
||||
{ "IC", &_rl_term_IC },
|
||||
{ "ce", &_rl_term_clreol },
|
||||
{ "cl", &_rl_term_clrpag },
|
||||
{ "cr", &_rl_term_cr },
|
||||
{ "dc", &_rl_term_dc },
|
||||
{ "ei", &_rl_term_ei },
|
||||
{ "ic", &_rl_term_ic },
|
||||
{ "im", &_rl_term_im },
|
||||
{ "kd", &_rl_term_kd },
|
||||
{ "kh", &_rl_term_kh }, /* home */
|
||||
{ "@7", &_rl_term_kH }, /* end */
|
||||
{ "kl", &_rl_term_kl },
|
||||
{ "kr", &_rl_term_kr },
|
||||
{ "ku", &_rl_term_ku },
|
||||
{ "ks", &_rl_term_ks },
|
||||
{ "ke", &_rl_term_ke },
|
||||
{ "le", &_rl_term_backspace },
|
||||
{ "mm", &_rl_term_mm },
|
||||
{ "mo", &_rl_term_mo },
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
{ "nd", &term_forward_char },
|
||||
{ "nd", &_rl_term_forward_char },
|
||||
#endif
|
||||
{ "pc", &term_pc },
|
||||
{ "up", &term_up },
|
||||
{ "vb", &visible_bell },
|
||||
{ "pc", &_rl_term_pc },
|
||||
{ "up", &_rl_term_up },
|
||||
{ "vb", &_rl_visible_bell },
|
||||
};
|
||||
|
||||
#define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string))
|
||||
@ -305,16 +337,17 @@ get_term_capabilities (bp)
|
||||
|
||||
int
|
||||
_rl_init_terminal_io (terminal_name)
|
||||
char *terminal_name;
|
||||
const char *terminal_name;
|
||||
{
|
||||
char *term, *buffer;
|
||||
const char *term;
|
||||
char *buffer;
|
||||
int tty, tgetent_ret;
|
||||
Keymap xkeymap;
|
||||
|
||||
term = terminal_name ? terminal_name : get_env_value ("TERM");
|
||||
term_clrpag = term_cr = term_clreol = (char *)NULL;
|
||||
term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
|
||||
_rl_term_clrpag = _rl_term_cr = _rl_term_clreol = (char *)NULL;
|
||||
tty = rl_instream ? fileno (rl_instream) : 0;
|
||||
screenwidth = screenheight = 0;
|
||||
_rl_screenwidth = _rl_screenheight = 0;
|
||||
|
||||
if (term == 0)
|
||||
term = "dumb";
|
||||
@ -345,41 +378,40 @@ _rl_init_terminal_io (terminal_name)
|
||||
FREE (term_buffer);
|
||||
buffer = term_buffer = term_string_buffer = (char *)NULL;
|
||||
|
||||
dumb_term = 1;
|
||||
_rl_term_autowrap = 0; /* used by _rl_get_screen_size */
|
||||
|
||||
#if defined (__EMX__)
|
||||
_emx_get_screensize (&screenwidth, &screenheight);
|
||||
screenwidth--;
|
||||
_emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
|
||||
_rl_screenwidth--;
|
||||
#else /* !__EMX__ */
|
||||
_rl_get_screen_size (tty, 0);
|
||||
#endif /* !__EMX__ */
|
||||
|
||||
/* Defaults. */
|
||||
if (screenwidth <= 0 || screenheight <= 0)
|
||||
if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
|
||||
{
|
||||
screenwidth = 79;
|
||||
screenheight = 24;
|
||||
_rl_screenwidth = 79;
|
||||
_rl_screenheight = 24;
|
||||
}
|
||||
|
||||
/* Everything below here is used by the redisplay code (tputs). */
|
||||
screenchars = screenwidth * screenheight;
|
||||
term_cr = "\r";
|
||||
term_im = term_ei = term_ic = term_IC = (char *)NULL;
|
||||
term_up = term_dc = term_DC = visible_bell = (char *)NULL;
|
||||
term_ku = term_kd = term_kl = term_kr = (char *)NULL;
|
||||
term_mm = term_mo = (char *)NULL;
|
||||
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
|
||||
_rl_term_cr = "\r";
|
||||
_rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
|
||||
_rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
|
||||
_rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
|
||||
_rl_term_mm = _rl_term_mo = (char *)NULL;
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
term_forward_char = (char *)NULL;
|
||||
#endif
|
||||
terminal_can_insert = term_has_meta = 0;
|
||||
_rl_terminal_can_insert = term_has_meta = 0;
|
||||
|
||||
/* Reasonable defaults for tgoto(). Readline currently only uses
|
||||
tgoto if term_IC or term_DC is defined, but just in case we
|
||||
tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
|
||||
change that later... */
|
||||
PC = '\0';
|
||||
BC = term_backspace = "\b";
|
||||
UP = term_up;
|
||||
BC = _rl_term_backspace = "\b";
|
||||
UP = _rl_term_up;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -388,12 +420,12 @@ _rl_init_terminal_io (terminal_name)
|
||||
|
||||
/* Set up the variables that the termcap library expects the application
|
||||
to provide. */
|
||||
PC = term_pc ? *term_pc : 0;
|
||||
BC = term_backspace;
|
||||
UP = term_up;
|
||||
PC = _rl_term_pc ? *_rl_term_pc : 0;
|
||||
BC = _rl_term_backspace;
|
||||
UP = _rl_term_up;
|
||||
|
||||
if (!term_cr)
|
||||
term_cr = "\r";
|
||||
if (!_rl_term_cr)
|
||||
_rl_term_cr = "\r";
|
||||
|
||||
_rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
|
||||
|
||||
@ -403,36 +435,36 @@ _rl_init_terminal_io (terminal_name)
|
||||
character insertion if *any one of* the capabilities `IC',
|
||||
`im', `ic' or `ip' is provided." But we can't do anything if
|
||||
only `ip' is provided, so... */
|
||||
terminal_can_insert = (term_IC || term_im || term_ic);
|
||||
_rl_terminal_can_insert = (_rl_term_IC || _rl_term_im || _rl_term_ic);
|
||||
|
||||
/* Check to see if this terminal has a meta key and clear the capability
|
||||
variables if there is none. */
|
||||
term_has_meta = (tgetflag ("km") || tgetflag ("MT"));
|
||||
if (!term_has_meta)
|
||||
term_mm = term_mo = (char *)NULL;
|
||||
_rl_term_mm = _rl_term_mo = (char *)NULL;
|
||||
|
||||
/* Attempt to find and bind the arrow keys. Do not override already
|
||||
bound keys in an overzealous attempt, however. */
|
||||
xkeymap = _rl_keymap;
|
||||
|
||||
_rl_keymap = emacs_standard_keymap;
|
||||
_rl_bind_if_unbound (term_ku, rl_get_previous_history);
|
||||
_rl_bind_if_unbound (term_kd, rl_get_next_history);
|
||||
_rl_bind_if_unbound (term_kr, rl_forward);
|
||||
_rl_bind_if_unbound (term_kl, rl_backward);
|
||||
_rl_bind_if_unbound (_rl_term_ku, rl_get_previous_history);
|
||||
_rl_bind_if_unbound (_rl_term_kd, rl_get_next_history);
|
||||
_rl_bind_if_unbound (_rl_term_kr, rl_forward);
|
||||
_rl_bind_if_unbound (_rl_term_kl, rl_backward);
|
||||
|
||||
_rl_bind_if_unbound (term_kh, rl_beg_of_line); /* Home */
|
||||
_rl_bind_if_unbound (term_kH, rl_end_of_line); /* End */
|
||||
_rl_bind_if_unbound (_rl_term_kh, rl_beg_of_line); /* Home */
|
||||
_rl_bind_if_unbound (_rl_term_kH, rl_end_of_line); /* End */
|
||||
|
||||
#if defined (VI_MODE)
|
||||
_rl_keymap = vi_movement_keymap;
|
||||
_rl_bind_if_unbound (term_ku, rl_get_previous_history);
|
||||
_rl_bind_if_unbound (term_kd, rl_get_next_history);
|
||||
_rl_bind_if_unbound (term_kr, rl_forward);
|
||||
_rl_bind_if_unbound (term_kl, rl_backward);
|
||||
_rl_bind_if_unbound (_rl_term_ku, rl_get_previous_history);
|
||||
_rl_bind_if_unbound (_rl_term_kd, rl_get_next_history);
|
||||
_rl_bind_if_unbound (_rl_term_kr, rl_forward);
|
||||
_rl_bind_if_unbound (_rl_term_kl, rl_backward);
|
||||
|
||||
_rl_bind_if_unbound (term_kh, rl_beg_of_line); /* Home */
|
||||
_rl_bind_if_unbound (term_kH, rl_end_of_line); /* End */
|
||||
_rl_bind_if_unbound (_rl_term_kh, rl_beg_of_line); /* Home */
|
||||
_rl_bind_if_unbound (_rl_term_kH, rl_end_of_line); /* End */
|
||||
#endif /* VI_MODE */
|
||||
|
||||
_rl_keymap = xkeymap;
|
||||
@ -442,7 +474,7 @@ _rl_init_terminal_io (terminal_name)
|
||||
|
||||
char *
|
||||
rl_get_termcap (cap)
|
||||
char *cap;
|
||||
const char *cap;
|
||||
{
|
||||
register int i;
|
||||
|
||||
@ -460,7 +492,7 @@ rl_get_termcap (cap)
|
||||
has changed. */
|
||||
int
|
||||
rl_reset_terminal (terminal_name)
|
||||
char *terminal_name;
|
||||
const char *terminal_name;
|
||||
{
|
||||
_rl_init_terminal_io (terminal_name);
|
||||
return 0;
|
||||
@ -486,7 +518,7 @@ _rl_output_character_function (c)
|
||||
/* Write COUNT characters from STRING to the output stream. */
|
||||
void
|
||||
_rl_output_some_chars (string, count)
|
||||
char *string;
|
||||
const char *string;
|
||||
int count;
|
||||
{
|
||||
fwrite (string, 1, count, _rl_out_stream);
|
||||
@ -499,9 +531,9 @@ _rl_backspace (count)
|
||||
{
|
||||
register int i;
|
||||
|
||||
if (term_backspace)
|
||||
if (_rl_term_backspace)
|
||||
for (i = 0; i < count; i++)
|
||||
tputs (term_backspace, 1, _rl_output_character_function);
|
||||
tputs (_rl_term_backspace, 1, _rl_output_character_function);
|
||||
else
|
||||
for (i = 0; i < count; i++)
|
||||
putc ('\b', _rl_out_stream);
|
||||
@ -510,11 +542,11 @@ _rl_backspace (count)
|
||||
|
||||
/* Move to the start of the next line. */
|
||||
int
|
||||
crlf ()
|
||||
rl_crlf ()
|
||||
{
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
if (term_cr)
|
||||
tputs (term_cr, 1, _rl_output_character_function);
|
||||
if (_rl_term_cr)
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif /* NEW_TTY_DRIVER */
|
||||
putc ('\n', _rl_out_stream);
|
||||
return 0;
|
||||
@ -522,7 +554,7 @@ crlf ()
|
||||
|
||||
/* Ring the terminal bell. */
|
||||
int
|
||||
ding ()
|
||||
rl_ding ()
|
||||
{
|
||||
if (readline_echoing_p)
|
||||
{
|
||||
@ -532,9 +564,9 @@ ding ()
|
||||
default:
|
||||
break;
|
||||
case VISIBLE_BELL:
|
||||
if (visible_bell)
|
||||
if (_rl_visible_bell)
|
||||
{
|
||||
tputs (visible_bell, 1, _rl_output_character_function);
|
||||
tputs (_rl_visible_bell, 1, _rl_output_character_function);
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
@ -558,8 +590,8 @@ void
|
||||
_rl_enable_meta_key ()
|
||||
{
|
||||
#if !defined (__DJGPP__)
|
||||
if (term_has_meta && term_mm)
|
||||
tputs (term_mm, 1, _rl_output_character_function);
|
||||
if (term_has_meta && _rl_term_mm)
|
||||
tputs (_rl_term_mm, 1, _rl_output_character_function);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -568,9 +600,9 @@ _rl_control_keypad (on)
|
||||
int on;
|
||||
{
|
||||
#if !defined (__DJGPP__)
|
||||
if (on && term_ks)
|
||||
tputs (term_ks, 1, _rl_output_character_function);
|
||||
else if (!on && term_ke)
|
||||
tputs (term_ke, 1, _rl_output_character_function);
|
||||
if (on && _rl_term_ks)
|
||||
tputs (_rl_term_ks, 1, _rl_output_character_function);
|
||||
else if (!on && _rl_term_ke)
|
||||
tputs (_rl_term_ke, 1, _rl_output_character_function);
|
||||
#endif
|
||||
}
|
||||
|
@ -68,10 +68,10 @@
|
||||
in words, or 1 if it is. */
|
||||
|
||||
int _rl_allow_pathname_alphabetic_chars = 0;
|
||||
static char *pathname_alphabetic_chars = "/-_=~.#$";
|
||||
static const char *pathname_alphabetic_chars = "/-_=~.#$";
|
||||
|
||||
int
|
||||
alphabetic (c)
|
||||
rl_alphabetic (c)
|
||||
int c;
|
||||
{
|
||||
if (ALPHABETIC (c))
|
||||
@ -85,16 +85,16 @@ alphabetic (c)
|
||||
int
|
||||
_rl_abort_internal ()
|
||||
{
|
||||
ding ();
|
||||
rl_ding ();
|
||||
rl_clear_message ();
|
||||
_rl_init_argument ();
|
||||
rl_pending_input = 0;
|
||||
rl_clear_pending_input ();
|
||||
|
||||
_rl_defining_kbd_macro = 0;
|
||||
while (_rl_executing_macro)
|
||||
while (rl_executing_macro)
|
||||
_rl_pop_executing_macro ();
|
||||
|
||||
rl_last_func = (Function *)NULL;
|
||||
rl_last_func = (rl_command_func_t *)NULL;
|
||||
longjmp (readline_top_level, 1);
|
||||
return (0);
|
||||
}
|
||||
@ -114,7 +114,7 @@ rl_tty_status (count, key)
|
||||
ioctl (1, TIOCSTAT, (char *)0);
|
||||
rl_refresh_line (count, key);
|
||||
#else
|
||||
ding ();
|
||||
rl_ding ();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@ -216,13 +216,35 @@ rl_tilde_expand (ignore, key)
|
||||
match in s1. The compare is case insensitive. */
|
||||
char *
|
||||
_rl_strindex (s1, s2)
|
||||
register char *s1, *s2;
|
||||
register const char *s1, *s2;
|
||||
{
|
||||
register int i, l, len;
|
||||
|
||||
for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++)
|
||||
if (_rl_strnicmp (s1 + i, s2, l) == 0)
|
||||
return (s1 + i);
|
||||
return ((char *) (s1 + i));
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
/* Find the first occurrence in STRING1 of any character from STRING2.
|
||||
Return a pointer to the character in STRING1. */
|
||||
char *
|
||||
_rl_strpbrk (string1, string2)
|
||||
const char *string1, *string2;
|
||||
{
|
||||
register const char *scan;
|
||||
|
||||
if (string2 == NULL)
|
||||
return ((char *)NULL);
|
||||
|
||||
for (; *string1; string1++)
|
||||
{
|
||||
for (scan = string2; *scan; scan++)
|
||||
{
|
||||
if (*string1 == *scan)
|
||||
return ((char *)string1);
|
||||
}
|
||||
}
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
@ -346,7 +368,7 @@ _rl_digit_value (c)
|
||||
#undef _rl_savestring
|
||||
char *
|
||||
_rl_savestring (s)
|
||||
char *s;
|
||||
const char *s;
|
||||
{
|
||||
return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s)));
|
||||
return (strcpy (xmalloc (1 + (int)strlen (s)), (s)));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user