diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | lib/Makefile.am | 2 | ||||
-rw-r--r-- | lib/textplugin.c | 22 |
3 files changed, 28 insertions, 4 deletions
@@ -7,6 +7,12 @@ * src/main.c: Add error message when given an invalid instruction. Add initial ui update to avoid corruption. + * lib/textplugin.c: + Add readline support to text plugin + * lib/Makefile.am: + Add readline libs/includes to text plugin + * src/Makefile.am: + Change binary name to gnurobots 2008-03-07 Bradley Smith <brad@brad-smith.co.uk> @@ -17,6 +23,8 @@ Add readline/history support to command line. * various: Fix code to compile with stricter flags. + * lib/Makefile.am: + Add readline libs/includes to x11 plugin 2005-09-06 Zeeshan Ali Khattak <zeenix@gmail.com> * src/main.c src/api.c include/api.h include/main.h: diff --git a/lib/Makefile.am b/lib/Makefile.am index 36a2a6c..f0ec6ab 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -36,7 +36,7 @@ pkglib_LTLIBRARIES = libgrobots-text.la $(CURSES_PLUGIN) $(X11_PLUGIN) libgrobots_text_la_SOURCES = textplugin.c libgrobots_text_la_LDFLAGS = -module -avoid-version -libgrobots_text_la_LIBADD = $(GLIB2_LIBS) +libgrobots_text_la_LIBADD = $(GLIB2_LIBS) $(READLINE_LIBS) libgrobots_curses_la_SOURCES = cursesplugin.c libgrobots_curses_la_LDFLAGS = -module -avoid-version diff --git a/lib/textplugin.c b/lib/textplugin.c index 61110d5..0c3059c 100644 --- a/lib/textplugin.c +++ b/lib/textplugin.c @@ -23,13 +23,17 @@ #include <glib.h> #include <glib/gprintf.h> #include <stdio.h> +#include <stdlib.h> #include "configs.h" #include "textplugin.h" +#include <readline.h> +#include <history.h> + enum { ARG_0, - ARG_MAP + ARG_MAP }; GType _text_plugin_type = 0; @@ -350,8 +354,20 @@ inline void text_plugin_get_string (TextPlugin *text, gchar *buff, gint len) { - 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 text_plugin_update_status (TextPlugin *text, |