Resolve conflicts
This commit is contained in:
parent
e8f10fd55c
commit
ea3d03fb07
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=157188
@ -1,8 +1,7 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/* complete.c -- filename completion for readline. */
|
||||
|
||||
/* Copyright (C) 1987-2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
@ -50,7 +49,9 @@
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
#if defined (HAVE_PWD_H)
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include "posixdir.h"
|
||||
#include "posixstat.h"
|
||||
@ -81,9 +82,9 @@ typedef int QSFUNC ();
|
||||
|
||||
/* Most systems don't declare getpwent in <pwd.h> if _POSIX_SOURCE is
|
||||
defined. */
|
||||
#if !defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE)
|
||||
#if defined (HAVE_GETPWENT) && (!defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE))
|
||||
extern struct passwd *getpwent PARAMS((void));
|
||||
#endif /* !HAVE_GETPW_DECLS || _POSIX_SOURCE */
|
||||
#endif /* HAVE_GETPWENT && (!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.
|
||||
@ -208,7 +209,8 @@ int rl_completion_type = 0;
|
||||
|
||||
/* Up to this many items will be displayed in response to a
|
||||
possible-completions call. After that, we ask the user if
|
||||
she is sure she wants to see them all. */
|
||||
she is sure she wants to see them all. A negative value means
|
||||
don't ask. */
|
||||
int rl_completion_query_items = 100;
|
||||
|
||||
int _rl_page_completions = 1;
|
||||
@ -623,6 +625,8 @@ fnprint (to_print)
|
||||
mbstate_t ps;
|
||||
const char *end;
|
||||
size_t tlen;
|
||||
int width, w;
|
||||
wchar_t wc;
|
||||
|
||||
end = to_print + strlen (to_print) + 1;
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
@ -655,21 +659,28 @@ fnprint (to_print)
|
||||
else
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
tlen = mbrlen (s, end - s, &ps);
|
||||
tlen = mbrtowc (&wc, s, end - s, &ps);
|
||||
if (MB_INVALIDCH (tlen))
|
||||
{
|
||||
tlen = 1;
|
||||
width = 1;
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
}
|
||||
else if (MB_NULLWCH (tlen))
|
||||
break;
|
||||
else
|
||||
{
|
||||
w = wcwidth (wc);
|
||||
width = (w >= 0) ? w : 1;
|
||||
}
|
||||
fwrite (s, 1, tlen, rl_outstream);
|
||||
s += tlen;
|
||||
printed_len += width;
|
||||
#else
|
||||
putc (*s, rl_outstream);
|
||||
s++;
|
||||
#endif
|
||||
printed_len++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -685,7 +696,7 @@ print_filename (to_print, full_pathname)
|
||||
char *to_print, *full_pathname;
|
||||
{
|
||||
int printed_len, extension_char, slen, tlen;
|
||||
char *s, c, *new_full_pathname;
|
||||
char *s, c, *new_full_pathname, *dn;
|
||||
|
||||
extension_char = 0;
|
||||
printed_len = fnprint (to_print);
|
||||
@ -710,7 +721,17 @@ print_filename (to_print, full_pathname)
|
||||
files in the root directory. If we pass a null string to the
|
||||
bash directory completion hook, for example, it will expand it
|
||||
to the current directory. We just want the `/'. */
|
||||
s = tilde_expand (full_pathname && *full_pathname ? full_pathname : "/");
|
||||
if (full_pathname == 0 || *full_pathname == 0)
|
||||
dn = "/";
|
||||
else if (full_pathname[0] != '/')
|
||||
dn = full_pathname;
|
||||
else if (full_pathname[1] == 0)
|
||||
dn = "//"; /* restore trailing slash to `//' */
|
||||
else if (full_pathname[1] == '/' && full_pathname[2] == 0)
|
||||
dn = "/"; /* don't turn /// into // */
|
||||
else
|
||||
dn = full_pathname;
|
||||
s = tilde_expand (dn);
|
||||
if (rl_directory_completion_hook)
|
||||
(*rl_directory_completion_hook) (&s);
|
||||
|
||||
@ -718,6 +739,10 @@ print_filename (to_print, full_pathname)
|
||||
tlen = strlen (to_print);
|
||||
new_full_pathname = (char *)xmalloc (slen + tlen + 2);
|
||||
strcpy (new_full_pathname, s);
|
||||
if (s[slen - 1] == '/')
|
||||
slen--;
|
||||
else
|
||||
new_full_pathname[slen] = '/';
|
||||
new_full_pathname[slen] = '/';
|
||||
strcpy (new_full_pathname + slen + 1, to_print);
|
||||
|
||||
@ -809,14 +834,7 @@ _rl_find_completion_word (fp, dp)
|
||||
quote substrings for the completer. Try to find the start
|
||||
of an unclosed quoted substring. */
|
||||
/* FOUND_QUOTE is set so we know what kind of quotes we found. */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
for (scan = pass_next = 0; scan < end;
|
||||
scan = ((MB_CUR_MAX == 1 || rl_byte_oriented)
|
||||
? (scan + 1)
|
||||
: _rl_find_next_mbchar (rl_line_buffer, scan, 1, MB_FIND_ANY)))
|
||||
#else
|
||||
for (scan = pass_next = 0; scan < end; scan++)
|
||||
#endif
|
||||
for (scan = pass_next = 0; scan < end; scan = MB_NEXTCHAR (rl_line_buffer, scan, 1, MB_FIND_ANY))
|
||||
{
|
||||
if (pass_next)
|
||||
{
|
||||
@ -866,11 +884,7 @@ _rl_find_completion_word (fp, dp)
|
||||
/* We didn't find an unclosed quoted substring upon which to do
|
||||
completion, so use the word break characters to find the
|
||||
substring on which to complete. */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
while (rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_ANY))
|
||||
#else
|
||||
while (--rl_point)
|
||||
#endif
|
||||
while (rl_point = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_ANY))
|
||||
{
|
||||
scan = rl_line_buffer[rl_point];
|
||||
|
||||
@ -1153,7 +1167,7 @@ compute_lcd_of_matches (match_list, matches, text)
|
||||
rl_completion_found_quote &&
|
||||
rl_filename_quoting_desired)
|
||||
{
|
||||
dtext = (*rl_filename_dequoting_function) (text, rl_completion_quote_character);
|
||||
dtext = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
|
||||
text = dtext;
|
||||
}
|
||||
|
||||
@ -1399,7 +1413,7 @@ display_matches (matches)
|
||||
|
||||
/* If there are many items, then ask the user if she really wants to
|
||||
see them all. */
|
||||
if (len >= rl_completion_query_items)
|
||||
if (rl_completion_query_items > 0 && len >= rl_completion_query_items)
|
||||
{
|
||||
rl_crlf ();
|
||||
fprintf (rl_outstream, "Display all %d possibilities? (y or n)", len);
|
||||
@ -1536,7 +1550,7 @@ append_to_match (text, delimiter, quote_char, nontrivial_match)
|
||||
: stat (filename, &finfo);
|
||||
if (s == 0 && S_ISDIR (finfo.st_mode))
|
||||
{
|
||||
if (_rl_complete_mark_directories)
|
||||
if (_rl_complete_mark_directories /* && rl_completion_suppress_append == 0 */)
|
||||
{
|
||||
/* This is clumsy. Avoid putting in a double slash if point
|
||||
is at the end of the line and the previous character is a
|
||||
@ -1850,16 +1864,20 @@ rl_username_completion_function (text, state)
|
||||
setpwent ();
|
||||
}
|
||||
|
||||
#if defined (HAVE_GETPWENT)
|
||||
while (entry = getpwent ())
|
||||
{
|
||||
/* Null usernames should result in all users as possible completions. */
|
||||
if (namelen == 0 || (STREQN (username, entry->pw_name, namelen)))
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (entry == 0)
|
||||
{
|
||||
#if defined (HAVE_GETPWENT)
|
||||
endpwent ();
|
||||
#endif
|
||||
return ((char *)NULL);
|
||||
}
|
||||
else
|
||||
@ -2171,9 +2189,11 @@ rl_menu_complete (count, ignore)
|
||||
return (0);
|
||||
}
|
||||
|
||||
match_list_index = (match_list_index + count) % match_list_size;
|
||||
match_list_index += count;
|
||||
if (match_list_index < 0)
|
||||
match_list_index += match_list_size;
|
||||
else
|
||||
match_list_index %= match_list_size;
|
||||
|
||||
if (match_list_index == 0 && match_list_size > 1)
|
||||
{
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/* display.c -- readline redisplay facility. */
|
||||
|
||||
/* Copyright (C) 1987-2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
@ -120,16 +119,24 @@ rl_voidfunc_t *rl_redisplay_function = rl_redisplay;
|
||||
int rl_display_fixed = 0;
|
||||
|
||||
int _rl_suppress_redisplay = 0;
|
||||
int _rl_want_redisplay = 0;
|
||||
|
||||
/* The stuff that gets printed out before the actual text of the line.
|
||||
This is usually pointing to rl_prompt. */
|
||||
char *rl_display_prompt = (char *)NULL;
|
||||
|
||||
/* Pseudo-global variables declared here. */
|
||||
|
||||
/* The visible cursor position. If you print some text, adjust this. */
|
||||
/* NOTE: _rl_last_c_pos is used as a buffer index when not in a locale
|
||||
supporting multibyte characters, and an absolute cursor position when
|
||||
in such a locale. This is an artifact of the donated multibyte support.
|
||||
Care must be taken when modifying its value. */
|
||||
int _rl_last_c_pos = 0;
|
||||
int _rl_last_v_pos = 0;
|
||||
|
||||
static int cpos_adjusted;
|
||||
|
||||
/* Number of lines currently on screen minus 1. */
|
||||
int _rl_vis_botlin = 0;
|
||||
|
||||
@ -182,6 +189,18 @@ static int prompt_last_screen_line;
|
||||
|
||||
static int prompt_physical_chars;
|
||||
|
||||
/* Variables to save and restore prompt and display information. */
|
||||
|
||||
/* These are getting numerous enough that it's time to create a struct. */
|
||||
|
||||
static char *saved_local_prompt;
|
||||
static char *saved_local_prefix;
|
||||
static int saved_last_invisible;
|
||||
static int saved_visible_length;
|
||||
static int saved_prefix_length;
|
||||
static int saved_invis_chars_first_line;
|
||||
static int saved_physical_chars;
|
||||
|
||||
/* 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
|
||||
@ -238,7 +257,8 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
|
||||
else if (ignoring && *p == RL_PROMPT_END_IGNORE)
|
||||
{
|
||||
ignoring = 0;
|
||||
last = r - ret - 1;
|
||||
if (p[-1] != RL_PROMPT_START_IGNORE)
|
||||
last = r - ret - 1;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
@ -337,7 +357,8 @@ rl_expand_prompt (prompt)
|
||||
FREE (local_prompt_prefix);
|
||||
|
||||
local_prompt = local_prompt_prefix = (char *)0;
|
||||
prompt_last_invisible = prompt_visible_length = 0;
|
||||
prompt_last_invisible = prompt_invis_chars_first_line = 0;
|
||||
prompt_visible_length = prompt_physical_chars = 0;
|
||||
|
||||
if (prompt == 0 || *prompt == 0)
|
||||
return (0);
|
||||
@ -425,7 +446,7 @@ rl_redisplay ()
|
||||
{
|
||||
register int in, out, c, linenum, cursor_linenum;
|
||||
register char *line;
|
||||
int c_pos, inv_botlin, lb_botlin, lb_linenum;
|
||||
int c_pos, inv_botlin, lb_botlin, lb_linenum, o_cpos;
|
||||
int newlines, lpos, temp, modmark, n0, num;
|
||||
char *prompt_this_line;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
@ -442,7 +463,7 @@ rl_redisplay ()
|
||||
if (!rl_display_prompt)
|
||||
rl_display_prompt = "";
|
||||
|
||||
if (invisible_line == 0)
|
||||
if (invisible_line == 0 || vis_lbreaks == 0)
|
||||
{
|
||||
init_line_structures (0);
|
||||
rl_on_new_line ();
|
||||
@ -835,7 +856,7 @@ rl_redisplay ()
|
||||
|
||||
if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
|
||||
{
|
||||
int nleft, pos, changed_screen_line;
|
||||
int nleft, pos, changed_screen_line, tx;
|
||||
|
||||
if (!rl_display_fixed || forced_display)
|
||||
{
|
||||
@ -866,9 +887,26 @@ rl_redisplay ()
|
||||
/* For each line in the buffer, do the updating display. */
|
||||
for (linenum = 0; linenum <= inv_botlin; linenum++)
|
||||
{
|
||||
o_cpos = _rl_last_c_pos;
|
||||
cpos_adjusted = 0;
|
||||
update_line (VIS_LINE(linenum), INV_LINE(linenum), linenum,
|
||||
VIS_LLEN(linenum), INV_LLEN(linenum), inv_botlin);
|
||||
|
||||
/* update_line potentially changes _rl_last_c_pos, but doesn't
|
||||
take invisible characters into account, since _rl_last_c_pos
|
||||
is an absolute cursor position in a multibyte locale. See
|
||||
if compensating here is the right thing, or if we have to
|
||||
change update_line itself. There is one case in which
|
||||
update_line adjusts _rl_last_c_pos itself (so it can pass
|
||||
_rl_move_cursor_relative accurate values); it communicates
|
||||
this back by setting cpos_adjusted */
|
||||
if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
|
||||
cpos_adjusted == 0 &&
|
||||
_rl_last_c_pos != o_cpos &&
|
||||
_rl_last_c_pos > wrap_offset &&
|
||||
o_cpos < prompt_last_invisible)
|
||||
_rl_last_c_pos -= wrap_offset;
|
||||
|
||||
/* If this is the line with the prompt, we might need to
|
||||
compensate for invisible characters in the new line. Do
|
||||
this only if there is not more than one new line (which
|
||||
@ -880,7 +918,10 @@ rl_redisplay ()
|
||||
(wrap_offset > visible_wrap_offset) &&
|
||||
(_rl_last_c_pos < visible_first_line_len))
|
||||
{
|
||||
nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
nleft = _rl_screenwidth - _rl_last_c_pos;
|
||||
else
|
||||
nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
|
||||
if (nleft)
|
||||
_rl_clear_to_eol (nleft);
|
||||
}
|
||||
@ -916,7 +957,7 @@ rl_redisplay ()
|
||||
the physical cursor position on the screen stays the same,
|
||||
but the buffer position needs to be adjusted to account
|
||||
for invisible characters. */
|
||||
if (cursor_linenum == 0 && wrap_offset)
|
||||
if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
|
||||
_rl_last_c_pos += wrap_offset;
|
||||
}
|
||||
|
||||
@ -937,7 +978,7 @@ rl_redisplay ()
|
||||
#endif
|
||||
_rl_output_some_chars (local_prompt, nleft);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft);
|
||||
_rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft) - wrap_offset;
|
||||
else
|
||||
_rl_last_c_pos = nleft;
|
||||
}
|
||||
@ -949,18 +990,31 @@ rl_redisplay ()
|
||||
start of the line and the cursor position. */
|
||||
nleft = c_pos - pos;
|
||||
|
||||
/* NLEFT is now a number of characters in a buffer. When in a
|
||||
multibyte locale, however, _rl_last_c_pos is an absolute cursor
|
||||
position that doesn't take invisible characters in the prompt
|
||||
into account. We use a fudge factor to compensate. */
|
||||
|
||||
/* Since _rl_backspace() doesn't know about invisible characters in the
|
||||
prompt, and there's no good way to tell it, we compensate for
|
||||
those characters here and call _rl_backspace() directly. */
|
||||
if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos)
|
||||
{
|
||||
_rl_backspace (_rl_last_c_pos - nleft);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_last_c_pos = _rl_col_width (&visible_line[pos], 0, nleft);
|
||||
tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset;
|
||||
else
|
||||
_rl_last_c_pos = nleft;
|
||||
tx = nleft;
|
||||
if (_rl_last_c_pos > tx)
|
||||
{
|
||||
_rl_backspace (_rl_last_c_pos - tx); /* XXX */
|
||||
_rl_last_c_pos = tx;
|
||||
}
|
||||
}
|
||||
|
||||
/* We need to note that in a multibyte locale we are dealing with
|
||||
_rl_last_c_pos as an absolute cursor position, but moving to a
|
||||
point specified by a buffer position (NLEFT) that doesn't take
|
||||
invisible characters into account. */
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_move_cursor_relative (nleft, &invisible_line[pos]);
|
||||
else if (nleft != _rl_last_c_pos)
|
||||
@ -1119,7 +1173,10 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
the exact cursor position and cut-and-paste with certain terminal
|
||||
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 (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
temp = _rl_last_c_pos;
|
||||
else
|
||||
temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
|
||||
if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
|
||||
&& _rl_last_v_pos == current_line - 1)
|
||||
{
|
||||
@ -1184,7 +1241,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
putc (new[0], rl_outstream);
|
||||
else
|
||||
putc (' ', rl_outstream);
|
||||
_rl_last_c_pos = 1; /* XXX */
|
||||
_rl_last_c_pos = 1;
|
||||
_rl_last_v_pos++;
|
||||
if (old[0] && new[0])
|
||||
old[0] = new[0];
|
||||
@ -1325,7 +1382,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
if (_rl_last_v_pos != current_line)
|
||||
{
|
||||
_rl_move_vert (current_line);
|
||||
if (current_line == 0 && visible_wrap_offset)
|
||||
if ((MB_CUR_MAX == 1 || rl_byte_oriented) && current_line == 0 && visible_wrap_offset)
|
||||
_rl_last_c_pos += visible_wrap_offset;
|
||||
}
|
||||
|
||||
@ -1354,7 +1411,12 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
#endif
|
||||
_rl_output_some_chars (local_prompt, lendiff);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff);
|
||||
{
|
||||
/* We take wrap_offset into account here so we can pass correct
|
||||
information to _rl_move_cursor_relative. */
|
||||
_rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff) - wrap_offset;
|
||||
cpos_adjusted = 1;
|
||||
}
|
||||
else
|
||||
_rl_last_c_pos = lendiff;
|
||||
}
|
||||
@ -1416,7 +1478,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
insert_some_chars (nfd, lendiff, col_lendiff);
|
||||
_rl_last_c_pos += col_lendiff;
|
||||
}
|
||||
else if (*ols == 0 && lendiff > 0)
|
||||
else if ((MB_CUR_MAX == 1 || rl_byte_oriented != 0) && *ols == 0 && lendiff > 0)
|
||||
{
|
||||
/* At the end of a line the characters do not have to
|
||||
be "inserted". They can just be placed on the screen. */
|
||||
@ -1455,6 +1517,10 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
/* cannot insert chars, write to EOL */
|
||||
_rl_output_some_chars (nfd, temp);
|
||||
_rl_last_c_pos += col_temp;
|
||||
/* If we're in a multibyte locale and were before the last invisible
|
||||
char in the current line (which implies we just output some invisible
|
||||
characters) we need to adjust _rl_last_c_pos, since it represents
|
||||
a physical character position. */
|
||||
}
|
||||
}
|
||||
else /* Delete characters from line. */
|
||||
@ -1486,7 +1552,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
if (temp > 0)
|
||||
{
|
||||
_rl_output_some_chars (nfd, temp);
|
||||
_rl_last_c_pos += col_temp;
|
||||
_rl_last_c_pos += col_temp; /* XXX */
|
||||
}
|
||||
lendiff = (oe - old) - (ne - new);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
@ -1548,7 +1614,7 @@ rl_on_new_line_with_prompt ()
|
||||
|
||||
l = strlen (prompt_last_line);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l);
|
||||
_rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l); /* XXX */
|
||||
else
|
||||
_rl_last_c_pos = l;
|
||||
|
||||
@ -1597,6 +1663,8 @@ rl_forced_update_display ()
|
||||
}
|
||||
|
||||
/* Move the cursor from _rl_last_c_pos to NEW, which are buffer indices.
|
||||
(Well, when we don't have multibyte characters, _rl_last_c_pos is a
|
||||
buffer index.)
|
||||
DATA is the contents of the screen line of interest; i.e., where
|
||||
the movement is being done. */
|
||||
void
|
||||
@ -1605,28 +1673,40 @@ _rl_move_cursor_relative (new, data)
|
||||
const char *data;
|
||||
{
|
||||
register int i;
|
||||
int woff; /* number of invisible chars on current line */
|
||||
int cpos, dpos; /* current and desired cursor positions */
|
||||
|
||||
/* If we don't have to do anything, then return. */
|
||||
woff = W_OFFSET (_rl_last_v_pos, wrap_offset);
|
||||
cpos = _rl_last_c_pos;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
/* If we have multibyte characters, NEW is indexed by the buffer point in
|
||||
a multibyte string, but _rl_last_c_pos is the display position. In
|
||||
this case, NEW's display position is not obvious and must be
|
||||
calculated. */
|
||||
if (MB_CUR_MAX == 1 || rl_byte_oriented)
|
||||
calculated. We need to account for invisible characters in this line,
|
||||
as long as we are past them and they are counted by _rl_col_width. */
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
if (_rl_last_c_pos == new)
|
||||
return;
|
||||
dpos = _rl_col_width (data, 0, new);
|
||||
if (dpos > woff)
|
||||
dpos -= woff;
|
||||
}
|
||||
else if (_rl_last_c_pos == _rl_col_width (data, 0, new))
|
||||
return;
|
||||
#else
|
||||
if (_rl_last_c_pos == new) return;
|
||||
else
|
||||
#endif
|
||||
dpos = new;
|
||||
|
||||
/* If we don't have to do anything, then return. */
|
||||
if (cpos == dpos)
|
||||
return;
|
||||
|
||||
/* It may be faster to output a CR, and then move forwards instead
|
||||
of moving backwards. */
|
||||
/* i == current physical cursor position. */
|
||||
i = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
i = _rl_last_c_pos;
|
||||
else
|
||||
#endif
|
||||
i = _rl_last_c_pos - woff;
|
||||
if (new == 0 || CR_FASTER (new, _rl_last_c_pos) ||
|
||||
(_rl_term_autowrap && i == _rl_screenwidth))
|
||||
{
|
||||
@ -1635,10 +1715,10 @@ _rl_move_cursor_relative (new, data)
|
||||
#else
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif /* !__MSDOS__ */
|
||||
_rl_last_c_pos = 0;
|
||||
cpos = _rl_last_c_pos = 0;
|
||||
}
|
||||
|
||||
if (_rl_last_c_pos < new)
|
||||
if (cpos < dpos)
|
||||
{
|
||||
/* Move the cursor forward. We do it by printing the command
|
||||
to move the cursor forward if there is one, else print that
|
||||
@ -1652,31 +1732,11 @@ _rl_move_cursor_relative (new, data)
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
if (_rl_term_forward_char)
|
||||
{
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
int width;
|
||||
width = _rl_col_width (data, _rl_last_c_pos, new);
|
||||
for (i = 0; i < width; i++)
|
||||
tputs (_rl_term_forward_char, 1, _rl_output_character_function);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = _rl_last_c_pos; i < new; i++)
|
||||
tputs (_rl_term_forward_char, 1, _rl_output_character_function);
|
||||
}
|
||||
}
|
||||
else if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
for (i = 0; i < new; i++)
|
||||
putc (data[i], rl_outstream);
|
||||
for (i = cpos; i < dpos; i++)
|
||||
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);
|
||||
|
||||
#else /* !HACK_TERMCAP_MOTION */
|
||||
|
||||
#endif /* HACK_TERMCAP_MOTION */
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
@ -1684,32 +1744,20 @@ _rl_move_cursor_relative (new, data)
|
||||
putc (data[i], rl_outstream);
|
||||
}
|
||||
else
|
||||
for (i = _rl_last_c_pos; i < new; i++)
|
||||
for (i = cpos; i < new; i++)
|
||||
putc (data[i], rl_outstream);
|
||||
|
||||
#endif /* !HACK_TERMCAP_MOTION */
|
||||
|
||||
}
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
/* NEW points to the buffer point, but _rl_last_c_pos is the display point.
|
||||
The byte length of the string is probably bigger than the column width
|
||||
of the string, which means that if NEW == _rl_last_c_pos, then NEW's
|
||||
display point is less than _rl_last_c_pos. */
|
||||
else if (_rl_last_c_pos >= new)
|
||||
#else
|
||||
else if (_rl_last_c_pos > new)
|
||||
#endif
|
||||
{
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_backspace (_rl_last_c_pos - _rl_col_width (data, 0, new));
|
||||
else
|
||||
_rl_backspace (_rl_last_c_pos - new);
|
||||
}
|
||||
else if (cpos > dpos)
|
||||
_rl_backspace (cpos - dpos);
|
||||
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_last_c_pos = _rl_col_width (data, 0, new);
|
||||
else
|
||||
_rl_last_c_pos = new;
|
||||
_rl_last_c_pos = dpos;
|
||||
}
|
||||
|
||||
/* PWP: move the cursor up or down. */
|
||||
@ -1798,9 +1846,9 @@ rl_character_len (c, pos)
|
||||
|
||||
return ((ISPRINT (uc)) ? 1 : 2);
|
||||
}
|
||||
|
||||
/* How to print things in the "echo-area". The prompt is treated as a
|
||||
mini-modeline. */
|
||||
static int msg_saved_prompt = 0;
|
||||
|
||||
#if defined (USE_VARARGS)
|
||||
int
|
||||
@ -1831,8 +1879,19 @@ rl_message (va_alist)
|
||||
#endif
|
||||
va_end (args);
|
||||
|
||||
if (saved_local_prompt == 0)
|
||||
{
|
||||
rl_save_prompt ();
|
||||
msg_saved_prompt = 1;
|
||||
}
|
||||
rl_display_prompt = msg_buf;
|
||||
local_prompt = expand_prompt (msg_buf, &prompt_visible_length,
|
||||
&prompt_last_invisible,
|
||||
&prompt_invis_chars_first_line,
|
||||
&prompt_physical_chars);
|
||||
local_prompt_prefix = (char *)NULL;
|
||||
(*rl_redisplay_function) ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else /* !USE_VARARGS */
|
||||
@ -1842,8 +1901,20 @@ rl_message (format, arg1, arg2)
|
||||
{
|
||||
sprintf (msg_buf, format, arg1, arg2);
|
||||
msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */
|
||||
|
||||
rl_display_prompt = msg_buf;
|
||||
if (saved_local_prompt == 0)
|
||||
{
|
||||
rl_save_prompt ();
|
||||
msg_saved_prompt = 1;
|
||||
}
|
||||
local_prompt = expand_prompt (msg_buf, &prompt_visible_length,
|
||||
&prompt_last_invisible,
|
||||
&prompt_invis_chars_first_line,
|
||||
&prompt_physical_chars);
|
||||
local_prompt_prefix = (char *)NULL;
|
||||
(*rl_redisplay_function) ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* !USE_VARARGS */
|
||||
@ -1853,6 +1924,11 @@ int
|
||||
rl_clear_message ()
|
||||
{
|
||||
rl_display_prompt = rl_prompt;
|
||||
if (msg_saved_prompt)
|
||||
{
|
||||
rl_restore_prompt ();
|
||||
msg_saved_prompt = 0;
|
||||
}
|
||||
(*rl_redisplay_function) ();
|
||||
return 0;
|
||||
}
|
||||
@ -1867,27 +1943,19 @@ rl_reset_line_state ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* These are getting numerous enough that it's time to create a struct. */
|
||||
|
||||
static char *saved_local_prompt;
|
||||
static char *saved_local_prefix;
|
||||
static int saved_last_invisible;
|
||||
static int saved_visible_length;
|
||||
static int saved_invis_chars_first_line;
|
||||
static int saved_physical_chars;
|
||||
|
||||
void
|
||||
rl_save_prompt ()
|
||||
{
|
||||
saved_local_prompt = local_prompt;
|
||||
saved_local_prefix = local_prompt_prefix;
|
||||
saved_prefix_length = prompt_prefix_length;
|
||||
saved_last_invisible = prompt_last_invisible;
|
||||
saved_visible_length = prompt_visible_length;
|
||||
saved_invis_chars_first_line = prompt_invis_chars_first_line;
|
||||
saved_physical_chars = prompt_physical_chars;
|
||||
|
||||
local_prompt = local_prompt_prefix = (char *)0;
|
||||
prompt_last_invisible = prompt_visible_length = 0;
|
||||
prompt_last_invisible = prompt_visible_length = prompt_prefix_length = 0;
|
||||
prompt_invis_chars_first_line = prompt_physical_chars = 0;
|
||||
}
|
||||
|
||||
@ -1899,10 +1967,16 @@ rl_restore_prompt ()
|
||||
|
||||
local_prompt = saved_local_prompt;
|
||||
local_prompt_prefix = saved_local_prefix;
|
||||
prompt_prefix_length = saved_prefix_length;
|
||||
prompt_last_invisible = saved_last_invisible;
|
||||
prompt_visible_length = saved_visible_length;
|
||||
prompt_invis_chars_first_line = saved_invis_chars_first_line;
|
||||
prompt_physical_chars = saved_physical_chars;
|
||||
|
||||
/* can test saved_local_prompt to see if prompt info has been saved. */
|
||||
saved_local_prompt = saved_local_prefix = (char *)0;
|
||||
saved_last_invisible = saved_visible_length = saved_prefix_length = 0;
|
||||
saved_invis_chars_first_line = saved_physical_chars = 0;
|
||||
}
|
||||
|
||||
char *
|
||||
@ -1936,6 +2010,8 @@ _rl_make_prompt_for_search (pchar)
|
||||
prompt_visible_length = saved_visible_length + 1;
|
||||
}
|
||||
|
||||
prompt_physical_chars = saved_physical_chars + 1;
|
||||
|
||||
return pmt;
|
||||
}
|
||||
|
||||
@ -1996,6 +2072,9 @@ insert_some_chars (string, count, col)
|
||||
char *string;
|
||||
int count, col;
|
||||
{
|
||||
#if defined (__MSDOS__) || defined (__MINGW32__)
|
||||
_rl_output_some_chars (string, count);
|
||||
#else
|
||||
/* DEBUGGING */
|
||||
if (MB_CUR_MAX == 1 || rl_byte_oriented)
|
||||
if (count != col)
|
||||
@ -2034,6 +2113,7 @@ insert_some_chars (string, count, col)
|
||||
if (_rl_term_ei && *_rl_term_ei)
|
||||
tputs (_rl_term_ei, 1, _rl_output_character_function);
|
||||
}
|
||||
#endif /* __MSDOS__ || __MINGW32__ */
|
||||
}
|
||||
|
||||
/* Delete COUNT characters from the display line. */
|
||||
@ -2044,6 +2124,7 @@ delete_chars (count)
|
||||
if (count > _rl_screenwidth) /* XXX */
|
||||
return;
|
||||
|
||||
#if !defined (__MSDOS__) && !defined (__MINGW32__)
|
||||
if (_rl_term_DC && *_rl_term_DC)
|
||||
{
|
||||
char *buffer;
|
||||
@ -2056,6 +2137,7 @@ delete_chars (count)
|
||||
while (count--)
|
||||
tputs (_rl_term_dc, 1, _rl_output_character_function);
|
||||
}
|
||||
#endif /* !__MSDOS__ && !__MINGW32__ */
|
||||
}
|
||||
|
||||
void
|
||||
@ -2111,18 +2193,10 @@ static void
|
||||
redraw_prompt (t)
|
||||
char *t;
|
||||
{
|
||||
char *oldp, *oldl, *oldlprefix;
|
||||
int oldlen, oldlast, oldplen, oldninvis, oldphyschars;
|
||||
char *oldp;
|
||||
|
||||
/* Geez, I should make this a struct. */
|
||||
oldp = rl_display_prompt;
|
||||
oldl = local_prompt;
|
||||
oldlprefix = local_prompt_prefix;
|
||||
oldlen = prompt_visible_length;
|
||||
oldplen = prompt_prefix_length;
|
||||
oldlast = prompt_last_invisible;
|
||||
oldninvis = prompt_invis_chars_first_line;
|
||||
oldphyschars = prompt_physical_chars;
|
||||
rl_save_prompt ();
|
||||
|
||||
rl_display_prompt = t;
|
||||
local_prompt = expand_prompt (t, &prompt_visible_length,
|
||||
@ -2130,16 +2204,11 @@ redraw_prompt (t)
|
||||
&prompt_invis_chars_first_line,
|
||||
&prompt_physical_chars);
|
||||
local_prompt_prefix = (char *)NULL;
|
||||
|
||||
rl_forced_update_display ();
|
||||
|
||||
rl_display_prompt = oldp;
|
||||
local_prompt = oldl;
|
||||
local_prompt_prefix = oldlprefix;
|
||||
prompt_visible_length = oldlen;
|
||||
prompt_prefix_length = oldplen;
|
||||
prompt_last_invisible = oldlast;
|
||||
prompt_invis_chars_first_line = oldninvis;
|
||||
prompt_physical_chars = oldphyschars;
|
||||
rl_restore_prompt();
|
||||
}
|
||||
|
||||
/* Redisplay the current line after a SIGWINCH is received. */
|
||||
|
@ -1,3 +1,4 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.\" MAN PAGE COMMENTS to
|
||||
.\"
|
||||
@ -6,13 +7,12 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet@ins.CWRU.Edu
|
||||
.\"
|
||||
.\" Last Change: Wed Jan 28 15:43:53 EST 2004
|
||||
.\" Last Change: Tue Sep 13 12:07:26 EDT 2005
|
||||
.\"
|
||||
.TH READLINE 3 "2004 January 28" "GNU Readline 5.0"
|
||||
.TH READLINE 3 "2005 Sep 13" "GNU Readline 5.1-beta1"
|
||||
.\"
|
||||
.\" File Name macro. This used to be `.PN', for Path Name,
|
||||
.\" but Sun doesn't seem to like that very much.
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.de FN
|
||||
\fI\|\\$1\|\fP
|
||||
@ -329,6 +329,10 @@ Except where noted, readline variables can take the values
|
||||
or
|
||||
.B Off
|
||||
(without regard to case).
|
||||
Unrecognized variable names are ignored.
|
||||
When a variable value is read, empty or null values, "on" (case-insensitive),
|
||||
and "1" are equivalent to \fBOn\fP. All other values are equivalent to
|
||||
\fBOff\fP.
|
||||
The variables and their default values are:
|
||||
.PP
|
||||
.PD 0
|
||||
@ -339,6 +343,11 @@ If set to \fBnone\fP, readline never rings the bell. If set to
|
||||
\fBvisible\fP, readline uses a visible bell if one is available.
|
||||
If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
|
||||
.TP
|
||||
.B bind\-tty\-special\-chars (On)
|
||||
If set to \fBOn\fP, readline attempts to bind the control characters
|
||||
treated specially by the kernel's terminal driver to their readline
|
||||
equivalents.
|
||||
.TP
|
||||
.B comment\-begin (``#'')
|
||||
The string that is inserted in \fBvi\fP mode when the
|
||||
.B insert\-comment
|
||||
@ -361,7 +370,7 @@ It may be set to any integer value greater than or equal to
|
||||
zero. If the number of possible completions is greater than
|
||||
or equal to the value of this variable, the user is asked whether
|
||||
or not he wishes to view them; otherwise they are simply listed
|
||||
on the terminal.
|
||||
on the terminal. A negative value causes readline to never ask.
|
||||
.TP
|
||||
.B convert\-meta (On)
|
||||
If set to \fBOn\fP, readline will convert characters with the
|
||||
@ -392,9 +401,9 @@ arrow keys.
|
||||
If set to \fBon\fP, tilde expansion is performed when readline
|
||||
attempts word completion.
|
||||
.TP
|
||||
.B history-preserve-point
|
||||
.B history\-preserve\-point (Off)
|
||||
If set to \fBon\fP, the history code attempts to place point at the
|
||||
same location on each history line retrived with \fBprevious-history\fP
|
||||
same location on each history line retrieved with \fBprevious-history\fP
|
||||
or \fBnext-history\fP.
|
||||
.TP
|
||||
.B horizontal\-scroll\-mode (Off)
|
||||
@ -692,6 +701,8 @@ With an argument
|
||||
insert the \fIn\fPth word from the previous command (the words
|
||||
in the previous command begin with word 0). A negative argument
|
||||
inserts the \fIn\fPth word from the end of the previous command.
|
||||
Once the argument \fIn\fP is computed, the argument is extracted
|
||||
as if the "!\fIn\fP" history expansion had been specified.
|
||||
.TP
|
||||
.B
|
||||
yank\-last\-arg (M\-.\^, M\-_\^)
|
||||
@ -700,6 +711,8 @@ the previous history entry). With an argument,
|
||||
behave exactly like \fByank\-nth\-arg\fP.
|
||||
Successive calls to \fByank\-last\-arg\fP move back through the history
|
||||
list, inserting the last argument of each line in turn.
|
||||
The history expansion facilities are used to extract the last argument,
|
||||
as if the "!$" history expansion had been specified.
|
||||
.PD
|
||||
.SS Commands for Changing Text
|
||||
.PP
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* $FreeBSD$ */
|
||||
/* Readline.h -- the names of functions callable from within readline. */
|
||||
|
||||
/* Copyright (C) 1987-2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
@ -20,7 +21,6 @@
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
/* $FreeBSD$ */
|
||||
#if !defined (_READLINE_H_)
|
||||
#define _READLINE_H_
|
||||
|
||||
@ -41,9 +41,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Hex-encoded Readline version number. */
|
||||
#define RL_READLINE_VERSION 0x0500 /* Readline 5.0 */
|
||||
#define RL_READLINE_VERSION 0x0501 /* Readline 5.1 */
|
||||
#define RL_VERSION_MAJOR 5
|
||||
#define RL_VERSION_MINOR 0
|
||||
#define RL_VERSION_MINOR 1
|
||||
|
||||
/* Readline data structures. */
|
||||
|
||||
@ -242,6 +242,7 @@ extern int rl_vi_column PARAMS((int, int));
|
||||
extern int rl_vi_delete_to PARAMS((int, int));
|
||||
extern int rl_vi_change_to PARAMS((int, int));
|
||||
extern int rl_vi_yank_to PARAMS((int, int));
|
||||
extern int rl_vi_rubout PARAMS((int, int));
|
||||
extern int rl_vi_delete PARAMS((int, int));
|
||||
extern int rl_vi_back_to_indent PARAMS((int, int));
|
||||
extern int rl_vi_first_print PARAMS((int, int));
|
||||
@ -303,6 +304,8 @@ extern int rl_bind_keyseq_in_map PARAMS((const char *, rl_command_func_t *, Keym
|
||||
extern int rl_bind_keyseq_if_unbound PARAMS((const char *, rl_command_func_t *));
|
||||
extern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
|
||||
extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
|
||||
|
||||
extern char *rl_variable_value PARAMS((const char *));
|
||||
extern int rl_variable_bind PARAMS((const char *, const char *));
|
||||
|
||||
/* Backwards compatibility, use rl_bind_keyseq_in_map instead. */
|
||||
@ -402,6 +405,7 @@ extern int rl_reset_terminal PARAMS((const char *));
|
||||
extern void rl_resize_terminal PARAMS((void));
|
||||
extern void rl_set_screen_size PARAMS((int, int));
|
||||
extern void rl_get_screen_size PARAMS((int *, int *));
|
||||
extern void rl_reset_screen_size PARAMS((void));
|
||||
|
||||
extern char *rl_get_termcap PARAMS((const char *));
|
||||
|
||||
@ -529,6 +533,11 @@ extern const char *rl_terminal_name;
|
||||
extern FILE *rl_instream;
|
||||
extern FILE *rl_outstream;
|
||||
|
||||
/* If non-zero, Readline gives values of LINES and COLUMNS from the environment
|
||||
greater precedence than values fetched from the kernel when computing the
|
||||
screen dimensions. */
|
||||
extern int rl_prefer_env_winsize;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call just
|
||||
before readline_internal () prints the first prompt. */
|
||||
extern rl_hook_func_t *rl_startup_hook;
|
||||
@ -760,29 +769,33 @@ extern int rl_inhibit_completion;
|
||||
#define MULT_MATCH 2
|
||||
|
||||
/* Possible state values for rl_readline_state */
|
||||
#define RL_STATE_NONE 0x00000 /* no state; before first call */
|
||||
#define RL_STATE_NONE 0x000000 /* 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_TTYCSAVED 0x40000 /* tty special chars saved */
|
||||
#define RL_STATE_INITIALIZING 0x000001 /* initializing */
|
||||
#define RL_STATE_INITIALIZED 0x000002 /* initialization done */
|
||||
#define RL_STATE_TERMPREPPED 0x000004 /* terminal is prepped */
|
||||
#define RL_STATE_READCMD 0x000008 /* reading a command key */
|
||||
#define RL_STATE_METANEXT 0x000010 /* reading input after ESC */
|
||||
#define RL_STATE_DISPATCHING 0x000020 /* dispatching to a command */
|
||||
#define RL_STATE_MOREINPUT 0x000040 /* reading more input in a command function */
|
||||
#define RL_STATE_ISEARCH 0x000080 /* doing incremental search */
|
||||
#define RL_STATE_NSEARCH 0x000100 /* doing non-inc search */
|
||||
#define RL_STATE_SEARCH 0x000200 /* doing a history search */
|
||||
#define RL_STATE_NUMERICARG 0x000400 /* reading numeric argument */
|
||||
#define RL_STATE_MACROINPUT 0x000800 /* getting input from a macro */
|
||||
#define RL_STATE_MACRODEF 0x001000 /* defining keyboard macro */
|
||||
#define RL_STATE_OVERWRITE 0x002000 /* overwrite mode */
|
||||
#define RL_STATE_COMPLETING 0x004000 /* doing completion */
|
||||
#define RL_STATE_SIGHANDLER 0x008000 /* in readline sighandler */
|
||||
#define RL_STATE_UNDOING 0x010000 /* doing an undo */
|
||||
#define RL_STATE_INPUTPENDING 0x020000 /* rl_execute_next called */
|
||||
#define RL_STATE_TTYCSAVED 0x040000 /* tty special chars saved */
|
||||
#define RL_STATE_CALLBACK 0x080000 /* using the callback interface */
|
||||
#define RL_STATE_VIMOTION 0x100000 /* reading vi motion arg */
|
||||
#define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command */
|
||||
#define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at least once */
|
||||
|
||||
#define RL_STATE_DONE 0x80000 /* done; accepted line */
|
||||
#define RL_STATE_DONE 0x800000 /* done; accepted line */
|
||||
|
||||
#define RL_SETSTATE(x) (rl_readline_state |= (x))
|
||||
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/* shell.c -- readline utility functions that are normally provided by
|
||||
bash when readline is linked as part of the shell. */
|
||||
|
||||
@ -50,8 +49,12 @@
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_FCNTL_H)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#if defined (HAVE_PWD_H)
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -59,9 +62,9 @@
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
#if !defined (HAVE_GETPW_DECLS)
|
||||
#if defined (HAVE_GETPWUID) && !defined (HAVE_GETPW_DECLS)
|
||||
extern struct passwd *getpwuid PARAMS((uid_t));
|
||||
#endif /* !HAVE_GETPW_DECLS */
|
||||
#endif /* HAVE_GETPWUID && !HAVE_GETPW_DECLS */
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
@ -124,16 +127,7 @@ sh_set_lines_and_columns (lines, cols)
|
||||
{
|
||||
char *b;
|
||||
|
||||
#if defined (HAVE_PUTENV)
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1);
|
||||
sprintf (b, "LINES=%d", lines);
|
||||
putenv (b);
|
||||
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("COLUMNS=") + 1);
|
||||
sprintf (b, "COLUMNS=%d", cols);
|
||||
putenv (b);
|
||||
#else /* !HAVE_PUTENV */
|
||||
# if defined (HAVE_SETENV)
|
||||
#if defined (HAVE_SETENV)
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
|
||||
sprintf (b, "%d", lines);
|
||||
setenv ("LINES", b, 1);
|
||||
@ -143,8 +137,17 @@ sh_set_lines_and_columns (lines, cols)
|
||||
sprintf (b, "%d", cols);
|
||||
setenv ("COLUMNS", b, 1);
|
||||
free (b);
|
||||
# endif /* HAVE_SETENV */
|
||||
#endif /* !HAVE_PUTENV */
|
||||
#else /* !HAVE_SETENV */
|
||||
# if defined (HAVE_PUTENV)
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1);
|
||||
sprintf (b, "LINES=%d", lines);
|
||||
putenv (b);
|
||||
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("COLUMNS=") + 1);
|
||||
sprintf (b, "COLUMNS=%d", cols);
|
||||
putenv (b);
|
||||
# endif /* HAVE_PUTENV */
|
||||
#endif /* !HAVE_SETENV */
|
||||
}
|
||||
|
||||
char *
|
||||
@ -161,9 +164,11 @@ sh_get_home_dir ()
|
||||
struct passwd *entry;
|
||||
|
||||
home_dir = (char *)NULL;
|
||||
#if defined (HAVE_GETPWUID)
|
||||
entry = getpwuid (getuid ());
|
||||
if (entry)
|
||||
home_dir = entry->pw_dir;
|
||||
#endif
|
||||
return (home_dir);
|
||||
}
|
||||
|
||||
@ -177,6 +182,7 @@ int
|
||||
sh_unset_nodelay_mode (fd)
|
||||
int fd;
|
||||
{
|
||||
#if defined (HAVE_FCNTL)
|
||||
int flags, bflags;
|
||||
|
||||
if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
|
||||
@ -197,6 +203,7 @@ sh_unset_nodelay_mode (fd)
|
||||
flags &= ~bflags;
|
||||
return (fcntl (fd, F_SETFL, flags));
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/* terminal.c -- controlling the terminal with termcap. */
|
||||
|
||||
/* Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996-2005 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.
|
||||
@ -71,6 +70,8 @@
|
||||
#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
|
||||
#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
|
||||
|
||||
int rl_prefer_env_winsize;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Terminal and Termcap */
|
||||
@ -147,6 +148,9 @@ static char *_rl_term_kh;
|
||||
static char *_rl_term_kH;
|
||||
static char *_rl_term_at7; /* @7 */
|
||||
|
||||
/* Delete key */
|
||||
static char *_rl_term_kD;
|
||||
|
||||
/* Insert key */
|
||||
static char *_rl_term_kI;
|
||||
|
||||
@ -193,12 +197,14 @@ _rl_get_screen_size (tty, ignore_env)
|
||||
#if defined (TIOCGWINSZ)
|
||||
struct winsize window_size;
|
||||
#endif /* TIOCGWINSZ */
|
||||
int wr, wc;
|
||||
|
||||
wr = wc = -1;
|
||||
#if defined (TIOCGWINSZ)
|
||||
if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
|
||||
{
|
||||
_rl_screenwidth = (int) window_size.ws_col;
|
||||
_rl_screenheight = (int) window_size.ws_row;
|
||||
wc = (int) window_size.ws_col;
|
||||
wr = (int) window_size.ws_row;
|
||||
}
|
||||
#endif /* TIOCGWINSZ */
|
||||
|
||||
@ -206,13 +212,25 @@ _rl_get_screen_size (tty, ignore_env)
|
||||
_emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
|
||||
#endif
|
||||
|
||||
if (ignore_env || rl_prefer_env_winsize == 0)
|
||||
{
|
||||
_rl_screenwidth = wc;
|
||||
_rl_screenheight = wr;
|
||||
}
|
||||
else
|
||||
_rl_screenwidth = _rl_screenheight = -1;
|
||||
|
||||
/* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV
|
||||
is unset. */
|
||||
is unset. If we prefer the environment, check it first before
|
||||
assigning the value returned by the kernel. */
|
||||
if (_rl_screenwidth <= 0)
|
||||
{
|
||||
if (ignore_env == 0 && (ss = sh_get_env_value ("COLUMNS")))
|
||||
_rl_screenwidth = atoi (ss);
|
||||
|
||||
if (_rl_screenwidth <= 0)
|
||||
_rl_screenwidth = wc;
|
||||
|
||||
#if !defined (__DJGPP__)
|
||||
if (_rl_screenwidth <= 0 && term_string_buffer)
|
||||
_rl_screenwidth = tgetnum ("co");
|
||||
@ -226,6 +244,9 @@ _rl_get_screen_size (tty, ignore_env)
|
||||
if (ignore_env == 0 && (ss = sh_get_env_value ("LINES")))
|
||||
_rl_screenheight = atoi (ss);
|
||||
|
||||
if (_rl_screenheight <= 0)
|
||||
_rl_screenheight = wr;
|
||||
|
||||
#if !defined (__DJGPP__)
|
||||
if (_rl_screenheight <= 0 && term_string_buffer)
|
||||
_rl_screenheight = tgetnum ("li");
|
||||
@ -254,16 +275,17 @@ void
|
||||
_rl_set_screen_size (rows, cols)
|
||||
int rows, cols;
|
||||
{
|
||||
if (rows == 0 || cols == 0)
|
||||
return;
|
||||
if (rows > 0)
|
||||
_rl_screenheight = rows;
|
||||
if (cols > 0)
|
||||
{
|
||||
_rl_screenwidth = cols;
|
||||
if (_rl_term_autowrap == 0)
|
||||
_rl_screenwidth--;
|
||||
}
|
||||
|
||||
_rl_screenheight = rows;
|
||||
_rl_screenwidth = cols;
|
||||
|
||||
if (_rl_term_autowrap == 0)
|
||||
_rl_screenwidth--;
|
||||
|
||||
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
|
||||
if (rows > 0 || cols > 0)
|
||||
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
|
||||
}
|
||||
|
||||
void
|
||||
@ -282,6 +304,12 @@ rl_get_screen_size (rows, cols)
|
||||
if (cols)
|
||||
*cols = _rl_screenwidth;
|
||||
}
|
||||
|
||||
void
|
||||
rl_reset_screen_size ()
|
||||
{
|
||||
_rl_get_screen_size (fileno (rl_instream), 0);
|
||||
}
|
||||
|
||||
void
|
||||
rl_resize_terminal ()
|
||||
@ -315,6 +343,7 @@ static struct _tc_string tc_strings[] =
|
||||
{ "ei", &_rl_term_ei },
|
||||
{ "ic", &_rl_term_ic },
|
||||
{ "im", &_rl_term_im },
|
||||
{ "kD", &_rl_term_kD }, /* delete */
|
||||
{ "kH", &_rl_term_kH }, /* home down ?? */
|
||||
{ "kI", &_rl_term_kI }, /* insert */
|
||||
{ "kd", &_rl_term_kd },
|
||||
@ -365,7 +394,6 @@ _rl_init_terminal_io (terminal_name)
|
||||
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;
|
||||
_rl_screenwidth = _rl_screenheight = 0;
|
||||
|
||||
if (term == 0)
|
||||
term = "dumb";
|
||||
@ -398,12 +426,17 @@ _rl_init_terminal_io (terminal_name)
|
||||
|
||||
_rl_term_autowrap = 0; /* used by _rl_get_screen_size */
|
||||
|
||||
/* Allow calling application to set default height and width, using
|
||||
rl_set_screen_size */
|
||||
if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
|
||||
{
|
||||
#if defined (__EMX__)
|
||||
_emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
|
||||
_rl_screenwidth--;
|
||||
_emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
|
||||
_rl_screenwidth--;
|
||||
#else /* !__EMX__ */
|
||||
_rl_get_screen_size (tty, 0);
|
||||
_rl_get_screen_size (tty, 0);
|
||||
#endif /* !__EMX__ */
|
||||
}
|
||||
|
||||
/* Defaults. */
|
||||
if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
|
||||
@ -418,7 +451,7 @@ _rl_init_terminal_io (terminal_name)
|
||||
_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_kh = _rl_term_kH = _rl_term_kI = (char *)NULL;
|
||||
_rl_term_kh = _rl_term_kH = _rl_term_kI = _rl_term_kD = (char *)NULL;
|
||||
_rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL;
|
||||
_rl_term_mm = _rl_term_mo = (char *)NULL;
|
||||
_rl_term_ve = _rl_term_vs = (char *)NULL;
|
||||
@ -450,7 +483,10 @@ _rl_init_terminal_io (terminal_name)
|
||||
|
||||
_rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
|
||||
|
||||
_rl_get_screen_size (tty, 0);
|
||||
/* Allow calling application to set default height and width, using
|
||||
rl_set_screen_size */
|
||||
if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
|
||||
_rl_get_screen_size (tty, 0);
|
||||
|
||||
/* "An application program can assume that the terminal can do
|
||||
character insertion if *any one of* the capabilities `IC',
|
||||
@ -495,6 +531,8 @@ bind_termcap_arrow_keys (map)
|
||||
rl_bind_keyseq_if_unbound (_rl_term_kh, rl_beg_of_line); /* Home */
|
||||
rl_bind_keyseq_if_unbound (_rl_term_at7, rl_end_of_line); /* End */
|
||||
|
||||
rl_bind_keyseq_if_unbound (_rl_term_kD, rl_delete);
|
||||
|
||||
_rl_keymap = xkeymap;
|
||||
}
|
||||
|
||||
@ -520,6 +558,7 @@ int
|
||||
rl_reset_terminal (terminal_name)
|
||||
const char *terminal_name;
|
||||
{
|
||||
_rl_screenwidth = _rl_screenheight = 0;
|
||||
_rl_init_terminal_io (terminal_name);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/* util.c -- readline utility functions */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
@ -46,6 +45,7 @@
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
#if defined (TIOCSTAT_IN_SYS_IOCTL)
|
||||
# include <sys/ioctl.h>
|
||||
@ -80,13 +80,29 @@ rl_alphabetic (c)
|
||||
strchr (pathname_alphabetic_chars, c) != NULL);
|
||||
}
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
int
|
||||
_rl_walphabetic (wc)
|
||||
wchar_t wc;
|
||||
{
|
||||
int c;
|
||||
|
||||
if (iswalnum (wc))
|
||||
return (1);
|
||||
|
||||
c = wc & 0177;
|
||||
return (_rl_allow_pathname_alphabetic_chars &&
|
||||
strchr (pathname_alphabetic_chars, c) != NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* How to abort things. */
|
||||
int
|
||||
_rl_abort_internal ()
|
||||
{
|
||||
rl_ding ();
|
||||
rl_clear_message ();
|
||||
_rl_init_argument ();
|
||||
_rl_reset_argument ();
|
||||
rl_clear_pending_input ();
|
||||
|
||||
RL_UNSETSTATE (RL_STATE_MACRODEF);
|
||||
|
@ -1,9 +1,8 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/* vi_mode.c -- A vi emulation mode for Bash.
|
||||
Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */
|
||||
|
||||
/* Copyright (C) 1987-2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
@ -92,6 +91,7 @@ static int _rl_vi_last_arg_sign = 1;
|
||||
static int _rl_vi_last_motion;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
static char _rl_vi_last_search_mbchar[MB_LEN_MAX];
|
||||
static int _rl_vi_last_search_mblen;
|
||||
#else
|
||||
static int _rl_vi_last_search_char;
|
||||
#endif
|
||||
@ -109,8 +109,22 @@ static int vi_mark_chars['z' - 'a' + 1];
|
||||
|
||||
static void _rl_vi_stuff_insert PARAMS((int));
|
||||
static void _rl_vi_save_insert PARAMS((UNDO_LIST *));
|
||||
|
||||
static int _rl_vi_arg_dispatch PARAMS((int));
|
||||
static int rl_digit_loop1 PARAMS((void));
|
||||
|
||||
static int _rl_vi_set_mark PARAMS((void));
|
||||
static int _rl_vi_goto_mark PARAMS((void));
|
||||
|
||||
static int _rl_vi_callback_getchar PARAMS((char *, int));
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
static int _rl_vi_callback_set_mark PARAMS((_rl_callback_generic_arg *));
|
||||
static int _rl_vi_callback_goto_mark PARAMS((_rl_callback_generic_arg *));
|
||||
static int _rl_vi_callback_change_char PARAMS((_rl_callback_generic_arg *));
|
||||
static int _rl_vi_callback_char_search PARAMS((_rl_callback_generic_arg *));
|
||||
#endif
|
||||
|
||||
void
|
||||
_rl_vi_initialize_line ()
|
||||
{
|
||||
@ -118,6 +132,8 @@ _rl_vi_initialize_line ()
|
||||
|
||||
for (i = 0; i < sizeof (vi_mark_chars) / sizeof (int); i++)
|
||||
vi_mark_chars[i] = -1;
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_VICMDONCE);
|
||||
}
|
||||
|
||||
void
|
||||
@ -673,6 +689,13 @@ rl_vi_movement_mode (count, key)
|
||||
|
||||
_rl_keymap = vi_movement_keymap;
|
||||
_rl_vi_done_inserting ();
|
||||
|
||||
/* This is how POSIX.2 says `U' should behave -- everything up until the
|
||||
first time you go into command mode should not be undone. */
|
||||
if (RL_ISSTATE (RL_STATE_VICMDONCE) == 0)
|
||||
rl_free_undo_list ();
|
||||
|
||||
RL_SETSTATE (RL_STATE_VICMDONCE);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -842,7 +865,9 @@ rl_vi_domove (key, nextkey)
|
||||
save = rl_numeric_arg;
|
||||
rl_numeric_arg = _rl_digit_value (c);
|
||||
rl_explicit_arg = 1;
|
||||
RL_SETSTATE (RL_STATE_NUMERICARG|RL_STATE_VIMOTION);
|
||||
rl_digit_loop1 ();
|
||||
RL_UNSETSTATE (RL_STATE_VIMOTION);
|
||||
rl_numeric_arg *= save;
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
c = rl_read_key (); /* real command */
|
||||
@ -915,52 +940,59 @@ rl_vi_domove (key, nextkey)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Process C as part of the current numeric argument. Return -1 if the
|
||||
argument should be aborted, 0 if we should not read any more chars, and
|
||||
1 if we should continue to read chars. */
|
||||
static int
|
||||
_rl_vi_arg_dispatch (c)
|
||||
int c;
|
||||
{
|
||||
int key;
|
||||
|
||||
key = c;
|
||||
if (c >= 0 && _rl_keymap[c].type == ISFUNC && _rl_keymap[c].function == rl_universal_argument)
|
||||
{
|
||||
rl_numeric_arg *= 4;
|
||||
return 1;
|
||||
}
|
||||
|
||||
c = UNMETA (c);
|
||||
|
||||
if (_rl_digit_p (c))
|
||||
{
|
||||
if (rl_explicit_arg)
|
||||
rl_numeric_arg = (rl_numeric_arg * 10) + _rl_digit_value (c);
|
||||
else
|
||||
rl_numeric_arg = _rl_digit_value (c);
|
||||
rl_explicit_arg = 1;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rl_clear_message ();
|
||||
rl_stuff_char (key);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* A simplified loop for vi. Don't dispatch key at end.
|
||||
Don't recognize minus sign?
|
||||
Should this do rl_save_prompt/rl_restore_prompt? */
|
||||
static int
|
||||
rl_digit_loop1 ()
|
||||
{
|
||||
int key, c;
|
||||
int c, r;
|
||||
|
||||
RL_SETSTATE(RL_STATE_NUMERICARG);
|
||||
while (1)
|
||||
{
|
||||
if (rl_numeric_arg > 1000000)
|
||||
{
|
||||
rl_explicit_arg = rl_numeric_arg = 0;
|
||||
rl_ding ();
|
||||
rl_clear_message ();
|
||||
RL_UNSETSTATE(RL_STATE_NUMERICARG);
|
||||
return 1;
|
||||
}
|
||||
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
key = c = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
if (_rl_arg_overflow ())
|
||||
return 1;
|
||||
|
||||
if (c >= 0 && _rl_keymap[c].type == ISFUNC &&
|
||||
_rl_keymap[c].function == rl_universal_argument)
|
||||
{
|
||||
rl_numeric_arg *= 4;
|
||||
continue;
|
||||
}
|
||||
c = _rl_arg_getchar ();
|
||||
|
||||
c = UNMETA (c);
|
||||
if (_rl_digit_p (c))
|
||||
{
|
||||
if (rl_explicit_arg)
|
||||
rl_numeric_arg = (rl_numeric_arg * 10) + _rl_digit_value (c);
|
||||
else
|
||||
rl_numeric_arg = _rl_digit_value (c);
|
||||
rl_explicit_arg = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rl_clear_message ();
|
||||
rl_stuff_char (key);
|
||||
break;
|
||||
}
|
||||
r = _rl_vi_arg_dispatch (c);
|
||||
if (r <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_NUMERICARG);
|
||||
@ -1050,8 +1082,9 @@ int
|
||||
rl_vi_yank_to (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int c, save = rl_point;
|
||||
int c, save;
|
||||
|
||||
save = rl_point;
|
||||
if (_rl_uppercase_p (key))
|
||||
rl_stuff_char ('$');
|
||||
|
||||
@ -1075,12 +1108,46 @@ rl_vi_yank_to (count, key)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_rubout (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int p, opoint;
|
||||
|
||||
if (count < 0)
|
||||
return (rl_vi_delete (-count, key));
|
||||
|
||||
if (rl_point == 0)
|
||||
{
|
||||
rl_ding ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
opoint = rl_point;
|
||||
if (count > 1 && MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
rl_backward_char (count, key);
|
||||
else if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
|
||||
else
|
||||
rl_point -= count;
|
||||
|
||||
if (rl_point < 0)
|
||||
rl_point = 0;
|
||||
|
||||
rl_kill_text (rl_point, opoint);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_delete (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int end;
|
||||
|
||||
if (count < 0)
|
||||
return (rl_vi_rubout (-count, key));
|
||||
|
||||
if (rl_end == 0)
|
||||
{
|
||||
rl_ding ();
|
||||
@ -1099,6 +1166,7 @@ rl_vi_delete (count, key)
|
||||
|
||||
if (rl_point > 0 && rl_point == rl_end)
|
||||
rl_backward_char (1, key);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -1119,64 +1187,102 @@ rl_vi_first_print (count, key)
|
||||
return (rl_vi_back_to_indent (1, key));
|
||||
}
|
||||
|
||||
static int _rl_cs_dir, _rl_cs_orig_dir;
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
static int
|
||||
_rl_vi_callback_char_search (data)
|
||||
_rl_callback_generic_arg *data;
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
_rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
|
||||
#else
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
_rl_vi_last_search_char = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
#endif
|
||||
|
||||
_rl_callback_func = 0;
|
||||
_rl_want_redisplay = 1;
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
return (_rl_char_search_internal (data->count, _rl_cs_dir, _rl_vi_last_search_mbchar, _rl_vi_last_search_mblen));
|
||||
#else
|
||||
return (_rl_char_search_internal (data->count, _rl_cs_dir, _rl_vi_last_search_char));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
rl_vi_char_search (count, key)
|
||||
int count, key;
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
static char *target;
|
||||
static int mb_len;
|
||||
static int tlen;
|
||||
#else
|
||||
static char target;
|
||||
#endif
|
||||
static int orig_dir, dir;
|
||||
|
||||
if (key == ';' || key == ',')
|
||||
dir = key == ';' ? orig_dir : -orig_dir;
|
||||
_rl_cs_dir = (key == ';') ? _rl_cs_orig_dir : -_rl_cs_orig_dir;
|
||||
else
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 't':
|
||||
_rl_cs_orig_dir = _rl_cs_dir = FTO;
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
_rl_cs_orig_dir = _rl_cs_dir = BTO;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
_rl_cs_orig_dir = _rl_cs_dir = FFIND;
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
_rl_cs_orig_dir = _rl_cs_dir = BFIND;
|
||||
break;
|
||||
}
|
||||
|
||||
if (vi_redoing)
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
target = _rl_vi_last_search_mbchar;
|
||||
#else
|
||||
target = _rl_vi_last_search_char;
|
||||
{
|
||||
/* set target and tlen below */
|
||||
}
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
else if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
{
|
||||
_rl_callback_data = _rl_callback_data_alloc (count);
|
||||
_rl_callback_data->i1 = _rl_cs_dir;
|
||||
_rl_callback_func = _rl_vi_callback_char_search;
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
mb_len = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
|
||||
target = _rl_vi_last_search_mbchar;
|
||||
_rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
|
||||
#else
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
_rl_vi_last_search_char = target = rl_read_key ();
|
||||
_rl_vi_last_search_char = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 't':
|
||||
orig_dir = dir = FTO;
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
orig_dir = dir = BTO;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
orig_dir = dir = FFIND;
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
orig_dir = dir = BFIND;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
return (_rl_char_search_internal (count, dir, target, mb_len));
|
||||
target = _rl_vi_last_search_mbchar;
|
||||
tlen = _rl_vi_last_search_mblen;
|
||||
#else
|
||||
return (_rl_char_search_internal (count, dir, target));
|
||||
target = _rl_vi_last_search_char;
|
||||
#endif
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
return (_rl_char_search_internal (count, _rl_cs_dir, target, tlen));
|
||||
#else
|
||||
return (_rl_char_search_internal (count, _rl_cs_dir, target));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1287,25 +1393,12 @@ rl_vi_bracktype (c)
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX - think about reading an entire mbchar with _rl_read_mbchar and
|
||||
inserting it in one bunch instead of the loop below (like in
|
||||
rl_vi_char_search or _rl_vi_change_mbchar_case). Set c to mbchar[0]
|
||||
for test against 033 or ^C. Make sure that _rl_read_mbchar does
|
||||
this right. */
|
||||
int
|
||||
rl_vi_change_char (count, key)
|
||||
int count, key;
|
||||
static int
|
||||
_rl_vi_change_char (count, c, mb)
|
||||
int count, c;
|
||||
char *mb;
|
||||
{
|
||||
int c, p;
|
||||
|
||||
if (vi_redoing)
|
||||
c = _rl_vi_last_replacement;
|
||||
else
|
||||
{
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
_rl_vi_last_replacement = c = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
}
|
||||
int p;
|
||||
|
||||
if (c == '\033' || c == CTRL ('C'))
|
||||
return -1;
|
||||
@ -1315,31 +1408,87 @@ rl_vi_change_char (count, key)
|
||||
{
|
||||
p = rl_point;
|
||||
rl_vi_delete (1, c);
|
||||
if (rl_point < p) /* Did we retreat at EOL? */
|
||||
rl_point++;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
if (rl_point < p) /* Did we retreat at EOL? */
|
||||
rl_point++;
|
||||
while (_rl_insert_char (1, c))
|
||||
{
|
||||
RL_SETSTATE (RL_STATE_MOREINPUT);
|
||||
c = rl_read_key ();
|
||||
RL_UNSETSTATE (RL_STATE_MOREINPUT);
|
||||
}
|
||||
}
|
||||
rl_insert_text (mb);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (rl_point < p) /* Did we retreat at EOL? */
|
||||
rl_point++;
|
||||
_rl_insert_char (1, c);
|
||||
}
|
||||
_rl_insert_char (1, c);
|
||||
}
|
||||
|
||||
/* The cursor shall be left on the last character changed. */
|
||||
rl_backward_char (1, c);
|
||||
|
||||
rl_end_undo_group ();
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
_rl_vi_callback_getchar (mb, mblen)
|
||||
char *mb;
|
||||
int mblen;
|
||||
{
|
||||
int c;
|
||||
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
c = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
c = _rl_read_mbstring (c, mb, mblen);
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
static int
|
||||
_rl_vi_callback_change_char (data)
|
||||
_rl_callback_generic_arg *data;
|
||||
{
|
||||
int c;
|
||||
char mb[MB_LEN_MAX];
|
||||
|
||||
_rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
|
||||
|
||||
_rl_callback_func = 0;
|
||||
_rl_want_redisplay = 1;
|
||||
|
||||
return (_rl_vi_change_char (data->count, c, mb));
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
rl_vi_change_char (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int c;
|
||||
char mb[MB_LEN_MAX];
|
||||
|
||||
if (vi_redoing)
|
||||
{
|
||||
c = _rl_vi_last_replacement;
|
||||
mb[0] = c;
|
||||
mb[1] = '\0';
|
||||
}
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
else if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
{
|
||||
_rl_callback_data = _rl_callback_data_alloc (count);
|
||||
_rl_callback_func = _rl_vi_callback_change_char;
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
_rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
|
||||
|
||||
return (_rl_vi_change_char (count, c, mb));
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_subst (count, key)
|
||||
int count, key;
|
||||
@ -1462,9 +1611,8 @@ rl_vi_possible_completions()
|
||||
#endif
|
||||
|
||||
/* Functions to save and restore marks. */
|
||||
int
|
||||
rl_vi_set_mark (count, key)
|
||||
int count, key;
|
||||
static int
|
||||
_rl_vi_set_mark ()
|
||||
{
|
||||
int ch;
|
||||
|
||||
@ -1482,9 +1630,36 @@ rl_vi_set_mark (count, key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
static int
|
||||
_rl_vi_callback_set_mark (data)
|
||||
_rl_callback_generic_arg *data;
|
||||
{
|
||||
_rl_callback_func = 0;
|
||||
_rl_want_redisplay = 1;
|
||||
|
||||
return (_rl_vi_set_mark ());
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
rl_vi_goto_mark (count, key)
|
||||
rl_vi_set_mark (count, key)
|
||||
int count, key;
|
||||
{
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
{
|
||||
_rl_callback_data = 0;
|
||||
_rl_callback_func = _rl_vi_callback_set_mark;
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
return (_rl_vi_set_mark ());
|
||||
}
|
||||
|
||||
static int
|
||||
_rl_vi_goto_mark ()
|
||||
{
|
||||
int ch;
|
||||
|
||||
@ -1513,4 +1688,31 @@ rl_vi_goto_mark (count, key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
static int
|
||||
_rl_vi_callback_goto_mark (data)
|
||||
_rl_callback_generic_arg *data;
|
||||
{
|
||||
_rl_callback_func = 0;
|
||||
_rl_want_redisplay = 1;
|
||||
|
||||
return (_rl_vi_goto_mark ());
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
rl_vi_goto_mark (count, key)
|
||||
int count, key;
|
||||
{
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
{
|
||||
_rl_callback_data = 0;
|
||||
_rl_callback_func = _rl_vi_callback_goto_mark;
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
return (_rl_vi_goto_mark ());
|
||||
}
|
||||
#endif /* VI_MODE */
|
||||
|
Loading…
Reference in New Issue
Block a user