Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit Partial rl_getc_function support from Jess Thrys...



details:   https://anonhg.NetBSD.org/src/rev/033248cc0bd3
branches:  trunk
changeset: 588244:033248cc0bd3
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Feb 12 16:15:07 2006 +0000

description:
Partial rl_getc_function support from Jess Thrysoee.

diffstat:

 lib/libedit/readline.c |  25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diffs (60 lines):

diff -r b381581f4a9e -r 033248cc0bd3 lib/libedit/readline.c
--- a/lib/libedit/readline.c    Sun Feb 12 15:53:34 2006 +0000
+++ b/lib/libedit/readline.c    Sun Feb 12 16:15:07 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: readline.c,v 1.58 2005/07/14 15:00:58 christos Exp $   */
+/*     $NetBSD: readline.c,v 1.59 2006/02/12 16:15:07 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.58 2005/07/14 15:00:58 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.59 2006/02/12 16:15:07 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -160,6 +160,7 @@
 static unsigned char    _el_rl_complete(EditLine *, int);
 static unsigned char    _el_rl_tstp(EditLine *, int);
 static char            *_get_prompt(EditLine *);
+static int              _getc_function(EditLine *, char *);
 static HIST_ENTRY      *_move_history(int);
 static int              _history_expand_command(const char *, size_t, size_t,
     char **);
@@ -198,6 +199,22 @@
 
 
 /*
+ * read one key from user defined input function
+ */
+static int
+_getc_function(EditLine *el, char *c)
+{
+       int i;
+
+       i = (*rl_getc_function)(NULL, 0);
+       if (i == -1)
+               return 0;
+       *c = i;
+       return 1;
+}
+
+
+/*
  * READLINE compatibility stuff
  */
 
@@ -242,6 +259,10 @@
        max_input_history = INT_MAX;
        el_set(e, EL_HIST, history, h);
 
+       /* setup getc function if valid */
+       if (rl_getc_function)
+               el_set(e, EL_GETCFN, _getc_function);
+
        /* for proper prompt printing in readline() */
        rl_prompt = strdup("");
        if (rl_prompt == NULL) {



Home | Main Index | Thread Index | Old Index