##// END OF EJS Templates
Cleanup of the old stateMachine code...
ldufrechou -
Show More
@@ -112,6 +112,29 b' class NonBlockingIPShell(object):'
112 @param time_loop: Define the sleep time between two thread's loop
112 @param time_loop: Define the sleep time between two thread's loop
113 @type int
113 @type int
114 '''
114 '''
115 #ipython0 initialisation
116 self.initIpython0(argv, user_ns, user_global_ns,
117 cin, cout, cerr,
118 ask_exit_handler)
119
120 #vars used by _execute
121 self._iter_more = 0
122 self._history_level = 0
123 self._complete_sep = re.compile('[\s\{\}\[\]\(\)]')
124 self._prompt = str(self._IP.outputcache.prompt1).strip()
125
126 #thread working vars
127 self._line_to_execute = ''
128
129 #vars that will be checked by GUI loop to handle thread states...
130 #will be replaced later by PostEvent GUI funtions...
131 self._doc_text = None
132 self._help_text = None
133 self._add_button = None
134
135 def initIpython0(self, argv=[], user_ns={}, user_global_ns=None,
136 cin=None, cout=None, cerr=None,
137 ask_exit_handler=None):
115 #first we redefine in/out/error functions of IPython
138 #first we redefine in/out/error functions of IPython
116 if cin:
139 if cin:
117 IPython.Shell.Term.cin = cin
140 IPython.Shell.Term.cin = cin
@@ -147,32 +170,12 b' class NonBlockingIPShell(object):'
147 #we replace the ipython default input command caller by our method
170 #we replace the ipython default input command caller by our method
148 IPython.iplib.raw_input_original = self._raw_input
171 IPython.iplib.raw_input_original = self._raw_input
149 #we replace the ipython default exit command by our method
172 #we replace the ipython default exit command by our method
150 self._IP.exit = self._setAskExit
173 self._IP.exit = ask_exit_handler
151 #we modify Exit and Quit Magic
152 ip = IPython.ipapi.get()
153 ip.expose_magic('Exit', self._setDoExit)
154 ip.expose_magic('Quit', self._setDoExit)
155 #we replace the help command
174 #we replace the help command
156 self._IP.user_ns['help'] = _Helper(self._pager_help)
175 self._IP.user_ns['help'] = _Helper(self._pager_help)
157
176
158 sys.excepthook = excepthook
177 sys.excepthook = excepthook
159
178
160 #vars used by _execute
161 self._iter_more = 0
162 self._history_level = 0
163 self._complete_sep = re.compile('[\s\{\}\[\]\(\)]')
164 self._prompt = str(self._IP.outputcache.prompt1).strip()
165
166 #thread working vars
167 self._line_to_execute = ''
168
169 #vars that will be checked by GUI loop to handle thread states...
170 #will be replaced later by PostEvent GUI funtions...
171 self._doc_text = None
172 self._help_text = None
173 self._ask_exit = False
174 self._add_button = None
175
176 #----------------------- Thread management section ----------------------
179 #----------------------- Thread management section ----------------------
177 def doExecute(self,line):
180 def doExecute(self,line):
178 """
181 """
@@ -185,19 +188,6 b' class NonBlockingIPShell(object):'
185 self.ce.start()
188 self.ce.start()
186
189
187 #----------------------- IPython management section ----------------------
190 #----------------------- IPython management section ----------------------
188 def getAskExit(self):
189 '''
190 returns the _ask_exit variable that can be checked by GUI to see if
191 IPython request an exit handling
192 '''
193 return self._ask_exit
194
195 def clearAskExit(self):
196 '''
197 clear the _ask_exit var when GUI as handled the request.
198 '''
199 self._ask_exit = False
200
201 def getDocText(self):
191 def getDocText(self):
202 """
192 """
203 Returns the output of the processing that need to be paged (if any)
193 Returns the output of the processing that need to be paged (if any)
@@ -350,20 +340,12 b' class NonBlockingIPShell(object):'
350 '''
340 '''
351 pass
341 pass
352
342
353 def _setAskExit(self):
343 #def _askExit(self):
354 '''
344 # '''
355 set the _ask_exit variable that can be checked by GUI to see if
345 # Can be redefined to generate post event to exit the Ipython shell
356 IPython request an exit handling
346 # '''
357 '''
347 # pass
358 self._ask_exit = True
359
348
360 def _setDoExit(self, toto, arg):
361 '''
362 set the _do_exit variable that can be checked by GUI to see if
363 IPython do a direct exit of the app
364 '''
365 self._do_exit = True
366
367 def _getHistoryMaxIndex(self):
349 def _getHistoryMaxIndex(self):
368 '''
350 '''
369 returns the max length of the history buffer
351 returns the max length of the history buffer
@@ -40,7 +40,7 b' except Exception,e:'
40 raise "Error importing IPython (%s)" % str(e)
40 raise "Error importing IPython (%s)" % str(e)
41
41
42
42
43 from NonBlockingIPShell import *
43 from ipshell_nonblocking import NonBlockingIPShell
44
44
45 class WxNonBlockingIPShell(NonBlockingIPShell):
45 class WxNonBlockingIPShell(NonBlockingIPShell):
46 '''
46 '''
@@ -70,6 +70,7 b' class WxNonBlockingIPShell(NonBlockingIPShell):'
70
70
71 self.wx_instance = wx_instance
71 self.wx_instance = wx_instance
72 self._IP.ask_exit = self._askExit
72 self._IP.ask_exit = self._askExit
73 self._IP.exit = self._askExit
73
74
74 #def addGUIShortcut(self,text,func):
75 #def addGUIShortcut(self,text,func):
75 # evt = self.IPythonAddButtonEvent(
76 # evt = self.IPythonAddButtonEvent(
@@ -529,14 +530,10 b' class WxIPythonViewPanel(wx.Panel):'
529 #---------------------------- IPython Thread Management ---------------------------------------
530 #---------------------------- IPython Thread Management ---------------------------------------
530 def stateDoExecuteLine(self):
531 def stateDoExecuteLine(self):
531 #print >>sys.__stdout__,"command:",self.getCurrentLine()
532 #print >>sys.__stdout__,"command:",self.getCurrentLine()
532 self.doExecuteLine(self.text_ctrl.getCurrentLine())
533 line=self.text_ctrl.getCurrentLine()
533
534 def doExecuteLine(self,line):
535 #print >>sys.__stdout__,"command:",line
536 self.IP.doExecute(line.replace('\t',' '*4))
534 self.IP.doExecute(line.replace('\t',' '*4))
537 self.updateHistoryTracker(self.text_ctrl.getCurrentLine())
535 self.updateHistoryTracker(self.text_ctrl.getCurrentLine())
538 self.setCurrentState('WAIT_END_OF_EXECUTION')
536 self.setCurrentState('WAIT_END_OF_EXECUTION')
539
540
537
541 def evtStateExecuteDone(self,evt):
538 def evtStateExecuteDone(self,evt):
542 self.doc = self.IP.getDocText()
539 self.doc = self.IP.getDocText()
General Comments 0
You need to be logged in to leave comments. Login now