summaryrefslogtreecommitdiff
path: root/lib/textplugin.c
diff options
context:
space:
mode:
authorBradley Smith2008-03-08 23:17:19 +0000
committerBradley Smith2008-03-08 23:17:19 +0000
commit3815d708662e2a3c288b70009b2799bbce4fc964 (patch)
treeeaaefae26689cde64ac9b5dd6b4d949d2487bf98 /lib/textplugin.c
parentChange binary name to gnurobots. (diff)
downloadgnurobots-3815d708662e2a3c288b70009b2799bbce4fc964.tar.gz
Add readline support to text plugin.
Signed-off-by: Bradley Smith <brad@brad-smith.co.uk>
Diffstat (limited to 'lib/textplugin.c')
-rw-r--r--lib/textplugin.c22
1 files changed, 19 insertions, 3 deletions
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,