Upgrade to readline 2.0 from bash1.14.1
This commit is contained in:
parent
c08acda30d
commit
6e4c5827ee
@ -1,17 +1,18 @@
|
||||
# $Id: Makefile,v 1.6 1994/05/11 15:49:41 ache Exp $
|
||||
# $Id: Makefile,v 1.7 1994/05/11 16:30:27 ache Exp $
|
||||
|
||||
SHLIB_MAJOR=1
|
||||
SHLIB_MINOR=0
|
||||
|
||||
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/readline -DVOID_SIGHANDLER \
|
||||
-DHAVE_UNISTD_H -DHAVE_STRING_H -DHAVE_STDLIB_H -DHAVE_VARARGS_H \
|
||||
-DVISIBLE_STATS -DVI_MODE -DPAREN_MATCHING \
|
||||
-DFreeBSD \
|
||||
-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp
|
||||
|
||||
LIB= readline
|
||||
SRCS+= readline.c funmap.c keymaps.c vi_mode.c parens.c \
|
||||
rltty.c complete.c bind.c isearch.c display.c signals.c \
|
||||
history.c search.c tilde.c xmalloc.c
|
||||
HEADERS= history.h readline.h keymaps.h chardefs.h tilde.h
|
||||
NOMAN= noman
|
||||
|
||||
beforeinstall:
|
||||
@ -22,6 +23,6 @@ beforeinstall:
|
||||
fi
|
||||
cd ${.CURDIR}/readline; \
|
||||
install -c -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
history.h readline.h keymaps.h chardefs.h ${DESTDIR}/usr/include/readline
|
||||
${HEADERS} ${DESTDIR}/usr/include/readline
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
|
6
gnu/lib/libreadline/README
Normal file
6
gnu/lib/libreadline/README
Normal file
@ -0,0 +1,6 @@
|
||||
This is the distribution of the Gnu Readline library. See the file
|
||||
STANDALONE for a description of the #defines that can be passed via
|
||||
the makefile to build readline on different systems.
|
||||
|
||||
The file rlconf.h contains defines that enable and disable certain
|
||||
readline features.
|
@ -11,11 +11,9 @@ Workaround for this implemented via TIOCGWINSZ/TIOCSWINSZ
|
||||
with same winsize structure: it does nothing expect polling
|
||||
process from background. Look tcsh_hack.readme for details.
|
||||
|
||||
Here is megred version with readline comes from gdb4.11
|
||||
and with readline 2.0 comes from bash1.13.1.CWRU
|
||||
|
||||
If you want 8-bit clean version, put
|
||||
set convert-meta off
|
||||
set output-meta on
|
||||
in your ~/.inputrc file
|
||||
|
||||
ache@astral.msk.su
|
||||
|
32
gnu/lib/libreadline/STANDALONE
Normal file
32
gnu/lib/libreadline/STANDALONE
Normal file
@ -0,0 +1,32 @@
|
||||
This is a description of C preprocessor defines that readline accepts.
|
||||
Most are passed in from the parent `make'; e.g. from the bash source
|
||||
directory.
|
||||
|
||||
NO_SYS_FILE <sys/file.h> is not present
|
||||
HAVE_UNISTD_H <unistd.h> exists
|
||||
HAVE_STDLIB_H <stdlib.h> exists
|
||||
HAVE_GETPW_DECLS declarations for the getpw functions are in <pwd.h>
|
||||
HAVE_VARARGS_H <varargs.h> exists and is usable
|
||||
HAVE_STRING_H <string.h> exists
|
||||
HAVE_ALLOCA_H <alloca.h> exists and is needed for alloca()
|
||||
HAVE_ALLOCA alloca(3) or a define for it exists
|
||||
PRAGMA_ALLOCA use of alloca() requires a #pragma, as in AIX 3.x
|
||||
VOID_SIGHANDLER signal handlers are void functions
|
||||
HAVE_DIRENT_H <dirent.h> exists and is usable
|
||||
HAVE_SYS_PTEM_H <sys/ptem.h> exists
|
||||
HAVE_SYS_PTE_H <sys/pte.h> exists
|
||||
HAVE_SYS_STREAM_H <sys/stream.h> exists
|
||||
|
||||
System-specific options:
|
||||
|
||||
OSF1 A machine running OSF/1
|
||||
BSD386 BSDI's BSD/386 version 1.0 or 1.1
|
||||
NetBSD NetBSD
|
||||
FreeBSD FreeBSD version 1.1
|
||||
_386BSD Old FreeBSD or NetBSD or ancient Jolitz 386bsd
|
||||
AIX AIX 3.x
|
||||
USG Running a variant of System V
|
||||
USGr3 Running System V.3
|
||||
XENIX_22 Xenix 2.2
|
||||
Linux Linux
|
||||
CRAY running a recent version of Cray UNICOS
|
41
gnu/lib/libreadline/ansi_stdlib.h
Normal file
41
gnu/lib/libreadline/ansi_stdlib.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* ansi_stdlib.h -- An ANSI Standard stdlib.h. */
|
||||
/* A minimal stdlib.h containing extern declarations for those functions
|
||||
that bash uses. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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.
|
||||
|
||||
Bash 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with Bash; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if !defined (_STDLIB_H_)
|
||||
#define _STDLIB_H_ 1
|
||||
|
||||
/* String conversion functions. */
|
||||
extern int atoi ();
|
||||
extern long int atol ();
|
||||
|
||||
/* Memory allocation functions. */
|
||||
extern char *malloc ();
|
||||
extern char *realloc ();
|
||||
extern void free ();
|
||||
|
||||
/* Other miscellaneous functions. */
|
||||
extern void abort ();
|
||||
extern void exit ();
|
||||
extern char *getenv ();
|
||||
extern void qsort ();
|
||||
|
||||
#endif /* _STDLIB_H */
|
@ -57,19 +57,22 @@ extern int errno;
|
||||
extern char *strchr (), *strrchr ();
|
||||
#endif /* !strchr && !__STDC__ */
|
||||
|
||||
extern char *tilde_expand ();
|
||||
|
||||
extern int _rl_horizontal_scroll_mode;
|
||||
extern int _rl_mark_modified_lines;
|
||||
extern int _rl_prefer_visible_bell;
|
||||
extern int _rl_bell_preference;
|
||||
extern int _rl_meta_flag;
|
||||
extern int rl_blink_matching_paren;
|
||||
extern int _rl_convert_meta_chars_to_ascii;
|
||||
extern int _rl_output_meta_chars;
|
||||
extern int _rl_complete_show_all;
|
||||
#if defined (VISIBLE_STATS)
|
||||
extern int rl_visible_stats;
|
||||
#endif /* VISIBLE_STATS */
|
||||
extern int rl_complete_with_tilde_expansion;
|
||||
extern int rl_completion_query_items;
|
||||
#if defined (VI_MODE)
|
||||
extern char *rl_vi_comment_begin;
|
||||
#endif
|
||||
|
||||
extern int rl_explicit_arg;
|
||||
extern int rl_editing_mode;
|
||||
@ -80,6 +83,9 @@ extern char *possible_control_prefixes[], *possible_meta_prefixes[];
|
||||
|
||||
extern char **rl_funmap_names ();
|
||||
|
||||
/* Forward declarations */
|
||||
void rl_set_keymap_from_edit_mode ();
|
||||
|
||||
static int glean_key_from_name ();
|
||||
|
||||
#if defined (STATIC_MALLOC)
|
||||
@ -105,6 +111,7 @@ rl_add_defun (name, function, key)
|
||||
if (key != -1)
|
||||
rl_bind_key (key, function);
|
||||
rl_add_funmap_entry (name, function);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Bind KEY to FUNCTION. Returns non-zero if KEY is out of range. */
|
||||
@ -120,12 +127,9 @@ rl_bind_key (key, function)
|
||||
{
|
||||
if (_rl_keymap[ESC].type == ISKMAP)
|
||||
{
|
||||
#if defined (CRAY)
|
||||
Keymap escmap = (Keymap)((int)_rl_keymap[ESC].function);
|
||||
#else
|
||||
Keymap escmap = (Keymap)_rl_keymap[ESC].function;
|
||||
#endif
|
||||
Keymap escmap;
|
||||
|
||||
escmap = FUNCTION_TO_KEYMAP (_rl_keymap, ESC);
|
||||
key = UNMETA (key);
|
||||
escmap[key].type = ISFUNC;
|
||||
escmap[key].function = function;
|
||||
@ -183,7 +187,7 @@ rl_set_key (keyseq, function, map)
|
||||
Function *function;
|
||||
Keymap map;
|
||||
{
|
||||
rl_generic_bind (ISFUNC, keyseq, function, map);
|
||||
return (rl_generic_bind (ISFUNC, keyseq, function, map));
|
||||
}
|
||||
|
||||
/* Bind the key sequence represented by the string KEYSEQ to
|
||||
@ -249,7 +253,7 @@ rl_generic_bind (type, keyseq, data, map)
|
||||
{
|
||||
ic = UNMETA (ic);
|
||||
if (map[ESC].type == ISKMAP)
|
||||
map = (Keymap) map[ESC].function;
|
||||
map = FUNCTION_TO_KEYMAP (map, ESC);
|
||||
}
|
||||
|
||||
if ((i + 1) < keys_len)
|
||||
@ -260,16 +264,16 @@ rl_generic_bind (type, keyseq, data, map)
|
||||
free ((char *)map[ic].function);
|
||||
|
||||
map[ic].type = ISKMAP;
|
||||
map[ic].function = (Function *)rl_make_bare_keymap ();
|
||||
map[ic].function = KEYMAP_TO_FUNCTION (rl_make_bare_keymap());
|
||||
}
|
||||
map = (Keymap)map[ic].function;
|
||||
map = FUNCTION_TO_KEYMAP (map, ic);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (map[ic].type == ISMACR)
|
||||
free ((char *)map[ic].function);
|
||||
|
||||
map[ic].function = (Function *)data;
|
||||
map[ic].function = KEYMAP_TO_FUNCTION (data);
|
||||
map[ic].type = type;
|
||||
}
|
||||
}
|
||||
@ -388,7 +392,7 @@ rl_function_of_keyseq (keyseq, map, type)
|
||||
}
|
||||
else
|
||||
{
|
||||
map = (Keymap)map[ESC].function;
|
||||
map = FUNCTION_TO_KEYMAP (map, ESC);
|
||||
ic = UNMETA (ic);
|
||||
}
|
||||
}
|
||||
@ -405,7 +409,7 @@ rl_function_of_keyseq (keyseq, map, type)
|
||||
return (map[ic].function);
|
||||
}
|
||||
else
|
||||
map = (Keymap)map[ic].function;
|
||||
map = FUNCTION_TO_KEYMAP (map, ic);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -415,6 +419,7 @@ rl_function_of_keyseq (keyseq, map, type)
|
||||
return (map[ic].function);
|
||||
}
|
||||
}
|
||||
return ((Function *) NULL);
|
||||
}
|
||||
|
||||
/* The last key bindings file read. */
|
||||
@ -424,15 +429,19 @@ static char *last_readline_init_file = (char *)NULL;
|
||||
rl_re_read_init_file (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
return (rl_read_init_file ((char *)NULL));
|
||||
int r;
|
||||
r = rl_read_init_file ((char *)NULL);
|
||||
rl_set_keymap_from_edit_mode ();
|
||||
return r;
|
||||
}
|
||||
|
||||
/* The final, last-ditch effort file name for an init file. */
|
||||
#define DEFAULT_INPUTRC "~/.inputrc"
|
||||
|
||||
/* Do key bindings from a file. If FILENAME is NULL it defaults
|
||||
to `~/.inputrc'. If the file existed and could be opened and
|
||||
read, 0 is returned, otherwise errno is returned. */
|
||||
to the first non-null filename from this list:
|
||||
1. the filename used for the previous call
|
||||
2. the value of the shell variable `INPUTRC'
|
||||
3. ~/.inputrc
|
||||
If the file existed and could be opened and read, 0 is returned,
|
||||
otherwise errno is returned. */
|
||||
int
|
||||
rl_read_init_file (filename)
|
||||
char *filename;
|
||||
@ -445,9 +454,10 @@ rl_read_init_file (filename)
|
||||
/* Default the filename. */
|
||||
if (!filename)
|
||||
{
|
||||
if (last_readline_init_file)
|
||||
filename = last_readline_init_file;
|
||||
else
|
||||
filename = last_readline_init_file;
|
||||
if (!filename)
|
||||
filename = getenv ("INPUTRC");
|
||||
if (!filename)
|
||||
filename = DEFAULT_INPUTRC;
|
||||
}
|
||||
|
||||
@ -462,10 +472,13 @@ rl_read_init_file (filename)
|
||||
else
|
||||
free (openname);
|
||||
|
||||
if (last_readline_init_file)
|
||||
free (last_readline_init_file);
|
||||
if (filename != last_readline_init_file)
|
||||
{
|
||||
if (last_readline_init_file)
|
||||
free (last_readline_init_file);
|
||||
|
||||
last_readline_init_file = savestring (filename);
|
||||
last_readline_init_file = savestring (filename);
|
||||
}
|
||||
|
||||
/* Read the file into BUFFER. */
|
||||
buffer = (char *)xmalloc ((int)finfo.st_size + 1);
|
||||
@ -487,6 +500,10 @@ rl_read_init_file (filename)
|
||||
/* Mark end of line. */
|
||||
line[i] = '\0';
|
||||
|
||||
/* Skip leading whitespace. */
|
||||
while (*line && whitespace (*line))
|
||||
line++;
|
||||
|
||||
/* If the line is not a comment, then parse it. */
|
||||
if (*line && *line != '#')
|
||||
rl_parse_and_bind (line);
|
||||
@ -552,7 +569,7 @@ parser_if (args)
|
||||
|
||||
/* Terminals like "aaa-60" are equivalent to "aaa". */
|
||||
tname = savestring (rl_terminal_name);
|
||||
tem = strrchr (tname, '-');
|
||||
tem = strchr (tname, '-');
|
||||
if (tem)
|
||||
*tem = '\0';
|
||||
|
||||
@ -682,9 +699,6 @@ handle_parser_directive (statement)
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Ugly but working hack for binding prefix meta. */
|
||||
#define PREFIX_META_HACK
|
||||
|
||||
static int substring_member_of_array ();
|
||||
|
||||
/* Read the binding command from STRING and perform it.
|
||||
@ -928,10 +942,11 @@ static struct {
|
||||
} boolean_varlist [] = {
|
||||
{ "horizontal-scroll-mode", &_rl_horizontal_scroll_mode },
|
||||
{ "mark-modified-lines", &_rl_mark_modified_lines },
|
||||
{ "prefer-visible-bell", &_rl_prefer_visible_bell },
|
||||
{ "meta-flag", &_rl_meta_flag },
|
||||
{ "blink-matching-paren", &rl_blink_matching_paren },
|
||||
{ "convert-meta", &_rl_convert_meta_chars_to_ascii },
|
||||
{ "show-all-if-ambiguous", &_rl_complete_show_all },
|
||||
{ "output-meta", &_rl_output_meta_chars },
|
||||
#if defined (VISIBLE_STATS)
|
||||
{ "visible-stats", &rl_visible_stats },
|
||||
#endif /* VISIBLE_STATS */
|
||||
@ -970,10 +985,6 @@ rl_variable_bind (name, value)
|
||||
#if defined (VI_MODE)
|
||||
_rl_keymap = vi_insertion_keymap;
|
||||
rl_editing_mode = vi_mode;
|
||||
#else
|
||||
#if defined (NOTDEF)
|
||||
ding ();
|
||||
#endif /* NOTDEF */
|
||||
#endif /* VI_MODE */
|
||||
}
|
||||
else if (strnicmp (value, "emacs", 5) == 0)
|
||||
@ -987,8 +998,6 @@ rl_variable_bind (name, value)
|
||||
else if (stricmp (name, "comment-begin") == 0)
|
||||
{
|
||||
#if defined (VI_MODE)
|
||||
extern char *rl_vi_comment_begin;
|
||||
|
||||
if (*value)
|
||||
{
|
||||
if (rl_vi_comment_begin)
|
||||
@ -1009,6 +1018,37 @@ rl_variable_bind (name, value)
|
||||
}
|
||||
rl_completion_query_items = nval;
|
||||
}
|
||||
else if (stricmp (name, "keymap") == 0)
|
||||
{
|
||||
Keymap kmap;
|
||||
kmap = rl_get_keymap_by_name (value);
|
||||
if (kmap)
|
||||
rl_set_keymap (kmap);
|
||||
}
|
||||
else if (stricmp (name, "bell-style") == 0)
|
||||
{
|
||||
if (!*value)
|
||||
_rl_bell_preference = AUDIBLE_BELL;
|
||||
else
|
||||
{
|
||||
if (stricmp (value, "none") == 0 || stricmp (value, "off") == 0)
|
||||
_rl_bell_preference = NO_BELL;
|
||||
else if (stricmp (value, "audible") == 0 || stricmp (value, "on") == 0)
|
||||
_rl_bell_preference = AUDIBLE_BELL;
|
||||
else if (stricmp (value, "visible") == 0)
|
||||
_rl_bell_preference = VISIBLE_BELL;
|
||||
}
|
||||
}
|
||||
else if (stricmp (name, "prefer-visible-bell") == 0)
|
||||
{
|
||||
/* Backwards compatibility. */
|
||||
if (*value && (stricmp (value, "on") == 0 ||
|
||||
(*value == '1' && !value[1])))
|
||||
_rl_bell_preference = VISIBLE_BELL;
|
||||
else
|
||||
_rl_bell_preference = AUDIBLE_BELL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1135,8 +1175,8 @@ rl_list_funmap_names (ignore)
|
||||
|
||||
/* Return a NULL terminated array of strings which represent the key
|
||||
sequences that are used to invoke FUNCTION in MAP. */
|
||||
static char **
|
||||
invoking_keyseqs_in_map (function, map)
|
||||
char **
|
||||
rl_invoking_keyseqs_in_map (function, map)
|
||||
Function *function;
|
||||
Keymap map;
|
||||
{
|
||||
@ -1194,11 +1234,7 @@ invoking_keyseqs_in_map (function, map)
|
||||
their target. Add the key sequences found to RESULT. */
|
||||
if (map[key].function)
|
||||
seqs =
|
||||
#if defined (CRAY)
|
||||
invoking_keyseqs_in_map (function, (Keymap)((int)map[key].function));
|
||||
#else
|
||||
invoking_keyseqs_in_map (function, (Keymap)map[key].function);
|
||||
#endif
|
||||
rl_invoking_keyseqs_in_map (function, FUNCTION_TO_KEYMAP (map, key));
|
||||
|
||||
if (seqs)
|
||||
{
|
||||
@ -1252,18 +1288,16 @@ char **
|
||||
rl_invoking_keyseqs (function)
|
||||
Function *function;
|
||||
{
|
||||
return (invoking_keyseqs_in_map (function, _rl_keymap));
|
||||
return (rl_invoking_keyseqs_in_map (function, _rl_keymap));
|
||||
}
|
||||
|
||||
/* Print all of the current functions and their bindings to
|
||||
rl_outstream. If an explicit argument is given, then print
|
||||
the output in such a way that it can be read back in. */
|
||||
int
|
||||
rl_dump_functions (count)
|
||||
int count;
|
||||
rl_dump_functions (count, key)
|
||||
int count, key;
|
||||
{
|
||||
void rl_function_dumper ();
|
||||
|
||||
rl_function_dumper (rl_explicit_arg);
|
||||
rl_on_new_line ();
|
||||
return (0);
|
||||
@ -1290,7 +1324,7 @@ rl_function_dumper (print_readably)
|
||||
char **invokers;
|
||||
|
||||
function = rl_named_function (name);
|
||||
invokers = invoking_keyseqs_in_map (function, _rl_keymap);
|
||||
invokers = rl_invoking_keyseqs_in_map (function, _rl_keymap);
|
||||
|
||||
if (print_readably)
|
||||
{
|
||||
@ -1339,7 +1373,22 @@ rl_function_dumper (print_readably)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. */
|
||||
void
|
||||
_rl_bind_if_unbound (keyseq, default_func)
|
||||
char *keyseq;
|
||||
Function *default_func;
|
||||
{
|
||||
Function *func;
|
||||
|
||||
if (keyseq)
|
||||
{
|
||||
func = rl_function_of_keyseq (keyseq, _rl_keymap, (int *)NULL);
|
||||
if (!func || func == rl_do_lowercase_version)
|
||||
rl_set_key (keyseq, default_func, _rl_keymap);
|
||||
}
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* String Utility Functions */
|
||||
|
@ -43,17 +43,19 @@
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
/* These next are for filename completion. Perhaps this belongs
|
||||
in a different place. */
|
||||
#include <pwd.h>
|
||||
#if defined (USG) && !defined (isc386) && !defined (sgi)
|
||||
extern struct passwd *getpwuid (), *getpwent ();
|
||||
#endif
|
||||
#if defined (isc386) && !defined (__STDC__) && defined (_POSIX_SOURCE)
|
||||
#if defined (USG) && !defined (HAVE_GETPW_DECLS)
|
||||
extern struct passwd *getpwent ();
|
||||
#endif
|
||||
#endif /* USG && !HAVE_GETPW_DECLS */
|
||||
|
||||
/* #define HACK_TERMCAP_MOTION */
|
||||
/* ISC systems don't define getpwent() if _POSIX_SOURCE is defined. */
|
||||
#if defined (isc386) && defined (_POSIX_SOURCE)
|
||||
# if defined (__STDC__)
|
||||
extern struct passwd *getpwent (void);
|
||||
# else
|
||||
extern struct passwd *getpwent ();
|
||||
# endif /* !__STDC__ */
|
||||
#endif /* isc386 && _POSIX_SOURCE */
|
||||
|
||||
#include "posixstat.h"
|
||||
|
||||
@ -95,11 +97,14 @@ extern char *xmalloc (), *xrealloc ();
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing on a directory name. The function is called with
|
||||
the address of a string (the current directory name) as an arg. */
|
||||
Function *rl_symbolic_link_hook = (Function *)NULL;
|
||||
Function *rl_directory_completion_hook = (Function *)NULL;
|
||||
|
||||
/* Non-zero means readline completion functions perform tilde expansion. */
|
||||
int rl_complete_with_tilde_expansion = 0;
|
||||
|
||||
/* If non-zero, non-unique completions always show the list of matches. */
|
||||
int _rl_complete_show_all = 0;
|
||||
|
||||
#if defined (VISIBLE_STATS)
|
||||
# if !defined (X_OK)
|
||||
# define X_OK 1
|
||||
@ -133,6 +138,10 @@ Function *rl_completion_entry_function = (Function *)NULL;
|
||||
array of strings returned. */
|
||||
CPPFunction *rl_attempted_completion_function = (CPPFunction *)NULL;
|
||||
|
||||
/* Non-zero means to suppress normal filename completion after the
|
||||
user-specified completion function has been called. */
|
||||
int rl_attempted_completion_over = 0;
|
||||
|
||||
/* Local variable states what happened during the last completion attempt. */
|
||||
static int completion_changed_buffer = 0;
|
||||
|
||||
@ -144,22 +153,24 @@ rl_complete (ignore, invoking_key)
|
||||
int ignore, invoking_key;
|
||||
{
|
||||
if (rl_last_func == rl_complete && !completion_changed_buffer)
|
||||
rl_complete_internal ('?');
|
||||
return (rl_complete_internal ('?'));
|
||||
else if (_rl_complete_show_all)
|
||||
return (rl_complete_internal ('!'));
|
||||
else
|
||||
rl_complete_internal (TAB);
|
||||
return (rl_complete_internal (TAB));
|
||||
}
|
||||
|
||||
/* List the possible completions. See description of rl_complete (). */
|
||||
rl_possible_completions (ignore, invoking_key)
|
||||
int ignore, invoking_key;
|
||||
{
|
||||
rl_complete_internal ('?');
|
||||
return (rl_complete_internal ('?'));
|
||||
}
|
||||
|
||||
rl_insert_completions (ignore, invoking_key)
|
||||
int ignore, invoking_key;
|
||||
{
|
||||
rl_complete_internal ('*');
|
||||
return (rl_complete_internal ('*'));
|
||||
}
|
||||
|
||||
/* The user must press "y" or "n". Non-zero return means "y" pressed. */
|
||||
@ -170,9 +181,9 @@ get_y_or_n ()
|
||||
for (;;)
|
||||
{
|
||||
c = rl_read_key ();
|
||||
if (c == 'y' || c == 'Y')
|
||||
if (c == 'y' || c == 'Y' || c == ' ')
|
||||
return (1);
|
||||
if (c == 'n' || c == 'N')
|
||||
if (c == 'n' || c == 'N' || c == RUBOUT)
|
||||
return (0);
|
||||
if (c == ABORT_CHAR)
|
||||
rl_abort ();
|
||||
@ -263,11 +274,90 @@ _delete_quotes (text)
|
||||
}
|
||||
#endif /* SHELL */
|
||||
|
||||
/* Return the portion of PATHNAME that should be output when listing
|
||||
possible completions. If we are hacking filename completion, we
|
||||
are only interested in the basename, the portion following the
|
||||
final slash. Otherwise, we return what we were passed. */
|
||||
static char *
|
||||
printable_part (pathname)
|
||||
char *pathname;
|
||||
{
|
||||
char *temp = (char *)NULL;
|
||||
|
||||
if (rl_filename_completion_desired)
|
||||
temp = strrchr (pathname, '/');
|
||||
|
||||
if (!temp)
|
||||
return (pathname);
|
||||
else
|
||||
return (++temp);
|
||||
}
|
||||
|
||||
/* Output TO_PRINT to rl_outstream. If VISIBLE_STATS is defined and we
|
||||
are using it, check for and output a single character for `special'
|
||||
filenames. Return 1 if we printed an extension character, 0 if not. */
|
||||
static int
|
||||
print_filename (to_print, full_pathname)
|
||||
char *to_print, *full_pathname;
|
||||
{
|
||||
#if !defined (VISIBLE_STATS)
|
||||
fputs (to_print, rl_outstream);
|
||||
return 0;
|
||||
#else
|
||||
char *s, c, *new_full_pathname;
|
||||
int extension_char = 0, slen, tlen;
|
||||
|
||||
fputs (to_print, rl_outstream);
|
||||
if (rl_filename_completion_desired && rl_visible_stats)
|
||||
{
|
||||
/* If to_print != full_pathname, to_print is the basename of the
|
||||
path passed. In this case, we try to expand the directory
|
||||
name before checking for the stat character. */
|
||||
if (to_print != full_pathname)
|
||||
{
|
||||
/* Terminate the directory name. */
|
||||
c = to_print[-1];
|
||||
to_print[-1] = '\0';
|
||||
|
||||
s = tilde_expand (full_pathname);
|
||||
if (rl_directory_completion_hook)
|
||||
(*rl_directory_completion_hook) (&s);
|
||||
|
||||
slen = strlen (s);
|
||||
tlen = strlen (to_print);
|
||||
new_full_pathname = xmalloc (slen + tlen + 2);
|
||||
strcpy (new_full_pathname, s);
|
||||
new_full_pathname[slen] = '/';
|
||||
strcpy (new_full_pathname + slen + 1, to_print);
|
||||
|
||||
extension_char = stat_char (new_full_pathname);
|
||||
|
||||
free (new_full_pathname);
|
||||
to_print[-1] = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = tilde_expand (full_pathname);
|
||||
extension_char = stat_char (s);
|
||||
}
|
||||
|
||||
free (s);
|
||||
if (extension_char)
|
||||
putc (extension_char, rl_outstream);
|
||||
return (extension_char != 0);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
#endif /* VISIBLE_STATS */
|
||||
}
|
||||
|
||||
/* Complete the word at or before point.
|
||||
WHAT_TO_DO says what to do with the completion.
|
||||
`?' means list the possible completions.
|
||||
TAB means do standard completion.
|
||||
`*' means insert all of the possible completions. */
|
||||
`*' means insert all of the possible completions.
|
||||
`!' means to do standard completion, and list all possible completions if
|
||||
there is more than one. */
|
||||
rl_complete_internal (what_to_do)
|
||||
int what_to_do;
|
||||
{
|
||||
@ -276,10 +366,10 @@ rl_complete_internal (what_to_do)
|
||||
int start, scan, end, delimiter = 0, pass_next;
|
||||
char *text, *saved_line_buffer;
|
||||
char *replacement;
|
||||
char quote_char = '\0';
|
||||
#if defined (SHELL)
|
||||
int found_quote = 0;
|
||||
#endif
|
||||
char quote_char = '\0';
|
||||
|
||||
if (rl_line_buffer)
|
||||
saved_line_buffer = savestring (rl_line_buffer);
|
||||
@ -352,12 +442,13 @@ rl_complete_internal (what_to_do)
|
||||
substring on which to complete. */
|
||||
while (--rl_point)
|
||||
{
|
||||
scan = rl_line_buffer[rl_point];
|
||||
#if defined (SHELL)
|
||||
/* Don't let word break characters in quoted substrings break
|
||||
words for the completer. */
|
||||
if (found_quote)
|
||||
{
|
||||
if (strchr (rl_completer_quote_characters, rl_line_buffer[rl_point]))
|
||||
if (strchr (rl_completer_quote_characters, scan))
|
||||
{
|
||||
quoted = !quoted;
|
||||
continue;
|
||||
@ -366,23 +457,23 @@ rl_complete_internal (what_to_do)
|
||||
continue;
|
||||
}
|
||||
#endif /* SHELL */
|
||||
if (strchr (rl_completer_word_break_characters, rl_line_buffer[rl_point]))
|
||||
if (strchr (rl_completer_word_break_characters, scan))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we are at a word break, then advance past it. */
|
||||
if (strchr (rl_completer_word_break_characters, rl_line_buffer[rl_point]))
|
||||
scan = rl_line_buffer[rl_point];
|
||||
if (strchr (rl_completer_word_break_characters, scan))
|
||||
{
|
||||
/* If the character that caused the word break was a quoting
|
||||
character, then remember it as the delimiter. */
|
||||
if (strchr ("\"'", rl_line_buffer[rl_point]) && (end - rl_point) > 1)
|
||||
delimiter = rl_line_buffer[rl_point];
|
||||
if (strchr ("\"'", scan) && (end - rl_point) > 1)
|
||||
delimiter = scan;
|
||||
|
||||
/* If the character isn't needed to determine something special
|
||||
about what kind of completion to perform, then advance past it. */
|
||||
if (!rl_special_prefixes ||
|
||||
!strchr (rl_special_prefixes, rl_line_buffer[rl_point]))
|
||||
if (!rl_special_prefixes || strchr (rl_special_prefixes, scan) == 0)
|
||||
rl_point++;
|
||||
}
|
||||
}
|
||||
@ -399,11 +490,9 @@ rl_complete_internal (what_to_do)
|
||||
{
|
||||
matches = (*rl_attempted_completion_function) (text, start, end);
|
||||
|
||||
if (matches)
|
||||
if (matches || rl_attempted_completion_over)
|
||||
{
|
||||
/* XXX - This is questionable code. - XXX */
|
||||
if (matches == (char **)-1)
|
||||
matches = (char **)NULL;
|
||||
rl_attempted_completion_over = 0;
|
||||
our_func = (Function *)NULL;
|
||||
goto after_usual_completion;
|
||||
}
|
||||
@ -441,6 +530,7 @@ rl_complete_internal (what_to_do)
|
||||
char *lowest_common;
|
||||
int j, newlen = 0;
|
||||
char dead_slot;
|
||||
char **temp_array;
|
||||
|
||||
/* Sort the items. */
|
||||
/* It is safe to sort this array, because the lowest common
|
||||
@ -464,25 +554,19 @@ rl_complete_internal (what_to_do)
|
||||
|
||||
/* We have marked all the dead slots with (char *)&dead_slot.
|
||||
Copy all the non-dead entries into a new array. */
|
||||
{
|
||||
char **temp_array =
|
||||
(char **)xmalloc ((3 + newlen) * sizeof (char *));
|
||||
temp_array = (char **)xmalloc ((3 + newlen) * sizeof (char *));
|
||||
for (i = j = 1; matches[i]; i++)
|
||||
{
|
||||
if (matches[i] != (char *)&dead_slot)
|
||||
temp_array[j++] = matches[i];
|
||||
}
|
||||
temp_array[j] = (char *)NULL;
|
||||
|
||||
for (i = 1, j = 1; matches[i]; i++)
|
||||
{
|
||||
if (matches[i] != (char *)&dead_slot)
|
||||
temp_array[j++] = matches[i];
|
||||
}
|
||||
if (matches[0] != (char *)&dead_slot)
|
||||
free (matches[0]);
|
||||
free (matches);
|
||||
|
||||
temp_array[j] = (char *)NULL;
|
||||
|
||||
if (matches[0] != (char *)&dead_slot)
|
||||
free (matches[0]);
|
||||
|
||||
free (matches);
|
||||
|
||||
matches = temp_array;
|
||||
}
|
||||
matches = temp_array;
|
||||
|
||||
/* Place the lowest common denominator back in [0]. */
|
||||
matches[0] = lowest_common;
|
||||
@ -500,6 +584,7 @@ rl_complete_internal (what_to_do)
|
||||
switch (what_to_do)
|
||||
{
|
||||
case TAB:
|
||||
case '!':
|
||||
/* If we are matching filenames, then here is our chance to
|
||||
do clever processing by re-examining the list. Call the
|
||||
ignore function with the array as a parameter. It can
|
||||
@ -529,7 +614,11 @@ rl_complete_internal (what_to_do)
|
||||
This also checks whether the common prefix of several
|
||||
matches needs to be quoted. If the common prefix should
|
||||
not be checked, add !matches[1] to the if clause. */
|
||||
if (rl_strpbrk (matches[0], rl_completer_word_break_characters))
|
||||
if (rl_strpbrk (matches[0], rl_completer_word_break_characters)
|
||||
#if defined (SHELL)
|
||||
|| rl_strpbrk (matches[0], "$`")
|
||||
#endif
|
||||
)
|
||||
do_replace = matches[1] ? MULT_MATCH : SINGLE_MATCH;
|
||||
|
||||
if (do_replace != NO_MATCH)
|
||||
@ -558,7 +647,7 @@ rl_complete_internal (what_to_do)
|
||||
free (mtext);
|
||||
|
||||
rlen = strlen (rtext);
|
||||
replacement = (char *)alloca (rlen + 1);
|
||||
replacement = xmalloc (rlen + 1);
|
||||
strcpy (replacement, rtext);
|
||||
if (do_replace == MULT_MATCH)
|
||||
replacement[rlen - 1] = '\0';
|
||||
@ -567,7 +656,7 @@ rl_complete_internal (what_to_do)
|
||||
/* Found an embedded word break character in a potential
|
||||
match, so we need to prepend a quote character if we
|
||||
are replacing the completion string. */
|
||||
replacement = (char *)alloca (strlen (matches[0]) + 2);
|
||||
replacement = xmalloc (strlen (matches[0]) + 2);
|
||||
quote_char = *rl_completer_quote_characters;
|
||||
*replacement = quote_char;
|
||||
strcpy (replacement + 1, matches[0]);
|
||||
@ -577,9 +666,13 @@ rl_complete_internal (what_to_do)
|
||||
|
||||
if (replacement)
|
||||
{
|
||||
rl_begin_undo_group ();
|
||||
rl_delete_text (start, rl_point);
|
||||
rl_point = start;
|
||||
rl_insert_text (replacement);
|
||||
rl_end_undo_group ();
|
||||
if (replacement != matches[0])
|
||||
free (replacement);
|
||||
}
|
||||
|
||||
/* If there are more matches, ring the bell to indicate.
|
||||
@ -589,7 +682,9 @@ rl_complete_internal (what_to_do)
|
||||
of the line, then add a space. */
|
||||
if (matches[1])
|
||||
{
|
||||
if (rl_editing_mode != vi_mode)
|
||||
if (what_to_do == '!')
|
||||
goto display_matches; /* XXX */
|
||||
else if (rl_editing_mode != vi_mode)
|
||||
ding (); /* There are other matches remaining. */
|
||||
}
|
||||
else
|
||||
@ -608,8 +703,7 @@ rl_complete_internal (what_to_do)
|
||||
struct stat finfo;
|
||||
char *filename = tilde_expand (matches[0]);
|
||||
|
||||
if ((stat (filename, &finfo) == 0) &&
|
||||
S_ISDIR (finfo.st_mode))
|
||||
if ((stat (filename, &finfo) == 0) && S_ISDIR (finfo.st_mode))
|
||||
{
|
||||
if (rl_line_buffer[rl_point] != '/')
|
||||
rl_insert_text ("/");
|
||||
@ -633,9 +727,9 @@ rl_complete_internal (what_to_do)
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
rl_begin_undo_group ();
|
||||
rl_delete_text (start, rl_point);
|
||||
rl_point = start;
|
||||
rl_begin_undo_group ();
|
||||
if (matches[1])
|
||||
{
|
||||
while (matches[i])
|
||||
@ -655,34 +749,17 @@ rl_complete_internal (what_to_do)
|
||||
|
||||
case '?':
|
||||
{
|
||||
int len, count, limit, max = 0;
|
||||
int len, count, limit, max;
|
||||
int j, k, l;
|
||||
|
||||
/* Handle simple case first. What if there is only one answer? */
|
||||
if (!matches[1])
|
||||
{
|
||||
char *temp = (char *)NULL;
|
||||
|
||||
if (rl_filename_completion_desired)
|
||||
temp = strrchr (matches[0], '/');
|
||||
|
||||
if (!temp)
|
||||
temp = matches[0];
|
||||
else
|
||||
temp++;
|
||||
char *temp;
|
||||
|
||||
temp = printable_part (matches[0]);
|
||||
crlf ();
|
||||
fprintf (rl_outstream, "%s", temp);
|
||||
#if defined (VISIBLE_STATS)
|
||||
if (rl_filename_completion_desired && rl_visible_stats)
|
||||
{
|
||||
int extension_char;
|
||||
|
||||
extension_char = stat_char (matches[0]);
|
||||
if (extension_char)
|
||||
putc (extension_char, rl_outstream);
|
||||
}
|
||||
#endif /* VISIBLE_STATS */
|
||||
print_filename (temp, matches[0]);
|
||||
crlf ();
|
||||
goto restart;
|
||||
}
|
||||
@ -690,23 +767,13 @@ rl_complete_internal (what_to_do)
|
||||
/* There is more than one answer. Find out how many there are,
|
||||
and find out what the maximum printed length of a single entry
|
||||
is. */
|
||||
for (i = 1; matches[i]; i++)
|
||||
display_matches:
|
||||
for (max = 0, i = 1; matches[i]; i++)
|
||||
{
|
||||
char *temp;
|
||||
int name_length;
|
||||
|
||||
/* If we are hacking filenames, then only count the characters
|
||||
after the last slash in the pathname. */
|
||||
if (rl_filename_completion_desired)
|
||||
temp = strrchr (matches[i], '/');
|
||||
else
|
||||
temp = (char *)NULL;
|
||||
|
||||
if (!temp)
|
||||
temp = matches[i];
|
||||
else
|
||||
temp++;
|
||||
|
||||
temp = printable_part (matches[i]);
|
||||
name_length = strlen (temp);
|
||||
|
||||
if (name_length > max)
|
||||
@ -764,40 +831,15 @@ rl_complete_internal (what_to_do)
|
||||
for (j = 0, l = i; j < limit; j++)
|
||||
{
|
||||
if (l > len || !matches[l])
|
||||
{
|
||||
break;
|
||||
}
|
||||
break;
|
||||
else
|
||||
{
|
||||
char *temp = (char *)NULL;
|
||||
char *temp;
|
||||
int printed_length;
|
||||
|
||||
if (rl_filename_completion_desired)
|
||||
temp = strrchr (matches[l], '/');
|
||||
|
||||
if (!temp)
|
||||
temp = matches[l];
|
||||
else
|
||||
temp++;
|
||||
|
||||
temp = printable_part (matches[l]);
|
||||
printed_length = strlen (temp);
|
||||
fprintf (rl_outstream, "%s", temp);
|
||||
|
||||
#if defined (VISIBLE_STATS)
|
||||
if (rl_filename_completion_desired &&
|
||||
rl_visible_stats)
|
||||
{
|
||||
int extension_char;
|
||||
|
||||
extension_char = stat_char (matches[l]);
|
||||
|
||||
if (extension_char)
|
||||
{
|
||||
putc (extension_char, rl_outstream);
|
||||
printed_length++;
|
||||
}
|
||||
}
|
||||
#endif /* VISIBLE_STATS */
|
||||
printed_length += print_filename (temp, matches[l]);
|
||||
|
||||
if (j + 1 < limit)
|
||||
{
|
||||
@ -835,6 +877,7 @@ rl_complete_internal (what_to_do)
|
||||
|
||||
free (saved_line_buffer);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined (VISIBLE_STATS)
|
||||
@ -848,11 +891,18 @@ stat_char (filename)
|
||||
char *filename;
|
||||
{
|
||||
struct stat finfo;
|
||||
int character = 0;
|
||||
int character, r;
|
||||
|
||||
if (stat (filename, &finfo) == -1)
|
||||
return (character);
|
||||
#if defined (S_ISLNK)
|
||||
r = lstat (filename, &finfo);
|
||||
#else
|
||||
r = stat (filename, &finfo);
|
||||
#endif
|
||||
|
||||
if (r == -1)
|
||||
return (0);
|
||||
|
||||
character = 0;
|
||||
if (S_ISDIR (finfo.st_mode))
|
||||
character = '/';
|
||||
#if defined (S_ISLNK)
|
||||
@ -888,9 +938,9 @@ username_completion_function (text, state)
|
||||
int state;
|
||||
char *text;
|
||||
{
|
||||
#if defined (_GO32_)
|
||||
#if defined (__GO32__)
|
||||
return (char *)NULL;
|
||||
#else /* !_GO32_ */
|
||||
#else /* !__GO32__ */
|
||||
static char *username = (char *)NULL;
|
||||
static struct passwd *entry;
|
||||
static int namelen, first_char, first_char_loc;
|
||||
@ -914,7 +964,8 @@ username_completion_function (text, state)
|
||||
|
||||
while (entry = getpwent ())
|
||||
{
|
||||
if (strncmp (username, entry->pw_name, namelen) == 0)
|
||||
if ((username[0] == entry->pw_name[0]) &&
|
||||
(strncmp (username, entry->pw_name, namelen) == 0))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -936,7 +987,7 @@ username_completion_function (text, state)
|
||||
|
||||
return (value);
|
||||
}
|
||||
#endif /* !_GO32_ */
|
||||
#endif /* !__GO32__ */
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
@ -1091,13 +1142,20 @@ filename_completion_function (text, state)
|
||||
users_dirname = savestring (dirname);
|
||||
{
|
||||
char *temp_dirname;
|
||||
int replace_dirname;
|
||||
|
||||
temp_dirname = tilde_expand (dirname);
|
||||
free (dirname);
|
||||
dirname = temp_dirname;
|
||||
|
||||
if (rl_symbolic_link_hook)
|
||||
(*rl_symbolic_link_hook) (&dirname);
|
||||
replace_dirname = 0;
|
||||
if (rl_directory_completion_hook)
|
||||
replace_dirname = (*rl_directory_completion_hook) (&dirname);
|
||||
if (replace_dirname)
|
||||
{
|
||||
free (users_dirname);
|
||||
users_dirname = savestring (dirname);
|
||||
}
|
||||
}
|
||||
directory = opendir (dirname);
|
||||
filename_len = strlen (filename);
|
||||
@ -1125,14 +1183,12 @@ filename_completion_function (text, state)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise, if these match upto the length of filename, then
|
||||
/* Otherwise, if these match up to the length of filename, then
|
||||
it is a match. */
|
||||
if (((int)D_NAMLEN (entry)) >= filename_len &&
|
||||
(entry->d_name[0] == filename[0]) &&
|
||||
(strncmp (filename, entry->d_name, filename_len) == 0))
|
||||
{
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1166,7 +1222,8 @@ filename_completion_function (text, state)
|
||||
{
|
||||
char *temp;
|
||||
|
||||
if (dirname && (strcmp (dirname, ".") != 0))
|
||||
/* dirname && (strcmp (dirname, ".") != 0) */
|
||||
if (dirname && (dirname[0] != '.' || dirname[1]))
|
||||
{
|
||||
if (rl_complete_with_tilde_expansion && *users_dirname == '~')
|
||||
{
|
||||
@ -1191,9 +1248,8 @@ filename_completion_function (text, state)
|
||||
strcat (temp, entry->d_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = (savestring (entry->d_name));
|
||||
}
|
||||
temp = (savestring (entry->d_name));
|
||||
|
||||
return (temp);
|
||||
}
|
||||
}
|
||||
@ -1239,10 +1295,11 @@ rl_tilde_expand (ignore, key)
|
||||
int len;
|
||||
|
||||
len = end - start + 1;
|
||||
temp = (char *)alloca (len + 1);
|
||||
temp = xmalloc (len + 1);
|
||||
strncpy (temp, rl_line_buffer + start, len);
|
||||
temp[len] = '\0';
|
||||
homedir = tilde_expand (temp);
|
||||
free (temp);
|
||||
|
||||
insert:
|
||||
rl_begin_undo_group ();
|
||||
|
@ -53,12 +53,13 @@ extern int readline_echoing_p;
|
||||
extern char *term_clreol, *term_im, *term_ic, *term_ei, *term_DC;
|
||||
/* Termcap variables. */
|
||||
extern char *term_up, *term_dc, *term_cr, *term_IC;
|
||||
extern int screenheight, screenwidth, terminal_can_insert;
|
||||
extern int screenheight, screenwidth, screenchars;
|
||||
extern int terminal_can_insert;
|
||||
|
||||
extern void _rl_output_some_chars ();
|
||||
extern void _rl_output_character_function ();
|
||||
extern int _rl_output_character_function ();
|
||||
|
||||
extern int _rl_convert_meta_chars_to_ascii;
|
||||
extern int _rl_output_meta_chars;
|
||||
extern int _rl_horizontal_scroll_mode;
|
||||
extern int _rl_mark_modified_lines;
|
||||
extern int _rl_prefer_visible_bell;
|
||||
@ -139,15 +140,138 @@ static int forced_display = 0;
|
||||
/* Default and initial buffer size. Can grow. */
|
||||
static int line_size = 1024;
|
||||
|
||||
static char *last_prompt_string = (char *)NULL;
|
||||
static char *local_prompt, *local_prompt_prefix;
|
||||
static int visible_length, prefix_length;
|
||||
|
||||
/* The number of invisible characters in the line currently being
|
||||
displayed on the screen. */
|
||||
static int visible_wrap_offset = 0;
|
||||
|
||||
/* The length (buffer offset) of the first line of the last (possibly
|
||||
multi-line) buffer displayed on the screen. */
|
||||
static int visible_first_line_len = 0;
|
||||
|
||||
/* 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. */
|
||||
|
||||
/* Current implementation:
|
||||
\001 (^A) start non-visible characters
|
||||
\002 (^B) end non-visible characters
|
||||
all characters except \001 and \002 (following a \001) are copied to
|
||||
the returned string; all characters except those between \001 and
|
||||
\002 are assumed to be `visible'. */
|
||||
|
||||
static char *
|
||||
expand_prompt (pmt, lp)
|
||||
char *pmt;
|
||||
int *lp;
|
||||
{
|
||||
char *r, *ret, *p;
|
||||
int l, rl, ignoring;
|
||||
|
||||
/* Short-circuit if we can. */
|
||||
if (strchr (pmt, RL_PROMPT_START_IGNORE) == 0)
|
||||
{
|
||||
r = savestring (pmt);
|
||||
if (lp)
|
||||
*lp = strlen (r);
|
||||
return r;
|
||||
}
|
||||
|
||||
l = strlen (pmt);
|
||||
r = ret = xmalloc (l + 1);
|
||||
|
||||
for (rl = ignoring = 0, p = pmt; p && *p; p++)
|
||||
{
|
||||
/* This code strips the invisible character string markers
|
||||
RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */
|
||||
if (*p == RL_PROMPT_START_IGNORE)
|
||||
{
|
||||
ignoring++;
|
||||
continue;
|
||||
}
|
||||
else if (ignoring && *p == RL_PROMPT_END_IGNORE)
|
||||
{
|
||||
ignoring = 0;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
*r++ = *p;
|
||||
if (!ignoring)
|
||||
rl++;
|
||||
}
|
||||
}
|
||||
|
||||
*r = '\0';
|
||||
if (lp)
|
||||
*lp = rl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Expand the prompt string into the various display components, if
|
||||
* necessary.
|
||||
*
|
||||
* local_prompt = expanded last line of string in rl_display_prompt
|
||||
* (portion after the final newline)
|
||||
* local_prompt_prefix = portion before last newline of rl_display_prompt,
|
||||
* expanded via expand_prompt
|
||||
* visible_length = number of visible characters in local_prompt
|
||||
* prefix_length = number of visible characters in local_prompt_prefix
|
||||
*
|
||||
* This function is called once per call to readline(). It may also be
|
||||
* called arbitrarily to expand the primary prompt.
|
||||
*
|
||||
* The return value is the number of visible characters on the last line
|
||||
* of the (possibly multi-line) prompt.
|
||||
*/
|
||||
int
|
||||
rl_expand_prompt (prompt)
|
||||
char *prompt;
|
||||
{
|
||||
char *p, *t;
|
||||
int c;
|
||||
|
||||
/* Clear out any saved values. */
|
||||
if (local_prompt)
|
||||
free (local_prompt);
|
||||
if (local_prompt_prefix)
|
||||
free (local_prompt_prefix);
|
||||
local_prompt = local_prompt_prefix = (char *)0;
|
||||
|
||||
p = strrchr (prompt, '\n');
|
||||
if (!p)
|
||||
{
|
||||
/* The prompt is only one line. */
|
||||
local_prompt = expand_prompt (prompt, &visible_length);
|
||||
local_prompt_prefix = (char *)0;
|
||||
return (visible_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The prompt spans multiple lines. */
|
||||
t = ++p;
|
||||
local_prompt = expand_prompt (p, &visible_length);
|
||||
c = *t; *t = '\0';
|
||||
/* The portion of the prompt string up to and including the
|
||||
final newline is now null-terminated. */
|
||||
local_prompt_prefix = expand_prompt (prompt, &prefix_length);
|
||||
*t = c;
|
||||
return (prefix_length);
|
||||
}
|
||||
}
|
||||
|
||||
/* Basic redisplay algorithm. */
|
||||
void
|
||||
rl_redisplay ()
|
||||
{
|
||||
register int in, out, c, linenum;
|
||||
register char *line = invisible_line;
|
||||
int c_pos = 0, inv_botlin = 0, wrap_offset, wrap_column;
|
||||
char *prompt_this_line;
|
||||
int c_pos = 0;
|
||||
int inv_botlin = 0; /* Number of lines in newly drawn buffer. */
|
||||
|
||||
if (!readline_echoing_p)
|
||||
return;
|
||||
@ -186,20 +310,41 @@ rl_redisplay ()
|
||||
if (visible_line[0] != invisible_line[0])
|
||||
rl_display_fixed = 0;
|
||||
|
||||
prompt_this_line = strrchr (rl_display_prompt, '\n');
|
||||
if (!prompt_this_line)
|
||||
prompt_this_line = rl_display_prompt;
|
||||
/* If the prompt to be displayed is the `primary' readline prompt (the
|
||||
one passed to readline()), use the values we have already expanded.
|
||||
If not, use what's already in rl_display_prompt. WRAP_OFFSET is the
|
||||
number of non-visible characters in the prompt string. */
|
||||
if (rl_display_prompt == rl_prompt)
|
||||
{
|
||||
int local_len = strlen (local_prompt);
|
||||
if (local_prompt_prefix && forced_display)
|
||||
_rl_output_some_chars (local_prompt_prefix, strlen (local_prompt_prefix));
|
||||
|
||||
if (local_prompt)
|
||||
strncpy (line + out, local_prompt, local_len);
|
||||
out += local_len;
|
||||
line[out] = '\0';
|
||||
wrap_offset = local_len - visible_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
prompt_this_line++;
|
||||
if (forced_display)
|
||||
_rl_output_some_chars
|
||||
(rl_display_prompt, prompt_this_line - rl_display_prompt);
|
||||
}
|
||||
int pmtlen;
|
||||
prompt_this_line = strrchr (rl_display_prompt, '\n');
|
||||
if (!prompt_this_line)
|
||||
prompt_this_line = rl_display_prompt;
|
||||
else
|
||||
{
|
||||
prompt_this_line++;
|
||||
if (forced_display)
|
||||
_rl_output_some_chars (rl_display_prompt, prompt_this_line - rl_display_prompt);
|
||||
}
|
||||
|
||||
strncpy (line + out, prompt_this_line, strlen (prompt_this_line));
|
||||
out += strlen (prompt_this_line);
|
||||
line[out] = '\0';
|
||||
pmtlen = strlen (prompt_this_line);
|
||||
strncpy (line + out, prompt_this_line, pmtlen);
|
||||
out += pmtlen;
|
||||
line[out] = '\0';
|
||||
wrap_offset = 0;
|
||||
}
|
||||
|
||||
for (in = 0; in < rl_end; in++)
|
||||
{
|
||||
@ -218,7 +363,7 @@ rl_redisplay ()
|
||||
|
||||
if (META_CHAR (c))
|
||||
{
|
||||
if (_rl_convert_meta_chars_to_ascii)
|
||||
if (_rl_output_meta_chars == 0)
|
||||
{
|
||||
sprintf (line + out, "\\%o", c);
|
||||
out += 4;
|
||||
@ -226,7 +371,6 @@ rl_redisplay ()
|
||||
else
|
||||
line[out++] = c;
|
||||
}
|
||||
#define DISPLAY_TABS
|
||||
#if defined (DISPLAY_TABS)
|
||||
else if (c == '\t')
|
||||
{
|
||||
@ -252,6 +396,8 @@ rl_redisplay ()
|
||||
if (c_pos < 0)
|
||||
c_pos = out;
|
||||
|
||||
/* C_POS == position in buffer where cursor should be placed. */
|
||||
|
||||
/* PWP: now is when things get a bit hairy. The visible and invisible
|
||||
line buffers are really multiple lines, which would wrap every
|
||||
(screenwidth - 1) characters. Go through each in turn, finding
|
||||
@ -263,7 +409,8 @@ rl_redisplay ()
|
||||
|
||||
if (!_rl_horizontal_scroll_mode && term_up && *term_up)
|
||||
{
|
||||
int total_screen_chars = (screenwidth * screenheight);
|
||||
int total_screen_chars = screenchars;
|
||||
int nleft, cursor_linenum, pos;
|
||||
|
||||
if (!rl_display_fixed || forced_display)
|
||||
{
|
||||
@ -275,15 +422,48 @@ rl_redisplay ()
|
||||
if (out >= total_screen_chars)
|
||||
out = total_screen_chars - 1;
|
||||
|
||||
/* Number of screen lines to display. */
|
||||
inv_botlin = out / screenwidth;
|
||||
/* Number of screen lines to display. The first line wraps at
|
||||
(screenwidth + wrap_offset) chars, the rest of the lines have
|
||||
screenwidth chars. */
|
||||
nleft = out - screenwidth - wrap_offset;
|
||||
if (nleft > 0)
|
||||
inv_botlin = 1 + nleft / screenwidth;
|
||||
else
|
||||
inv_botlin = 0;
|
||||
|
||||
/* The first line is at character position 0 in the buffer. The
|
||||
second and subsequent lines start at N * screenwidth, offset by
|
||||
OFFSET. OFFSET is wrap_offset for the invisible line and
|
||||
visible_wrap_offset for the line currently displayed. */
|
||||
|
||||
#define L_OFFSET(n, offset) ((n) > 0 ? ((n) * screenwidth) + (offset) : 0)
|
||||
#define VIS_CHARS(line) &visible_line[L_OFFSET((line), visible_wrap_offset)]
|
||||
#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)
|
||||
#define INV_LINE(line) &invisible_line[L_OFFSET((line), wrap_offset)]
|
||||
|
||||
/* For each line in the buffer, do the updating display. */
|
||||
for (linenum = 0; linenum <= inv_botlin; linenum++)
|
||||
update_line (linenum > _rl_vis_botlin ? ""
|
||||
: &visible_line[linenum * screenwidth],
|
||||
&invisible_line[linenum * screenwidth],
|
||||
linenum);
|
||||
{
|
||||
update_line (VIS_LINE(linenum), INV_LINE(linenum), linenum);
|
||||
|
||||
/* 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
|
||||
implies that we completely overwrite the old visible line)
|
||||
and the new line is shorter than the old. */
|
||||
if (linenum == 0 &&
|
||||
inv_botlin == 0 &&
|
||||
(wrap_offset > visible_wrap_offset) &&
|
||||
(_rl_last_c_pos < visible_first_line_len))
|
||||
{
|
||||
nleft = screenwidth + wrap_offset - _rl_last_c_pos;
|
||||
clear_to_eol (nleft);
|
||||
}
|
||||
|
||||
/* Since the new first line is now visible, save its length. */
|
||||
if (linenum == 0)
|
||||
visible_first_line_len = _rl_last_c_pos;
|
||||
}
|
||||
|
||||
/* We may have deleted some lines. If so, clear the left over
|
||||
blank ones at the bottom out. */
|
||||
@ -292,7 +472,7 @@ rl_redisplay ()
|
||||
char *tt;
|
||||
for (; linenum <= _rl_vis_botlin; linenum++)
|
||||
{
|
||||
tt = &visible_line[linenum * screenwidth];
|
||||
tt = VIS_CHARS (linenum);
|
||||
_rl_move_vert (linenum);
|
||||
_rl_move_cursor_relative (0, tt);
|
||||
clear_to_eol
|
||||
@ -302,9 +482,19 @@ rl_redisplay ()
|
||||
_rl_vis_botlin = inv_botlin;
|
||||
|
||||
/* Move the cursor where it should be. */
|
||||
_rl_move_vert (c_pos / screenwidth);
|
||||
_rl_move_cursor_relative (c_pos % screenwidth,
|
||||
&invisible_line[(c_pos / screenwidth) * screenwidth]);
|
||||
/* Which line? */
|
||||
nleft = c_pos - screenwidth - wrap_offset;
|
||||
if (nleft > 0)
|
||||
cursor_linenum = 1 + nleft / screenwidth;
|
||||
else
|
||||
cursor_linenum = 0;
|
||||
_rl_move_vert (cursor_linenum);
|
||||
|
||||
/* Where on that line? And where does that line start
|
||||
in the buffer? */
|
||||
pos = L_OFFSET(cursor_linenum, wrap_offset);
|
||||
nleft = c_pos - pos;
|
||||
_rl_move_cursor_relative (nleft, &invisible_line[pos]);
|
||||
}
|
||||
}
|
||||
else /* Do horizontal scrolling. */
|
||||
@ -350,6 +540,7 @@ rl_redisplay ()
|
||||
visible_line = invisible_line;
|
||||
invisible_line = temp;
|
||||
rl_display_fixed = 0;
|
||||
visible_wrap_offset = wrap_offset;
|
||||
}
|
||||
}
|
||||
|
||||
@ -357,12 +548,12 @@ rl_redisplay ()
|
||||
line on the screen; vis:
|
||||
|
||||
/old first difference
|
||||
/beginning of line | /old last same /old EOL
|
||||
v v v v
|
||||
/beginning of line | /old last same /old EOL
|
||||
v v v v
|
||||
old: eddie> Oh, my little gruntle-buggy is to me, as lurgid as
|
||||
new: eddie> Oh, my little buggy says to me, as lurgid as
|
||||
^ ^ ^ ^
|
||||
\beginning of line | \new last same \new end of line
|
||||
^ ^ ^ ^
|
||||
\beginning of line | \new last same \new end of line
|
||||
\new first difference
|
||||
|
||||
All are character pointers for the sake of speed. Special cases for
|
||||
@ -494,6 +685,7 @@ rl_on_new_line ()
|
||||
|
||||
_rl_last_c_pos = _rl_last_v_pos = 0;
|
||||
_rl_vis_botlin = last_lmargin = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Actually update the display, period. */
|
||||
@ -508,6 +700,7 @@ rl_forced_update_display ()
|
||||
rl_on_new_line ();
|
||||
forced_display++;
|
||||
rl_redisplay ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Move the cursor from _rl_last_c_pos to NEW, which are buffer indices.
|
||||
@ -553,7 +746,7 @@ _rl_move_cursor_relative (new, data)
|
||||
#else
|
||||
for (i = _rl_last_c_pos; i < new; i++)
|
||||
putc (data[i], rl_outstream);
|
||||
#endif /* HACK_TERMCAP_MOTION */
|
||||
#endif /* HACK_TERMCAP_MOTION */
|
||||
}
|
||||
else
|
||||
backspace (_rl_last_c_pos - new);
|
||||
@ -570,14 +763,14 @@ _rl_move_vert (to)
|
||||
if (_rl_last_v_pos == to || to > screenheight)
|
||||
return;
|
||||
|
||||
#if defined (_GO32_)
|
||||
#if defined (__GO32__)
|
||||
{
|
||||
int row, col;
|
||||
|
||||
ScreenGetCursor (&row, &col);
|
||||
ScreenSetCursor ((row + to - _rl_last_v_pos), col);
|
||||
}
|
||||
#else /* !_GO32_ */
|
||||
#else /* !__GO32__ */
|
||||
|
||||
if ((delta = to - _rl_last_v_pos) > 0)
|
||||
{
|
||||
@ -592,18 +785,20 @@ _rl_move_vert (to)
|
||||
for (i = 0; i < -delta; i++)
|
||||
tputs (term_up, 1, _rl_output_character_function);
|
||||
}
|
||||
#endif /* !_GO32_ */
|
||||
#endif /* !__GO32__ */
|
||||
_rl_last_v_pos = to; /* Now TO is here */
|
||||
}
|
||||
|
||||
/* Physically print C on rl_outstream. This is for functions which know
|
||||
how to optimize the display. */
|
||||
how to optimize the display. Return the number of characters output. */
|
||||
rl_show_char (c)
|
||||
int c;
|
||||
{
|
||||
if (META_CHAR (c) && _rl_convert_meta_chars_to_ascii)
|
||||
int n = 1;
|
||||
if (META_CHAR (c) && (_rl_output_meta_chars == 0))
|
||||
{
|
||||
fprintf (rl_outstream, "M-");
|
||||
n += 2;
|
||||
c = UNMETA (c);
|
||||
}
|
||||
|
||||
@ -613,11 +808,14 @@ rl_show_char (c)
|
||||
if (c < 32)
|
||||
#endif /* !DISPLAY_TABS */
|
||||
{
|
||||
fprintf (rl_outstream, "C-");
|
||||
n += 2;
|
||||
c += 64;
|
||||
}
|
||||
|
||||
putc (c, rl_outstream);
|
||||
fflush (rl_outstream);
|
||||
return n;
|
||||
}
|
||||
|
||||
int
|
||||
@ -625,7 +823,7 @@ rl_character_len (c, pos)
|
||||
register int c, pos;
|
||||
{
|
||||
if (META_CHAR (c))
|
||||
return (_rl_convert_meta_chars_to_ascii ? 4 : 1);
|
||||
return ((_rl_output_meta_chars == 0) ? 4 : 1);
|
||||
|
||||
if (c == '\t')
|
||||
{
|
||||
@ -636,10 +834,7 @@ rl_character_len (c, pos)
|
||||
#endif /* !DISPLAY_TABS */
|
||||
}
|
||||
|
||||
if (isprint (c))
|
||||
return (1);
|
||||
else
|
||||
return (2);
|
||||
return ((isprint (c)) ? 1 : 2);
|
||||
}
|
||||
|
||||
/* How to print things in the "echo-area". The prompt is treated as a
|
||||
@ -659,6 +854,7 @@ rl_message (va_alist)
|
||||
|
||||
rl_display_prompt = msg_buf;
|
||||
rl_redisplay ();
|
||||
return 0;
|
||||
}
|
||||
#else /* !HAVE_VARARGS_H */
|
||||
rl_message (format, arg1, arg2)
|
||||
@ -667,6 +863,7 @@ rl_message (format, arg1, arg2)
|
||||
sprintf (msg_buf, format, arg1, arg2);
|
||||
rl_display_prompt = msg_buf;
|
||||
rl_redisplay ();
|
||||
return 0;
|
||||
}
|
||||
#endif /* !HAVE_VARARGS_H */
|
||||
|
||||
@ -675,6 +872,7 @@ rl_clear_message ()
|
||||
{
|
||||
rl_display_prompt = rl_prompt;
|
||||
rl_redisplay ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
rl_reset_line_state ()
|
||||
@ -683,6 +881,7 @@ rl_reset_line_state ()
|
||||
|
||||
rl_display_prompt = rl_prompt ? rl_prompt : "";
|
||||
forced_display = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Quick redisplay hack when erasing characters at the end of the line. */
|
||||
@ -707,13 +906,13 @@ static void
|
||||
clear_to_eol (count)
|
||||
int count;
|
||||
{
|
||||
#if !defined (_GO32_)
|
||||
#if !defined (__GO32__)
|
||||
if (term_clreol)
|
||||
{
|
||||
tputs (term_clreol, 1, _rl_output_character_function);
|
||||
}
|
||||
else
|
||||
#endif /* !_GO32_ */
|
||||
#endif /* !__GO32__ */
|
||||
{
|
||||
register int i;
|
||||
|
||||
@ -733,7 +932,7 @@ insert_some_chars (string, count)
|
||||
char *string;
|
||||
int count;
|
||||
{
|
||||
#if defined (_GO32_)
|
||||
#if defined (__GO32__)
|
||||
int row, col, width;
|
||||
char *row_start;
|
||||
|
||||
@ -779,7 +978,7 @@ insert_some_chars (string, count)
|
||||
if (term_ei && *term_ei)
|
||||
tputs (term_ei, 1, _rl_output_character_function);
|
||||
}
|
||||
#endif /* !_GO32_ */
|
||||
#endif /* !__GO32__ */
|
||||
}
|
||||
|
||||
/* Delete COUNT characters from the display line. */
|
||||
@ -787,7 +986,7 @@ static void
|
||||
delete_chars (count)
|
||||
int count;
|
||||
{
|
||||
#if defined (_GO32_)
|
||||
#if defined (__GO32__)
|
||||
int row, col, width;
|
||||
char *row_start;
|
||||
|
||||
@ -814,5 +1013,5 @@ delete_chars (count)
|
||||
while (count--)
|
||||
tputs (term_dc, 1, _rl_output_character_function);
|
||||
}
|
||||
#endif /* !_GO32_ */
|
||||
#endif /* !__GO32__ */
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
This file documents the user interface to the GNU History library.
|
||||
|
||||
Copyright (C) 1988, 1991 Free Software Foundation, Inc.
|
||||
Authored by Brian Fox.
|
||||
Authored by Brian Fox and Chet Ramey.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of this manual
|
||||
provided the copyright notice and this permission notice are preserved on
|
||||
@ -48,8 +48,8 @@ information on using the GNU History Library in your own programs,
|
||||
@cindex expansion
|
||||
|
||||
The History library provides a history expansion feature that is similar
|
||||
to the history expansion in Csh. The following text describes the sytax
|
||||
that you use to manipulate the history information.
|
||||
to the history expansion in @code{csh}. The following text describes
|
||||
the syntax used to manipulate the history information.
|
||||
|
||||
History expansion takes place in two parts. The first is to determine
|
||||
which line from the previous history should be used during substitution.
|
||||
@ -57,13 +57,13 @@ The second is to select portions of that line for inclusion into the
|
||||
current one. The line selected from the previous history is called the
|
||||
@dfn{event}, and the portions of that line that are acted upon are
|
||||
called @dfn{words}. The line is broken into words in the same fashion
|
||||
that the Bash shell does, so that several English (or Unix) words
|
||||
that Bash does, so that several English (or Unix) words
|
||||
surrounded by quotes are considered as one word.
|
||||
|
||||
@menu
|
||||
* Event Designators:: How to specify which history line to use.
|
||||
* Word Designators:: Specifying which words are of interest.
|
||||
* Modifiers:: Modifying the results of susbstitution.
|
||||
* Modifiers:: Modifying the results of substitution.
|
||||
@end menu
|
||||
|
||||
@node Event Designators
|
||||
@ -76,8 +76,8 @@ history list.
|
||||
@table @asis
|
||||
|
||||
@item @code{!}
|
||||
Start a history subsititution, except when followed by a space, tab, or
|
||||
the end of the line... @key{=} or @key{(}.
|
||||
Start a history substitution, except when followed by a space, tab,
|
||||
the end of the line, @key{=} or @key{(}.
|
||||
|
||||
@item @code{!!}
|
||||
Refer to the previous command. This is a synonym for @code{!-1}.
|
||||
@ -94,6 +94,14 @@ Refer to the most recent command starting with @var{string}.
|
||||
@item @code{!?string}[@code{?}]
|
||||
Refer to the most recent command containing @var{string}.
|
||||
|
||||
@item @code{!#}
|
||||
The entire command line typed so far.
|
||||
|
||||
@item @code{^string1^string2^}
|
||||
Quick Substitution. Repeat the last command, replacing @var{string1}
|
||||
with @var{string2}. Equivalent to
|
||||
@code{!!:s/string1/string2/}.
|
||||
|
||||
@end table
|
||||
|
||||
@node Word Designators
|
||||
@ -107,13 +115,13 @@ with the first word being denoted by a 0 (zero).
|
||||
@table @code
|
||||
|
||||
@item 0 (zero)
|
||||
The zero'th word. For many applications, this is the command word.
|
||||
The @code{0}th word. For many applications, this is the command word.
|
||||
|
||||
@item n
|
||||
The @var{n}'th word.
|
||||
The @var{n}th word.
|
||||
|
||||
@item ^
|
||||
The first argument. that is, word 1.
|
||||
The first argument; that is, word 1.
|
||||
|
||||
@item $
|
||||
The last argument.
|
||||
@ -122,12 +130,18 @@ The last argument.
|
||||
The word matched by the most recent @code{?string?} search.
|
||||
|
||||
@item x-y
|
||||
A range of words; @code{-@var{y}} Abbreviates @code{0-@var{y}}.
|
||||
A range of words; @code{-@var{y}} abbreviates @code{0-@var{y}}.
|
||||
|
||||
@item *
|
||||
All of the words, excepting the zero'th. This is a synonym for @code{1-$}.
|
||||
It is not an error to use @key{*} if there is just one word in the event.
|
||||
The empty string is returned in that case.
|
||||
All of the words, except the @code{0}th. This is a synonym for @code{1-$}.
|
||||
It is not an error to use @key{*} if there is just one word in the event;
|
||||
the empty string is returned in that case.
|
||||
|
||||
@item x*
|
||||
Abbreviates @code{x-$}
|
||||
|
||||
@item x-
|
||||
Abbreviates @code{x-$} like @code{x*}, but omits the last word.
|
||||
|
||||
@end table
|
||||
|
||||
@ -139,11 +153,6 @@ of the following modifiers, each preceded by a @key{:}.
|
||||
|
||||
@table @code
|
||||
|
||||
@item #
|
||||
The entire command line typed so far. This means the current command,
|
||||
not the previous command, so it really isn't a word designator, and doesn't
|
||||
belong in this section.
|
||||
|
||||
@item h
|
||||
Remove a trailing pathname component, leaving only the head.
|
||||
|
||||
@ -151,11 +160,38 @@ Remove a trailing pathname component, leaving only the head.
|
||||
Remove a trailing suffix of the form @samp{.}@var{suffix}, leaving the basename.
|
||||
|
||||
@item e
|
||||
Remove all but the suffix.
|
||||
Remove all but the trailing suffix.
|
||||
|
||||
@item t
|
||||
Remove all leading pathname components, leaving the tail.
|
||||
|
||||
@item p
|
||||
Print the new command but do not execute it.
|
||||
|
||||
@ifset BashFeatures
|
||||
@item q
|
||||
Quote the substituted words, escaping further substitutions.
|
||||
|
||||
@item x
|
||||
Quote the substituted words as with @code{q},
|
||||
but break into words at spaces, tabs, and newlines.
|
||||
@end ifset
|
||||
|
||||
@item s/old/new/
|
||||
Substitute @var{new} for the first occurrence of @var{old} in the
|
||||
event line. Any delimiter may be used in place of @key{/}.
|
||||
The delimiter may be quoted in @var{old} and @var{new}
|
||||
with a single backslash. If @key{&} appears in @var{new},
|
||||
it is replaced by @var{old}. A single backslash will quote
|
||||
the @key{&}. The final delimiter is optional if it is the last
|
||||
character on the input line.
|
||||
|
||||
@item &
|
||||
Repeat the previous substitution.
|
||||
|
||||
@item g
|
||||
Cause changes to be applied over the entire event line. Used in
|
||||
conjunction with @code{s}, as in @code{gs/old/new/}, or with
|
||||
@code{&}.
|
||||
|
||||
@end table
|
||||
|
@ -5,14 +5,14 @@
|
||||
|
||||
@ignore
|
||||
This file documents the end user interface to the GNU command line
|
||||
editing feautres. It is to be an appendix to manuals for programs which
|
||||
editing features. It is to be an appendix to manuals for programs which
|
||||
use these features. There is a document entitled "readline.texinfo"
|
||||
which contains both end-user and programmer documentation for the GNU
|
||||
Readline Library.
|
||||
|
||||
Copyright (C) 1988 Free Software Foundation, Inc.
|
||||
|
||||
Authored by Brian Fox.
|
||||
Authored by Brian Fox and Chet Ramey.
|
||||
|
||||
Permission is granted to process this file through Tex and print the
|
||||
results, provided the printed document carries copying permission notice
|
||||
@ -39,18 +39,23 @@ into another language, under the above conditions for modified versions.
|
||||
@node Command Line Editing
|
||||
@chapter Command Line Editing
|
||||
|
||||
This text describes GNU's command line editing interface.
|
||||
This chapter describes the basic features of the GNU
|
||||
command line editing interface.
|
||||
|
||||
@menu
|
||||
* Introduction and Notation:: Notation used in this text.
|
||||
* Readline Interaction:: The minimum set of commands for editing a line.
|
||||
* Readline Init File:: Customizing Readline from a user's view.
|
||||
* Bindable Readline Commands:: A description of most of the Readline commands
|
||||
available for binding
|
||||
* Readline vi Mode:: A short description of how to make Readline
|
||||
behave line the vi editor.
|
||||
@end menu
|
||||
|
||||
@node Introduction and Notation
|
||||
@section Introduction to Line Editing
|
||||
|
||||
The following paragraphs describe the notation we use to represent
|
||||
The following paragraphs describe the notation used to represent
|
||||
keystrokes.
|
||||
|
||||
The text @key{C-k} is read as `Control-K' and describes the character
|
||||
@ -97,19 +102,19 @@ regardless of the location of the cursor within the line.
|
||||
|
||||
In order to enter characters into the line, simply type them. The typed
|
||||
character appears where the cursor was, and then the cursor moves one
|
||||
space to the right. If you mistype a character, you can use @key{DEL} to
|
||||
back up, and delete the mistyped character.
|
||||
space to the right. If you mistype a character, you can use your
|
||||
erase character to back up and delete the mistyped character.
|
||||
|
||||
Sometimes you may miss typing a character that you wanted to type, and
|
||||
not notice your error until you have typed several other characters. In
|
||||
that case, you can type @key{C-b} to move the cursor to the left, and then
|
||||
correct your mistake. Aftwerwards, you can move the cursor to the right
|
||||
correct your mistake. Afterwards, you can move the cursor to the right
|
||||
with @key{C-f}.
|
||||
|
||||
When you add text in the middle of a line, you will notice that characters
|
||||
to the right of the cursor get `pushed over' to make room for the text
|
||||
to the right of the cursor are `pushed over' to make room for the text
|
||||
that you have inserted. Likewise, when you delete text behind the cursor,
|
||||
characters to the right of the cursor get `pulled back' to fill in the
|
||||
characters to the right of the cursor are `pulled back' to fill in the
|
||||
blank space created by the removal of the text. A list of the basic bare
|
||||
essentials for editing the text of an input line follows.
|
||||
|
||||
@ -123,7 +128,7 @@ Delete the character to the left of the cursor.
|
||||
@item @key{C-d}
|
||||
Delete the character underneath the cursor.
|
||||
@item @w{Printing characters}
|
||||
Insert itself into the line at the cursor.
|
||||
Insert the character into the line at the cursor.
|
||||
@item @key{C-_}
|
||||
Undo the last thing that you did. You can undo all the way back to an
|
||||
empty line.
|
||||
@ -160,11 +165,19 @@ operate on characters while meta keystrokes operate on words.
|
||||
@subsection Readline Killing Commands
|
||||
|
||||
@dfn{Killing} text means to delete the text from the line, but to save
|
||||
it away for later use, usually by @dfn{yanking} it back into the line.
|
||||
it away for later use, usually by @dfn{yanking} (re-inserting)
|
||||
it back into the line.
|
||||
If the description for a command says that it `kills' text, then you can
|
||||
be sure that you can get the text back in a different (or the same)
|
||||
place later.
|
||||
|
||||
When you use a kill command, the text is saved in a @dfn{kill-ring}.
|
||||
Any number of consecutive kills save all of the killed text together, so
|
||||
that when you yank it back, you get it all. The kill
|
||||
ring is not line specific; the text that you killed on a previously
|
||||
typed line is available to be yanked back later, when you are typing
|
||||
another line.
|
||||
|
||||
Here is the list of commands for killing text.
|
||||
|
||||
@table @key
|
||||
@ -186,7 +199,7 @@ Kill from the cursor to the previous whitespace. This is different than
|
||||
@end table
|
||||
|
||||
And, here is how to @dfn{yank} the text back into the line. Yanking
|
||||
is
|
||||
means to copy the most-recently-killed text from the kill buffer.
|
||||
|
||||
@table @key
|
||||
@item C-y
|
||||
@ -197,13 +210,6 @@ Rotate the kill-ring, and yank the new top. You can only do this if
|
||||
the prior command is @key{C-y} or @key{M-y}.
|
||||
@end table
|
||||
|
||||
When you use a kill command, the text is saved in a @dfn{kill-ring}.
|
||||
Any number of consecutive kills save all of the killed text together, so
|
||||
that when you yank it back, you get it in one clean sweep. The kill
|
||||
ring is not line specific; the text that you killed on a previously
|
||||
typed line is available to be yanked back later, when you are typing
|
||||
another line.
|
||||
|
||||
@node Readline Arguments
|
||||
@subsection Readline Arguments
|
||||
|
||||
@ -226,81 +232,155 @@ the @key{C-d} command an argument of 10, you could type @key{M-1 0 C-d}.
|
||||
@section Readline Init File
|
||||
|
||||
Although the Readline library comes with a set of Emacs-like
|
||||
keybindings, it is possible that you would like to use a different set
|
||||
keybindings installed by default,
|
||||
it is possible that you would like to use a different set
|
||||
of keybindings. You can customize programs that use Readline by putting
|
||||
commands in an @dfn{init} file in your home directory. The name of this
|
||||
file is @file{~/.inputrc}.
|
||||
file is taken from the value of the shell variable @code{INPUTRC}. If
|
||||
that variable is unset, the default is @file{~/.inputrc}.
|
||||
|
||||
When a program which uses the Readline library starts up, the
|
||||
@file{~/.inputrc} file is read, and the keybindings are set.
|
||||
init file is read, and the key bindings are set.
|
||||
|
||||
In addition, the @code{C-x C-r} command re-reads this init file, thus
|
||||
incorporating any changes that you might have made to it.
|
||||
|
||||
@menu
|
||||
* Readline Init Syntax:: Syntax for the commands in @file{~/.inputrc}.
|
||||
* Readline Vi Mode:: Switching to @code{vi} mode in Readline.
|
||||
* Readline Init Syntax:: Syntax for the commands in the inputrc file.
|
||||
* Conditional Init Constructs:: Conditional key bindings in the inputrc file.
|
||||
@end menu
|
||||
|
||||
@node Readline Init Syntax
|
||||
@subsection Readline Init Syntax
|
||||
|
||||
There are only four constructs allowed in the @file{~/.inputrc}
|
||||
file:
|
||||
There are only a few basic constructs allowed in the
|
||||
Readline init file. Blank lines are ignored.
|
||||
Lines beginning with a @key{#} are comments.
|
||||
Lines beginning with a @key{$} indicate conditional
|
||||
constructs (@pxref{Conditional Init Constructs}). Other lines
|
||||
denote variable settings and key bindings.
|
||||
|
||||
@table @asis
|
||||
@item Variable Settings
|
||||
You can change the state of a few variables in Readline. You do this by
|
||||
You can change the state of a few variables in Readline by
|
||||
using the @code{set} command within the init file. Here is how you
|
||||
would specify that you wish to use Vi line editing commands:
|
||||
would specify that you wish to use @code{vi} line editing commands:
|
||||
|
||||
@example
|
||||
set editing-mode vi
|
||||
@end example
|
||||
|
||||
Right now, there are only a few variables which can be set; so few in
|
||||
fact, that we just iterate them here:
|
||||
Right now, there are only a few variables which can be set;
|
||||
so few, in fact, that we just list them here:
|
||||
|
||||
@table @code
|
||||
|
||||
@item editing-mode
|
||||
@vindex editing-mode
|
||||
The @code{editing-mode} variable controls which editing mode you are
|
||||
using. By default, GNU Readline starts up in Emacs editing mode, where
|
||||
the keystrokes are most similar to Emacs. This variable can either be
|
||||
set to @code{emacs} or @code{vi}.
|
||||
using. By default, Readline starts up in Emacs editing mode, where
|
||||
the keystrokes are most similar to Emacs. This variable can be
|
||||
set to either @code{emacs} or @code{vi}.
|
||||
|
||||
@item horizontal-scroll-mode
|
||||
@vindex horizontal-scroll-mode
|
||||
This variable can either be set to @code{On} or @code{Off}. Setting it
|
||||
This variable can be set to either @code{On} or @code{Off}. Setting it
|
||||
to @code{On} means that the text of the lines that you edit will scroll
|
||||
horizontally on a single screen line when they are larger than the width
|
||||
horizontally on a single screen line when they are longer than the width
|
||||
of the screen, instead of wrapping onto a new screen line. By default,
|
||||
this variable is set to @code{Off}.
|
||||
|
||||
@item mark-modified-lines
|
||||
@vindex mark-modified-lines
|
||||
This variable when set to @code{On}, says to display an asterisk
|
||||
(@samp{*}) at the starts of history lines which have been modified.
|
||||
This variable is off by default.
|
||||
This variable, when set to @code{On}, says to display an asterisk
|
||||
(@samp{*}) at the start of history lines which have been modified.
|
||||
This variable is @code{off} by default.
|
||||
|
||||
@item bell-style
|
||||
@vindex bell-style
|
||||
Controls what happens when Readline wants to ring the terminal bell.
|
||||
If set to @code{none}, Readline never rings the bell. If set to
|
||||
@code{visible}, Readline uses a visible bell if one is available.
|
||||
If set to @code{audible} (the default), Readline attempts to ring
|
||||
the terminal's bell.
|
||||
|
||||
@item comment-begin
|
||||
@vindex comment-begin
|
||||
The string to insert at the beginning of the line when the
|
||||
@code{vi-comment} command is executed. The default value
|
||||
is @code{"#"}.
|
||||
|
||||
@item meta-flag
|
||||
@vindex meta-flag
|
||||
If set to @code{on}, Readline will enable eight-bit input (it
|
||||
will not strip the eighth bit from the characters it reads),
|
||||
regardless of what the terminal claims it can support. The
|
||||
default value is @code{off}.
|
||||
|
||||
@item convert-meta
|
||||
@vindex convert-meta
|
||||
If set to @code{on}, Readline will convert characters with the
|
||||
eigth bit set to an ASCII key sequence by stripping the eigth
|
||||
bit and prepending an @key{ESC} character, converting them to a
|
||||
meta-prefixed key sequence. The default value is @code{on}.
|
||||
|
||||
@item output-meta
|
||||
@vindex output-meta
|
||||
If set to @code{on}, Readline will display characters with the
|
||||
eighth bit set directly rather than as a meta-prefixed escape
|
||||
sequence. The default is @code{off}.
|
||||
|
||||
@item completion-query-items
|
||||
@vindex completion-query-items
|
||||
The number of possible completions that determines when the user is
|
||||
asked whether he wants to see the list of possibilities. If the
|
||||
number of possible completions is greater than this value,
|
||||
Readline will ask the user whether or not he wishes to view
|
||||
them; otherwise, they are simply listed. The default limit is
|
||||
@code{100}.
|
||||
|
||||
@item keymap
|
||||
@vindex keymap
|
||||
Sets Readline's idea of the current keymap for key binding commands.
|
||||
Acceptable @code{keymap} names are
|
||||
@code{emacs},
|
||||
@code{emacs-standard},
|
||||
@code{emacs-meta},
|
||||
@code{emacs-ctlx},
|
||||
@code{vi},
|
||||
@code{vi-move},
|
||||
@code{vi-command}, and
|
||||
@code{vi-insert}.
|
||||
@code{vi} is equivalent to @code{vi-command}; @code{emacs} is
|
||||
equivalent to @code{emacs-standard}. The default value is @code{emacs}.
|
||||
The value of the @code{editing-mode} variable also affects the
|
||||
default keymap.
|
||||
|
||||
@item show-all-if-ambiguous
|
||||
@vindex show-all-if-ambiguous
|
||||
This alters the default behavior of the completion functions. If
|
||||
set to @code{on},
|
||||
words which have more than one possible completion cause the
|
||||
matches to be listed immediately instead of ringing the bell.
|
||||
The default value is @code{off}.
|
||||
|
||||
@item expand-tilde
|
||||
@vindex expand-tilde
|
||||
If set to @code{on}, tilde expansion is performed when Readline
|
||||
attempts word completion. The default is @code{off}.
|
||||
|
||||
@item prefer-visible-bell
|
||||
@vindex prefer-visible-bell
|
||||
If this variable is set to @code{On} it means to use a visible bell if
|
||||
one is available, rather than simply ringing the terminal bell. By
|
||||
default, the value is @code{Off}.
|
||||
@end table
|
||||
|
||||
@item Key Bindings
|
||||
The syntax for controlling keybindings in the @file{~/.inputrc} file is
|
||||
simple. First you have to know the @i{name} of the command that you
|
||||
The syntax for controlling key bindings in the init file is
|
||||
simple. First you have to know the name of the command that you
|
||||
want to change. The following pages contain tables of the command name,
|
||||
the default keybinding, and a short description of what the command
|
||||
does.
|
||||
|
||||
Once you know the name of the command, simply place the name of the key
|
||||
you wish to bind the command to, a colon, and then the name of the
|
||||
command on a line in the @file{~/.inputrc} file. The name of the key
|
||||
command on a line in the init file. The name of the key
|
||||
can be expressed in different ways, depending on which is most
|
||||
comfortable for you.
|
||||
|
||||
@ -319,10 +399,11 @@ expressed on the right hand side (that is, to insert the text
|
||||
@samp{>&output} into the line).
|
||||
|
||||
@item @w{"@var{keyseq}": @var{function-name} or @var{macro}}
|
||||
@var{keyseq} differs from @var{keyname} above in that strings denoting
|
||||
an entire key sequence can be specified. Simply place the key sequence
|
||||
in double quotes. GNU Emacs style key escapes can be used, as in the
|
||||
following example:
|
||||
@var{keyseq} differs from @var{keyname} above in that strings
|
||||
denoting an entire key sequence can be specified, by placing
|
||||
the key sequence in double quotes. Some GNU Emacs style key
|
||||
escapes can be used, as in the following example, but the
|
||||
special character names are not recognized.
|
||||
|
||||
@example
|
||||
"\C-u": universal-argument
|
||||
@ -334,10 +415,98 @@ In the above example, @samp{C-u} is bound to the function
|
||||
@code{universal-argument} (just as it was in the first example),
|
||||
@samp{C-x C-r} is bound to the function @code{re-read-init-file}, and
|
||||
@samp{ESC [ 1 1 ~} is bound to insert the text @samp{Function Key 1}.
|
||||
The following escape sequences are available when specifying key
|
||||
sequences:
|
||||
|
||||
@table @code
|
||||
@item @kbd{\C-}
|
||||
control prefix
|
||||
@item @kbd{\M-}
|
||||
meta prefix
|
||||
@item @kbd{\e}
|
||||
an escape character
|
||||
@item @kbd{\\}
|
||||
backslash
|
||||
@item @kbd{\"}
|
||||
@key{"}
|
||||
@item @kbd{\'}
|
||||
@key{'}
|
||||
@end table
|
||||
|
||||
When entering the text of a macro, single or double quotes should
|
||||
be used to indicate a macro definition. Unquoted text
|
||||
is assumed to be a function name. Backslash
|
||||
will quote any character in the macro text, including @key{"}
|
||||
and @key{'}.
|
||||
For example, the following binding will make @kbd{C-x \}
|
||||
insert a single @key{\} into the line:
|
||||
@example
|
||||
"\C-x\\": "\\"
|
||||
@end example
|
||||
|
||||
@end table
|
||||
@end table
|
||||
|
||||
@node Conditional Init Constructs
|
||||
@subsection Conditional Init Constructs
|
||||
|
||||
Readline implements a facility similar in spirit to the conditional
|
||||
compilation features of the C preprocessor which allows key
|
||||
bindings and variable settings to be performed as the result
|
||||
of tests. There are three parser directives used.
|
||||
|
||||
@ftable @code
|
||||
@item $if
|
||||
The @code{$if} construct allows bindings to be made based on the
|
||||
editing mode, the terminal being used, or the application using
|
||||
Readline. The text of the test extends to the end of the line;
|
||||
no characters are required to isolate it.
|
||||
|
||||
@table @code
|
||||
@item mode
|
||||
The @code{mode=} form of the @code{$if} directive is used to test
|
||||
whether Readline is in @code{emacs} or @code{vi} mode.
|
||||
This may be used in conjunction
|
||||
with the @samp{set keymap} command, for instance, to set bindings in
|
||||
the @code{emacs-standard} and @code{emacs-ctlx} keymaps only if
|
||||
Readline is starting out in @code{emacs} mode.
|
||||
|
||||
@item term
|
||||
The @code{term=} form may be used to include terminal-specific
|
||||
key bindings, perhaps to bind the key sequences output by the
|
||||
terminal's function keys. The word on the right side of the
|
||||
@samp{=} is tested against the full name of the terminal and the
|
||||
portion of the terminal name before the first @samp{-}. This
|
||||
allows @var{sun} to match both @var{sun} and @var{sun-cmd},
|
||||
for instance.
|
||||
|
||||
@item application
|
||||
The @var{application} construct is used to include
|
||||
application-specific settings. Each program using the Readline
|
||||
library sets the @var{application name}, and you can test for it.
|
||||
This could be used to bind key sequences to functions useful for
|
||||
a specific program. For instance, the following command adds a
|
||||
key sequence that quotes the current or previous word in Bash:
|
||||
@example
|
||||
$if bash
|
||||
# Quote the current or previous word
|
||||
"\C-xq": "\eb\"\ef\""
|
||||
$endif
|
||||
@end example
|
||||
@end table
|
||||
|
||||
@item $endif
|
||||
This command, as you saw in the previous example, terminates an
|
||||
@code{$if} command.
|
||||
|
||||
@item $else
|
||||
Commands in this branch of the @code{$if} directive are executed if
|
||||
the test fails.
|
||||
@end ftable
|
||||
|
||||
@node Bindable Readline Commands
|
||||
@section Bindable Readline Commands
|
||||
|
||||
@menu
|
||||
* Commands For Moving:: Moving about the line.
|
||||
* Commands For History:: Getting at previous lines.
|
||||
@ -345,11 +514,12 @@ In the above example, @samp{C-u} is bound to the function
|
||||
* Commands For Killing:: Commands for killing and yanking.
|
||||
* Numeric Arguments:: Specifying numeric arguments, repeat counts.
|
||||
* Commands For Completion:: Getting Readline to do the typing for you.
|
||||
* Miscellaneous Commands:: Other miscillaneous commands.
|
||||
* Keyboard Macros:: Saving and re-executing typed characters
|
||||
* Miscellaneous Commands:: Other miscellaneous commands.
|
||||
@end menu
|
||||
|
||||
@node Commands For Moving
|
||||
@subsubsection Commands For Moving
|
||||
@subsection Commands For Moving
|
||||
@ftable @code
|
||||
@item beginning-of-line (C-a)
|
||||
Move to the start of the current line.
|
||||
@ -364,24 +534,38 @@ Move forward a character.
|
||||
Move back a character.
|
||||
|
||||
@item forward-word (M-f)
|
||||
Move forward to the end of the next word.
|
||||
Move forward to the end of the next word. Words are composed of
|
||||
letters and digits.
|
||||
|
||||
@item backward-word (M-b)
|
||||
Move back to the start of this, or the previous, word.
|
||||
Move back to the start of this, or the previous, word. Words are
|
||||
composed of letters and digits.
|
||||
|
||||
@item clear-screen (C-l)
|
||||
Clear the screen leaving the current line at the top of the screen.
|
||||
Clear the screen and redraw the current line,
|
||||
leaving the current line at the top of the screen.
|
||||
|
||||
@item redraw-current-line ()
|
||||
Refresh the current line. By default, this is unbound.
|
||||
|
||||
@end ftable
|
||||
|
||||
@node Commands For History
|
||||
@subsubsection Commands For Manipulating The History
|
||||
@subsection Commands For Manipulating The History
|
||||
|
||||
@ftable @code
|
||||
@item accept-line (Newline, Return)
|
||||
@ifset BashFeatures
|
||||
Accept the line regardless of where the cursor is. If this line is
|
||||
non-empty, add it to the history list according to the setting of
|
||||
the @code{HISTCONTROL} variable. If this line was a history
|
||||
line, then restore the history line to its original state.
|
||||
@end ifset
|
||||
@ifclear BashFeatures
|
||||
Accept the line regardless of where the cursor is. If this line is
|
||||
non-empty, add it to the history list. If this line was a history
|
||||
line, then restore the history line to its original state.
|
||||
@end ifclear
|
||||
|
||||
@item previous-history (C-p)
|
||||
Move `up' through the history list.
|
||||
@ -393,7 +577,7 @@ Move `down' through the history list.
|
||||
Move to the first line in the history.
|
||||
|
||||
@item end-of-history (M->)
|
||||
Move to the end of the input history, i.e., the line you are entering!
|
||||
Move to the end of the input history, i.e., the line you are entering.
|
||||
|
||||
@item reverse-search-history (C-r)
|
||||
Search backward starting at the current line and moving `up' through
|
||||
@ -401,17 +585,44 @@ the history as necessary. This is an incremental search.
|
||||
|
||||
@item forward-search-history (C-s)
|
||||
Search forward starting at the current line and moving `down' through
|
||||
the the history as neccessary.
|
||||
the the history as necessary. This is an incremental search.
|
||||
|
||||
@item non-incremental-reverse-search-history (M-p)
|
||||
Search backward starting at the current line and moving `up'
|
||||
through the history as necessary using a non-incremental search
|
||||
for a string supplied by the user.
|
||||
|
||||
@item non-incremental-forward-search-history (M-n)
|
||||
Search forward starting at the current line and moving `down'
|
||||
through the the history as necessary using a non-incremental search
|
||||
for a string supplied by the user.
|
||||
|
||||
@item history-search-forward ()
|
||||
Search forward through the history for the string of characters
|
||||
between the start of the current line and the current point. This
|
||||
is a non-incremental search. By default, this command is unbound.
|
||||
|
||||
@item history-search-backward ()
|
||||
Search backward through the history for the string of characters
|
||||
between the start of the current line and the current point. This
|
||||
is a non-incremental search. By default, this command is unbound.
|
||||
|
||||
@item yank-nth-arg (M-C-y)
|
||||
Insert the first argument to the previous command (usually
|
||||
the second word on the previous line). With an argument @var{n},
|
||||
insert the @var{n}th word from the previous command (the words
|
||||
in the previous command begin with word 0). A negative argument
|
||||
inserts the @var{n}th word from the end of the previous command.
|
||||
|
||||
@end ftable
|
||||
|
||||
@node Commands For Text
|
||||
@subsubsection Commands For Changing Text
|
||||
@subsection Commands For Changing Text
|
||||
|
||||
@ftable @code
|
||||
@item delete-char (C-d)
|
||||
Delete the character under the cursor. If the cursor is at the
|
||||
beginning of the line, and there are no characters in the line, and
|
||||
beginning of the line, there are no characters in the line, and
|
||||
the last character typed was not C-d, then return EOF.
|
||||
|
||||
@item backward-delete-char (Rubout)
|
||||
@ -420,7 +631,7 @@ the characters instead of deleting them.
|
||||
|
||||
@item quoted-insert (C-q, C-v)
|
||||
Add the next character that you type to the line verbatim. This is
|
||||
how to insert things like C-q for example.
|
||||
how to insert key sequences like @key{C-q}, for example.
|
||||
|
||||
@item tab-insert (M-TAB)
|
||||
Insert a tab character.
|
||||
@ -429,9 +640,12 @@ Insert a tab character.
|
||||
Insert yourself.
|
||||
|
||||
@item transpose-chars (C-t)
|
||||
Drag the character before point forward over the character at point.
|
||||
Point moves forward as well. If point is at the end of the line, then
|
||||
transpose the two characters before point. Negative args don't work.
|
||||
Drag the character before the cursor forward over
|
||||
the character at the cursor, moving the
|
||||
cursor forward as well. If the insertion point
|
||||
is at the end of the line, then this
|
||||
transposes the last two characters of the line.
|
||||
Negative argumentss don't work.
|
||||
|
||||
@item transpose-words (M-t)
|
||||
Drag the word behind the cursor past the word in front of the cursor
|
||||
@ -439,47 +653,56 @@ moving the cursor over that word as well.
|
||||
|
||||
@item upcase-word (M-u)
|
||||
Uppercase the current (or following) word. With a negative argument,
|
||||
do the previous word, but do not move point.
|
||||
do the previous word, but do not move the cursor.
|
||||
|
||||
@item downcase-word (M-l)
|
||||
Lowercase the current (or following) word. With a negative argument,
|
||||
do the previous word, but do not move point.
|
||||
do the previous word, but do not move the cursor.
|
||||
|
||||
@item capitalize-word (M-c)
|
||||
Uppercase the current (or following) word. With a negative argument,
|
||||
do the previous word, but do not move point.
|
||||
Capitalize the current (or following) word. With a negative argument,
|
||||
do the previous word, but do not move the cursor.
|
||||
|
||||
@end ftable
|
||||
|
||||
@node Commands For Killing
|
||||
@subsubsection Killing And Yanking
|
||||
@subsection Killing And Yanking
|
||||
|
||||
@ftable @code
|
||||
|
||||
@item kill-line (C-k)
|
||||
Kill the text from the current cursor position to the end of the line.
|
||||
|
||||
@item backward-kill-line ()
|
||||
Kill backward to the beginning of the line. This is normally unbound.
|
||||
@item backward-kill-line (C-x Rubout)
|
||||
Kill backward to the beginning of the line.
|
||||
|
||||
@item unix-line-discard (C-u)
|
||||
Kill backward from the cursor to the beginning of the current line.
|
||||
Save the killed text on the kill-ring.
|
||||
|
||||
@item kill-whole-line ()
|
||||
Kill all characters on the current line, no matter where the
|
||||
cursor is. By default, this is unbound.
|
||||
|
||||
@item kill-word (M-d)
|
||||
Kill from the cursor to the end of the current word, or if between
|
||||
words, to the end of the next word.
|
||||
words, to the end of the next word. Word boundaries are the same
|
||||
as @code{forward-word}.
|
||||
|
||||
@item backward-kill-word (M-DEL)
|
||||
Kill the word behind the cursor.
|
||||
|
||||
@item unix-line-discard (C-u)
|
||||
Do what C-u used to do in Unix line input. We save the killed text on
|
||||
the kill-ring, though.
|
||||
Kill the word behind the cursor. Word boundaries are the same
|
||||
as @code{backward-word}.
|
||||
|
||||
@item unix-word-rubout (C-w)
|
||||
Do what C-w used to do in Unix line input. The killed text is saved
|
||||
on the kill-ring. This is different than backward-kill-word because
|
||||
the word boundaries differ.
|
||||
Kill the word behind the cursor, using white space as a word
|
||||
boundary. The killed text is saved on the kill-ring.
|
||||
|
||||
@item delete-horizontal-space ()
|
||||
Delete all spaces and tabs around point. By default, this is unbound.
|
||||
|
||||
@item yank (C-y)
|
||||
Yank the top of the kill ring into the buffer at point.
|
||||
Yank the top of the kill ring into the buffer at the current
|
||||
cursor position.
|
||||
|
||||
@item yank-pop (M-y)
|
||||
Rotate the kill-ring, and yank the new top. You can only do this if
|
||||
@ -487,7 +710,7 @@ the prior command is yank or yank-pop.
|
||||
@end ftable
|
||||
|
||||
@node Numeric Arguments
|
||||
@subsubsection Specifying Numeric Arguments
|
||||
@subsection Specifying Numeric Arguments
|
||||
@ftable @code
|
||||
|
||||
@item digit-argument (M-0, M-1, ... M--)
|
||||
@ -495,64 +718,148 @@ Add this digit to the argument already accumulating, or start a new
|
||||
argument. M-- starts a negative argument.
|
||||
|
||||
@item universal-argument ()
|
||||
Do what C-u does in emacs. By default, this is not bound.
|
||||
Each time this is executed, the argument count is multiplied by four.
|
||||
The argument count is initially one, so executing this function the
|
||||
first time makes the argument count four. By default, this is not
|
||||
bound to a key.
|
||||
@end ftable
|
||||
|
||||
|
||||
@node Commands For Completion
|
||||
@subsubsection Letting Readline Type For You
|
||||
@subsection Letting Readline Type For You
|
||||
|
||||
@ftable @code
|
||||
@item complete (TAB)
|
||||
Attempt to do completion on the text before point. This is
|
||||
Attempt to do completion on the text before the cursor. This is
|
||||
implementation defined. Generally, if you are typing a filename
|
||||
argument, you can do filename completion; if you are typing a command,
|
||||
you can do command completion, if you are typing in a symbol to GDB, you
|
||||
can do symbol name completion, if you are typing in a variable to Bash,
|
||||
you can do variable name completion...
|
||||
you can do variable name completion, and so on.
|
||||
@ifset BashFeatures
|
||||
See the Bash manual page for a complete list of available completion
|
||||
functions.
|
||||
@end ifset
|
||||
|
||||
@item possible-completions (M-?)
|
||||
List the possible completions of the text before point.
|
||||
List the possible completions of the text before the cursor.
|
||||
|
||||
@item insert-completions ()
|
||||
Insert all completions of the text before point that would have
|
||||
been generated by @code{possible-completions}. By default, this
|
||||
is not bound to a key.
|
||||
|
||||
@end ftable
|
||||
|
||||
@node Keyboard Macros
|
||||
@subsection Keyboard Macros
|
||||
@ftable @code
|
||||
|
||||
@item start-kbd-macro (C-x ()
|
||||
Begin saving the characters typed into the current keyboard macro.
|
||||
|
||||
@item end-kbd-macro (C-x ))
|
||||
Stop saving the characters typed into the current keyboard macro
|
||||
and save the definition.
|
||||
|
||||
@item call-last-kbd-macro (C-x e)
|
||||
Re-execute the last keyboard macro defined, by making the characters
|
||||
in the macro appear as if typed at the keyboard.
|
||||
|
||||
@end ftable
|
||||
|
||||
@node Miscellaneous Commands
|
||||
@subsubsection Some Miscellaneous Commands
|
||||
@subsection Some Miscellaneous Commands
|
||||
@ftable @code
|
||||
|
||||
@item re-read-init-file (C-x C-r)
|
||||
Read in the contents of your @file{~/.inputrc} file, and incorporate
|
||||
any bindings found there.
|
||||
Read in the contents of your init file, and incorporate
|
||||
any bindings or variable assignments found there.
|
||||
|
||||
@item abort (C-g)
|
||||
Ding! Stops things.
|
||||
Abort the current editing command and
|
||||
ring the terminal's bell (subject to the setting of
|
||||
@code{bell-style}).
|
||||
|
||||
@item do-uppercase-version (M-a, M-b, ...)
|
||||
Run the command that is bound to your uppercase brother.
|
||||
Run the command that is bound to the corresoponding uppercase
|
||||
character.
|
||||
|
||||
@item prefix-meta (ESC)
|
||||
Make the next character that you type be metafied. This is for people
|
||||
without a meta key. Typing @samp{ESC f} is equivalent to typing
|
||||
@samp{M-f}.
|
||||
|
||||
@item undo (C-_)
|
||||
@item undo (C-_, C-x C-u)
|
||||
Incremental undo, separately remembered for each line.
|
||||
|
||||
@item revert-line (M-r)
|
||||
Undo all changes made to this line. This is like typing the `undo'
|
||||
Undo all changes made to this line. This is like typing the @code{undo}
|
||||
command enough times to get back to the beginning.
|
||||
|
||||
@item tilde-expand (M-~)
|
||||
Perform tilde expansion on the current word.
|
||||
|
||||
@item dump-functions ()
|
||||
Print all of the functions and their key bindings to the
|
||||
readline output stream. If a numeric argument is supplied,
|
||||
the output is formatted in such a way that it can be made part
|
||||
of an @var{inputrc} file.
|
||||
|
||||
@ifset BashFeatures
|
||||
@item display-shell-version (C-x C-v)
|
||||
Display version information about the current instance of Bash.
|
||||
|
||||
@item shell-expand-line (M-C-e)
|
||||
Expand the line the way the shell does when it reads it. This
|
||||
performs alias and history expansion as well as all of the shell
|
||||
word expansions.
|
||||
|
||||
@item history-expand-line (M-^)
|
||||
Perform history expansion on the current line.
|
||||
|
||||
@item insert-last-argument (M-., M-_)
|
||||
Insert the last argument to the previous command (the last word on
|
||||
the previous line). With an argument @var{n},
|
||||
insert the @var{n}th word from the previous command (the words
|
||||
in the previous command begin with word 0). A negative argument
|
||||
inserts the @var{n}th word from the end of the previous command.
|
||||
|
||||
@item operate-and-get-next (C-o)
|
||||
Accept the current line for execution and fetch the next line
|
||||
relative to the current line from the history for editing. Any
|
||||
argument is ignored.
|
||||
|
||||
@item emacs-editing-mode (C-e)
|
||||
When in @code{vi} editing mode, this causes a switch back to
|
||||
emacs editing mode, as if the command @code{set -o emacs} had
|
||||
been executed.
|
||||
|
||||
@end ifset
|
||||
|
||||
@end ftable
|
||||
|
||||
@node Readline Vi Mode
|
||||
@subsection Readline Vi Mode
|
||||
@node Readline vi Mode
|
||||
@section Readline vi Mode
|
||||
|
||||
While the Readline library does not have a full set of Vi editing
|
||||
functions, it does contain enough to allow simple editing of the line.
|
||||
While the Readline library does not have a full set of @code{vi}
|
||||
editing functions, it does contain enough to allow simple editing
|
||||
of the line. The Readline @code{vi} mode behaves as specified in
|
||||
the Posix 1003.2 standard.
|
||||
|
||||
In order to switch interactively between Emacs and Vi editing modes, use
|
||||
the command M-C-j (toggle-editing-mode).
|
||||
@ifset BashFeatures
|
||||
In order to switch interactively between @code{Emacs} and @code{Vi}
|
||||
editing modes, use the @code{set -o emacs} and @code{set -o vi}
|
||||
commands (@pxref{The Set Builtin}).
|
||||
@end ifset
|
||||
@ifclear BashFeatures
|
||||
In order to switch interactively between @code{Emacs} and @code{Vi}
|
||||
editing modes, use the command M-C-j (toggle-editing-mode).
|
||||
@end ifclear
|
||||
The Readline default is @code{emacs} mode.
|
||||
|
||||
When you enter a line in Vi mode, you are already placed in `insertion'
|
||||
mode, as if you had typed an `i'. Pressing @key{ESC} switches you into
|
||||
`edit' mode, where you can edit the text of the line with the standard
|
||||
Vi movement keys, move to previous history lines with `k', and following
|
||||
lines with `j', and so forth.
|
||||
When you enter a line in @code{vi} mode, you are already placed in
|
||||
`insertion' mode, as if you had typed an @samp{i}. Pressing @key{ESC}
|
||||
switches you into `command' mode, where you can edit the text of the
|
||||
line with the standard @code{vi} movement keys, move to previous
|
||||
history lines with @samp{k}, and following lines with @samp{j}, and
|
||||
so forth.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -322,7 +322,7 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter y with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter thorn (Icelandic) */
|
||||
{ ISFUNC, rl_insert } /* Latin small letter y with diaeresis */
|
||||
#endif /* MEYMAP_SIZE > 128 */
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
||||
KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
|
||||
@ -336,7 +336,7 @@ KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-Control-e */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-Control-f */
|
||||
{ ISFUNC, rl_abort }, /* Meta-Control-g */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-Control-h */
|
||||
{ ISFUNC, rl_backward_kill_word }, /* Meta-Control-h */
|
||||
{ ISFUNC, rl_tab_insert }, /* Meta-Control-i */
|
||||
{ ISFUNC, rl_vi_editing_mode }, /* Meta-Control-j */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-Control-k */
|
||||
@ -356,7 +356,7 @@ KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
|
||||
{ ISFUNC, rl_yank_nth_arg }, /* Meta-Control-y */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-Control-z */
|
||||
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-Control-[ */
|
||||
{ ISFUNC, rl_complete }, /* Meta-Control-[ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-Control-\ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-Control-] */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-Control-^ */
|
||||
@ -469,7 +469,7 @@ KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-{ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-| */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-} */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-~ */
|
||||
{ ISFUNC, rl_tilde_expand }, /* Meta-~ */
|
||||
{ ISFUNC, rl_backward_kill_word }, /* Meta-rubout */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
|
@ -36,6 +36,7 @@ extern char *xmalloc (), *xrealloc ();
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include "rlconf.h"
|
||||
#include "readline.h"
|
||||
|
||||
FUNMAP **funmap = (FUNMAP **)NULL;
|
||||
@ -68,18 +69,24 @@ static FUNMAP default_funmap[] = {
|
||||
{ "do-lowercase-version", rl_do_lowercase_version },
|
||||
{ "downcase-word", rl_downcase_word },
|
||||
{ "dump-functions", rl_dump_functions },
|
||||
{ "emacs-editing-mode", rl_emacs_editing_mode },
|
||||
{ "end-kbd-macro", rl_end_kbd_macro },
|
||||
{ "end-of-history", rl_end_of_history },
|
||||
{ "end-of-line", rl_end_of_line },
|
||||
{ "forward-char", rl_forward },
|
||||
{ "forward-search-history", rl_forward_search_history },
|
||||
{ "forward-word", rl_forward_word },
|
||||
{ "history-search-backward", rl_history_search_backward },
|
||||
{ "history-search-forward", rl_history_search_forward },
|
||||
{ "insert-completions", rl_insert_completions },
|
||||
{ "kill-whole-line", rl_kill_full_line },
|
||||
{ "kill-line", rl_kill_line },
|
||||
{ "kill-word", rl_kill_word },
|
||||
{ "next-history", rl_get_next_history },
|
||||
{ "non-incremental-forward-search-history", rl_noninc_forward_search },
|
||||
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search },
|
||||
{ "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
|
||||
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
|
||||
{ "possible-completions", rl_possible_completions },
|
||||
{ "previous-history", rl_get_previous_history },
|
||||
{ "quoted-insert", rl_quoted_insert },
|
||||
@ -90,6 +97,7 @@ static FUNMAP default_funmap[] = {
|
||||
{ "self-insert", rl_insert },
|
||||
{ "start-kbd-macro", rl_start_kbd_macro },
|
||||
{ "tab-insert", rl_tab_insert },
|
||||
{ "tilde-expand", rl_tilde_expand },
|
||||
{ "transpose-chars", rl_transpose_chars },
|
||||
{ "transpose-words", rl_transpose_words },
|
||||
{ "undo", rl_undo_command },
|
||||
@ -102,7 +110,6 @@ static FUNMAP default_funmap[] = {
|
||||
{ "yank-pop", rl_yank_pop },
|
||||
|
||||
#if defined (VI_MODE)
|
||||
|
||||
{ "vi-append-eol", rl_vi_append_eol },
|
||||
{ "vi-append-mode", rl_vi_append_mode },
|
||||
{ "vi-arg-digit", rl_vi_arg_digit },
|
||||
@ -135,10 +142,12 @@ static FUNMAP default_funmap[] = {
|
||||
{ "vi-overstrike-delete", rl_vi_overstrike_delete },
|
||||
{ "vi-prev-word", rl_vi_prev_word },
|
||||
{ "vi-put", rl_vi_put },
|
||||
{ "vi-redo", rl_vi_redo },
|
||||
{ "vi-replace", rl_vi_replace },
|
||||
{ "vi-search", rl_vi_search },
|
||||
{ "vi-search-again", rl_vi_search_again },
|
||||
{ "vi-subst", rl_vi_subst },
|
||||
{ "vi-tilde-expand", rl_vi_tilde_expand },
|
||||
{ "vi-yank-arg", rl_vi_yank_arg },
|
||||
{ "vi-yank-to", rl_vi_yank_to },
|
||||
|
||||
@ -163,6 +172,7 @@ rl_add_funmap_entry (name, function)
|
||||
funmap[funmap_entry]->function = function;
|
||||
|
||||
funmap[++funmap_entry] = (FUNMAP *)NULL;
|
||||
return funmap_entry;
|
||||
}
|
||||
|
||||
static int funmap_initialized = 0;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,27 +27,27 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# define alloca __builtin_alloca
|
||||
#else
|
||||
# if defined (sparc) || defined (HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "memalloc.h"
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
|
||||
#define STREQN(a, b, n) (((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
|
||||
|
||||
/* Variables imported from other files in the readline library. */
|
||||
extern Keymap _rl_keymap;
|
||||
extern HIST_ENTRY *saved_line_for_history;
|
||||
extern int rl_line_buffer_len;
|
||||
extern int rl_point, rl_end;
|
||||
extern char *rl_prompt, *rl_line_buffer;
|
||||
extern char *rl_line_buffer;
|
||||
|
||||
/* Remove these declarations when we have a complete libgnu.a. */
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
|
||||
static void rl_search_history ();
|
||||
static int rl_search_history ();
|
||||
|
||||
/* Last line found by the current incremental search, so we don't `find'
|
||||
identical lines many times in a row. */
|
||||
static char *prev_line_found;
|
||||
|
||||
/* Search backwards through the history looking for a string which is typed
|
||||
interactively. Start with the current line. */
|
||||
@ -55,7 +55,7 @@ rl_reverse_search_history (sign, key)
|
||||
int sign;
|
||||
int key;
|
||||
{
|
||||
rl_search_history (-sign, key);
|
||||
return (rl_search_history (-sign, key));
|
||||
}
|
||||
|
||||
/* Search forwards through the history looking for a string which is typed
|
||||
@ -64,7 +64,7 @@ rl_forward_search_history (sign, key)
|
||||
int sign;
|
||||
int key;
|
||||
{
|
||||
rl_search_history (sign, key);
|
||||
return (rl_search_history (sign, key));
|
||||
}
|
||||
|
||||
/* Display the current state of the search in the echo-area.
|
||||
@ -77,11 +77,9 @@ rl_display_search (search_string, reverse_p, where)
|
||||
char *search_string;
|
||||
int reverse_p, where;
|
||||
{
|
||||
char *message = (char *)NULL;
|
||||
|
||||
message =
|
||||
(char *)xmalloc (1 + (search_string ? strlen (search_string) : 0) + 30);
|
||||
char *message;
|
||||
|
||||
message = xmalloc (1 + (search_string ? strlen (search_string) : 0) + 30);
|
||||
*message = '\0';
|
||||
|
||||
#if defined (NOTDEF)
|
||||
@ -109,7 +107,7 @@ rl_display_search (search_string, reverse_p, where)
|
||||
This is analogous to i-search. We start the search in the current line.
|
||||
DIRECTION is which direction to search; >= 0 means forward, < 0 means
|
||||
backwards. */
|
||||
static void
|
||||
static int
|
||||
rl_search_history (direction, invoking_key)
|
||||
int direction;
|
||||
int invoking_key;
|
||||
@ -124,7 +122,7 @@ rl_search_history (direction, invoking_key)
|
||||
int search_string_size;
|
||||
|
||||
/* The list of lines to search through. */
|
||||
char **lines;
|
||||
char **lines, *allocated_line = (char *)NULL;
|
||||
|
||||
/* The length of LINES. */
|
||||
int hlen;
|
||||
@ -136,13 +134,13 @@ rl_search_history (direction, invoking_key)
|
||||
int orig_point = rl_point;
|
||||
int orig_line = where_history ();
|
||||
int last_found_line = orig_line;
|
||||
int c, done = 0;
|
||||
int c, done = 0, found, failed, sline_len;
|
||||
|
||||
/* The line currently being searched. */
|
||||
char *sline;
|
||||
|
||||
/* Offset in that line. */
|
||||
int index;
|
||||
int line_index;
|
||||
|
||||
/* Non-zero if we are doing a reverse search. */
|
||||
int reverse = (direction < 0);
|
||||
@ -154,21 +152,18 @@ rl_search_history (direction, invoking_key)
|
||||
|
||||
/* Allocate space for this many lines, +1 for the current input line,
|
||||
and remember those lines. */
|
||||
lines = (char **)alloca ((1 + (hlen = i)) * sizeof (char *));
|
||||
lines = (char **)xmalloc ((1 + (hlen = i)) * sizeof (char *));
|
||||
for (i = 0; i < hlen; i++)
|
||||
lines[i] = hlist[i]->line;
|
||||
|
||||
if (saved_line_for_history)
|
||||
lines[i] = saved_line_for_history->line;
|
||||
else
|
||||
/* So I have to type it in this way instead. */
|
||||
{
|
||||
char *alloced_line;
|
||||
|
||||
/* Keep that MIPS alloca () happy. */
|
||||
alloced_line = (char *)alloca (1 + strlen (rl_line_buffer));
|
||||
lines[i] = alloced_line;
|
||||
strcpy (lines[i], &rl_line_buffer[0]);
|
||||
/* Keep track of this so we can free it. */
|
||||
allocated_line = xmalloc (1 + strlen (rl_line_buffer));
|
||||
strcpy (allocated_line, &rl_line_buffer[0]);
|
||||
lines[i] = allocated_line;
|
||||
}
|
||||
|
||||
hlen++;
|
||||
@ -177,39 +172,37 @@ rl_search_history (direction, invoking_key)
|
||||
i = orig_line;
|
||||
|
||||
/* Initialize search parameters. */
|
||||
search_string = (char *)xmalloc (search_string_size = 128);
|
||||
search_string = xmalloc (search_string_size = 128);
|
||||
*search_string = '\0';
|
||||
search_string_index = 0;
|
||||
|
||||
/* Normalize DIRECTION into 1 or -1. */
|
||||
if (direction >= 0)
|
||||
direction = 1;
|
||||
else
|
||||
direction = -1;
|
||||
direction = (direction >= 0) ? 1 : -1;
|
||||
|
||||
rl_display_search (search_string, reverse, -1);
|
||||
|
||||
sline = rl_line_buffer;
|
||||
index = rl_point;
|
||||
sline_len = strlen (sline);
|
||||
line_index = rl_point;
|
||||
|
||||
found = failed = 0;
|
||||
while (!done)
|
||||
{
|
||||
Function *f = (Function *)NULL;
|
||||
|
||||
/* Read a key and decide how to proceed. */
|
||||
c = rl_read_key ();
|
||||
|
||||
/* Hack C to Do What I Mean. */
|
||||
{
|
||||
Function *f = (Function *)NULL;
|
||||
if (_rl_keymap[c].type == ISFUNC)
|
||||
{
|
||||
f = _rl_keymap[c].function;
|
||||
|
||||
if (_rl_keymap[c].type == ISFUNC)
|
||||
{
|
||||
f = _rl_keymap[c].function;
|
||||
|
||||
if (f == rl_reverse_search_history)
|
||||
c = reverse ? -1 : -2;
|
||||
else if (f == rl_forward_search_history)
|
||||
c = !reverse ? -1 : -2;
|
||||
}
|
||||
}
|
||||
if (f == rl_reverse_search_history)
|
||||
c = reverse ? -1 : -2;
|
||||
else if (f == rl_forward_search_history)
|
||||
c = !reverse ? -1 : -2;
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
@ -217,22 +210,36 @@ rl_search_history (direction, invoking_key)
|
||||
done = 1;
|
||||
continue;
|
||||
|
||||
/* case invoking_key: */
|
||||
case -1:
|
||||
goto search_again;
|
||||
if (!search_string_index)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
if (reverse)
|
||||
--line_index;
|
||||
else
|
||||
{
|
||||
if (line_index != sline_len)
|
||||
++line_index;
|
||||
else
|
||||
ding ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* switch directions */
|
||||
case -2:
|
||||
direction = -direction;
|
||||
reverse = (direction < 0);
|
||||
|
||||
goto do_search;
|
||||
break;
|
||||
|
||||
case CTRL ('G'):
|
||||
strcpy (rl_line_buffer, lines[orig_line]);
|
||||
rl_point = orig_point;
|
||||
rl_end = strlen (rl_line_buffer);
|
||||
rl_clear_message ();
|
||||
free (allocated_line);
|
||||
free (lines);
|
||||
return;
|
||||
|
||||
default:
|
||||
@ -244,134 +251,122 @@ rl_search_history (direction, invoking_key)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Add character to search string and continue search. */
|
||||
if (search_string_index + 2 >= search_string_size)
|
||||
search_string = (char *)xrealloc
|
||||
(search_string, (search_string_size += 128));
|
||||
{
|
||||
search_string_size += 128;
|
||||
search_string = xrealloc (search_string, search_string_size);
|
||||
}
|
||||
search_string[search_string_index++] = c;
|
||||
search_string[search_string_index] = '\0';
|
||||
goto do_search;
|
||||
|
||||
search_again:
|
||||
|
||||
if (!search_string_index)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
if (reverse)
|
||||
--index;
|
||||
else
|
||||
if (index != strlen (sline))
|
||||
++index;
|
||||
else
|
||||
ding ();
|
||||
}
|
||||
do_search:
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (reverse)
|
||||
{
|
||||
while (index >= 0)
|
||||
if (strncmp
|
||||
(search_string, sline + index, search_string_index)
|
||||
== 0)
|
||||
goto string_found;
|
||||
else
|
||||
index--;
|
||||
}
|
||||
else
|
||||
{
|
||||
register int limit =
|
||||
(strlen (sline) - search_string_index) + 1;
|
||||
|
||||
while (index < limit)
|
||||
{
|
||||
if (strncmp (search_string,
|
||||
sline + index,
|
||||
search_string_index) == 0)
|
||||
goto string_found;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
next_line:
|
||||
i += direction;
|
||||
|
||||
/* At limit for direction? */
|
||||
if ((reverse && i < 0) ||
|
||||
(!reverse && i == hlen))
|
||||
goto search_failed;
|
||||
|
||||
sline = lines[i];
|
||||
if (reverse)
|
||||
index = strlen (sline);
|
||||
else
|
||||
index = 0;
|
||||
|
||||
/* If the search string is longer than the current
|
||||
line, no match. */
|
||||
if (search_string_index > (int)strlen (sline))
|
||||
goto next_line;
|
||||
|
||||
/* Start actually searching. */
|
||||
if (reverse)
|
||||
index -= search_string_index;
|
||||
}
|
||||
|
||||
search_failed:
|
||||
/* We cannot find the search string. Ding the bell. */
|
||||
ding ();
|
||||
i = last_found_line;
|
||||
break;
|
||||
|
||||
string_found:
|
||||
/* We have found the search string. Just display it. But don't
|
||||
actually move there in the history list until the user accepts
|
||||
the location. */
|
||||
{
|
||||
int line_len;
|
||||
|
||||
line_len = strlen (lines[i]);
|
||||
|
||||
if (line_len >= rl_line_buffer_len)
|
||||
rl_extend_line_buffer (line_len);
|
||||
|
||||
strcpy (rl_line_buffer, lines[i]);
|
||||
rl_point = index;
|
||||
rl_end = line_len;
|
||||
last_found_line = i;
|
||||
rl_display_search
|
||||
(search_string, reverse, (i == orig_line) ? -1 : i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
found = failed = 0;
|
||||
while (1)
|
||||
{
|
||||
int limit = sline_len - search_string_index + 1;
|
||||
|
||||
/* Search the current line. */
|
||||
while (reverse ? (line_index >= 0) : (line_index < limit))
|
||||
{
|
||||
if (STREQN(search_string, sline + line_index, search_string_index))
|
||||
{
|
||||
found++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
line_index += reverse ? -1 : 1;
|
||||
}
|
||||
if (found)
|
||||
break;
|
||||
|
||||
/* Move to the next line, but skip new copies of the line
|
||||
we just found and lines shorter than the string we're
|
||||
searching for. */
|
||||
do
|
||||
{
|
||||
/* Move to the next line. */
|
||||
i += direction;
|
||||
|
||||
/* At limit for direction? */
|
||||
if ((reverse && i < 0) || (!reverse && i == hlen))
|
||||
{
|
||||
failed++;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We will need these later. */
|
||||
sline = lines[i];
|
||||
sline_len = strlen (sline);
|
||||
}
|
||||
while ((prev_line_found && STREQ (prev_line_found, lines[i])) ||
|
||||
(search_string_index > sline_len));
|
||||
|
||||
if (failed)
|
||||
break;
|
||||
|
||||
/* Now set up the line for searching... */
|
||||
if (reverse)
|
||||
line_index = sline_len - search_string_index;
|
||||
else
|
||||
line_index = 0;
|
||||
}
|
||||
|
||||
if (failed)
|
||||
{
|
||||
/* We cannot find the search string. Ding the bell. */
|
||||
ding ();
|
||||
i = last_found_line;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We have found the search string. Just display it. But don't
|
||||
actually move there in the history list until the user accepts
|
||||
the location. */
|
||||
if (found)
|
||||
{
|
||||
int line_len;
|
||||
|
||||
prev_line_found = lines[i];
|
||||
line_len = strlen (lines[i]);
|
||||
|
||||
if (line_len >= rl_line_buffer_len)
|
||||
rl_extend_line_buffer (line_len);
|
||||
|
||||
strcpy (rl_line_buffer, lines[i]);
|
||||
rl_point = line_index;
|
||||
rl_end = line_len;
|
||||
last_found_line = i;
|
||||
rl_display_search (search_string, reverse, (i == orig_line) ? -1 : i);
|
||||
}
|
||||
}
|
||||
|
||||
/* The searching is over. The user may have found the string that she
|
||||
was looking for, or else she may have exited a failing search. If
|
||||
INDEX is -1, then that shows that the string searched for was not
|
||||
found. We use this to determine where to place rl_point. */
|
||||
{
|
||||
int now = last_found_line;
|
||||
LINE_INDEX is -1, then that shows that the string searched for was
|
||||
not found. We use this to determine where to place rl_point. */
|
||||
|
||||
/* First put back the original state. */
|
||||
strcpy (rl_line_buffer, lines[orig_line]);
|
||||
/* First put back the original state. */
|
||||
strcpy (rl_line_buffer, lines[orig_line]);
|
||||
|
||||
/* Free the search string. */
|
||||
free (search_string);
|
||||
/* Free the search string. */
|
||||
free (search_string);
|
||||
|
||||
if (now < orig_line)
|
||||
rl_get_previous_history (orig_line - now);
|
||||
else
|
||||
rl_get_next_history (now - orig_line);
|
||||
if (last_found_line < orig_line)
|
||||
rl_get_previous_history (orig_line - last_found_line);
|
||||
else
|
||||
rl_get_next_history (last_found_line - orig_line);
|
||||
|
||||
/* If the index of the "matched" string is less than zero, then the
|
||||
final search string was never matched, so put point somewhere
|
||||
reasonable. */
|
||||
if (index < 0)
|
||||
index = strlen (rl_line_buffer);
|
||||
/* If the string was not found, put point at the end of the line. */
|
||||
if (line_index < 0)
|
||||
line_index = strlen (rl_line_buffer);
|
||||
rl_point = line_index;
|
||||
rl_clear_message ();
|
||||
|
||||
rl_point = index;
|
||||
rl_clear_message ();
|
||||
}
|
||||
free (allocated_line);
|
||||
free (lines);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include "rlconf.h"
|
||||
#include "keymaps.h"
|
||||
#include "emacs_keymap.c"
|
||||
|
||||
@ -32,6 +33,9 @@
|
||||
#include "vi_keymap.c"
|
||||
#endif
|
||||
|
||||
extern int rl_do_lowercase_version ();
|
||||
extern int rl_rubout (), rl_insert ();
|
||||
|
||||
#if defined (STATIC_MALLOC)
|
||||
static char *xmalloc (), *xrealloc ();
|
||||
#else
|
||||
@ -90,7 +94,6 @@ rl_copy_keymap (map)
|
||||
Keymap
|
||||
rl_make_keymap ()
|
||||
{
|
||||
extern int rl_insert (), rl_rubout ();
|
||||
register int i;
|
||||
Keymap newmap;
|
||||
|
||||
@ -118,6 +121,7 @@ rl_make_keymap ()
|
||||
}
|
||||
|
||||
/* Free the storage associated with MAP. */
|
||||
void
|
||||
rl_discard_keymap (map)
|
||||
Keymap (map);
|
||||
{
|
||||
|
56
gnu/lib/libreadline/memalloc.h
Normal file
56
gnu/lib/libreadline/memalloc.h
Normal file
@ -0,0 +1,56 @@
|
||||
/* memalloc.h -- consolidate code for including alloca.h or malloc.h and
|
||||
defining alloca. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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.
|
||||
|
||||
Bash 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with Bash; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if !defined (__MEMALLOC_H__)
|
||||
# define __MEMALLOC_H__
|
||||
|
||||
#if defined (sparc) && defined (sun) && !defined (HAVE_ALLOCA_H)
|
||||
# define HAVE_ALLOCA_H
|
||||
#endif
|
||||
|
||||
#if defined (__GNUC__) && !defined (HAVE_ALLOCA)
|
||||
# define HAVE_ALLOCA
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_ALLOCA_H) && !defined (HAVE_ALLOCA)
|
||||
# define HAVE_ALLOCA
|
||||
#endif /* HAVE_ALLOCA_H && !HAVE_ALLOCA */
|
||||
|
||||
#if !defined (BUILDING_MAKEFILE)
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# undef alloca
|
||||
# define alloca __builtin_alloca
|
||||
#else /* !__GNUC__ */
|
||||
# if defined (HAVE_ALLOCA_H)
|
||||
# if defined (IBMESA)
|
||||
# include <malloc.h>
|
||||
# else /* !IBMESA */
|
||||
# include <alloca.h>
|
||||
# endif /* !IBMESA */
|
||||
# else
|
||||
extern char *alloca ();
|
||||
# endif /* !HAVE_ALLOCA_H */
|
||||
#endif /* !__GNUC__ */
|
||||
|
||||
#endif /* !BUILDING_MAKEFILE */
|
||||
|
||||
#endif /* __MEMALLOC_H__ */
|
@ -27,6 +27,8 @@
|
||||
#endif
|
||||
#include "readline.h"
|
||||
|
||||
extern int rl_explicit_arg;
|
||||
|
||||
/* Non-zero means try to blink the matching open parenthesis when the
|
||||
close parenthesis is inserted. */
|
||||
#if defined (FD_SET)
|
||||
@ -40,8 +42,6 @@ static int find_matching_open ();
|
||||
rl_insert_close (count, invoking_key)
|
||||
int count, invoking_key;
|
||||
{
|
||||
extern int rl_explicit_arg;
|
||||
|
||||
if (rl_explicit_arg || !rl_blink_matching_paren)
|
||||
rl_insert (count, invoking_key);
|
||||
else
|
||||
@ -58,7 +58,7 @@ rl_insert_close (count, invoking_key)
|
||||
|
||||
/* Emacs might message or ring the bell here, but I don't. */
|
||||
if (match_point < 0)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
FD_ZERO (&readfds);
|
||||
FD_SET (fileno (rl_instream), &readfds);
|
||||
@ -74,6 +74,7 @@ rl_insert_close (count, invoking_key)
|
||||
rl_insert (count, invoking_key);
|
||||
#endif /* !FD_SET */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -32,19 +32,23 @@ extern char *xmalloc ();
|
||||
#define UNMETA(c) ((c) & (~meta_character_bit))
|
||||
#define UNCTRL(c) to_upper(((c)|control_character_bit))
|
||||
|
||||
#define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1)))
|
||||
#define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1)))
|
||||
#define lowercase_p(c) islower(c)
|
||||
#define uppercase_p(c) isupper(c)
|
||||
|
||||
#define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c))
|
||||
#define pure_alphabetic(c) isalpha(c)
|
||||
|
||||
#ifndef to_upper
|
||||
#define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c))
|
||||
#define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c))
|
||||
#define to_upper(c) toupper(c)
|
||||
#define to_lower(c) tolower(c)
|
||||
#endif
|
||||
|
||||
#define CTRL_P(c) ((c) < control_character_threshold)
|
||||
#define META_P(c) ((c) > meta_character_threshold)
|
||||
|
||||
#ifndef digit_value
|
||||
#define digit_value(x) ((x) - '0')
|
||||
#endif
|
||||
|
||||
#ifndef NEWLINE
|
||||
#define NEWLINE '\n'
|
||||
#endif
|
||||
@ -54,7 +58,7 @@ extern char *xmalloc ();
|
||||
#endif
|
||||
|
||||
#ifndef RUBOUT
|
||||
#define RUBOUT 0x07f
|
||||
#define RUBOUT 0x7f
|
||||
#endif
|
||||
|
||||
#ifndef TAB
|
||||
@ -74,7 +78,7 @@ extern char *xmalloc ();
|
||||
#ifdef SPACE
|
||||
#undef SPACE
|
||||
#endif
|
||||
#define SPACE 0x020
|
||||
#define SPACE 0x20
|
||||
|
||||
#ifdef ESC
|
||||
#undef ESC
|
||||
|
@ -125,6 +125,10 @@ extern int history_search ();
|
||||
error message. */
|
||||
extern int history_expand ();
|
||||
|
||||
/* Return an array of tokens, much as the shell might. The tokens are
|
||||
parsed out of STRING. */
|
||||
extern char **history_tokenize ();
|
||||
|
||||
/* Extract a string segment consisting of the FIRST through LAST
|
||||
arguments present in STRING. Arguments are broken up as in
|
||||
the shell. */
|
||||
@ -133,3 +137,13 @@ extern char *history_arg_extract ();
|
||||
/* Return the number of bytes that the primary history entries are using.
|
||||
This just adds up the lengths of the_history->lines. */
|
||||
extern int history_total_bytes ();
|
||||
|
||||
/* Exported history variables. */
|
||||
extern int history_stifled;
|
||||
extern int history_length;
|
||||
extern int max_input_history;
|
||||
extern char history_expansion_char;
|
||||
extern char history_subst_char;
|
||||
extern char history_comment_char;
|
||||
extern char *history_no_expand_chars;
|
||||
extern int history_base;
|
||||
|
@ -66,24 +66,26 @@ extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
|
||||
|
||||
/* Return a new, empty keymap.
|
||||
Free it with free() when you are done. */
|
||||
Keymap rl_make_bare_keymap ();
|
||||
extern Keymap rl_make_bare_keymap ();
|
||||
|
||||
/* Return a new keymap which is a copy of MAP. */
|
||||
Keymap rl_copy_keymap ();
|
||||
extern Keymap rl_copy_keymap ();
|
||||
|
||||
/* Return a new keymap with the printing characters bound to rl_insert,
|
||||
the lowercase Meta characters bound to run their equivalents, and
|
||||
the Meta digits bound to produce numeric arguments. */
|
||||
Keymap rl_make_keymap ();
|
||||
extern Keymap rl_make_keymap ();
|
||||
|
||||
extern void rl_discard_keymap ();
|
||||
|
||||
/* Return the keymap corresponding to a given name. Names look like
|
||||
`emacs' or `emacs-meta' or `vi-insert'. */
|
||||
Keymap rl_get_keymap_by_name ();
|
||||
extern Keymap rl_get_keymap_by_name ();
|
||||
|
||||
/* Return the current keymap. */
|
||||
Keymap rl_get_keymap ();
|
||||
extern Keymap rl_get_keymap ();
|
||||
|
||||
/* Set the current keymap to MAP. */
|
||||
void rl_set_keymap ();
|
||||
extern void rl_set_keymap ();
|
||||
|
||||
#endif /* _KEYMAPS_H_ */
|
||||
|
@ -24,6 +24,7 @@
|
||||
#define _READLINE_H_
|
||||
|
||||
#include <readline/keymaps.h>
|
||||
#include <readline/tilde.h>
|
||||
|
||||
/* The functions for manipulating the text of the line within readline.
|
||||
Most of these functions are bound to keys by default. */
|
||||
@ -38,13 +39,29 @@ extern int
|
||||
rl_forward_word (), rl_tab_insert (), rl_yank_pop (), rl_yank_nth_arg (),
|
||||
rl_backward_kill_word (), rl_backward_kill_line (), rl_transpose_words (),
|
||||
rl_complete (), rl_possible_completions (), rl_insert_completions (),
|
||||
rl_do_lowercase_version (),
|
||||
rl_do_lowercase_version (), rl_kill_full_line (),
|
||||
rl_digit_argument (), rl_universal_argument (), rl_abort (),
|
||||
rl_undo_command (), rl_revert_line (), rl_beginning_of_history (),
|
||||
rl_end_of_history (), rl_forward_search_history (), rl_insert (),
|
||||
rl_upcase_word (), rl_downcase_word (), rl_capitalize_word (),
|
||||
rl_restart_output (), rl_re_read_init_file (), rl_dump_functions (),
|
||||
rl_delete_horizontal_space ();
|
||||
rl_delete_horizontal_space (), rl_history_search_forward (),
|
||||
rl_history_search_backward ();
|
||||
|
||||
/* `Public' utility functions. */
|
||||
extern int rl_insert_text (), rl_delete_text (), rl_kill_text ();
|
||||
extern int rl_complete_internal ();
|
||||
extern int rl_expand_prompt ();
|
||||
extern int rl_initialize ();
|
||||
extern int rl_set_signals (), rl_clear_signals ();
|
||||
extern int rl_init_argument (), rl_digit_argument ();
|
||||
extern int rl_read_key (), rl_getc (), rl_stuff_char ();
|
||||
extern int maybe_save_line (), maybe_unsave_line (), maybe_replace_line ();
|
||||
extern int rl_modifying ();
|
||||
|
||||
extern int rl_begin_undo_group (), rl_end_undo_group ();
|
||||
extern void rl_add_undo (), free_undo_list ();
|
||||
extern int rl_do_undo ();
|
||||
|
||||
extern int rl_insert_close ();
|
||||
|
||||
@ -57,6 +74,7 @@ extern int
|
||||
rl_noninc_forward_search_again (), rl_noninc_reverse_search_again ();
|
||||
|
||||
/* Things for vi mode. */
|
||||
extern int rl_vi_check (), rl_vi_textmod_command ();
|
||||
extern int
|
||||
rl_vi_redo (), rl_vi_tilde_expand (),
|
||||
rl_vi_movement_mode (), rl_vi_insertion_mode (), rl_vi_arg_digit (),
|
||||
@ -73,8 +91,8 @@ extern int
|
||||
rl_vi_complete (), rl_vi_fetch_history ();
|
||||
|
||||
/* Keyboard macro commands. */
|
||||
extern int
|
||||
rl_start_kbd_macro (), rl_end_kbd_macro (), rl_call_last_kbd_macro ();
|
||||
extern int rl_start_kbd_macro (), rl_end_kbd_macro ();
|
||||
extern int rl_call_last_kbd_macro ();
|
||||
|
||||
extern int rl_arrow_keys(), rl_refresh_line ();
|
||||
|
||||
@ -137,10 +155,10 @@ extern char *rl_basic_word_break_characters;
|
||||
rl_basic_word_break_characters. */
|
||||
extern char *rl_completer_word_break_characters;
|
||||
|
||||
/* List of characters which are used to quote a substring of the command
|
||||
line, upon which completion is to be performed for the entire substring.
|
||||
Within quoted substrings, rl_completer_word_break_characters are treated
|
||||
as normal characters, unless they also appear in this list. */
|
||||
/* List of characters which can be used to quote a substring of the line.
|
||||
Completion occurs on the entire substring, and within the substring
|
||||
rl_completer_word_break_characters are treated as any other character,
|
||||
unless they also appear within this list. */
|
||||
extern char *rl_completer_quote_characters;
|
||||
|
||||
/* List of characters that are word break characters, but should be left
|
||||
@ -177,7 +195,10 @@ extern Function *rl_startup_hook;
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing on a directory name. The function is called with
|
||||
the address of a string (the current directory name) as an arg. */
|
||||
extern Function *rl_symbolic_link_hook;
|
||||
extern Function *rl_directory_completion_hook;
|
||||
|
||||
/* Backwards compatibility with previous versions of readline. */
|
||||
#define rl_symbolic_link_hook rl_directory_completion_hook
|
||||
|
||||
/* The address of a function to call periodically while Readline is
|
||||
awaiting character input, or NULL, for no event handling. */
|
||||
@ -187,28 +208,9 @@ extern Function *rl_event_hook;
|
||||
with an asterisk. */
|
||||
extern int rl_show_star;
|
||||
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Tilde Variables That Can be Externally Set */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* If non-null, this contains the address of a function to call if the
|
||||
standard meaning for expanding a tilde fails. The function is called
|
||||
with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
|
||||
which is the expansion, or a NULL pointer if there is no expansion. */
|
||||
extern Function *tilde_expansion_failure_hook;
|
||||
|
||||
/* When non-null, this is a NULL terminated array of strings which
|
||||
are duplicates for a tilde prefix. Bash uses this to expand
|
||||
`=~' and `:~'. */
|
||||
extern char **tilde_additional_prefixes;
|
||||
|
||||
/* When non-null, this is a NULL terminated array of strings which match
|
||||
the end of a username, instead of just "/". Bash sets this to
|
||||
`/' and `:'. */
|
||||
extern char **tilde_additional_suffixes;
|
||||
/* Non-zero means to suppress normal filename completion after the
|
||||
user-specified completion function has been called. */
|
||||
extern int rl_attempted_completion_over;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
@ -219,14 +221,47 @@ extern char **tilde_additional_suffixes;
|
||||
/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */
|
||||
extern char *readline ();
|
||||
|
||||
/* These functions are from complete.c. */
|
||||
/* Return an array of strings which are the result of repeatadly calling
|
||||
FUNC with TEXT. */
|
||||
extern char **completion_matches ();
|
||||
extern char *username_completion_function ();
|
||||
extern char *filename_completion_function ();
|
||||
|
||||
/* These functions are from bind.c. */
|
||||
/* rl_add_defun (char *name, Function *function, int key)
|
||||
Add NAME to the list of named functions. Make FUNCTION
|
||||
be the function that gets called.
|
||||
If KEY is not -1, then bind it. */
|
||||
extern int rl_add_defun ();
|
||||
extern int rl_bind_key (), rl_bind_key_in_map ();
|
||||
extern int rl_unbind_key (), rl_unbind_key_in_map ();
|
||||
extern int rl_set_key ();
|
||||
extern int rl_macro_bind (), rl_generic_bind (), rl_variable_bind ();
|
||||
extern int rl_translate_keyseq ();
|
||||
extern Function *rl_named_function (), *rl_function_of_keyseq ();
|
||||
extern int rl_parse_and_bind ();
|
||||
extern Keymap rl_get_keymap (), rl_get_keymap_by_name ();
|
||||
extern void rl_set_keymap ();
|
||||
extern char **rl_invoking_keyseqs (), **rl_invoking_keyseqs_in_map ();
|
||||
extern void rl_function_dumper ();
|
||||
extern int rl_read_init_file ();
|
||||
|
||||
/* Functions in funmap.c */
|
||||
extern void rl_list_funmap_names ();
|
||||
extern void rl_initialize_funmap ();
|
||||
|
||||
/* Functions in display.c */
|
||||
extern void rl_redisplay ();
|
||||
extern int rl_message (), rl_clear_message ();
|
||||
extern int rl_reset_line_state ();
|
||||
extern int rl_character_len ();
|
||||
extern int rl_show_char ();
|
||||
extern int crlf (), rl_on_new_line ();
|
||||
extern int rl_forced_update_display ();
|
||||
|
||||
/* Definitions available for use by readline clients. */
|
||||
#define RL_PROMPT_START_IGNORE '\001'
|
||||
#define RL_PROMPT_END_IGNORE '\002'
|
||||
|
||||
#endif /* _READLINE_H_ */
|
||||
|
38
gnu/lib/libreadline/readline/tilde.h
Normal file
38
gnu/lib/libreadline/readline/tilde.h
Normal file
@ -0,0 +1,38 @@
|
||||
/* tilde.h: Externally available variables and function in libtilde.a. */
|
||||
|
||||
#if !defined (__TILDE_H__)
|
||||
# define __TILDE_H__
|
||||
|
||||
/* Function pointers can be declared as (Function *)foo. */
|
||||
#if !defined (__FUNCTION_DEF)
|
||||
# define __FUNCTION_DEF
|
||||
typedef int Function ();
|
||||
typedef void VFunction ();
|
||||
typedef char *CPFunction ();
|
||||
typedef char **CPPFunction ();
|
||||
#endif /* _FUNCTION_DEF */
|
||||
|
||||
/* If non-null, this contains the address of a function to call if the
|
||||
standard meaning for expanding a tilde fails. The function is called
|
||||
with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
|
||||
which is the expansion, or a NULL pointer if there is no expansion. */
|
||||
extern CPFunction *tilde_expansion_failure_hook;
|
||||
|
||||
/* When non-null, this is a NULL terminated array of strings which
|
||||
are duplicates for a tilde prefix. Bash uses this to expand
|
||||
`=~' and `:~'. */
|
||||
extern char **tilde_additional_prefixes;
|
||||
|
||||
/* When non-null, this is a NULL terminated array of strings which match
|
||||
the end of a username, instead of just "/". Bash sets this to
|
||||
`:' and `=~'. */
|
||||
extern char **tilde_additional_suffixes;
|
||||
|
||||
/* Return a new string which is the result of tilde expanding STRING. */
|
||||
extern char *tilde_expand ();
|
||||
|
||||
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
|
||||
tilde. If there is no expansion, call tilde_expansion_failure_hook. */
|
||||
extern char *tilde_expand_word ();
|
||||
|
||||
#endif /* __TILDE_H__ */
|
57
gnu/lib/libreadline/rlconf.h
Normal file
57
gnu/lib/libreadline/rlconf.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* rlconf.h -- readline configuration definitions */
|
||||
|
||||
/* Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the Readline Library (the Library), a set of
|
||||
routines for providing Emacs style line input to programs that ask
|
||||
for it.
|
||||
|
||||
The 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
The 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,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if !defined (_RLCONF_H_)
|
||||
#define _RLCONF_H_
|
||||
|
||||
/* Define this if you want the vi-mode editing available. */
|
||||
#define VI_MODE
|
||||
|
||||
/* Define this to get an indication of file type when listing completions. */
|
||||
#define VISIBLE_STATS
|
||||
|
||||
/* If defined, readline shows opening parens and braces when closing
|
||||
paren or brace entered. */
|
||||
#define PAREN_MATCHING
|
||||
|
||||
/* This definition is needed by readline.c, rltty.c, and signals.c. */
|
||||
/* If on, then readline handles signals in a way that doesn't screw. */
|
||||
#define HANDLE_SIGNALS
|
||||
|
||||
/* Ugly but working hack for binding prefix meta. */
|
||||
#define PREFIX_META_HACK
|
||||
|
||||
/* The final, last-ditch effort file name for an init file. */
|
||||
#define DEFAULT_INPUTRC "~/.inputrc"
|
||||
|
||||
/* If defined, expand tabs to spaces. */
|
||||
#define DISPLAY_TABS
|
||||
|
||||
/* If defined, use the terminal escape sequence to move the cursor forward
|
||||
over a character when updating the line rather than rewriting it. */
|
||||
/* #define HACK_TERMCAP_MOTION */
|
||||
|
||||
/* The string inserted by the vi-mode `insert comment' command. */
|
||||
#define VI_COMMENT_BEGIN_DEFAULT "#"
|
||||
|
||||
#endif /* _RLCONF_H_ */
|
@ -26,13 +26,8 @@
|
||||
#if !defined (_RLDEFS_H)
|
||||
#define _RLDEFS_H
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# undef alloca
|
||||
# define alloca __builtin_alloca
|
||||
#else
|
||||
# if defined (sparc) || defined (HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# endif
|
||||
#if !defined (PRAGMA_ALLOCA)
|
||||
# include "memalloc.h"
|
||||
#endif
|
||||
|
||||
#define NEW_TTY_DRIVER
|
||||
@ -75,11 +70,11 @@
|
||||
|
||||
/* System V.3 machines have the old 4.1 BSD `reliable' signal interface. */
|
||||
#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
|
||||
# if defined (USGr3)
|
||||
# if defined (USGr3) && !defined (XENIX_22)
|
||||
# if !defined (HAVE_USG_SIGHOLD)
|
||||
# define HAVE_USG_SIGHOLD
|
||||
# endif /* !HAVE_USG_SIGHOLD */
|
||||
# endif /* USGr3 */
|
||||
# endif /* USGr3 && !XENIX_22 */
|
||||
#endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
|
||||
|
||||
/* Other (BSD) machines use sgtty. */
|
||||
@ -125,7 +120,9 @@
|
||||
#endif /* !HAVE_DIRENT_H */
|
||||
|
||||
#if defined (USG) && defined (TIOCGWINSZ) && !defined (Linux)
|
||||
# include <sys/stream.h>
|
||||
# if defined (HAVE_SYS_STREAM_H)
|
||||
# include <sys/stream.h>
|
||||
# endif /* HAVE_SYS_STREAM_H */
|
||||
# if defined (HAVE_SYS_PTEM_H)
|
||||
# include <sys/ptem.h>
|
||||
# endif /* HAVE_SYS_PTEM_H */
|
||||
@ -137,7 +134,7 @@
|
||||
/* Posix macro to check file in statbuf for directory-ness.
|
||||
This requires that <sys/stat.h> be included before this test. */
|
||||
#if defined (S_IFDIR) && !defined (S_ISDIR)
|
||||
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
# define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
/* Decide which flavor of the header file describing the C library
|
||||
@ -163,14 +160,31 @@ extern char *strchr (), *strrchr ();
|
||||
# include <varargs.h>
|
||||
#endif /* HAVE_VARARGS_H */
|
||||
|
||||
/* This definition is needed by readline.c, rltty.c, and signals.c. */
|
||||
/* If on, then readline handles signals in a way that doesn't screw. */
|
||||
#define HANDLE_SIGNALS
|
||||
|
||||
#if !defined (emacs_mode)
|
||||
# define no_mode -1
|
||||
# define vi_mode 0
|
||||
# define emacs_mode 1
|
||||
#endif
|
||||
|
||||
/* If you cast map[key].function to type (Keymap) on a Cray,
|
||||
the compiler takes the value of map[key].function and
|
||||
divides it by 4 to convert between pointer types (pointers
|
||||
to functions and pointers to structs are different sizes).
|
||||
This is not what is wanted. */
|
||||
#if defined (CRAY)
|
||||
# define FUNCTION_TO_KEYMAP(map, key) (Keymap)((int)map[key].function)
|
||||
# define KEYMAP_TO_FUNCTION(data) (Function *)((int)(data))
|
||||
#else
|
||||
# define FUNCTION_TO_KEYMAP(map, key) (Keymap)(map[key].function)
|
||||
# define KEYMAP_TO_FUNCTION(data) (Function *)(data)
|
||||
#endif
|
||||
|
||||
/* Possible values for _rl_bell_preference. */
|
||||
#define NO_BELL 0
|
||||
#define AUDIBLE_BELL 1
|
||||
#define VISIBLE_BELL 2
|
||||
|
||||
/* CONFIGURATION SECTION */
|
||||
#include "rlconf.h"
|
||||
|
||||
#endif /* !_RLDEFS_H */
|
||||
|
@ -40,10 +40,10 @@ extern int errno;
|
||||
extern int readline_echoing_p;
|
||||
extern int _rl_eof_char;
|
||||
|
||||
#if defined (_GO32_)
|
||||
#if defined (__GO32__)
|
||||
# include <sys/pc.h>
|
||||
# undef HANDLE_SIGNALS
|
||||
#endif /* _GO32_ */
|
||||
#endif /* __GO32__ */
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
@ -107,10 +107,10 @@ release_sigint ()
|
||||
|
||||
sigint_blocked = 0;
|
||||
}
|
||||
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Controlling the Meta Key */
|
||||
/* Controlling the Meta Key and Keypad */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
@ -118,11 +118,13 @@ extern int term_has_meta;
|
||||
extern char *term_mm;
|
||||
extern char *term_mo;
|
||||
|
||||
static void
|
||||
extern char *term_ks;
|
||||
extern char *term_ke;
|
||||
static int
|
||||
outchar (c)
|
||||
int c;
|
||||
{
|
||||
putc (c, rl_outstream);
|
||||
return putc (c, rl_outstream);
|
||||
}
|
||||
|
||||
/* Turn on/off the meta key depending on ON. */
|
||||
@ -138,7 +140,17 @@ control_meta_key (on)
|
||||
tputs (term_mo, 1, outchar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
control_keypad (on)
|
||||
int on;
|
||||
{
|
||||
if (on && term_ks)
|
||||
tputs (term_ks, 1, outchar);
|
||||
else if (!on && term_ke)
|
||||
tputs (term_ke, 1, outchar);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Saving and Restoring the TTY */
|
||||
@ -250,7 +262,7 @@ prepare_terminal_settings (meta_flag, otio, tiop)
|
||||
int meta_flag;
|
||||
TIOTYPE otio, *tiop;
|
||||
{
|
||||
#if !defined (_GO32_)
|
||||
#if !defined (__GO32__)
|
||||
readline_echoing_p = (otio.sgttyb.sg_flags & ECHO);
|
||||
|
||||
/* Copy the original settings to the structure we're going to use for
|
||||
@ -316,7 +328,7 @@ prepare_terminal_settings (meta_flag, otio, tiop)
|
||||
tiop->ltchars.t_dsuspc = -1; /* C-y */
|
||||
tiop->ltchars.t_lnextc = -1; /* C-v */
|
||||
#endif /* TIOCGLTC */
|
||||
#endif /* !_GO32_ */
|
||||
#endif /* !__GO32__ */
|
||||
}
|
||||
|
||||
#else /* !defined (NEW_TTY_DRIVER) */
|
||||
@ -455,7 +467,7 @@ void
|
||||
rl_prep_terminal (meta_flag)
|
||||
int meta_flag;
|
||||
{
|
||||
#if !defined (_GO32_)
|
||||
#if !defined (__GO32__)
|
||||
int tty = fileno (rl_instream);
|
||||
TIOTYPE tio;
|
||||
|
||||
@ -482,17 +494,18 @@ rl_prep_terminal (meta_flag)
|
||||
}
|
||||
|
||||
control_meta_key (1);
|
||||
control_keypad (1);
|
||||
terminal_prepped = 1;
|
||||
|
||||
release_sigint ();
|
||||
#endif /* !_GO32_ */
|
||||
#endif /* !__GO32__ */
|
||||
}
|
||||
|
||||
/* Restore the terminal's normal settings and modes. */
|
||||
void
|
||||
rl_deprep_terminal ()
|
||||
{
|
||||
#if !defined (_GO32_)
|
||||
#if !defined (__GO32__)
|
||||
int tty = fileno (rl_instream);
|
||||
|
||||
if (!terminal_prepped)
|
||||
@ -508,10 +521,11 @@ rl_deprep_terminal ()
|
||||
}
|
||||
|
||||
control_meta_key (0);
|
||||
control_keypad (0);
|
||||
terminal_prepped = 0;
|
||||
|
||||
release_sigint ();
|
||||
#endif /* !_GO32_ */
|
||||
#endif /* !__GO32__ */
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
@ -548,6 +562,8 @@ rl_restart_output (count, key)
|
||||
# endif /* TCXONC */
|
||||
# endif /* !TERMIOS_TTY_DRIVER */
|
||||
#endif /* !TIOCSTART */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
rl_stop_output (count, key)
|
||||
@ -573,6 +589,8 @@ rl_stop_output (count, key)
|
||||
# endif /* TCXONC */
|
||||
# endif /* !TERMIOS_TTY_DRIVER */
|
||||
#endif /* !TIOCSTOP */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
@ -23,17 +23,15 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# define alloca __builtin_alloca
|
||||
#else
|
||||
# if defined (sparc) || defined (HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "memalloc.h"
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
|
||||
#define STREQN(a, b, n) (((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
|
||||
|
||||
#define abs(x) (((x) > 0) ? (x) : -(x))
|
||||
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
|
||||
/* Variables imported from readline.c */
|
||||
@ -42,9 +40,14 @@ extern Keymap _rl_keymap;
|
||||
extern char *rl_prompt;
|
||||
extern char *rl_line_buffer;
|
||||
extern HIST_ENTRY *saved_line_for_history;
|
||||
extern Function *rl_last_func;
|
||||
|
||||
/* Functions imported from the rest of the library. */
|
||||
extern int _rl_free_history_entry ();
|
||||
|
||||
static char *noninc_search_string = (char *) NULL;
|
||||
static int noninc_history_pos = 0;
|
||||
static char *prev_line_found = (char *) NULL;
|
||||
|
||||
/* Search the history list for STRING starting at absolute history position
|
||||
POS. If STRING begins with `^', the search must match STRING at the
|
||||
@ -123,7 +126,7 @@ noninc_dosearch (string, dir)
|
||||
rl_clear_message ();
|
||||
|
||||
if (saved_line_for_history)
|
||||
free_history_entry (saved_line_for_history);
|
||||
_rl_free_history_entry (saved_line_for_history);
|
||||
saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
@ -147,14 +150,16 @@ noninc_search (dir, pchar)
|
||||
rl_line_buffer[0] = 0;
|
||||
rl_end = rl_point = 0;
|
||||
|
||||
/* XXX - this needs fixing to work with the prompt expansion stuff - XXX */
|
||||
pmtlen = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
|
||||
p = (char *)alloca (2 + pmtlen);
|
||||
p = xmalloc (2 + pmtlen);
|
||||
if (pmtlen)
|
||||
strcpy (p, rl_prompt);
|
||||
p[pmtlen] = pchar ? pchar : ':';
|
||||
p[pmtlen + 1] = '\0';
|
||||
|
||||
rl_message (p, 0, 0);
|
||||
free (p);
|
||||
|
||||
/* Read the search string. */
|
||||
while (c = rl_read_key ())
|
||||
@ -170,11 +175,15 @@ noninc_search (dir, pchar)
|
||||
rl_point = saved_point;
|
||||
return;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
rl_rubout (1);
|
||||
break;
|
||||
|
||||
case CTRL('W'):
|
||||
rl_unix_word_rubout ();
|
||||
break;
|
||||
|
||||
case CTRL('U'):
|
||||
rl_dispatch (c, _rl_keymap);
|
||||
rl_unix_line_discard ();
|
||||
break;
|
||||
|
||||
case RETURN:
|
||||
@ -273,3 +282,79 @@ rl_noninc_reverse_search_again (count, key)
|
||||
noninc_dosearch (noninc_search_string, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rl_history_search_internal (count, direction)
|
||||
int count, direction;
|
||||
{
|
||||
HIST_ENTRY *temp, *old_temp;
|
||||
int line_len;
|
||||
|
||||
maybe_save_line ();
|
||||
|
||||
temp = old_temp = (HIST_ENTRY *)NULL;
|
||||
while (count)
|
||||
{
|
||||
temp = (direction < 0) ? previous_history () : next_history ();
|
||||
if (!temp)
|
||||
break;
|
||||
if (STREQN (rl_line_buffer, temp->line, rl_point))
|
||||
{
|
||||
/* Don't find multiple instances of the same line. */
|
||||
if (prev_line_found && STREQ (prev_line_found, temp->line))
|
||||
continue;
|
||||
if (direction < 0)
|
||||
old_temp = temp;
|
||||
prev_line_found = temp->line;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
if (!temp)
|
||||
{
|
||||
if (direction < 0 && old_temp)
|
||||
temp = old_temp;
|
||||
else
|
||||
{
|
||||
maybe_unsave_line ();
|
||||
ding ();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
line_len = strlen (temp->line);
|
||||
if (line_len >= rl_line_buffer_len)
|
||||
rl_extend_line_buffer (line_len);
|
||||
strcpy (rl_line_buffer, temp->line);
|
||||
rl_undo_list = (UNDO_LIST *)temp->data;
|
||||
rl_end = line_len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Search forward in the history for the string of characters
|
||||
from the start of the line to rl_point. This is a non-incremental
|
||||
search. */
|
||||
int
|
||||
rl_history_search_forward (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (count == 0)
|
||||
return (0);
|
||||
if (rl_last_func != rl_history_search_forward)
|
||||
prev_line_found = (char *)NULL;
|
||||
return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1));
|
||||
}
|
||||
|
||||
/* Search backward through the history for the string of characters
|
||||
from the start of the line to rl_point. This is a non-incremental
|
||||
search. */
|
||||
int
|
||||
rl_history_search_backward (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (count == 0)
|
||||
return (0);
|
||||
if (rl_last_func != rl_history_search_backward)
|
||||
prev_line_found = (char *)NULL;
|
||||
return (rl_history_search_internal (abs (count), (count > 0) ? -1 : 1));
|
||||
}
|
||||
|
@ -62,10 +62,11 @@ static void cr ();
|
||||
|
||||
extern int readline_echoing_p;
|
||||
extern int rl_pending_input;
|
||||
extern char *term_cr;
|
||||
|
||||
extern int _rl_meta_flag;
|
||||
|
||||
extern void _rl_output_character_function ();
|
||||
extern int _rl_output_character_function ();
|
||||
|
||||
extern void free_undo_list ();
|
||||
|
||||
@ -79,9 +80,9 @@ extern void free_undo_list ();
|
||||
to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
|
||||
typedef sighandler SigHandler ();
|
||||
|
||||
#if defined (_GO32_)
|
||||
#if defined (__GO32__)
|
||||
# undef HANDLE_SIGNALS
|
||||
#endif /* _GO32_ */
|
||||
#endif /* __GO32__ */
|
||||
|
||||
#if defined (STATIC_MALLOC)
|
||||
static char *xmalloc (), *xrealloc ();
|
||||
@ -125,11 +126,14 @@ rl_handle_sigwinch (sig)
|
||||
/* Interrupt handling. */
|
||||
static SigHandler
|
||||
*old_int = (SigHandler *)NULL,
|
||||
*old_alrm = (SigHandler *)NULL;
|
||||
#if !defined (SHELL)
|
||||
static SigHandler
|
||||
*old_tstp = (SigHandler *)NULL,
|
||||
*old_ttou = (SigHandler *)NULL,
|
||||
*old_ttin = (SigHandler *)NULL,
|
||||
*old_cont = (SigHandler *)NULL,
|
||||
*old_alrm = (SigHandler *)NULL;
|
||||
*old_cont = (SigHandler *)NULL;
|
||||
#endif /* !SHELL */
|
||||
|
||||
/* Handle an interrupt character. */
|
||||
static sighandler
|
||||
@ -261,6 +265,7 @@ rl_set_signals ()
|
||||
old_sigwinch =
|
||||
(SigHandler *) rl_set_sighandler (SIGWINCH, rl_handle_sigwinch);
|
||||
#endif /* SIGWINCH */
|
||||
return 0;
|
||||
}
|
||||
|
||||
rl_clear_signals ()
|
||||
@ -284,14 +289,14 @@ rl_clear_signals ()
|
||||
#if defined (SIGWINCH)
|
||||
signal (SIGWINCH, old_sigwinch);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Move to the start of the current line. */
|
||||
static void
|
||||
cr ()
|
||||
{
|
||||
extern char *term_cr;
|
||||
|
||||
if (term_cr)
|
||||
tputs (term_cr, 1, _rl_output_character_function);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
*** rltty.c.orig Tue May 10 02:18:03 1994
|
||||
--- rltty.c Tue May 10 03:12:55 1994
|
||||
*** rltty.c.orig Thu May 12 19:02:50 1994
|
||||
--- rltty.c Thu May 12 19:03:06 1994
|
||||
***************
|
||||
*** 21,26 ****
|
||||
--- 21,27 ----
|
||||
@ -11,8 +11,8 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
***************
|
||||
*** 347,352 ****
|
||||
--- 348,359 ----
|
||||
*** 359,364 ****
|
||||
--- 360,371 ----
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
|
@ -19,18 +19,7 @@
|
||||
along with Readline; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# undef alloca
|
||||
# define alloca __builtin_alloca
|
||||
#else /* !__GNUC__ */
|
||||
# if defined (_AIX)
|
||||
#pragma alloca
|
||||
# else /* !_AIX */
|
||||
# if defined (HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# endif /* HAVE_ALLOCA_H */
|
||||
# endif /* !AIX */
|
||||
#endif /* !__GNUC__ */
|
||||
#include "memalloc.h"
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
@ -44,15 +33,12 @@
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include <tilde.h>
|
||||
#include "tilde.h"
|
||||
#include <pwd.h>
|
||||
|
||||
#if defined (USG) && !defined (isc386) && !defined (sgi)
|
||||
extern struct passwd *getpwuid (), *getpwent ();
|
||||
#endif
|
||||
#if defined (isc386) && !defined (__STDC__) && defined (_POSIX_SOURCE)
|
||||
extern struct passwd *getpwent ();
|
||||
#endif
|
||||
#if defined (USG) && !defined (HAVE_GETPW_DECLS)
|
||||
extern struct passwd *getpwuid (), *getpwnam ();
|
||||
#endif /* USG && !defined (HAVE_GETPW_DECLS) */
|
||||
|
||||
#if !defined (savestring)
|
||||
extern char *xmalloc ();
|
||||
@ -254,21 +240,23 @@ tilde_expand_word (filename)
|
||||
temp_home = entry->pw_dir;
|
||||
}
|
||||
|
||||
temp_name = (char *)alloca (1 + strlen (&dirname[1])
|
||||
+ (temp_home ? strlen (temp_home) : 0));
|
||||
temp_name = xmalloc (1 + strlen (&dirname[1])
|
||||
+ (temp_home ? strlen (temp_home) : 0));
|
||||
temp_name[0] = '\0';
|
||||
if (temp_home)
|
||||
strcpy (temp_name, temp_home);
|
||||
strcat (temp_name, &dirname[1]);
|
||||
strcat (temp_name, dirname + 1);
|
||||
free (dirname);
|
||||
dirname = savestring (temp_name);
|
||||
dirname = temp_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
char u_name[257];
|
||||
struct passwd *user_entry;
|
||||
char *username = (char *)alloca (257);
|
||||
char *username;
|
||||
int i, c;
|
||||
|
||||
username = u_name;
|
||||
for (i = 1; c = dirname[i]; i++)
|
||||
{
|
||||
if (c == '/')
|
||||
@ -291,25 +279,25 @@ tilde_expand_word (filename)
|
||||
|
||||
if (expansion)
|
||||
{
|
||||
temp_name = (char *)alloca (1 + strlen (expansion)
|
||||
temp_name = xmalloc (1 + strlen (expansion)
|
||||
+ strlen (&dirname[i]));
|
||||
strcpy (temp_name, expansion);
|
||||
strcat (temp_name, &dirname[i]);
|
||||
free (expansion);
|
||||
goto return_name;
|
||||
free (dirname);
|
||||
dirname = temp_name;
|
||||
}
|
||||
}
|
||||
/* We shouldn't report errors. */
|
||||
}
|
||||
else
|
||||
{
|
||||
temp_name = (char *)alloca (1 + strlen (user_entry->pw_dir)
|
||||
+ strlen (&dirname[i]));
|
||||
temp_name = xmalloc (1 + strlen (user_entry->pw_dir)
|
||||
+ strlen (&dirname[i]));
|
||||
strcpy (temp_name, user_entry->pw_dir);
|
||||
strcat (temp_name, &dirname[i]);
|
||||
return_name:
|
||||
free (dirname);
|
||||
dirname = savestring (temp_name);
|
||||
dirname = temp_name;
|
||||
}
|
||||
endpwent ();
|
||||
}
|
||||
|
@ -26,7 +26,9 @@
|
||||
|
||||
#include "readline.h"
|
||||
|
||||
#if 0
|
||||
extern KEYMAP_ENTRY_ARRAY vi_escape_keymap;
|
||||
#endif
|
||||
|
||||
/* The keymap arrays for handling vi mode. */
|
||||
KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
|
||||
@ -59,7 +61,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
|
||||
{ ISFUNC, rl_yank }, /* Control-y */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-z */
|
||||
|
||||
{ ISFUNC, rl_abort }, /* Control-[ */
|
||||
{ ISFUNC, rl_abort }, /* Control-[ */ /* vi_escape_keymap */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-\ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-] */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-^ */
|
||||
@ -84,7 +86,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
|
||||
{ ISFUNC, rl_vi_search }, /* / */
|
||||
|
||||
/* Regular digits. */
|
||||
{ ISFUNC, rl_vi_arg_digit }, /* 0 */
|
||||
{ ISFUNC, rl_beg_of_line }, /* 0 */
|
||||
{ ISFUNC, rl_vi_arg_digit }, /* 1 */
|
||||
{ ISFUNC, rl_vi_arg_digit }, /* 2 */
|
||||
{ ISFUNC, rl_vi_arg_digit }, /* 3 */
|
||||
@ -592,8 +594,9 @@ KEYMAP_ENTRY_ARRAY vi_insertion_keymap = {
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
||||
/* Unused for the time being. */
|
||||
#if 0
|
||||
KEYMAP_ENTRY_ARRAY vi_escape_keymap = {
|
||||
|
||||
/* The regular control keys come first. */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-@ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-a */
|
||||
@ -871,3 +874,4 @@ KEYMAP_ENTRY_ARRAY vi_escape_keymap = {
|
||||
{ ISFUNC, (Function *)0x0 }
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
#endif
|
||||
|
@ -20,12 +20,14 @@
|
||||
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,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* VI Emulation Mode */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
#include "rlconf.h"
|
||||
|
||||
#if defined (VI_MODE)
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -36,12 +38,6 @@
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (STATIC_MALLOC)
|
||||
static char *xmalloc (), *xrealloc ();
|
||||
#else
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
#endif /* STATIC_MALLOC */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Some standard library routines. */
|
||||
@ -77,6 +73,12 @@ extern char *xmalloc (), *xrealloc ();
|
||||
#define VI_COMMENT_BEGIN_DEFAULT "#"
|
||||
#endif
|
||||
|
||||
#if defined (STATIC_MALLOC)
|
||||
static char *xmalloc (), *xrealloc ();
|
||||
#else
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
#endif /* STATIC_MALLOC */
|
||||
|
||||
/* Variables imported from readline.c */
|
||||
extern int rl_point, rl_end, rl_mark, rl_done;
|
||||
extern FILE *rl_instream;
|
||||
@ -86,11 +88,13 @@ extern char *rl_prompt;
|
||||
extern char *rl_line_buffer;
|
||||
extern int rl_arg_sign;
|
||||
|
||||
extern void _rl_dispatch ();
|
||||
|
||||
extern void rl_extend_line_buffer ();
|
||||
extern int rl_vi_check (), rl_digit_loop1 ();
|
||||
extern int rl_vi_check ();
|
||||
|
||||
/* Non-zero means enter insertion mode. */
|
||||
int _rl_vi_doing_insert = 0;
|
||||
static int _rl_vi_doing_insert = 0;
|
||||
|
||||
/* String inserted into the line by rl_vi_comment (). */
|
||||
char *rl_vi_comment_begin = (char *)NULL;
|
||||
@ -106,9 +110,14 @@ static Keymap vi_replace_map = (Keymap)NULL;
|
||||
/* The number of characters inserted in the last replace operation. */
|
||||
static int vi_replace_count = 0;
|
||||
|
||||
int _rl_vi_last_command = 'i'; /* default `.' puts you in insert mode */
|
||||
int _rl_vi_last_repeat = 1;
|
||||
int _rl_vi_last_arg_sign = 1;
|
||||
/* If non-zero, we have text inserted after a c[motion] command that put
|
||||
us implicitly into insert mode. Some people want this text to be
|
||||
attached to the command so that it is `redoable' with `.'. */
|
||||
static int vi_continued_command = 0;
|
||||
|
||||
static int _rl_vi_last_command = 'i'; /* default `.' puts you in insert mode */
|
||||
static int _rl_vi_last_repeat = 1;
|
||||
static int _rl_vi_last_arg_sign = 1;
|
||||
static int _rl_vi_last_motion = 0;
|
||||
static int _rl_vi_last_search_char = 0;
|
||||
static int _rl_vi_last_replacement = 0;
|
||||
@ -118,8 +127,10 @@ static int vi_redoing = 0;
|
||||
/* Text modification commands. These are the `redoable' commands. */
|
||||
static char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
|
||||
|
||||
static int rl_digit_loop1 ();
|
||||
|
||||
void
|
||||
rl_vi_set_last ()
|
||||
_rl_vi_reset_last ()
|
||||
{
|
||||
_rl_vi_last_command = 'i';
|
||||
_rl_vi_last_repeat = 1;
|
||||
@ -127,6 +138,15 @@ rl_vi_set_last ()
|
||||
_rl_vi_last_motion = 0;
|
||||
}
|
||||
|
||||
void
|
||||
_rl_vi_set_last (key, repeat, sign)
|
||||
int key, repeat, sign;
|
||||
{
|
||||
_rl_vi_last_command = key;
|
||||
_rl_vi_last_repeat = repeat;
|
||||
_rl_vi_last_arg_sign = sign;
|
||||
}
|
||||
|
||||
/* Is the command C a VI mode text modification command? */
|
||||
int
|
||||
rl_vi_textmod_command (c)
|
||||
@ -148,7 +168,7 @@ rl_vi_redo (count, c)
|
||||
}
|
||||
|
||||
vi_redoing = 1;
|
||||
rl_dispatch (_rl_vi_last_command, _rl_keymap);
|
||||
_rl_dispatch (_rl_vi_last_command, _rl_keymap);
|
||||
vi_redoing = 0;
|
||||
|
||||
return (0);
|
||||
@ -158,9 +178,6 @@ rl_vi_redo (count, c)
|
||||
rl_vi_yank_arg (count)
|
||||
int count;
|
||||
{
|
||||
/* vi mode is defined to insert a space before the last argument. */
|
||||
rl_insert (1, ' ');
|
||||
|
||||
/* Readline thinks that the first word on a line is the 0th, while vi
|
||||
thinks the first word on a line is the 1st. Compensate. */
|
||||
if (rl_explicit_arg)
|
||||
@ -168,7 +185,6 @@ rl_vi_yank_arg (count)
|
||||
else
|
||||
rl_yank_nth_arg ('$', 0);
|
||||
|
||||
rl_vi_insertion_mode ();
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -256,7 +272,10 @@ rl_vi_complete (ignore, key)
|
||||
rl_complete (0, key);
|
||||
|
||||
if (key == '*' || key == '\\')
|
||||
rl_vi_insertion_mode ();
|
||||
{
|
||||
_rl_vi_set_last (key, 1, rl_arg_sign);
|
||||
rl_vi_insertion_mode ();
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -265,6 +284,7 @@ rl_vi_tilde_expand (ignore, key)
|
||||
int ignore, key;
|
||||
{
|
||||
rl_tilde_expand (0, key);
|
||||
_rl_vi_set_last (key, 1, rl_arg_sign); /* XXX */
|
||||
rl_vi_insertion_mode ();
|
||||
return (0);
|
||||
}
|
||||
@ -292,7 +312,7 @@ rl_vi_prev_word (count, key)
|
||||
|
||||
/* Next word in vi mode. */
|
||||
rl_vi_next_word (count, key)
|
||||
int count;
|
||||
int count, key;
|
||||
{
|
||||
if (count < 0)
|
||||
return (rl_vi_prev_word (-count, key));
|
||||
@ -493,7 +513,7 @@ rl_vi_insert_beg ()
|
||||
rl_vi_append_mode ()
|
||||
{
|
||||
if (rl_point < rl_end)
|
||||
rl_point += 1;
|
||||
rl_point++;
|
||||
rl_vi_insertion_mode ();
|
||||
return (0);
|
||||
}
|
||||
@ -522,25 +542,33 @@ rl_vi_insertion_mode ()
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
_rl_vi_done_inserting ()
|
||||
{
|
||||
if (_rl_vi_doing_insert)
|
||||
{
|
||||
rl_end_undo_group ();
|
||||
/* Now, the text between rl_undo_list->next->start and
|
||||
rl_undo_list->next->end is what was inserted while in insert
|
||||
mode. */
|
||||
_rl_vi_doing_insert = 0;
|
||||
vi_continued_command = 1;
|
||||
}
|
||||
else
|
||||
vi_continued_command = 0;
|
||||
}
|
||||
|
||||
rl_vi_movement_mode ()
|
||||
{
|
||||
if (rl_point > 0)
|
||||
rl_backward (1);
|
||||
|
||||
rl_vi_set_last ();
|
||||
#if 0
|
||||
_rl_vi_reset_last ();
|
||||
#endif
|
||||
|
||||
_rl_keymap = vi_movement_keymap;
|
||||
vi_done_inserting ();
|
||||
return (0);
|
||||
}
|
||||
|
||||
vi_done_inserting ()
|
||||
{
|
||||
if (_rl_vi_doing_insert)
|
||||
{
|
||||
rl_end_undo_group ();
|
||||
_rl_vi_doing_insert = 0;
|
||||
}
|
||||
_rl_vi_done_inserting ();
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -639,9 +667,7 @@ rl_vi_domove (key, nextkey)
|
||||
c = rl_read_key (); /* real command */
|
||||
*nextkey = c;
|
||||
}
|
||||
else if ((key == 'd' && c == 'd') ||
|
||||
(key == 'y' && c == 'y') ||
|
||||
(key == 'c' && c == 'c'))
|
||||
else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
|
||||
{
|
||||
rl_mark = rl_end;
|
||||
rl_beg_of_line ();
|
||||
@ -660,7 +686,7 @@ rl_vi_domove (key, nextkey)
|
||||
rl_line_buffer[rl_end++] = ' ';
|
||||
rl_line_buffer[rl_end] = '\0';
|
||||
|
||||
rl_dispatch (c, _rl_keymap);
|
||||
_rl_dispatch (c, _rl_keymap);
|
||||
|
||||
/* Remove the blank that we added. */
|
||||
rl_end = old_end;
|
||||
@ -675,23 +701,30 @@ rl_vi_domove (key, nextkey)
|
||||
/* rl_vi_f[wW]ord () leaves the cursor on the first character of the next
|
||||
word. If we are not at the end of the line, and we are on a
|
||||
non-whitespace character, move back one (presumably to whitespace). */
|
||||
if ((c == 'w' || c == 'W') && (rl_point < rl_end) &&
|
||||
if ((to_upper (c) == 'W') && rl_point < rl_end && rl_point > rl_mark &&
|
||||
!whitespace (rl_line_buffer[rl_point]))
|
||||
rl_point--;
|
||||
|
||||
/* If cw or cW, back up to the end of a word, so the behaviour of ce
|
||||
or cE is the actual result. Brute-force, no subtlety. */
|
||||
if (key == 'c' && (to_upper (c) == 'W'))
|
||||
if (key == 'c' && rl_point >= rl_mark && (to_upper (c) == 'W'))
|
||||
{
|
||||
while (rl_point && whitespace (rl_line_buffer[rl_point]))
|
||||
/* Don't move farther back than where we started. */
|
||||
while (rl_point > rl_mark && whitespace (rl_line_buffer[rl_point]))
|
||||
rl_point--;
|
||||
|
||||
/* Move past the end of the word so that the kill doesn't remove the
|
||||
last letter of the previous word. Only do this if we are not at
|
||||
the end of the line. */
|
||||
if ((rl_point >= 0) && (rl_point < (rl_end - 1)) &&
|
||||
!whitespace (rl_line_buffer[rl_point]))
|
||||
rl_point++;
|
||||
/* Posix.2 says that if cw or cW moves the cursor towards the end of
|
||||
the line, the character under the cursor should be deleted. */
|
||||
if (rl_point == rl_mark)
|
||||
rl_point++;
|
||||
else
|
||||
{
|
||||
/* Move past the end of the word so that the kill doesn't
|
||||
remove the last letter of the previous word. Only do this
|
||||
if we are not at the end of the line. */
|
||||
if (rl_point >= 0 && rl_point < (rl_end - 1) && !whitespace (rl_line_buffer[rl_point]))
|
||||
rl_point++;
|
||||
}
|
||||
}
|
||||
|
||||
if (rl_mark < rl_point)
|
||||
@ -702,6 +735,7 @@ rl_vi_domove (key, nextkey)
|
||||
|
||||
/* A simplified loop for vi. Don't dispatch key at end.
|
||||
Don't recognize minus sign? */
|
||||
static int
|
||||
rl_digit_loop1 ()
|
||||
{
|
||||
int key, c;
|
||||
@ -790,9 +824,11 @@ rl_vi_change_to (count, key)
|
||||
if ((to_upper (c) == 'W') && rl_point < start_pos)
|
||||
rl_point = start_pos;
|
||||
|
||||
rl_kill_text (rl_point, rl_mark);
|
||||
|
||||
rl_begin_undo_group ();
|
||||
_rl_vi_doing_insert = 1;
|
||||
rl_kill_text (rl_point, rl_mark);
|
||||
_rl_vi_set_last (key, count, rl_arg_sign);
|
||||
rl_vi_insertion_mode ();
|
||||
|
||||
return (0);
|
||||
@ -930,7 +966,7 @@ rl_vi_char_search (count, key)
|
||||
if (pos == 0)
|
||||
{
|
||||
ding ();
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
pos--;
|
||||
@ -1096,7 +1132,6 @@ rl_vi_subst (count, key)
|
||||
int count, key;
|
||||
{
|
||||
rl_begin_undo_group ();
|
||||
_rl_vi_doing_insert = 1;
|
||||
|
||||
if (uppercase_p (key))
|
||||
{
|
||||
@ -1108,7 +1143,12 @@ rl_vi_subst (count, key)
|
||||
|
||||
rl_end_undo_group ();
|
||||
|
||||
_rl_vi_set_last (key, count, rl_arg_sign);
|
||||
|
||||
rl_begin_undo_group ();
|
||||
_rl_vi_doing_insert = 1;
|
||||
rl_vi_insertion_mode ();
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -1202,6 +1242,7 @@ rl_vi_replace (count, key)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Try to complete the word we are standing on or the word that ends with
|
||||
the previous character. A space matches everything. Word delimiters are
|
||||
space and ;. */
|
||||
@ -1211,9 +1252,9 @@ rl_vi_possible_completions()
|
||||
|
||||
if (rl_line_buffer[rl_point] != ' ' && rl_line_buffer[rl_point] != ';')
|
||||
{
|
||||
while (rl_line_buffer[rl_point] != ' ' &&
|
||||
while (rl_point < rl_end && rl_line_buffer[rl_point] != ' ' &&
|
||||
rl_line_buffer[rl_point] != ';')
|
||||
;
|
||||
rl_point++;
|
||||
}
|
||||
else if (rl_line_buffer[rl_point - 1] == ';')
|
||||
{
|
||||
@ -1226,6 +1267,7 @@ rl_vi_possible_completions()
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (STATIC_MALLOC)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user