libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] gvars3 Makefile.in configure configure.ac gvars...


From: Georg Klein
Subject: [libcvd-members] gvars3 Makefile.in configure configure.ac gvars...
Date: Tue, 12 Feb 2008 19:37:16 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    gvars3
Changes by:     Georg Klein <georgklein>        08/02/12 19:37:16

Modified files:
        .              : Makefile.in configure configure.ac 
        gvars3         : GUI.h 
        src            : GUI.cc 

Log message:
        Added GUI::StartParserThread() and StopParserThread() commands.
        These fire up a parser thread, which either uses readline on not, 
depending
        on the presence/selection of readline in autoconf.
        
        n.b. The non-readline version of StopParserThread needs the user to
        press enter, 'cause I don't know how to get cin.readline() to abort.
        
        ps. if you put the line
          atexit(StopParserThread);
        in your main.cc, it cleans up readline even in some crashes. magic.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gvars3/Makefile.in?cvsroot=libcvd&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gvars3/configure?cvsroot=libcvd&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gvars3/configure.ac?cvsroot=libcvd&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gvars3/gvars3/GUI.h?cvsroot=libcvd&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gvars3/src/GUI.cc?cvsroot=libcvd&r1=1.19&r2=1.20

Patches:
Index: Makefile.in
===================================================================
RCS file: /cvsroot/libcvd/gvars3/Makefile.in,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- Makefile.in 1 Feb 2008 14:57:35 -0000       1.20
+++ Makefile.in 12 Feb 2008 19:37:15 -0000      1.21
@@ -95,6 +95,8 @@
 ifeq (@have_readline@,yes)
        OBJS+=src/GUI_readline.o 
     CPPFLAGS+=-DGUI_HAVE_READLINE
+else
+       OBJS+=src/GUI_non_readline.o 
 endif
 
 ifeq (@have_fltk@,yes)

Index: configure
===================================================================
RCS file: /cvsroot/libcvd/gvars3/configure,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- configure   1 Feb 2008 14:57:35 -0000       1.13
+++ configure   12 Feb 2008 19:37:15 -0000      1.14
@@ -850,6 +850,7 @@
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-TooN=directory  Specify location for TooN
+  --without-readline      Disable use of libreadline
   --with-x                use the X Window System
   --with-headless    Build additional headless library
 
@@ -2863,6 +2864,15 @@
 
################################################################################
 
 
+# Check whether --with-readline or --without-readline was given.
+if test "${with_readline+set}" = set; then
+  withval="$with_readline"
+  with_readline="$withval"
+else
+  with_readline=yes
+fi;
+if test "$with_readline" == "yes"
+then
 foo_LIBS="$LIBS"
 for curse in "" ncurses curses
 do
@@ -3035,7 +3045,7 @@
                unset ac_cv_lib_readline_rl_done
        fi
 done
-
+fi
 
################################################################################
 #
 # Basic dialogue box functionality

Index: configure.ac
===================================================================
RCS file: /cvsroot/libcvd/gvars3/configure.ac,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- configure.ac        1 Feb 2008 14:57:35 -0000       1.12
+++ configure.ac        12 Feb 2008 19:37:15 -0000      1.13
@@ -120,7 +120,9 @@
 
################################################################################
 
################################################################################
 
-
+AC_ARG_WITH(readline,   [  --without-readline      Disable use of 
libreadline], [with_readline="$withval"], [with_readline=yes])
+if test "$with_readline" == "yes"
+then
 foo_LIBS="$LIBS"
 for curse in "" ncurses curses
 do
@@ -143,7 +145,7 @@
                unset ac_cv_lib_readline_rl_done
        fi
 done
-
+fi
 
################################################################################
 #
 # Basic dialogue box functionality

Index: gvars3/GUI.h
===================================================================
RCS file: /cvsroot/libcvd/gvars3/gvars3/GUI.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- gvars3/GUI.h        17 May 2007 12:01:57 -0000      1.6
+++ gvars3/GUI.h        12 Feb 2008 19:37:15 -0000      1.7
@@ -56,6 +56,13 @@
          bool CallCallbacks(std::string sCommand, std::string sParams);
          void SetupReadlineCompletion();
 
+         /// Start a thread which parses user input from the console.
+         /// Uses libreadline if configured, or just plain old iostream 
readline
+         void StartParserThread();
+         /// Stop the console parser thread, if running
+         /// Top tip: This is static so that it can be used with atexit(void*)
+         static void StopParserThread();
+         
        /// parse command line arguments for GVar values. It expects the form 
--name value and will stop
        /// parsing when this form is not true anymore. possible cases are a 
single --, an argument, etc..
        /// if it finds an argument --exec it interprets the next argument as a 
file name to load via LoadFile
@@ -81,6 +88,8 @@
          void *mptr;
          GUICallbackProc cbp;
 
+         static void *mpParserThread;
+
          std::map<std::string, CallbackVector > mmCallBackMap;
          std::set<std::string> builtins;
          std::map<std::string, std::vector<std::string> > mmQueues;

Index: src/GUI.cc
===================================================================
RCS file: /cvsroot/libcvd/gvars3/src/GUI.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- src/GUI.cc  12 Feb 2008 17:56:54 -0000      1.19
+++ src/GUI.cc  12 Feb 2008 19:37:15 -0000      1.20
@@ -22,7 +22,11 @@
 #include "gvars3/GUI.h"
 #include "gvars3/GStringUtil.h"
 
-
+#ifdef GUI_HAVE_READLINE
+#include <gvars3/GUI_readline.h>
+#else
+#include <gvars3/GUI_non_readline.h>
+#endif
 
 #include <cctype>
 #include <sstream>
@@ -33,6 +37,7 @@
 #include <algorithm>
 
 
+
 using namespace std;
 namespace GVars3
 {
@@ -621,13 +626,6 @@
       vQueue.clear();   // do not clear the queue if the command was 
runqueue_noclear!
   }
 
-  ///////////////////////////////////////
-  ///////////////////////////////////////
-  ////////     Readline stuff:
-  ///////////////////////////////////////
-  ///////////////////////////////////////
-
-
   int GUI::parseArguments( const int argc, char * argv[], int start, const 
string prefix, const string execKeyword ){
     while(start < argc){
       string opt = argv[start];
@@ -718,6 +716,15 @@
   };
   
   
+
+  ///////////////////////////////////////
+  ///////////////////////////////////////
+  ////////     Parser/Readline stuff:
+  ///////////////////////////////////////
+  ///////////////////////////////////////
+
+  void* GUI::mpParserThread = NULL;
+  
 #ifdef GUI_HAVE_READLINE
 #include <readline/readline.h>
 #include <readline/history.h>
@@ -765,6 +772,29 @@
 #endif
 
 
+  void GUI::StartParserThread()
+  {
+    if(mpParserThread)  // Only makes sense to have one instance of the parser 
thread.
+      return;
+    
+#ifdef GUI_HAVE_READLINE
+    mpParserThread = new spawn_readline_thread("quit");
+#else
+    mpParserThread = new spawn_non_readline_thread("");
+#endif
+  }
+
+  void GUI::StopParserThread()
+  {
+    if(!mpParserThread)
+      return;
+#ifdef GUI_HAVE_READLINE
+    delete( (spawn_readline_thread*) mpParserThread);
+#else
+    delete( (spawn_non_readline_thread*) mpParserThread);
+#endif    
+    mpParserThread = NULL;
+  }
 
 
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]