Enlightenment CVS committal
Author : kwo
Project : e16
Module : e
Dir : e16/e/eesh
Modified Files:
Makefile.am main.c
Log Message:
Added possibility to use readline in eesh (--with-readline, default off).
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/eesh/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- Makefile.am 15 Jul 2003 18:35:02 -0000 1.5
+++ Makefile.am 17 Aug 2003 10:11:50 -0000 1.6
@@ -12,7 +12,7 @@
file.c \
alert.c
-LDADD = $(X_PRE_LIBS) $(X_LIBS) -lX11 $(X_EXTRA_LIBS) -lm
+LDADD = $(X_PRE_LIBS) $(X_LIBS) -lX11 $(X_EXTRA_LIBS) $(RL_LIBS) -lm
INCLUDES = $(IMLIB_CFLAGS) -I$(top_builddir) -I$(top_srcdir)/intl
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/eesh/main.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- main.c 31 Mar 2000 02:25:12 -0000 1.10
+++ main.c 17 Aug 2003 10:11:50 -0000 1.11
@@ -28,26 +28,51 @@
#endif
#include <sys/types.h>
#include <unistd.h>
+#if USE_READLINE
+#include <readline/readline.h>
+#include <readline/history.h>
+#endif
extern char waitonly;
+#if !USE_READLINE
+static char buf[10240];
static int stdin_state;
-void restore_stdin_state(void);
-void
+#endif
+static Client *e;
+
+static void
restore_stdin_state(void)
{
+#if USE_READLINE
+ rl_callback_handler_remove();
+#else
fcntl(0, F_SETFL, stdin_state);
+#endif
+}
+
+static void
+process_line(char *line)
+{
+ if (line == NULL)
+ exit(0);
+ if (*line == '\0')
+ return;
+
+ CommsSend(e, line);
+ XSync(disp, False);
+#if USE_READLINE
+ add_history(line);
+#endif
}
int
main(int argc, char **argv)
{
XEvent ev;
- Client *me, *e;
- char buf[10240];
- int i, j, k;
+ Client *me;
+ int i, j;
fd_set fd;
- signed char ret;
char *command;
waitonly = 0;
@@ -119,10 +144,16 @@
}
XSync(disp, False);
- j = 0;
+
+#if USE_READLINE
+ rl_callback_handler_install("", process_line);
+#else
stdin_state = fcntl(0, F_GETFL, 0);
- atexit(restore_stdin_state);
fcntl(0, F_SETFL, O_NONBLOCK);
+#endif
+ atexit(restore_stdin_state);
+
+ j = 0;
for (;;)
{
if (waitonly)
@@ -145,6 +176,11 @@
if (FD_ISSET(0, &fd))
{
+#if USE_READLINE
+ rl_callback_read_char();
+#else
+ int k, ret;
+
k = 0;
while ((ret = read(0, &(buf[j]), 1) > 0))
{
@@ -153,16 +189,14 @@
{
buf[j] = 0;
if (strlen(buf) > 0)
- {
- CommsSend(e, buf);
- XSync(disp, False);
- }
+ process_line(buf);
j = -1;
}
j++;
}
if ((ret < 0) || ((k == 0) && (ret == 0)))
exit(0);
+#endif
}
else if (FD_ISSET(ConnectionNumber(disp), &fd))
{
@@ -178,5 +212,6 @@
}
}
}
+
return 0;
}
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs