readline and completion fixes

This commit is contained in:
Chet Ramey
2023-04-20 11:27:36 -04:00
parent a46164736e
commit d052bd6fd9
19 changed files with 8015 additions and 7681 deletions
+20 -15
View File
@@ -1126,19 +1126,6 @@ rl_redisplay (void)
olen = sprintf (obuf, "\\%o", c);
if (lpos + olen >= _rl_screenwidth)
{
temp = _rl_screenwidth - lpos;
CHECK_INV_LBREAKS ();
inv_lbreaks[++newlines] = out + temp;
#if defined (HANDLE_MULTIBYTE)
line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn;
#endif
lpos = olen - temp;
}
else
lpos += olen;
for (temp = 0; temp < olen; temp++)
{
invis_addc (&out, obuf[temp], cur_face);
@@ -2043,6 +2030,8 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
#if defined (HANDLE_MULTIBYTE)
/* Find the last character that is the same between the two lines. This
bounds the region that needs to change. */
/* In this case, `last character' means the one farthest from the end of
the line. */
if (mb_cur_max > 1 && rl_byte_oriented == 0)
{
ols = old + _rl_find_prev_mbchar (old, oe - old, MB_FIND_ANY);
@@ -2059,7 +2048,7 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
*olsf != *nlsf)
break;
if (*ols == ' ')
if (*ols != ' ')
wsatend = 0;
ols = old + _rl_find_prev_mbchar (old, ols - old, MB_FIND_ANY);
@@ -2128,7 +2117,23 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
/* We have moved up to a new screen line. This line may or may not have
invisible characters on it, but we do our best to recalculate
visible_wrap_offset based on what we know. */
if (current_line == 0)
/* This first clause handles the case where the prompt has been
recalculated (e.g., by rl_message) but the old prompt is still on
the visible line because we haven't overwritten it yet. We want
to somehow use the old prompt information, but we only want to do
this once. */
if (current_line == 0 && saved_local_prompt && old[0] == saved_local_prompt[0] && memcmp (old, saved_local_prompt, saved_local_length) == 0)
visible_wrap_offset = saved_invis_chars_first_line;
/* This clause handles the opposite: the prompt has been restored (e.g.,
by rl_clear_message) but the old saved_local_prompt (now NULL, so we
can't directly check it) is still on the visible line because we
haven't overwritten it yet. We guess that there aren't any invisible
characters in any of the prompts we put in with rl_message */
else if (current_line == 0 && local_prompt && new[0] == local_prompt[0] &&
(memcmp (new, local_prompt, local_prompt_len) == 0) &&
(memcmp (old, local_prompt, local_prompt_len) != 0))
visible_wrap_offset = 0;
else if (current_line == 0)
visible_wrap_offset = prompt_invis_chars_first_line; /* XXX */
#if 0 /* XXX - not yet */
else if (current_line == prompt_last_screen_line && wrap_offset > prompt_invis_chars_first_line)
+3 -3
View File
@@ -2643,7 +2643,7 @@ com_list (char *arg)
if (!arg)
arg = "";
sprintf (syscom, "ls -FClg %s", arg);
snprintf (syscom, sizeof (syscom), "ls -FClg %s", arg);
return (system (syscom));
@}
@@ -2655,9 +2655,9 @@ com_view (char *arg)
#if defined (__MSDOS__)
/* more.com doesn't grok slashes in pathnames */
sprintf (syscom, "less %s", arg);
snprintf (syscom, sizeof (syscom), "less %s", arg);
#else
sprintf (syscom, "more %s", arg);
snprintf (syscom, sizeof (syscom), "more %s", arg);
#endif
return (system (syscom));
@}
+3 -3
View File
@@ -292,7 +292,7 @@ com_list (arg)
if (!arg)
arg = "";
sprintf (syscom, "ls -FClg %s", arg);
snprintf (syscom, sizeof (syscom), "ls -FClg %s", arg);
return (system (syscom));
}
@@ -305,9 +305,9 @@ com_view (arg)
#if defined (__MSDOS__)
/* more.com doesn't grok slashes in pathnames */
sprintf (syscom, "less %s", arg);
snprintf (syscom, sizeof (syscom), "less %s", arg);
#else
sprintf (syscom, "more %s", arg);
snprintf (syscom, sizeof (syscom), "more %s", arg);
#endif
return (system (syscom));
}
+1 -1
View File
@@ -730,7 +730,7 @@ history_expand_internal (const char *string, int start, int qc, int *end_index_p
/* If `&' appears in the rhs, it's supposed to be replaced
with the lhs. */
if (member ('&', subst_rhs))
if (subst_lhs && member ('&', subst_rhs))
postproc_subst_rhs ();
}
else
+1
View File
@@ -526,6 +526,7 @@ extern int _rl_menu_complete_prefix_first;
/* display.c */
extern int _rl_vis_botlin;
extern int _rl_last_c_pos;
extern int _rl_last_v_pos;
extern int _rl_suppress_redisplay;
extern int _rl_want_redisplay;
+3 -2
View File
@@ -1229,11 +1229,12 @@ _rl_rubout_char (int count, int key)
c = rl_line_buffer[--rl_point];
rl_delete_text (rl_point, orig_point);
/* The erase-at-end-of-line hack is of questionable merit now. */
if (rl_point == rl_end && ISPRINT ((unsigned char)c) && _rl_last_c_pos)
if (rl_point == rl_end && ISPRINT ((unsigned char)c) && _rl_last_c_pos && _rl_last_v_pos == 0)
{
int l;
l = rl_character_len (c, rl_point);
_rl_erase_at_end_of_line (l);
if (_rl_last_c_pos >= l)
_rl_erase_at_end_of_line (l);
}
}
else
+3 -2
View File
@@ -1090,6 +1090,7 @@ _rl_vi_arg_dispatch (int c)
}
else
{
rl_restore_prompt ();
rl_clear_message ();
rl_stuff_char (key);
return 0; /* done */
@@ -1320,7 +1321,7 @@ rl_domove_read_callback (_rl_vimotion_cxt *m)
/* Readine vi motion char starting numeric argument */
else if (_rl_digit_p (c) && RL_ISSTATE (RL_STATE_CALLBACK) && RL_ISSTATE (RL_STATE_VIMOTION) && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0))
{
RL_SETSTATE (RL_STATE_NUMERICARG);
_rl_arg_init ();
return (_rl_vi_arg_dispatch (c));
}
#endif
@@ -1330,7 +1331,7 @@ rl_domove_read_callback (_rl_vimotion_cxt *m)
save = rl_numeric_arg;
rl_numeric_arg = _rl_digit_value (c);
rl_explicit_arg = 1;
RL_SETSTATE (RL_STATE_NUMERICARG);
_rl_arg_init ();
rl_digit_loop1 ();
rl_numeric_arg *= save;
c = rl_vi_domove_getchar (m);
+1 -1
View File
@@ -23,7 +23,7 @@
#include <bashansi.h>
size_t
strlcpy(const char *dest, const const char *src, size_t size)
strlcpy(char *dest, const const char *src, size_t size)
{
size_t ret;