aboutsummaryrefslogtreecommitdiffstats
path: root/common/ttyio.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2006-09-21 13:30:45 +0000
committerWerner Koch <[email protected]>2006-09-21 13:30:45 +0000
commit43ab905823df0ae44607cda41da9c105e009c1e5 (patch)
tree155ab1ee960c61dbaa5c4db6747358fa0117bf14 /common/ttyio.c
parentCleanups. (diff)
downloadgnupg-43ab905823df0ae44607cda41da9c105e009c1e5.tar.gz
gnupg-43ab905823df0ae44607cda41da9c105e009c1e5.zip
Various updates
Diffstat (limited to 'common/ttyio.c')
-rw-r--r--common/ttyio.c85
1 files changed, 51 insertions, 34 deletions
diff --git a/common/ttyio.c b/common/ttyio.c
index 38883afa5..8b8f8835f 100644
--- a/common/ttyio.c
+++ b/common/ttyio.c
@@ -47,15 +47,10 @@
#endif
#include <errno.h>
#include <ctype.h>
-#ifdef HAVE_LIBREADLINE
-#include <readline/readline.h>
-#include <readline/history.h>
-#endif
-
#include "util.h"
-#include "memory.h"
#include "ttyio.h"
+#include "common-defs.h"
#define CONTROL_D ('D' - 'A' + 1)
@@ -82,6 +77,11 @@ static int no_terminal;
static int restore_termios;
#endif
+/* Hooks set by gpgrlhelp.c if required. */
+static void (*my_rl_set_completer) (rl_completion_func_t *);
+static void (*my_rl_inhibit_completion) (int);
+static void (*my_rl_cleanup_after_signal) (void);
+
/* This is a wrapper around ttyname so that we can use it even when
@@ -181,34 +181,6 @@ init_ttyfp(void)
}
-#ifdef HAVE_LIBREADLINE
-void
-tty_enable_completion(rl_completion_func_t *completer)
-{
-/* if( no_terminal ) */
-/* return; */
-
-/* if( !initialized ) */
-/* init_ttyfp(); */
-
-/* rl_attempted_completion_function=completer; */
-/* rl_inhibit_completion=0; */
-}
-
-void
-tty_disable_completion(void)
-{
-/* if( no_terminal ) */
-/* return; */
-
-/* if( !initialized ) */
-/* init_ttyfp(); */
-
-/* rl_inhibit_completion=1; */
-}
-#endif /*HAVE_LIBREADLINE*/
-
-
int
tty_batchmode( int onoff )
{
@@ -597,3 +569,48 @@ tty_get_answer_is_yes( const char *prompt )
xfree(p);
return yes;
}
+
+
+/* Called by gnupg_rl_initialize to setup the reradline support. */
+void
+tty_private_set_rl_hooks (void (*set_completer) (rl_completion_func_t*),
+ void (*inhibit_completion) (int),
+ void (*cleanup_after_signal) (void))
+{
+ my_rl_set_completer = set_completer;
+ my_rl_inhibit_completion = inhibit_completion;
+ my_rl_cleanup_after_signal = cleanup_after_signal;
+}
+
+
+void
+tty_enable_completion (rl_completion_func_t *completer)
+{
+ if (no_terminal || !my_rl_set_completer )
+ return;
+
+ if (!initialized)
+ init_ttyfp();
+
+ my_rl_set_completer (completer);
+}
+
+void
+tty_disable_completion (void)
+{
+ if (no_terminal || !my_rl_inhibit_completion)
+ return;
+
+ if (!initialized)
+ init_ttyfp();
+
+ my_rl_inhibit_completion (1);
+}
+
+
+void
+tty_cleanup_rl_after_signal (void)
+{
+ if (my_rl_cleanup_after_signal)
+ my_rl_cleanup_after_signal ();
+}