mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-10 21:50:49 +02:00
commit bash-20080507 snapshot
This commit is contained in:
+47
-18
@@ -1,6 +1,6 @@
|
||||
/* bind.c -- key binding and startup file support for the readline library. */
|
||||
|
||||
/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2008 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
@@ -1431,6 +1431,7 @@ static const struct {
|
||||
{ "page-completions", &_rl_page_completions, 0 },
|
||||
{ "prefer-visible-bell", &_rl_prefer_visible_bell, V_SPECIAL },
|
||||
{ "print-completions-horizontally", &_rl_print_completions_horizontally, 0 },
|
||||
{ "revert-all-at-newline", &_rl_revert_all_at_newline, 0 },
|
||||
{ "show-all-if-ambiguous", &_rl_complete_show_all, 0 },
|
||||
{ "show-all-if-unmodified", &_rl_complete_show_unmodified, 0 },
|
||||
#if defined (VISIBLE_STATS)
|
||||
@@ -1489,11 +1490,12 @@ typedef int _rl_sv_func_t PARAMS((const char *));
|
||||
/* Forward declarations */
|
||||
static int sv_bell_style PARAMS((const char *));
|
||||
static int sv_combegin PARAMS((const char *));
|
||||
static int sv_dispprefix PARAMS((const char *));
|
||||
static int sv_compquery PARAMS((const char *));
|
||||
static int sv_editmode PARAMS((const char *));
|
||||
static int sv_histsize PARAMS((const char *));
|
||||
static int sv_isrchterm PARAMS((const char *));
|
||||
static int sv_keymap PARAMS((const char *));
|
||||
static int sv_histsize PARAMS((const char *));
|
||||
|
||||
static const struct {
|
||||
const char * const name;
|
||||
@@ -1502,6 +1504,7 @@ static const struct {
|
||||
} string_varlist[] = {
|
||||
{ "bell-style", V_STRING, sv_bell_style },
|
||||
{ "comment-begin", V_STRING, sv_combegin },
|
||||
{ "completion-prefix-display-length", V_INT, sv_dispprefix },
|
||||
{ "completion-query-items", V_INT, sv_compquery },
|
||||
{ "editing-mode", V_STRING, sv_editmode },
|
||||
{ "history-size", V_INT, sv_histsize },
|
||||
@@ -1615,6 +1618,22 @@ sv_combegin (value)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
sv_dispprefix (value)
|
||||
const char *value;
|
||||
{
|
||||
int nval = 0;
|
||||
|
||||
if (value && *value)
|
||||
{
|
||||
nval = atoi (value);
|
||||
if (nval < 0)
|
||||
nval = 0;
|
||||
}
|
||||
_rl_completion_prefix_display_length = nval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sv_compquery (value)
|
||||
const char *value;
|
||||
@@ -1631,6 +1650,22 @@ sv_compquery (value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sv_histsize (value)
|
||||
const char *value;
|
||||
{
|
||||
int nval = 500;
|
||||
|
||||
if (value && *value)
|
||||
{
|
||||
nval = atoi (value);
|
||||
if (nval < 0)
|
||||
return 1;
|
||||
}
|
||||
stifle_history (nval);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sv_keymap (value)
|
||||
const char *value;
|
||||
@@ -1699,22 +1734,6 @@ sv_isrchterm (value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sv_histsize (value)
|
||||
const char *value;
|
||||
{
|
||||
int nval = 500;
|
||||
|
||||
if (value && *value)
|
||||
{
|
||||
nval = atoi (value);
|
||||
if (nval < 0)
|
||||
return 1;
|
||||
}
|
||||
stifle_history (nval);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return the character which matches NAME.
|
||||
For example, `Space' returns ' '. */
|
||||
|
||||
@@ -2237,6 +2256,11 @@ _rl_get_string_variable_value (name)
|
||||
}
|
||||
else if (_rl_stricmp (name, "comment-begin") == 0)
|
||||
return (_rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
|
||||
else if (_rl_stricmp (name, "completion-prefix-display-length") == 0)
|
||||
{
|
||||
sprintf (numbuf, "%d", _rl_completion_prefix_display_length);
|
||||
return (numbuf);
|
||||
}
|
||||
else if (_rl_stricmp (name, "completion-query-items") == 0)
|
||||
{
|
||||
sprintf (numbuf, "%d", rl_completion_query_items);
|
||||
@@ -2244,6 +2268,11 @@ _rl_get_string_variable_value (name)
|
||||
}
|
||||
else if (_rl_stricmp (name, "editing-mode") == 0)
|
||||
return (rl_get_keymap_name_from_edit_mode ());
|
||||
else if (_rl_stricmp (name, "history-size") == 0)
|
||||
{
|
||||
sprintf (numbuf, "%d", history_is_stifled() ? history_max_entries : 0);
|
||||
return (numbuf);
|
||||
}
|
||||
else if (_rl_stricmp (name, "isearch-terminators") == 0)
|
||||
{
|
||||
if (_rl_isearch_terminators == 0)
|
||||
|
||||
+70
-42
@@ -1,6 +1,6 @@
|
||||
/* bind.c -- key binding and startup file support for the readline library. */
|
||||
|
||||
/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2008 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
@@ -317,7 +317,7 @@ rl_macro_bind (keyseq, macro, map)
|
||||
|
||||
if (rl_translate_keyseq (macro, macro_keys, ¯o_keys_len))
|
||||
{
|
||||
free (macro_keys);
|
||||
xfree (macro_keys);
|
||||
return -1;
|
||||
}
|
||||
rl_generic_bind (ISMACR, keyseq, macro_keys, map);
|
||||
@@ -347,7 +347,7 @@ rl_generic_bind (type, keyseq, data, map)
|
||||
if (keyseq == 0 || *keyseq == 0)
|
||||
{
|
||||
if (type == ISMACR)
|
||||
free (data);
|
||||
xfree (data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ rl_generic_bind (type, keyseq, data, map)
|
||||
KEYS into KEYS_LEN. */
|
||||
if (rl_translate_keyseq (keyseq, keys, &keys_len))
|
||||
{
|
||||
free (keys);
|
||||
xfree (keys);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ rl_generic_bind (type, keyseq, data, map)
|
||||
ic = uc;
|
||||
if (ic < 0 || ic >= KEYMAP_SIZE)
|
||||
{
|
||||
free (keys);
|
||||
xfree (keys);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ rl_generic_bind (type, keyseq, data, map)
|
||||
else
|
||||
{
|
||||
if (map[ic].type == ISMACR)
|
||||
free ((char *)map[ic].function);
|
||||
xfree ((char *)map[ic].function);
|
||||
else if (map[ic].type == ISKMAP)
|
||||
{
|
||||
map = FUNCTION_TO_KEYMAP (map, ic);
|
||||
@@ -427,7 +427,7 @@ rl_generic_bind (type, keyseq, data, map)
|
||||
|
||||
rl_binding_keymap = map;
|
||||
}
|
||||
free (keys);
|
||||
xfree (keys);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -793,7 +793,7 @@ _rl_read_file (filename, sizep)
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
free (buffer);
|
||||
xfree (buffer);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
@@ -863,7 +863,7 @@ _rl_read_init_file (filename, include_level)
|
||||
|
||||
openname = tilde_expand (filename);
|
||||
buffer = _rl_read_file (openname, &file_size);
|
||||
free (openname);
|
||||
xfree (openname);
|
||||
|
||||
if (buffer == 0)
|
||||
return (errno);
|
||||
@@ -911,7 +911,7 @@ _rl_read_init_file (filename, include_level)
|
||||
current_readline_init_lineno++;
|
||||
}
|
||||
|
||||
free (buffer);
|
||||
xfree (buffer);
|
||||
currently_reading_init_file = 0;
|
||||
return (0);
|
||||
}
|
||||
@@ -1002,7 +1002,7 @@ parser_if (args)
|
||||
`$if term=sun-cmd' into their .inputrc. */
|
||||
_rl_parsing_conditionalized_out = _rl_stricmp (args + 5, tname) &&
|
||||
_rl_stricmp (args + 5, rl_terminal_name);
|
||||
free (tname);
|
||||
xfree (tname);
|
||||
}
|
||||
#if defined (VI_MODE)
|
||||
else if (_rl_strnicmp (args, "mode=", 5) == 0)
|
||||
@@ -1352,7 +1352,7 @@ rl_parse_and_bind (string)
|
||||
else
|
||||
rl_bind_keyseq (seq, rl_named_function (funname));
|
||||
|
||||
free (seq);
|
||||
xfree (seq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1489,11 +1489,12 @@ typedef int _rl_sv_func_t PARAMS((const char *));
|
||||
/* Forward declarations */
|
||||
static int sv_bell_style PARAMS((const char *));
|
||||
static int sv_combegin PARAMS((const char *));
|
||||
static int sv_dispprefix PARAMS((const char *));
|
||||
static int sv_compquery PARAMS((const char *));
|
||||
static int sv_editmode PARAMS((const char *));
|
||||
static int sv_histsize PARAMS((const char *));
|
||||
static int sv_isrchterm PARAMS((const char *));
|
||||
static int sv_keymap PARAMS((const char *));
|
||||
static int sv_histsize PARAMS((const char *));
|
||||
|
||||
static const struct {
|
||||
const char * const name;
|
||||
@@ -1502,6 +1503,7 @@ static const struct {
|
||||
} string_varlist[] = {
|
||||
{ "bell-style", V_STRING, sv_bell_style },
|
||||
{ "comment-begin", V_STRING, sv_combegin },
|
||||
{ "completion-prefix-display-length", V_INT, sv_dispprefix },
|
||||
{ "completion-query-items", V_INT, sv_compquery },
|
||||
{ "editing-mode", V_STRING, sv_editmode },
|
||||
{ "history-size", V_INT, sv_histsize },
|
||||
@@ -1615,6 +1617,22 @@ sv_combegin (value)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
sv_dispprefix (value)
|
||||
const char *value;
|
||||
{
|
||||
int nval = 0;
|
||||
|
||||
if (value && *value)
|
||||
{
|
||||
nval = atoi (value);
|
||||
if (nval < 0)
|
||||
nval = 0;
|
||||
}
|
||||
_rl_completion_prefix_display_length = nval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sv_compquery (value)
|
||||
const char *value;
|
||||
@@ -1631,6 +1649,22 @@ sv_compquery (value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sv_histsize (value)
|
||||
const char *value;
|
||||
{
|
||||
int nval = 500;
|
||||
|
||||
if (value && *value)
|
||||
{
|
||||
nval = atoi (value);
|
||||
if (nval < 0)
|
||||
return 1;
|
||||
}
|
||||
stifle_history (nval);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sv_keymap (value)
|
||||
const char *value;
|
||||
@@ -1695,26 +1729,10 @@ sv_isrchterm (value)
|
||||
rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
|
||||
_rl_isearch_terminators[end] = '\0';
|
||||
|
||||
free (v);
|
||||
xfree (v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sv_histsize (value)
|
||||
const char *value;
|
||||
{
|
||||
int nval = 500;
|
||||
|
||||
if (value && *value)
|
||||
{
|
||||
nval = atoi (value);
|
||||
if (nval < 0)
|
||||
return 1;
|
||||
}
|
||||
stifle_history (nval);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return the character which matches NAME.
|
||||
For example, `Space' returns ' '. */
|
||||
|
||||
@@ -1856,7 +1874,7 @@ rl_list_funmap_names ()
|
||||
for (i = 0; funmap_names[i]; i++)
|
||||
fprintf (rl_outstream, "%s\n", funmap_names[i]);
|
||||
|
||||
free (funmap_names);
|
||||
xfree (funmap_names);
|
||||
}
|
||||
|
||||
static char *
|
||||
@@ -2022,7 +2040,7 @@ rl_invoking_keyseqs_in_map (function, map)
|
||||
}
|
||||
|
||||
strcat (keyname, seqs[i]);
|
||||
free (seqs[i]);
|
||||
xfree (seqs[i]);
|
||||
|
||||
if (result_index + 2 > result_size)
|
||||
{
|
||||
@@ -2034,7 +2052,7 @@ rl_invoking_keyseqs_in_map (function, map)
|
||||
result[result_index] = (char *)NULL;
|
||||
}
|
||||
|
||||
free (seqs);
|
||||
xfree (seqs);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2086,10 +2104,10 @@ rl_function_dumper (print_readably)
|
||||
{
|
||||
fprintf (rl_outstream, "\"%s\": %s\n",
|
||||
invokers[j], name);
|
||||
free (invokers[j]);
|
||||
xfree (invokers[j]);
|
||||
}
|
||||
|
||||
free (invokers);
|
||||
xfree (invokers);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2113,9 +2131,9 @@ rl_function_dumper (print_readably)
|
||||
fprintf (rl_outstream, "...\n");
|
||||
|
||||
for (j = 0; invokers[j]; j++)
|
||||
free (invokers[j]);
|
||||
xfree (invokers[j]);
|
||||
|
||||
free (invokers);
|
||||
xfree (invokers);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2161,8 +2179,8 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
|
||||
fprintf (rl_outstream, "%s%s outputs %s\n", prefix ? prefix : "",
|
||||
keyname,
|
||||
out ? out : "");
|
||||
free (keyname);
|
||||
free (out);
|
||||
xfree (keyname);
|
||||
xfree (out);
|
||||
break;
|
||||
case ISFUNC:
|
||||
break;
|
||||
@@ -2185,13 +2203,13 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
|
||||
out = (char *)xmalloc (strlen (keyname) + prefix_len + 1);
|
||||
strcpy (out, prefix);
|
||||
strcpy (out + prefix_len, keyname);
|
||||
free (keyname);
|
||||
xfree (keyname);
|
||||
keyname = out;
|
||||
}
|
||||
}
|
||||
|
||||
_rl_macro_dumper_internal (print_readably, FUNCTION_TO_KEYMAP (map, key), keyname);
|
||||
free (keyname);
|
||||
xfree (keyname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2237,6 +2255,11 @@ _rl_get_string_variable_value (name)
|
||||
}
|
||||
else if (_rl_stricmp (name, "comment-begin") == 0)
|
||||
return (_rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
|
||||
else if (_rl_stricmp (name, "completion-prefix-display-length") == 0)
|
||||
{
|
||||
sprintf (numbuf, "%d", _rl_completion_prefix_display_length);
|
||||
return (numbuf);
|
||||
}
|
||||
else if (_rl_stricmp (name, "completion-query-items") == 0)
|
||||
{
|
||||
sprintf (numbuf, "%d", rl_completion_query_items);
|
||||
@@ -2244,6 +2267,11 @@ _rl_get_string_variable_value (name)
|
||||
}
|
||||
else if (_rl_stricmp (name, "editing-mode") == 0)
|
||||
return (rl_get_keymap_name_from_edit_mode ());
|
||||
else if (_rl_stricmp (name, "history-size") == 0)
|
||||
{
|
||||
sprintf (numbuf, "%d", history_is_stifled() ? history_max_entries : 0);
|
||||
return (numbuf);
|
||||
}
|
||||
else if (_rl_stricmp (name, "isearch-terminators") == 0)
|
||||
{
|
||||
if (_rl_isearch_terminators == 0)
|
||||
@@ -2252,7 +2280,7 @@ _rl_get_string_variable_value (name)
|
||||
if (ret)
|
||||
{
|
||||
strncpy (numbuf, ret, sizeof (numbuf) - 1);
|
||||
free (ret);
|
||||
xfree (ret);
|
||||
numbuf[sizeof(numbuf) - 1] = '\0';
|
||||
}
|
||||
else
|
||||
|
||||
+54
-13
@@ -110,8 +110,8 @@ static int get_y_or_n PARAMS((int));
|
||||
static int _rl_internal_pager PARAMS((int));
|
||||
static char *printable_part PARAMS((char *));
|
||||
static int fnwidth PARAMS((const char *));
|
||||
static int fnprint PARAMS((const char *));
|
||||
static int print_filename PARAMS((char *, char *));
|
||||
static int fnprint PARAMS((const char *, int));
|
||||
static int print_filename PARAMS((char *, char *, int));
|
||||
|
||||
static char **gen_completion_matches PARAMS((char *, int, int, rl_compentry_func_t *, int, int));
|
||||
|
||||
@@ -164,6 +164,12 @@ int _rl_completion_case_fold;
|
||||
Unix) when doing filename completion. */
|
||||
int _rl_match_hidden_files = 1;
|
||||
|
||||
/* Length in characters of a common prefix replaced with an ellipsis (`...')
|
||||
when displaying completion matches. Matches whose printable portion has
|
||||
more than this number of displaying characters in common will have the common
|
||||
display prefix replaced with an ellipsis. */
|
||||
int _rl_completion_prefix_display_length = 0;
|
||||
|
||||
/* Global variables available to applications using readline. */
|
||||
|
||||
#if defined (VISIBLE_STATS)
|
||||
@@ -647,9 +653,12 @@ fnwidth (string)
|
||||
return width;
|
||||
}
|
||||
|
||||
#define ELLIPSIS_LEN 3
|
||||
|
||||
static int
|
||||
fnprint (to_print)
|
||||
fnprint (to_print, prefix_bytes)
|
||||
const char *to_print;
|
||||
int prefix_bytes;
|
||||
{
|
||||
int printed_len;
|
||||
const char *s;
|
||||
@@ -665,7 +674,23 @@ fnprint (to_print)
|
||||
#endif
|
||||
|
||||
printed_len = 0;
|
||||
s = to_print;
|
||||
|
||||
/* Don't print only the ellipsis if the common prefix is one of the
|
||||
possible completions */
|
||||
if (to_print[prefix_bytes] == '\0')
|
||||
prefix_bytes = 0;
|
||||
|
||||
if (prefix_bytes)
|
||||
{
|
||||
char ellipsis;
|
||||
|
||||
ellipsis = (to_print[prefix_bytes] == '.') ? '_' : '.';
|
||||
for (w = 0; w < ELLIPSIS_LEN; w++)
|
||||
putc (ellipsis, rl_outstream);
|
||||
printed_len = ELLIPSIS_LEN;
|
||||
}
|
||||
|
||||
s = to_print + prefix_bytes;
|
||||
while (*s)
|
||||
{
|
||||
if (CTRL_CHAR (*s))
|
||||
@@ -724,14 +749,15 @@ fnprint (to_print)
|
||||
filenames. Return the number of characters we output. */
|
||||
|
||||
static int
|
||||
print_filename (to_print, full_pathname)
|
||||
print_filename (to_print, full_pathname, prefix_bytes)
|
||||
char *to_print, *full_pathname;
|
||||
int prefix_bytes;
|
||||
{
|
||||
int printed_len, extension_char, slen, tlen;
|
||||
char *s, c, *new_full_pathname, *dn;
|
||||
|
||||
extension_char = 0;
|
||||
printed_len = fnprint (to_print);
|
||||
printed_len = fnprint (to_print, prefix_bytes);
|
||||
|
||||
#if defined (VISIBLE_STATS)
|
||||
if (rl_filename_completion_desired && (rl_visible_stats || _rl_complete_mark_directories))
|
||||
@@ -1289,8 +1315,24 @@ rl_display_match_list (matches, len, max)
|
||||
int len, max;
|
||||
{
|
||||
int count, limit, printed_len, lines;
|
||||
int i, j, k, l;
|
||||
char *temp;
|
||||
int i, j, k, l, common_length, sind;
|
||||
char *temp, *t;
|
||||
|
||||
/* Find the length of the prefix common to all items: length as displayed
|
||||
characters (common_length) and as a byte index into the matches (sind) */
|
||||
common_length = sind = 0;
|
||||
if (_rl_completion_prefix_display_length > 0)
|
||||
{
|
||||
t = printable_part (matches[0]);
|
||||
temp = strrchr (t, '/');
|
||||
common_length = temp ? fnwidth (temp) : fnwidth (t);
|
||||
sind = temp ? strlen (temp) : strlen (t);
|
||||
|
||||
if (common_length > _rl_completion_prefix_display_length && common_length > ELLIPSIS_LEN)
|
||||
max -= common_length - ELLIPSIS_LEN;
|
||||
else
|
||||
common_length = sind = 0;
|
||||
}
|
||||
|
||||
/* How many items of MAX length can we fit in the screen window? */
|
||||
max += 2;
|
||||
@@ -1329,7 +1371,7 @@ rl_display_match_list (matches, len, max)
|
||||
else
|
||||
{
|
||||
temp = printable_part (matches[l]);
|
||||
printed_len = print_filename (temp, matches[l]);
|
||||
printed_len = print_filename (temp, matches[l], sind);
|
||||
|
||||
if (j + 1 < limit)
|
||||
for (k = 0; k < max - printed_len; k++)
|
||||
@@ -1353,7 +1395,7 @@ rl_display_match_list (matches, len, max)
|
||||
for (i = 1; matches[i]; i++)
|
||||
{
|
||||
temp = printable_part (matches[i]);
|
||||
printed_len = print_filename (temp, matches[i]);
|
||||
printed_len = print_filename (temp, matches[i], sind);
|
||||
/* Have we reached the end of this line? */
|
||||
if (matches[i+1])
|
||||
{
|
||||
@@ -1403,7 +1445,7 @@ display_matches (matches)
|
||||
{
|
||||
temp = printable_part (matches[0]);
|
||||
rl_crlf ();
|
||||
print_filename (temp, matches[0]);
|
||||
print_filename (temp, matches[0], 0);
|
||||
rl_crlf ();
|
||||
|
||||
rl_forced_update_display ();
|
||||
@@ -2221,8 +2263,7 @@ rl_old_menu_complete (count, invoking_key)
|
||||
/* matches[0] is lcd if match_list_size > 1, but the circular buffer
|
||||
code below should take care of it. */
|
||||
|
||||
if
|
||||
(match_list_size > 1 && _rl_complete_show_all)
|
||||
if (match_list_size > 1 && _rl_complete_show_all)
|
||||
display_matches (matches);
|
||||
}
|
||||
|
||||
|
||||
+54
-13
@@ -110,8 +110,8 @@ static int get_y_or_n PARAMS((int));
|
||||
static int _rl_internal_pager PARAMS((int));
|
||||
static char *printable_part PARAMS((char *));
|
||||
static int fnwidth PARAMS((const char *));
|
||||
static int fnprint PARAMS((const char *));
|
||||
static int print_filename PARAMS((char *, char *));
|
||||
static int fnprint PARAMS((const char *, int));
|
||||
static int print_filename PARAMS((char *, char *, int));
|
||||
|
||||
static char **gen_completion_matches PARAMS((char *, int, int, rl_compentry_func_t *, int, int));
|
||||
|
||||
@@ -164,6 +164,12 @@ int _rl_completion_case_fold;
|
||||
Unix) when doing filename completion. */
|
||||
int _rl_match_hidden_files = 1;
|
||||
|
||||
/* Length in characters of a common prefix replaced with an ellipsis (`...')
|
||||
when displaying completion matches. Matches whose printable portion has
|
||||
more than this number of displaying characters in common will have the common
|
||||
display prefix replaced with an ellipsis. */
|
||||
int _rl_completion_prefix_display_length = 0;
|
||||
|
||||
/* Global variables available to applications using readline. */
|
||||
|
||||
#if defined (VISIBLE_STATS)
|
||||
@@ -647,9 +653,12 @@ fnwidth (string)
|
||||
return width;
|
||||
}
|
||||
|
||||
#define ELLIPSIS_LEN 3
|
||||
|
||||
static int
|
||||
fnprint (to_print)
|
||||
fnprint (to_print, prefix_bytes)
|
||||
const char *to_print;
|
||||
int prefix_bytes;
|
||||
{
|
||||
int printed_len;
|
||||
const char *s;
|
||||
@@ -665,7 +674,23 @@ fnprint (to_print)
|
||||
#endif
|
||||
|
||||
printed_len = 0;
|
||||
s = to_print;
|
||||
|
||||
/* Don't print only the ellipsis if the common prefix is one of the
|
||||
possible completions */
|
||||
if (to_print[prefix_bytes] == '\0')
|
||||
prefix_bytes = 0;
|
||||
|
||||
if (prefix_bytes)
|
||||
{
|
||||
char ellipsis;
|
||||
|
||||
ellipsis = (to_print[prefix_bytes] == '.') ? '_' : '.';
|
||||
for (w = 0; w < ELLIPSIS_LEN; w++)
|
||||
putc (ellipsis, rl_outstream);
|
||||
printed_len = ELLIPSIS_LEN;
|
||||
}
|
||||
|
||||
s = to_print + prefix_bytes;
|
||||
while (*s)
|
||||
{
|
||||
if (CTRL_CHAR (*s))
|
||||
@@ -724,14 +749,15 @@ fnprint (to_print)
|
||||
filenames. Return the number of characters we output. */
|
||||
|
||||
static int
|
||||
print_filename (to_print, full_pathname)
|
||||
print_filename (to_print, full_pathname, prefix_bytes)
|
||||
char *to_print, *full_pathname;
|
||||
int prefix_bytes;
|
||||
{
|
||||
int printed_len, extension_char, slen, tlen;
|
||||
char *s, c, *new_full_pathname, *dn;
|
||||
|
||||
extension_char = 0;
|
||||
printed_len = fnprint (to_print);
|
||||
printed_len = fnprint (to_print, prefix_bytes);
|
||||
|
||||
#if defined (VISIBLE_STATS)
|
||||
if (rl_filename_completion_desired && (rl_visible_stats || _rl_complete_mark_directories))
|
||||
@@ -1193,8 +1219,7 @@ compute_lcd_of_matches (match_list, matches, text)
|
||||
}
|
||||
|
||||
/* sort the list to get consistent answers. */
|
||||
if (rl_sort_completion_matches)
|
||||
qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare);
|
||||
qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare);
|
||||
|
||||
si = strlen (text);
|
||||
if (si <= low)
|
||||
@@ -1290,8 +1315,24 @@ rl_display_match_list (matches, len, max)
|
||||
int len, max;
|
||||
{
|
||||
int count, limit, printed_len, lines;
|
||||
int i, j, k, l;
|
||||
char *temp;
|
||||
int i, j, k, l, common_length, sind;
|
||||
char *temp, *t;
|
||||
|
||||
/* Find the length of the prefix common to all items: length as displayed
|
||||
characters (common_length) and as a byte index into the matches (sind) */
|
||||
common_length = sind = 0;
|
||||
if (_rl_completion_prefix_display_length > 0)
|
||||
{
|
||||
t = printable_part (matches[0]);
|
||||
temp = strrchr (t, '/');
|
||||
common_length = temp ? fnwidth (temp) : fnwidth (t);
|
||||
sind = temp ? strlen (temp) : strlen (t);
|
||||
|
||||
if (common_length > _rl_completion_prefix_display_length && common_length > ELLIPSIS_LEN)
|
||||
max -= common_length - ELLIPSIS_LEN;
|
||||
else
|
||||
common_length = sind = 0;
|
||||
}
|
||||
|
||||
/* How many items of MAX length can we fit in the screen window? */
|
||||
max += 2;
|
||||
@@ -1330,7 +1371,7 @@ rl_display_match_list (matches, len, max)
|
||||
else
|
||||
{
|
||||
temp = printable_part (matches[l]);
|
||||
printed_len = print_filename (temp, matches[l]);
|
||||
printed_len = print_filename (temp, matches[l], sind);
|
||||
|
||||
if (j + 1 < limit)
|
||||
for (k = 0; k < max - printed_len; k++)
|
||||
@@ -1354,7 +1395,7 @@ rl_display_match_list (matches, len, max)
|
||||
for (i = 1; matches[i]; i++)
|
||||
{
|
||||
temp = printable_part (matches[i]);
|
||||
printed_len = print_filename (temp, matches[i]);
|
||||
printed_len = print_filename (temp, matches[i], sind);
|
||||
/* Have we reached the end of this line? */
|
||||
if (matches[i+1])
|
||||
{
|
||||
@@ -1404,7 +1445,7 @@ display_matches (matches)
|
||||
{
|
||||
temp = printable_part (matches[0]);
|
||||
rl_crlf ();
|
||||
print_filename (temp, matches[0]);
|
||||
print_filename (temp, matches[0], 0);
|
||||
rl_crlf ();
|
||||
|
||||
rl_forced_update_display ();
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet@ins.CWRU.Edu
|
||||
.\"
|
||||
.\" Last Change: Thu Feb 9 09:49:51 EST 2006
|
||||
.\" Last Change: Thu May 8 09:29:59 EDT 2008
|
||||
.\"
|
||||
.TH READLINE 3 "2006 Apr 26" "GNU Readline 5.2"
|
||||
.TH READLINE 3 "2008 May 8" "GNU Readline 5.2"
|
||||
.\"
|
||||
.\" File Name macro. This used to be `.PN', for Path Name,
|
||||
.\" but Sun doesn't seem to like that very much.
|
||||
@@ -34,8 +34,8 @@ readline \- get a line from a user with editing
|
||||
\fBreadline\fP (\fIconst char *prompt\fP);
|
||||
.fi
|
||||
.SH COPYRIGHT
|
||||
.if n Readline is Copyright (C) 1989\-2004 by the Free Software Foundation, Inc.
|
||||
.if t Readline is Copyright \(co 1989\-2004 by the Free Software Foundation, Inc.
|
||||
.if n Readline is Copyright (C) 1989\-2008 by the Free Software Foundation, Inc.
|
||||
.if t Readline is Copyright \(co 1989\-2008 by the Free Software Foundation, Inc.
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
.B readline
|
||||
@@ -365,6 +365,12 @@ in vi command mode.
|
||||
If set to \fBOn\fP, readline performs filename matching and completion
|
||||
in a case\-insensitive fashion.
|
||||
.TP
|
||||
.B completion\-prefix\-display\-length (0)
|
||||
The length in characters of the common prefix of a list of possible
|
||||
completions that is displayed without modification. When set to a
|
||||
value greater than zero, common prefixes longer than this value are
|
||||
replaced with an ellipsis when displaying possible completions.
|
||||
.TP
|
||||
.B completion\-query\-items (100)
|
||||
This determines when the user is queried about viewing
|
||||
the number of possible completions
|
||||
@@ -475,6 +481,12 @@ to display a screenful of possible completions at a time.
|
||||
If set to \fBOn\fP, readline will display completions with matches
|
||||
sorted horizontally in alphabetical order, rather than down the screen.
|
||||
.TP
|
||||
.B revert\-all\-at\-newline (Off)
|
||||
If set to \fBon\fP, readline will undo all changes to history lines
|
||||
before returning when \fBaccept\-line\fP is executed. By default,
|
||||
history lines may be modified and retain individual undo lists across
|
||||
calls to \fBreadline\fP.
|
||||
.TP
|
||||
.B show\-all\-if\-ambiguous (Off)
|
||||
This alters the default behavior of the completion functions. If
|
||||
set to
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet@ins.CWRU.Edu
|
||||
.\"
|
||||
.\" Last Change: Thu Feb 9 09:49:51 EST 2006
|
||||
.\" Last Change: Thu May 8 09:29:59 EDT 2008
|
||||
.\"
|
||||
.TH READLINE 3 "2006 Apr 26" "GNU Readline 5.2"
|
||||
.TH READLINE 3 "2008 May 8" "GNU Readline 5.2"
|
||||
.\"
|
||||
.\" File Name macro. This used to be `.PN', for Path Name,
|
||||
.\" but Sun doesn't seem to like that very much.
|
||||
@@ -34,8 +34,8 @@ readline \- get a line from a user with editing
|
||||
\fBreadline\fP (\fIconst char *prompt\fP);
|
||||
.fi
|
||||
.SH COPYRIGHT
|
||||
.if n Readline is Copyright (C) 1989\-2004 by the Free Software Foundation, Inc.
|
||||
.if t Readline is Copyright \(co 1989\-2004 by the Free Software Foundation, Inc.
|
||||
.if n Readline is Copyright (C) 1989\-2008 by the Free Software Foundation, Inc.
|
||||
.if t Readline is Copyright \(co 1989\-2008 by the Free Software Foundation, Inc.
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
.B readline
|
||||
@@ -365,6 +365,12 @@ in vi command mode.
|
||||
If set to \fBOn\fP, readline performs filename matching and completion
|
||||
in a case\-insensitive fashion.
|
||||
.TP
|
||||
.B completion\-prefix\-display\-length (0)
|
||||
The length in characters of the common prefix of a list of possible
|
||||
completions that is displayed without modification. When set to a
|
||||
value greater than zero, common prefixes longer than this value are
|
||||
replaced with an ellipsis when displaying possible completions.
|
||||
.TP
|
||||
.B completion\-query\-items (100)
|
||||
This determines when the user is queried about viewing
|
||||
the number of possible completions
|
||||
@@ -408,6 +414,7 @@ attempts word completion.
|
||||
If set to \fBon\fP, the history code attempts to place point at the
|
||||
same location on each history line retrieved with \fBprevious-history\fP
|
||||
or \fBnext-history\fP.
|
||||
.TP
|
||||
.B history\-size (0)
|
||||
Set the maximum number of history entries saved in the history list. If
|
||||
set to zero, the number of entries in the history list is not limited.
|
||||
|
||||
@@ -426,6 +426,13 @@ If set to @samp{on}, Readline performs filename matching and completion
|
||||
in a case-insensitive fashion.
|
||||
The default value is @samp{off}.
|
||||
|
||||
@item completion-prefix-display-length
|
||||
@vindex completion-prefix-display-length
|
||||
The length in characters of the common prefix of a list of possible
|
||||
completions that is displayed without modification. When set to a
|
||||
value greater than zero, common prefixes longer than this value are
|
||||
replaced with an ellipsis when displaying possible completions.
|
||||
|
||||
@item completion-query-items
|
||||
@vindex completion-query-items
|
||||
The number of possible completions that determines when the user is
|
||||
@@ -563,6 +570,13 @@ If set to @samp{on}, Readline will display completions with matches
|
||||
sorted horizontally in alphabetical order, rather than down the screen.
|
||||
The default is @samp{off}.
|
||||
|
||||
@item revert-all-at-newline
|
||||
@vindex revert-all-at-newline
|
||||
If set to @samp{on}, Readline will undo all changes to history lines
|
||||
before returning when @code{accept-line} is executed. By default,
|
||||
history lines may be modified and retain individual undo lists across
|
||||
calls to @code{readline}. The default is @samp{off}.
|
||||
|
||||
@item show-all-if-ambiguous
|
||||
@vindex show-all-if-ambiguous
|
||||
This alters the default behavior of the completion functions. If
|
||||
|
||||
@@ -426,6 +426,13 @@ If set to @samp{on}, Readline performs filename matching and completion
|
||||
in a case-insensitive fashion.
|
||||
The default value is @samp{off}.
|
||||
|
||||
@item completion-prefix-display-length
|
||||
@vindex completion-prefix-display-length
|
||||
The length in characters of the common prefix of a list of possible
|
||||
completions that is displayed without modification. When set to a
|
||||
value greater than zero, common prefixes longer than this value are
|
||||
replaced with an ellipsis when displaying possible completions.
|
||||
|
||||
@item completion-query-items
|
||||
@vindex completion-query-items
|
||||
The number of possible completions that determines when the user is
|
||||
@@ -563,6 +570,13 @@ If set to @samp{on}, Readline will display completions with matches
|
||||
sorted horizontally in alphabetical order, rather than down the screen.
|
||||
The default is @samp{off}.
|
||||
|
||||
@item revert-all-at-newline
|
||||
@vindex revert-all-at-newline
|
||||
If set to @samp{on}, Readline will undo all changes to history lines
|
||||
before returning when @code{accept-line} is executed. By default,
|
||||
history lines may be edited and retain individual undo lists across
|
||||
calls to @code{readline}. The default is @samp{off}.
|
||||
|
||||
@item show-all-if-ambiguous
|
||||
@vindex show-all-if-ambiguous
|
||||
This alters the default behavior of the completion functions. If
|
||||
@@ -1666,10 +1680,10 @@ matches were generated.
|
||||
@item complete
|
||||
@btindex complete
|
||||
@example
|
||||
@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
|
||||
@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-E] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
|
||||
[-F @var{function}] [-C @var{command}] [-X @var{filterpat}]
|
||||
[-P @var{prefix}] [-S @var{suffix}] @var{name} [@var{name} @dots{}]}
|
||||
@code{complete -pr [@var{name} @dots{}]}
|
||||
@code{complete -pr [-E] [@var{name} @dots{}]}
|
||||
@end example
|
||||
|
||||
Specify how arguments to each @var{name} should be completed.
|
||||
@@ -1679,6 +1693,9 @@ reused as input.
|
||||
The @option{-r} option removes a completion specification for
|
||||
each @var{name}, or, if no @var{name}s are supplied, all
|
||||
completion specifications.
|
||||
The @option{-E} option indicates that the remaining options and actions should
|
||||
apply to ``empty'' command completion; that is, completion attempted on a
|
||||
blank line.
|
||||
|
||||
The process of applying these completion specifications when word completion
|
||||
is attempted is described above (@pxref{Programmable Completion}).
|
||||
@@ -1851,8 +1868,6 @@ argument, an attempt is made to remove a completion specification for
|
||||
a @var{name} for which no specification exists, or
|
||||
an error occurs adding a completion specification.
|
||||
|
||||
@end table
|
||||
|
||||
@item compopt
|
||||
@btindex compopt
|
||||
@example
|
||||
@@ -1870,4 +1885,6 @@ The return value is true unless an invalid option is supplied, an attempt
|
||||
is made to modify the options for a @var{name} for which no completion
|
||||
specification exists, or an output error occurs.
|
||||
|
||||
@end table
|
||||
|
||||
@end ifset
|
||||
|
||||
@@ -4,7 +4,7 @@ Copyright (C) 1988-2008 Free Software Foundation, Inc.
|
||||
|
||||
@set EDITION 5.2
|
||||
@set VERSION 5.2
|
||||
@set UPDATED 7 April 2008
|
||||
@set UPDATED-MONTH April 2008
|
||||
@set UPDATED 8 May 2008
|
||||
@set UPDATED-MONTH May 2008
|
||||
|
||||
@set LASTCHANGE Mon Apr 7 23:00:49 EDT 2008
|
||||
@set LASTCHANGE Thu May 8 09:29:33 EDT 2008
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
@ignore
|
||||
Copyright (C) 1988-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2008 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set EDITION 5.2
|
||||
@set VERSION 5.2
|
||||
@set UPDATED 14 December 2007
|
||||
@set UPDATED-MONTH December 2007
|
||||
@set UPDATED 7 April 2008
|
||||
@set UPDATED-MONTH April 2008
|
||||
|
||||
@set LASTCHANGE Fri Dec 14 23:24:03 EST 2007
|
||||
@set LASTCHANGE Mon Apr 7 23:00:49 EDT 2008
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* history.c -- standalone history library */
|
||||
|
||||
/* Copyright (C) 1989-2005 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2008 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (the Library), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
@@ -483,7 +483,7 @@ stifle_history (max)
|
||||
|
||||
/* Stop stifling the history. This returns the previous maximum
|
||||
number of history entries. The value is positive if the history
|
||||
was stifled, negative if it wasn't. */
|
||||
was stifled, negative if it wasn't. */
|
||||
int
|
||||
unstifle_history ()
|
||||
{
|
||||
|
||||
@@ -158,7 +158,7 @@ history_set_pos (pos)
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Return the current history array. The caller has to be carefull, since this
|
||||
/* Return the current history array. The caller has to be careful, since this
|
||||
is the actual array of data, and could be bashed or made corrupt easily.
|
||||
The array is terminated with a NULL pointer. */
|
||||
HIST_ENTRY **
|
||||
|
||||
@@ -371,6 +371,7 @@ extern int _rl_complete_show_all;
|
||||
extern int _rl_complete_show_unmodified;
|
||||
extern int _rl_complete_mark_directories;
|
||||
extern int _rl_complete_mark_symlink_dirs;
|
||||
extern int _rl_completion_prefix_display_length;
|
||||
extern int _rl_print_completions_horizontally;
|
||||
extern int _rl_completion_case_fold;
|
||||
extern int _rl_match_hidden_files;
|
||||
|
||||
@@ -149,12 +149,9 @@ extern int rl_visible_stats;
|
||||
extern int rl_line_buffer_len;
|
||||
extern int rl_arg_sign;
|
||||
extern int rl_visible_prompt_length;
|
||||
extern int readline_echoing_p;
|
||||
extern int rl_key_sequence_length;
|
||||
extern int rl_byte_oriented;
|
||||
|
||||
extern _rl_keyseq_cxt *_rl_kscxt;
|
||||
|
||||
/* display.c */
|
||||
extern int rl_display_fixed;
|
||||
|
||||
@@ -294,6 +291,10 @@ extern int _rl_restore_tty_signals PARAMS((void));
|
||||
/* search.c */
|
||||
extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *));
|
||||
|
||||
/* signals.c */
|
||||
extern void _rl_block_sigint PARAMS((void));
|
||||
extern void _rl_release_sigint PARAMS((void));
|
||||
|
||||
/* terminal.c */
|
||||
extern void _rl_get_screen_size PARAMS((int, int));
|
||||
extern int _rl_init_terminal_io PARAMS((const char *));
|
||||
@@ -396,6 +397,7 @@ extern int _rl_history_saved_point;
|
||||
extern _rl_arg_cxt _rl_argcxt;
|
||||
|
||||
/* readline.c */
|
||||
extern int _rl_echoing_p;
|
||||
extern int _rl_horizontal_scroll_mode;
|
||||
extern int _rl_mark_modified_lines;
|
||||
extern int _rl_bell_preference;
|
||||
@@ -411,7 +413,8 @@ extern FILE *_rl_in_stream;
|
||||
extern FILE *_rl_out_stream;
|
||||
extern int _rl_last_command_was_kill;
|
||||
extern int _rl_eof_char;
|
||||
extern procenv_t readline_top_level;
|
||||
extern procenv_t _rl_top_level;
|
||||
extern _rl_keyseq_cxt *_rl_kscxt;
|
||||
|
||||
/* search.c */
|
||||
extern _rl_search_cxt *_rl_nscxt;
|
||||
|
||||
Reference in New Issue
Block a user