mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-06 11:50:49 +02:00
commit bash-20060413 snapshot
This commit is contained in:
+59
-62
@@ -125,73 +125,73 @@ rl_callback_read_char ()
|
||||
return;
|
||||
}
|
||||
|
||||
if (RL_ISSTATE (RL_STATE_ISEARCH))
|
||||
do
|
||||
{
|
||||
eof = _rl_isearch_callback (_rl_iscxt);
|
||||
if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
|
||||
rl_callback_read_char ();
|
||||
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_NSEARCH))
|
||||
{
|
||||
eof = _rl_nsearch_callback (_rl_nscxt);
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_NUMERICARG))
|
||||
{
|
||||
eof = _rl_arg_callback (_rl_argcxt);
|
||||
if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
|
||||
rl_callback_read_char ();
|
||||
/* XXX - this should handle _rl_last_command_was_kill better */
|
||||
else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
|
||||
_rl_internal_char_cleanup ();
|
||||
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_MULTIKEY))
|
||||
{
|
||||
eof = _rl_dispatch_callback (_rl_kscxt); /* For now */
|
||||
while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED))
|
||||
eof = _rl_dispatch_callback (_rl_kscxt);
|
||||
if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0)
|
||||
if (RL_ISSTATE (RL_STATE_ISEARCH))
|
||||
{
|
||||
_rl_internal_char_cleanup ();
|
||||
_rl_want_redisplay = 1;
|
||||
eof = _rl_isearch_callback (_rl_iscxt);
|
||||
if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
|
||||
rl_callback_read_char ();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (_rl_callback_func)
|
||||
{
|
||||
/* This allows functions that simply need to read an additional character
|
||||
(like quoted-insert) to register a function to be called when input is
|
||||
available. _rl_callback_data is simply a pointer to a struct that has
|
||||
the argument count originally passed to the registering function and
|
||||
space for any additional parameters. */
|
||||
eof = (*_rl_callback_func) (_rl_callback_data);
|
||||
/* If the function `deregisters' itself, make sure the data is cleaned
|
||||
up. */
|
||||
if (_rl_callback_func == 0)
|
||||
else if (RL_ISSTATE (RL_STATE_NSEARCH))
|
||||
{
|
||||
if (_rl_callback_data)
|
||||
eof = _rl_nsearch_callback (_rl_nscxt);
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_NUMERICARG))
|
||||
{
|
||||
eof = _rl_arg_callback (_rl_argcxt);
|
||||
if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
|
||||
rl_callback_read_char ();
|
||||
/* XXX - this should handle _rl_last_command_was_kill better */
|
||||
else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
|
||||
_rl_internal_char_cleanup ();
|
||||
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_MULTIKEY))
|
||||
{
|
||||
eof = _rl_dispatch_callback (_rl_kscxt); /* For now */
|
||||
while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED))
|
||||
eof = _rl_dispatch_callback (_rl_kscxt);
|
||||
if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0)
|
||||
{
|
||||
_rl_callback_data_dispose (_rl_callback_data);
|
||||
_rl_callback_data = 0;
|
||||
_rl_internal_char_cleanup ();
|
||||
_rl_want_redisplay = 1;
|
||||
}
|
||||
_rl_internal_char_cleanup ();
|
||||
}
|
||||
}
|
||||
else
|
||||
eof = readline_internal_char ();
|
||||
else if (_rl_callback_func)
|
||||
{
|
||||
/* This allows functions that simply need to read an additional
|
||||
character (like quoted-insert) to register a function to be
|
||||
called when input is available. _rl_callback_data is simply a
|
||||
pointer to a struct that has the argument count originally
|
||||
passed to the registering function and space for any additional
|
||||
parameters. */
|
||||
eof = (*_rl_callback_func) (_rl_callback_data);
|
||||
/* If the function `deregisters' itself, make sure the data is
|
||||
cleaned up. */
|
||||
if (_rl_callback_func == 0)
|
||||
{
|
||||
if (_rl_callback_data)
|
||||
{
|
||||
_rl_callback_data_dispose (_rl_callback_data);
|
||||
_rl_callback_data = 0;
|
||||
}
|
||||
_rl_internal_char_cleanup ();
|
||||
}
|
||||
}
|
||||
else
|
||||
eof = readline_internal_char ();
|
||||
|
||||
if (rl_done == 0 && _rl_want_redisplay)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
_rl_want_redisplay = 0;
|
||||
}
|
||||
if (rl_done == 0 && _rl_want_redisplay)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
_rl_want_redisplay = 0;
|
||||
}
|
||||
|
||||
/* We loop in case some function has pushed input back with rl_execute_next. */
|
||||
for (;;)
|
||||
{
|
||||
if (rl_done)
|
||||
{
|
||||
line = readline_internal_teardown (eof);
|
||||
@@ -213,11 +213,8 @@ rl_callback_read_char ()
|
||||
if (in_handler == 0 && rl_linefunc)
|
||||
_rl_callback_newline ();
|
||||
}
|
||||
if (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT))
|
||||
eof = readline_internal_char ();
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT));
|
||||
}
|
||||
|
||||
/* Remove the handler, and make sure the terminal is in its normal state. */
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
/* callback.c -- functions to use readline as an X `callback' mechanism. */
|
||||
|
||||
/* 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.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "rlconf.h"
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
#include "readline.h"
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* Private data for callback registration functions. See comments in
|
||||
rl_callback_read_char for more details. */
|
||||
_rl_callback_func_t *_rl_callback_func = 0;
|
||||
_rl_callback_generic_arg *_rl_callback_data = 0;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Callback Readline Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Allow using readline in situations where a program may have multiple
|
||||
things to handle at once, and dispatches them via select(). Call
|
||||
rl_callback_handler_install() with the prompt and a function to call
|
||||
whenever a complete line of input is ready. The user must then
|
||||
call rl_callback_read_char() every time some input is available, and
|
||||
rl_callback_read_char() will call the user's function with the complete
|
||||
text read in at each end of line. The terminal is kept prepped and
|
||||
signals handled all the time, except during calls to the user's function. */
|
||||
|
||||
rl_vcpfunc_t *rl_linefunc; /* user callback function */
|
||||
static int in_handler; /* terminal_prepped and signals set? */
|
||||
|
||||
/* Make sure the terminal is set up, initialize readline, and prompt. */
|
||||
static void
|
||||
_rl_callback_newline ()
|
||||
{
|
||||
rl_initialize ();
|
||||
|
||||
if (in_handler == 0)
|
||||
{
|
||||
in_handler = 1;
|
||||
|
||||
if (rl_prep_term_function)
|
||||
(*rl_prep_term_function) (_rl_meta_flag);
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_set_signals ();
|
||||
#endif
|
||||
}
|
||||
|
||||
readline_internal_setup ();
|
||||
}
|
||||
|
||||
/* Install a readline handler, set up the terminal, and issue the prompt. */
|
||||
void
|
||||
rl_callback_handler_install (prompt, linefunc)
|
||||
const char *prompt;
|
||||
rl_vcpfunc_t *linefunc;
|
||||
{
|
||||
rl_set_prompt (prompt);
|
||||
RL_SETSTATE (RL_STATE_CALLBACK);
|
||||
rl_linefunc = linefunc;
|
||||
_rl_callback_newline ();
|
||||
}
|
||||
|
||||
/* Read one character, and dispatch to the handler if it ends the line. */
|
||||
void
|
||||
rl_callback_read_char ()
|
||||
{
|
||||
char *line;
|
||||
int eof, jcode;
|
||||
static procenv_t olevel;
|
||||
|
||||
if (rl_linefunc == NULL)
|
||||
{
|
||||
fprintf (stderr, "readline: readline_callback_read_char() called with no handler!\r\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
memcpy ((void *)olevel, (void *)readline_top_level, sizeof (procenv_t));
|
||||
jcode = setjmp (readline_top_level);
|
||||
if (jcode)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
_rl_want_redisplay = 0;
|
||||
memcpy ((void *)readline_top_level, (void *)olevel, sizeof (procenv_t));
|
||||
return;
|
||||
}
|
||||
|
||||
if (RL_ISSTATE (RL_STATE_ISEARCH))
|
||||
{
|
||||
eof = _rl_isearch_callback (_rl_iscxt);
|
||||
if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
|
||||
rl_callback_read_char ();
|
||||
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_NSEARCH))
|
||||
{
|
||||
eof = _rl_nsearch_callback (_rl_nscxt);
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_NUMERICARG))
|
||||
{
|
||||
eof = _rl_arg_callback (_rl_argcxt);
|
||||
if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
|
||||
rl_callback_read_char ();
|
||||
/* XXX - this should handle _rl_last_command_was_kill better */
|
||||
else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
|
||||
_rl_internal_char_cleanup ();
|
||||
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_MULTIKEY))
|
||||
{
|
||||
eof = _rl_dispatch_callback (_rl_kscxt); /* For now */
|
||||
while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED))
|
||||
eof = _rl_dispatch_callback (_rl_kscxt);
|
||||
if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0)
|
||||
{
|
||||
_rl_internal_char_cleanup ();
|
||||
_rl_want_redisplay = 1;
|
||||
}
|
||||
}
|
||||
else if (_rl_callback_func)
|
||||
{
|
||||
/* This allows functions that simply need to read an additional character
|
||||
(like quoted-insert) to register a function to be called when input is
|
||||
available. _rl_callback_data is simply a pointer to a struct that has
|
||||
the argument count originally passed to the registering function and
|
||||
space for any additional parameters. */
|
||||
eof = (*_rl_callback_func) (_rl_callback_data);
|
||||
/* If the function `deregisters' itself, make sure the data is cleaned
|
||||
up. */
|
||||
if (_rl_callback_func == 0)
|
||||
{
|
||||
if (_rl_callback_data)
|
||||
{
|
||||
_rl_callback_data_dispose (_rl_callback_data);
|
||||
_rl_callback_data = 0;
|
||||
}
|
||||
_rl_internal_char_cleanup ();
|
||||
}
|
||||
}
|
||||
else
|
||||
eof = readline_internal_char ();
|
||||
|
||||
if (rl_done == 0 && _rl_want_redisplay)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
_rl_want_redisplay = 0;
|
||||
}
|
||||
|
||||
/* We loop in case some function has pushed input back with rl_execute_next. */
|
||||
for (;;)
|
||||
{
|
||||
if (rl_done)
|
||||
{
|
||||
line = readline_internal_teardown (eof);
|
||||
|
||||
if (rl_deprep_term_function)
|
||||
(*rl_deprep_term_function) ();
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_clear_signals ();
|
||||
#endif
|
||||
in_handler = 0;
|
||||
(*rl_linefunc) (line);
|
||||
|
||||
/* If the user did not clear out the line, do it for him. */
|
||||
if (rl_line_buffer[0])
|
||||
_rl_init_line_state ();
|
||||
|
||||
/* Redisplay the prompt if readline_handler_{install,remove}
|
||||
not called. */
|
||||
if (in_handler == 0 && rl_linefunc)
|
||||
_rl_callback_newline ();
|
||||
}
|
||||
if (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT))
|
||||
eof = readline_internal_char ();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove the handler, and make sure the terminal is in its normal state. */
|
||||
void
|
||||
rl_callback_handler_remove ()
|
||||
{
|
||||
rl_linefunc = NULL;
|
||||
RL_UNSETSTATE (RL_STATE_CALLBACK);
|
||||
if (in_handler)
|
||||
{
|
||||
in_handler = 0;
|
||||
if (rl_deprep_term_function)
|
||||
(*rl_deprep_term_function) ();
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_clear_signals ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
_rl_callback_generic_arg *
|
||||
_rl_callback_data_alloc (count)
|
||||
int count;
|
||||
{
|
||||
_rl_callback_generic_arg *arg;
|
||||
|
||||
arg = (_rl_callback_generic_arg *)xmalloc (sizeof (_rl_callback_generic_arg));
|
||||
arg->count = count;
|
||||
|
||||
arg->i1 = arg->i2 = 0;
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
void _rl_callback_data_dispose (arg)
|
||||
_rl_callback_generic_arg *arg;
|
||||
{
|
||||
if (arg)
|
||||
free (arg);
|
||||
}
|
||||
|
||||
#endif
|
||||
+33
-10
@@ -170,6 +170,7 @@ static int line_size = 1024;
|
||||
include invisible characters. */
|
||||
|
||||
static char *local_prompt, *local_prompt_prefix;
|
||||
static int local_prompt_len;
|
||||
static int prompt_visible_length, prompt_prefix_length;
|
||||
|
||||
/* The number of invisible characters in the line currently being
|
||||
@@ -366,6 +367,7 @@ rl_expand_prompt (prompt)
|
||||
FREE (local_prompt_prefix);
|
||||
|
||||
local_prompt = local_prompt_prefix = (char *)0;
|
||||
local_prompt_len = 0;
|
||||
prompt_last_invisible = prompt_invis_chars_first_line = 0;
|
||||
prompt_visible_length = prompt_physical_chars = 0;
|
||||
|
||||
@@ -381,6 +383,7 @@ rl_expand_prompt (prompt)
|
||||
&prompt_invis_chars_first_line,
|
||||
&prompt_physical_chars);
|
||||
local_prompt_prefix = (char *)0;
|
||||
local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
|
||||
return (prompt_visible_length);
|
||||
}
|
||||
else
|
||||
@@ -399,6 +402,7 @@ rl_expand_prompt (prompt)
|
||||
&prompt_invis_chars_first_line,
|
||||
(int *)NULL);
|
||||
*t = c;
|
||||
local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
|
||||
return (prompt_prefix_length);
|
||||
}
|
||||
}
|
||||
@@ -506,24 +510,23 @@ rl_redisplay ()
|
||||
number of non-visible characters in the prompt string. */
|
||||
if (rl_display_prompt == rl_prompt || local_prompt)
|
||||
{
|
||||
int local_len = local_prompt ? strlen (local_prompt) : 0;
|
||||
if (local_prompt_prefix && forced_display)
|
||||
_rl_output_some_chars (local_prompt_prefix, strlen (local_prompt_prefix));
|
||||
|
||||
if (local_len > 0)
|
||||
if (local_prompt_len > 0)
|
||||
{
|
||||
temp = local_len + out + 2;
|
||||
temp = local_prompt_len + out + 2;
|
||||
if (temp >= line_size)
|
||||
{
|
||||
line_size = (temp + 1024) - (temp % 1024);
|
||||
visible_line = (char *)xrealloc (visible_line, line_size);
|
||||
line = invisible_line = (char *)xrealloc (invisible_line, line_size);
|
||||
}
|
||||
strncpy (line + out, local_prompt, local_len);
|
||||
out += local_len;
|
||||
strncpy (line + out, local_prompt, local_prompt_len);
|
||||
out += local_prompt_len;
|
||||
}
|
||||
line[out] = '\0';
|
||||
wrap_offset = local_len - prompt_visible_length;
|
||||
wrap_offset = local_prompt_len - prompt_visible_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -633,7 +636,7 @@ rl_redisplay ()
|
||||
Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
n0 = num;
|
||||
temp = local_prompt ? strlen (local_prompt) : 0;
|
||||
temp = local_prompt_len;
|
||||
while (num < temp)
|
||||
{
|
||||
if (_rl_col_width (local_prompt, n0, num) > _rl_screenwidth)
|
||||
@@ -908,12 +911,16 @@ rl_redisplay ()
|
||||
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 */
|
||||
this back by setting cpos_adjusted. If we assume that
|
||||
_rl_last_c_pos is correct (an absolute cursor position) each
|
||||
time update_line is called, then we can assume in our
|
||||
calculations that o_cpos does not need to be adjusted by
|
||||
wrap_offset. */
|
||||
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)
|
||||
o_cpos < (prompt_last_invisible-wrap_offset))
|
||||
_rl_last_c_pos -= wrap_offset;
|
||||
|
||||
/* If this is the line with the prompt, we might need to
|
||||
@@ -1411,7 +1418,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
sequences (like drawing the `unbold' sequence without a corresponding
|
||||
`bold') that manifests itself on certain terminals. */
|
||||
|
||||
lendiff = local_prompt ? strlen (local_prompt) : 0;
|
||||
lendiff = local_prompt_len;
|
||||
od = ofd - old; /* index of first difference in visible line */
|
||||
if (current_line == 0 && !_rl_horizontal_scroll_mode &&
|
||||
_rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 &&
|
||||
@@ -1434,7 +1441,19 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
_rl_last_c_pos = lendiff;
|
||||
}
|
||||
|
||||
/* When this function returns, _rl_last_c_pos is correct, and an absolute
|
||||
cursor postion in multibyte mode, but a buffer index when not in a
|
||||
multibyte locale. */
|
||||
_rl_move_cursor_relative (od, old);
|
||||
#if 1
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
/* We need to indicate that the cursor position is correct in the presence of
|
||||
invisible characters in the prompt string. Let's see if setting this when
|
||||
we make sure we're at the end of the drawn prompt string works. */
|
||||
if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_last_c_pos == prompt_physical_chars)
|
||||
cpos_adjusted = 1;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* if (len (new) > len (old))
|
||||
lendiff == difference in buffer
|
||||
@@ -1701,7 +1720,11 @@ _rl_move_cursor_relative (new, data)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
dpos = _rl_col_width (data, 0, new);
|
||||
#if 0
|
||||
if (dpos > woff)
|
||||
#else
|
||||
if (dpos > prompt_last_invisible)
|
||||
#endif
|
||||
dpos -= woff;
|
||||
}
|
||||
else
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+55
-18
@@ -170,6 +170,7 @@ static int line_size = 1024;
|
||||
include invisible characters. */
|
||||
|
||||
static char *local_prompt, *local_prompt_prefix;
|
||||
static int local_prompt_len;
|
||||
static int prompt_visible_length, prompt_prefix_length;
|
||||
|
||||
/* The number of invisible characters in the line currently being
|
||||
@@ -366,6 +367,7 @@ rl_expand_prompt (prompt)
|
||||
FREE (local_prompt_prefix);
|
||||
|
||||
local_prompt = local_prompt_prefix = (char *)0;
|
||||
local_prompt_len = 0;
|
||||
prompt_last_invisible = prompt_invis_chars_first_line = 0;
|
||||
prompt_visible_length = prompt_physical_chars = 0;
|
||||
|
||||
@@ -381,6 +383,7 @@ rl_expand_prompt (prompt)
|
||||
&prompt_invis_chars_first_line,
|
||||
&prompt_physical_chars);
|
||||
local_prompt_prefix = (char *)0;
|
||||
local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
|
||||
return (prompt_visible_length);
|
||||
}
|
||||
else
|
||||
@@ -399,6 +402,7 @@ rl_expand_prompt (prompt)
|
||||
&prompt_invis_chars_first_line,
|
||||
(int *)NULL);
|
||||
*t = c;
|
||||
local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
|
||||
return (prompt_prefix_length);
|
||||
}
|
||||
}
|
||||
@@ -506,24 +510,23 @@ rl_redisplay ()
|
||||
number of non-visible characters in the prompt string. */
|
||||
if (rl_display_prompt == rl_prompt || local_prompt)
|
||||
{
|
||||
int local_len = local_prompt ? strlen (local_prompt) : 0;
|
||||
if (local_prompt_prefix && forced_display)
|
||||
_rl_output_some_chars (local_prompt_prefix, strlen (local_prompt_prefix));
|
||||
|
||||
if (local_len > 0)
|
||||
if (local_prompt_len > 0)
|
||||
{
|
||||
temp = local_len + out + 2;
|
||||
temp = local_prompt_len + out + 2;
|
||||
if (temp >= line_size)
|
||||
{
|
||||
line_size = (temp + 1024) - (temp % 1024);
|
||||
visible_line = (char *)xrealloc (visible_line, line_size);
|
||||
line = invisible_line = (char *)xrealloc (invisible_line, line_size);
|
||||
}
|
||||
strncpy (line + out, local_prompt, local_len);
|
||||
out += local_len;
|
||||
strncpy (line + out, local_prompt, local_prompt_len);
|
||||
out += local_prompt_len;
|
||||
}
|
||||
line[out] = '\0';
|
||||
wrap_offset = local_len - prompt_visible_length;
|
||||
wrap_offset = local_prompt_len - prompt_visible_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -633,7 +636,7 @@ rl_redisplay ()
|
||||
Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
n0 = num;
|
||||
temp = local_prompt ? strlen (local_prompt) : 0;
|
||||
temp = local_prompt_len;
|
||||
while (num < temp)
|
||||
{
|
||||
if (_rl_col_width (local_prompt, n0, num) > _rl_screenwidth)
|
||||
@@ -908,12 +911,16 @@ rl_redisplay ()
|
||||
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 */
|
||||
this back by setting cpos_adjusted. If we assume that
|
||||
_rl_last_c_pos is correct (an absolute cursor position) each
|
||||
time update_line is called, then we can assume in our
|
||||
calculations that o_cpos does not need to be adjusted by
|
||||
wrap_offset. */
|
||||
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)
|
||||
o_cpos < (prompt_last_invisible-wrap_offset))
|
||||
_rl_last_c_pos -= wrap_offset;
|
||||
|
||||
/* If this is the line with the prompt, we might need to
|
||||
@@ -1411,7 +1418,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
sequences (like drawing the `unbold' sequence without a corresponding
|
||||
`bold') that manifests itself on certain terminals. */
|
||||
|
||||
lendiff = local_prompt ? strlen (local_prompt) : 0;
|
||||
lendiff = local_prompt_len;
|
||||
od = ofd - old; /* index of first difference in visible line */
|
||||
if (current_line == 0 && !_rl_horizontal_scroll_mode &&
|
||||
_rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 &&
|
||||
@@ -1434,7 +1441,17 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
_rl_last_c_pos = lendiff;
|
||||
}
|
||||
|
||||
/* When this function returns, _rl_last_c_pos is correct, and an absolute
|
||||
cursor postion in multibyte mode, but a buffer index when not in a
|
||||
multibyte locale. */
|
||||
_rl_move_cursor_relative (od, old);
|
||||
#if 1
|
||||
/* We need to indicate that the cursor position is correct in the presence of
|
||||
invisible characters in the prompt string. Let's see if setting this when
|
||||
we make sure we're at the end of the drawn prompt string works. */
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_last_c_pos == prompt_physical_chars)
|
||||
cpos_adjusted = 1;
|
||||
#endif
|
||||
|
||||
/* if (len (new) > len (old))
|
||||
lendiff == difference in buffer
|
||||
@@ -1701,7 +1718,11 @@ _rl_move_cursor_relative (new, data)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
dpos = _rl_col_width (data, 0, new);
|
||||
#if 0
|
||||
if (dpos > woff)
|
||||
#else
|
||||
if (dpos > prompt_last_invisible)
|
||||
#endif
|
||||
dpos -= woff;
|
||||
}
|
||||
else
|
||||
@@ -1998,20 +2019,36 @@ _rl_make_prompt_for_search (pchar)
|
||||
int pchar;
|
||||
{
|
||||
int len;
|
||||
char *pmt;
|
||||
char *pmt, *p;
|
||||
|
||||
rl_save_prompt ();
|
||||
|
||||
len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
|
||||
pmt = (char *)xmalloc (len + 2);
|
||||
if (len)
|
||||
strcpy (pmt, rl_prompt);
|
||||
pmt[len] = pchar;
|
||||
pmt[len+1] = '\0';
|
||||
/* We've saved the prompt, and can do anything with the various prompt
|
||||
strings we need before they're restored. We want the unexpanded
|
||||
portion of the prompt string after any final newline. */
|
||||
p = rl_prompt ? strrchr (rl_prompt, '\n') : 0;
|
||||
if (p == 0)
|
||||
{
|
||||
len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
|
||||
pmt = (char *)xmalloc (len + 2);
|
||||
if (len)
|
||||
strcpy (pmt, rl_prompt);
|
||||
pmt[len] = pchar;
|
||||
pmt[len+1] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
p++;
|
||||
len = strlen (p);
|
||||
pmt = (char *)xmalloc (len + 2);
|
||||
if (len)
|
||||
strcpy (pmt, p);
|
||||
pmt[len] = pchar;
|
||||
pmt[len+1] = '\0';
|
||||
}
|
||||
|
||||
/* will be overwritten by expand_prompt, called from rl_message */
|
||||
prompt_physical_chars = saved_physical_chars + 1;
|
||||
|
||||
return pmt;
|
||||
}
|
||||
|
||||
|
||||
@@ -179,6 +179,7 @@ rl_gather_tyi ()
|
||||
struct timeval timeout;
|
||||
#endif
|
||||
|
||||
chars_avail = 0;
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
@@ -220,6 +221,13 @@ rl_gather_tyi ()
|
||||
}
|
||||
#endif /* O_NDELAY */
|
||||
|
||||
#if defined (__MINGW32__)
|
||||
/* Use getch/_kbhit to check for available console input, in the same way
|
||||
that we read it normally. */
|
||||
chars_avail = isatty (tty) ? _kbhit () : 0;
|
||||
result = 0;
|
||||
#endif
|
||||
|
||||
/* If there's nothing available, don't waste time trying to read
|
||||
something. */
|
||||
if (chars_avail <= 0)
|
||||
@@ -303,6 +311,11 @@ _rl_input_available ()
|
||||
return (chars_avail);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (__MINGW32__)
|
||||
if (isatty (tty))
|
||||
return (_kbhit ());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -113,7 +113,7 @@ _rl_next_macro_key ()
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
c = rl_executing_macro[executing_macro_index++];
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK) && RL_ISSTATE (RL_STATE_READCMD) && rl_executing_macro[executing_macro_index] == 0)
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK) && RL_ISSTATE (RL_STATE_READCMD|RL_STATE_MOREINPUT) && rl_executing_macro[executing_macro_index] == 0)
|
||||
_rl_pop_executing_macro ();
|
||||
return c;
|
||||
#else
|
||||
|
||||
+5
-5
@@ -404,17 +404,17 @@ tilde_expand_word (filename)
|
||||
free (expansion);
|
||||
}
|
||||
}
|
||||
free (username);
|
||||
/* If we don't have a failure hook, or if the failure hook did not
|
||||
expand the tilde, return a copy of what we were passed. */
|
||||
if (dirname == 0)
|
||||
dirname = savestring (filename);
|
||||
}
|
||||
#if defined (HAVE_GETPWENT)
|
||||
else
|
||||
{
|
||||
free (username);
|
||||
dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len);
|
||||
}
|
||||
dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len);
|
||||
#endif
|
||||
|
||||
free (username);
|
||||
#if defined (HAVE_GETPWENT)
|
||||
endpwent ();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user