From e873d9aba5c545c1fa78e13a496baf6ac746f889 Mon Sep 17 00:00:00 2001 From: Bradley Smith Date: Fri, 7 Mar 2008 21:49:03 +0000 Subject: Add readline support to x11_plugin's commandline input. Signed-off-by: Bradley Smith --- lib/Makefile.am | 4 ++-- lib/x11plugin.c | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/Makefile.am b/lib/Makefile.am index f3d6283..36a2a6c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -30,7 +30,7 @@ else X11_PLUGIN= endif -INCLUDES = $(GLIB2_CFLAGS) $(CURSES_CFLAGS) $(X_FLAGS) -I$(top_builddir)/include +INCLUDES = $(GLIB2_CFLAGS) $(CURSES_CFLAGS) $(X_FLAGS) -I$(top_builddir)/include $(READLINE_CFLAGS) pkglib_LTLIBRARIES = libgrobots-text.la $(CURSES_PLUGIN) $(X11_PLUGIN) @@ -44,5 +44,5 @@ libgrobots_curses_la_LIBADD = $(GLIB2_LIBS) $(CURSES_LIBS) libgrobots_x11_la_SOURCES = x11plugin.c libgrobots_x11_la_LDFLAGS = -module -avoid-version -libgrobots_x11_la_LIBADD = $(GLIB2_LIBS) $(X_LIBS) +libgrobots_x11_la_LIBADD = $(GLIB2_LIBS) $(X_LIBS) $(READLINE_LIBS) diff --git a/lib/x11plugin.c b/lib/x11plugin.c index 4585be5..81bba80 100644 --- a/lib/x11plugin.c +++ b/lib/x11plugin.c @@ -27,6 +27,8 @@ #include "configs.h" #include "x11plugin.h" +#include + enum { ARG_0, @@ -580,8 +582,23 @@ inline void x11_plugin_get_string (X11Plugin *x11, /* You want me to write a text-box using xlib? * You got to be kidding me * */ - fputs (prompt, stdout); - fgets (buff, len, stdin); +/* fputs (prompt, stdout); */ +/* fgets (buff, len, stdin); */ + + char* line = (char*)NULL; + + line = readline(prompt); + + if(line && *line) + { + add_history(line); + + g_strlcpy(buff, line, len); + } + else + buff = ""; + + free(line); } inline void x11_update_status (X11Plugin *x11, -- cgit v1.1