summaryrefslogtreecommitdiff
path: root/lib/libedit
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2003-09-14 21:48:54 +0000
committerchristos <christos@NetBSD.org>2003-09-14 21:48:54 +0000
commit166e18a7fd0e18fbcb47dfe86b187c2ea32bba8a (patch)
tree5f93869f5dd98f47d7e2e0a80687bee867d118e1 /lib/libedit
parent6d126df0a6dfbddfe172519edff4ed7f7fb0836a (diff)
- provide enough hooks to compile gdb-5.3
- fix el_get(e, EL_TERMINAL, (char **))
Diffstat (limited to 'lib/libedit')
-rw-r--r--lib/libedit/el.c9
-rw-r--r--lib/libedit/readline.c53
-rw-r--r--lib/libedit/readline/readline.h55
-rw-r--r--lib/libedit/shlib_version4
-rw-r--r--lib/libedit/term.c12
-rw-r--r--lib/libedit/term.h4
6 files changed, 112 insertions, 25 deletions
diff --git a/lib/libedit/el.c b/lib/libedit/el.c
index 0ee833788c2..afd5e5da124 100644
--- a/lib/libedit/el.c
+++ b/lib/libedit/el.c
@@ -1,4 +1,4 @@
-/* $NetBSD: el.c,v 1.32 2003/08/07 16:44:30 agc Exp $ */
+/* $NetBSD: el.c,v 1.33 2003/09/14 21:48:54 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
#else
-__RCSID("$NetBSD: el.c,v 1.32 2003/08/07 16:44:30 agc Exp $");
+__RCSID("$NetBSD: el.c,v 1.33 2003/09/14 21:48:54 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -293,11 +293,12 @@ el_get(EditLine *el, int op, void *ret)
rv = 0;
break;
-#if 0 /* XXX */
case EL_TERMINAL:
- rv = term_get(el, (const char *) &ret);
+ term_get(el, (const char **)ret);
+ rv = 0;
break;
+#if 0 /* XXX */
case EL_BIND:
case EL_TELLTC:
case EL_SETTC:
diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c
index ab580ed5bce..a6feaa5ba74 100644
--- a/lib/libedit/readline.c
+++ b/lib/libedit/readline.c
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.31 2003/06/19 16:04:57 christos Exp $ */
+/* $NetBSD: readline.c,v 1.32 2003/09/14 21:48:54 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.31 2003/06/19 16:04:57 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.32 2003/09/14 21:48:54 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -94,8 +94,23 @@ char *rl_completer_word_break_characters = NULL;
char *rl_completer_quote_characters = NULL;
CPFunction *rl_completion_entry_function = NULL;
CPPFunction *rl_attempted_completion_function = NULL;
+Function *rl_pre_input_hook = NULL;
+Function *rl_startup1_hook = NULL;
+Function *rl_getc_function = NULL;
+char *rl_terminal_name = NULL;
+int rl_already_prompted = 0;
+int rl_filename_completion_desired = 0;
+int rl_ignore_completion_duplicates = 0;
+VFunction *rl_redisplay_function = NULL;
+Function *rl_completion_display_matches_hook = NULL;
+Function *rl_prep_term_function = NULL;
+Function *rl_deprep_term_function = NULL;
/*
+ * The current prompt string.
+ */
+char *rl_prompt = NULL;
+/*
* This is set to character indicating type of completion being done by
* rl_complete_internal(); this is available for application completion
* functions.
@@ -141,17 +156,13 @@ static char *_rl_compat_sub(const char *, const char *,
static int rl_complete_internal(int);
static int _rl_qsort_string_compare(const void *, const void *);
-/*
- * needed for prompt switching in readline()
- */
-static char *el_rl_prompt = NULL;
-
/* ARGSUSED */
static char *
_get_prompt(EditLine *el __attribute__((__unused__)))
{
- return (el_rl_prompt);
+ rl_already_prompted = 1;
+ return (rl_prompt);
}
@@ -221,8 +232,8 @@ rl_initialize(void)
el_set(e, EL_HIST, history, h);
/* for proper prompt printing in readline() */
- el_rl_prompt = strdup("");
- if (el_rl_prompt == NULL) {
+ rl_prompt = strdup("");
+ if (rl_prompt == NULL) {
history_end(h);
el_end(e);
return -1;
@@ -233,6 +244,10 @@ rl_initialize(void)
/* set default mode to "emacs"-style and read setting afterwards */
/* so this can be overriden */
el_set(e, EL_EDITOR, "emacs");
+ if (rl_terminal_name != NULL)
+ el_set(e, EL_TERMINAL, rl_terminal_name);
+ else
+ el_get(e, EL_TERMINAL, &rl_terminal_name);
/*
* Word completition - this has to go AFTER rebinding keys
@@ -242,7 +257,6 @@ rl_initialize(void)
"ReadLine compatible completition function",
_el_rl_complete);
el_set(e, EL_BIND, "^I", "rl_complete", NULL);
-
/*
* Find out where the rl_complete function was added; this is
* used later to detect that lastcmd was also rl_complete.
@@ -266,6 +280,9 @@ rl_initialize(void)
rl_line_buffer = memchr(li->buffer, *li->buffer, 1);
rl_point = rl_end = 0;
+ if (rl_startup_hook)
+ (*rl_startup_hook)(NULL, 0);
+
return (0);
}
@@ -288,12 +305,18 @@ readline(const char *prompt)
/* update prompt accordingly to what has been passed */
if (!prompt)
prompt = "";
- if (strcmp(el_rl_prompt, prompt) != 0) {
- free(el_rl_prompt);
- el_rl_prompt = strdup(prompt);
- if (el_rl_prompt == NULL)
+ if (strcmp(rl_prompt, prompt) != 0) {
+ free(rl_prompt);
+ rl_prompt = strdup(prompt);
+ if (rl_prompt == NULL)
return NULL;
}
+
+ if (rl_pre_input_hook)
+ (*rl_pre_input_hook)(NULL, 0);
+
+ rl_already_prompted = 0;
+
/* get one line from input stream */
ret = el_gets(e, &count);
diff --git a/lib/libedit/readline/readline.h b/lib/libedit/readline/readline.h
index dac6e284f4a..c124ba81dd9 100644
--- a/lib/libedit/readline/readline.h
+++ b/lib/libedit/readline/readline.h
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.h,v 1.2 2002/03/18 16:01:03 christos Exp $ */
+/* $NetBSD: readline.h,v 1.3 2003/09/14 21:48:55 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -53,6 +53,32 @@ typedef struct _hist_entry {
const char *data;
} HIST_ENTRY;
+typedef struct _keymap_entry {
+ char type;
+#define ISFUNC 0
+#define ISKMAP 1
+#define ISMACR 2
+ Function *function;
+} KEYMAP_ENTRY;
+
+#define KEYMAP_SIZE 256
+
+typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
+typedef KEYMAP_ENTRY *Keymap;
+
+#define control_character_threshold 0x20
+#define control_character_bit 0x40
+
+#ifndef CTRL
+#define CTRL(a) ((a) & 037)
+#endif
+#ifndef UNCTRL
+#define UNCTRL(a) (((a) - 'a' + 'A')|control_character_bit)
+#endif
+
+#define RUBOUT 0x7f
+#define ABORT_CHAR CTRL('G')
+
/* global variables used by readline enabled applications */
#ifdef __cplusplus
extern "C" {
@@ -74,6 +100,24 @@ extern int rl_completion_type;
extern int rl_completion_query_items;
extern char *rl_special_prefixes;
extern int rl_completion_append_character;
+extern Function *rl_pre_input_hook;
+extern Function *rl_startup_hook;
+extern char *rl_terminal_name;
+extern int rl_already_prompted;
+extern char *rl_prompt;
+/*
+ * The following is not implemented
+ */
+extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
+ emacs_meta_keymap,
+ emacs_ctlx_keymap;
+extern int rl_filename_completion_desired;
+extern int rl_ignore_completion_duplicates;
+extern Function *rl_getc_function;
+extern VFunction *rl_redisplay_function;
+extern Function *rl_completion_display_matches_hook;
+extern VFunction *rl_prep_term_function;
+extern VFunction *rl_deprep_term_function;
/* supported functions */
char *readline(const char *);
@@ -111,6 +155,15 @@ void rl_display_match_list(char **, int, int);
int rl_insert(int, int);
void rl_reset_terminal(const char *);
int rl_bind_key(int, int (*)(int, int));
+
+/*
+ * The following are not implemented
+ */
+Keymap rl_get_keymap(void);
+Keymap rl_make_bare_keymap(void);
+int rl_add_defun(const char *, Function *, int);
+int rl_generic_bind(int, const char *, const char *, Keymap);
+int rl_bind_key_in_map(int, Function *, Keymap);
#ifdef __cplusplus
}
#endif
diff --git a/lib/libedit/shlib_version b/lib/libedit/shlib_version
index edd3802dfad..4f224a52b9b 100644
--- a/lib/libedit/shlib_version
+++ b/lib/libedit/shlib_version
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.12 2001/10/09 13:50:30 christos Exp $
+# $NetBSD: shlib_version,v 1.13 2003/09/14 21:48:55 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=2
-minor=6
+minor=7
diff --git a/lib/libedit/term.c b/lib/libedit/term.c
index 9962b04aa57..9bb6f88ea76 100644
--- a/lib/libedit/term.c
+++ b/lib/libedit/term.c
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.37 2003/08/07 16:44:34 agc Exp $ */
+/* $NetBSD: term.c,v 1.38 2003/09/14 21:48:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#else
-__RCSID("$NetBSD: term.c,v 1.37 2003/08/07 16:44:34 agc Exp $");
+__RCSID("$NetBSD: term.c,v 1.38 2003/09/14 21:48:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -352,6 +352,7 @@ term_init(EditLine *el)
term_init_arrow(el);
return (0);
}
+
/* term_end():
* Clean up the terminal stuff
*/
@@ -873,6 +874,12 @@ term_clear_to_bottom(EditLine *el)
}
#endif
+protected void
+term_get(EditLine *el, const char **term)
+{
+ *term = el->el_term.t_name;
+}
+
/* term_set():
* Read in the terminal capabilities from the requested terminal
@@ -954,6 +961,7 @@ term_set(EditLine *el, const char *term)
return (-1);
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
term_bind_arrow(el);
+ el->el_term.t_name = term;
return (i <= 0 ? -1 : 0);
}
diff --git a/lib/libedit/term.h b/lib/libedit/term.h
index 088f93137c1..24b1ef8868d 100644
--- a/lib/libedit/term.h
+++ b/lib/libedit/term.h
@@ -1,4 +1,4 @@
-/* $NetBSD: term.h,v 1.14 2003/08/07 16:44:34 agc Exp $ */
+/* $NetBSD: term.h,v 1.15 2003/09/14 21:48:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -50,6 +50,7 @@ typedef struct { /* Symbolic function key bindings */
} fkey_t;
typedef struct {
+ const char *t_name; /* the terminal name */
coord_t t_size; /* # lines and cols */
int t_flags;
#define TERM_CAN_INSERT 0x001 /* Has insert cap */
@@ -96,6 +97,7 @@ protected void term_print_arrow(EditLine *, const char *);
protected int term_clear_arrow(EditLine *, const char *);
protected int term_set_arrow(EditLine *, const char *, key_value_t *, int);
protected void term_end(EditLine *);
+protected void term_get(EditLine *, const char **);
protected int term_set(EditLine *, const char *);
protected int term_settc(EditLine *, int, const char **);
protected int term_telltc(EditLine *, int, const char **);