]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxGUIScriptingInterface.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkWxGUIScriptingInterface.cxx
index 245e1f2a927ebfcb3258f1c350b2090e3b66b68f..966c1f70486f924d6c5f3eb88e6b00215d0f4322 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/10/21 14:38:31 $
-  Version:   $Revision: 1.31 $
+  Date:      $Date: 2008/12/15 09:04:47 $
+  Version:   $Revision: 1.32 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -95,7 +95,8 @@ namespace bbtk
     mInterpreter->SetUser(this);
     mInterpreter->SetCommandLine(true);
     mInterpreter->SetThrow(true);
-    
+    //    mInterpreter->AddBreakObserver
+    //boost::bind( &WxGUIScriptingInterface::InterpreterUserOnBreak, this ));
     //==============
     // Menu
     wxInitAllImageHandlers();
@@ -260,7 +261,8 @@ namespace bbtk
     m_mgr.Update();
     //   LoadPerspective();
 
-
+    mBreaked = false;  
+    
     wxTipWindow* tip = new wxTipWindow(this,
                                       _T("\n                  Welcome to bbStudio !\n\n   To run a demo or example:\n     1. click on the 'Demos' or 'Examples' link\n     2. select a demo or example\n     3. click on the '[source]' link : the source file is loaded in bbStudio\n     4. click on the 'Run' button (the arrow at the bottom right of the source file)   \n"),1000);
     tip->CenterOnParent();
@@ -282,24 +284,54 @@ namespace bbtk
     mWxGUITextEditor->Open(filename);
   }
   //================================================================
-  
-#define CATCH_MACRO                                                    \
-  catch (QuitException e)                                              \
+  /*
+  catch (BreakException e)                                             \
     {                                                                  \
-      std::cout << "* quit exception caught"<<std::endl;               \
+      std::cout << "* BREAK"<<std::endl;                               \
+      if (e.IsInScriptFile())                                          \
+       std::cout << "* FILE   : '"<<e.GetScriptFile()<<"'"<<std::endl; \
+      std::cout << "* LINE   : "<<e.GetScriptLine()<<std::endl;                \
     }                                                                  \
-  catch (InterpreterError e)                                           \
+  catch (QuitException e)                                              \
     {                                                                  \
-      std::cerr << "* IERROR : "<<e.GetErrorMessage()<<std::endl;              \
+      std::cout << "* QUIT"<<std::endl;                                        \
       if (e.IsInScriptFile())                                          \
-       std::cerr << "* FILE   : '"<<e.GetScriptFile()<<"'"<<std::endl; \
-      std::cerr << "* LINE   : "<<e.GetScriptLine()<<std::endl;                \
-      int lev = bbtk::MessageManager::GetMessageLevel("Error");                \
-      if (lev > 0) {                                                   \
-       std::cerr << "* Exception thrown : "<<std::endl;                \
-       std::cerr << "*  OBJECT : " <<e.GetObject()<<std::endl;         \
-       std::cerr << "*  FILE   : " <<e.GetSourceFile()<<std::endl;     \
-      }                                                                        \
+       std::cout << "* FILE   : '"<<e.GetScriptFile()<<"'"<<std::endl; \
+      std::cout << "* LINE   : "<<e.GetScriptLine()<<std::endl;                \
+    }                                                                  \
+*/
+  
+#define CATCH_MACRO                                                    \
+  catch (InterpreterException e)                                       \
+    {                                                                  \
+      if (e.GetErrorMessage()=="quit")                                 \
+       {                                                               \
+         std::cerr << "* QUIT ENCOUNTERED"<<std::endl;                 \
+         if (e.IsInScriptFile())                                       \
+           std::cerr << "* FILE   : '"<<e.GetScriptFile()<<"'"<<std::endl; \
+         std::cerr << "* LINE   : "<<e.GetScriptLine()<<std::endl;     \
+       }                                                               \
+      else if (e.GetErrorMessage()=="break")                           \
+       {                                                               \
+         mBreaked = true;                                              \
+         std::cerr << "* BREAK"<<std::endl;                            \
+         if (e.IsInScriptFile())                                       \
+           std::cerr << "* FILE   : '"<<e.GetScriptFile()<<"'"<<std::endl; \
+         std::cerr << "* LINE   : "<<e.GetScriptLine()<<std::endl;     \
+       }                                                               \
+      else                                                             \
+       {                                                               \
+         std::cerr << "* ERROR : "<<e.GetErrorMessage()<<std::endl;    \
+         if (e.IsInScriptFile())                                       \
+           std::cerr << "* FILE   : '"<<e.GetScriptFile()<<"'"<<std::endl; \
+         std::cerr << "* LINE   : "<<e.GetScriptLine()<<std::endl;     \
+         int lev = bbtk::MessageManager::GetMessageLevel("Error");     \
+         if (lev > 0) {                                                \
+           std::cerr << "* Exception thrown : "<<std::endl;            \
+           std::cerr << "*  OBJECT : " <<e.GetObject()<<std::endl;     \
+           std::cerr << "*  FILE   : " <<e.GetSourceFile()<<std::endl; \
+         }                                                             \
+       }                                                               \
     }
   
   //================================================================
@@ -338,9 +370,16 @@ namespace bbtk
     (*buf) << mWxGUITextEditor->GetCurrentPage()->GetText();
     try 
       {
-       //      std::cout << "RUN"<<std::endl;
-       if (mwxMenuItemReset->IsChecked()) WxGUICommandEnter("reset");
-       mInterpreter->InterpretBuffer(buf);
+       if (!mBreaked)
+         {
+           if (mwxMenuItemReset->IsChecked()) WxGUICommandEnter("reset");
+           mInterpreter->InterpretBuffer(buf);
+         }
+       else 
+         {
+           mBreaked = false;
+           mInterpreter->InterpretCurrentStreams();
+         }
        //      std::cout << "EO RUN"<<std::endl;
       }
     CATCH_MACRO;
@@ -609,6 +648,16 @@ namespace bbtk
   } 
   //================================================================  
   
+  /*
+  //================================================================
+  void WxGUIScriptingInterface::InterpreterUserOnBreak()
+  {
+    //    std::cout << "Break" << std::endl;
+    
+  }
+  //================================================================
+  */
+
   //================================================================  
   bool WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked(const std::string& target)
   {