##// END OF EJS Templates
BIG improvement on cout management....
ldufrechou -
Show More
@@ -302,18 +302,6 b' class WxConsoleView(stc.StyledTextCtrl):'
302 return self.GetTextRange(self.getCurrentPromptStart(),
302 return self.GetTextRange(self.getCurrentPromptStart(),
303 self.getCurrentLineEnd())
303 self.getCurrentLineEnd())
304
304
305 def showReturned(self, text):
306 '''
307 Show returned text from last command and print new prompt.
308
309 @param text: Text to show.
310 @type text: string
311 '''
312 self.write('\n'+text)
313 if text:
314 self.write('\n')
315 self.showPrompt()
316
317 def moveCursorOnNewValidKey(self):
305 def moveCursorOnNewValidKey(self):
318 #If cursor is at wrong position put it at last line...
306 #If cursor is at wrong position put it at last line...
319 if self.GetCurrentPos() < self.getCurrentPromptStart():
307 if self.GetCurrentPos() < self.getCurrentPromptStart():
@@ -461,6 +449,7 b' class IPShellWidget(wx.Panel):'
461 because it seems to be more useful
449 because it seems to be more useful
462 Any idea to make it more 'generic' welcomed.
450 Any idea to make it more 'generic' welcomed.
463 '''
451 '''
452
464 def __init__(self, parent, intro=None,
453 def __init__(self, parent, intro=None,
465 background_color="BLACK", add_button_handler=None,
454 background_color="BLACK", add_button_handler=None,
466 wx_ip_shell=None,
455 wx_ip_shell=None,
@@ -475,7 +464,6 b' class IPShellWidget(wx.Panel):'
475
464
476 ### IPython non blocking shell instanciation ###
465 ### IPython non blocking shell instanciation ###
477 self.cout = StringIO()
466 self.cout = StringIO()
478
479 self.add_button_handler = add_button_handler
467 self.add_button_handler = add_button_handler
480
468
481 if wx_ip_shell is not None:
469 if wx_ip_shell is not None:
@@ -501,9 +489,11 b' class IPShellWidget(wx.Panel):'
501 self.IP.getPrompt(),
489 self.IP.getPrompt(),
502 intro=welcome_text,
490 intro=welcome_text,
503 background_color=background_color)
491 background_color=background_color)
492
493 self.cout.write = self.text_ctrl.write
504
494
505 self.text_ctrl.Bind(wx.EVT_KEY_DOWN, self.keyPress, self.text_ctrl)
495 self.text_ctrl.Bind(wx.EVT_KEY_DOWN, self.keyPress, self.text_ctrl)
506
496
507 ### making the layout of the panel ###
497 ### making the layout of the panel ###
508 sizer = wx.BoxSizer(wx.VERTICAL)
498 sizer = wx.BoxSizer(wx.VERTICAL)
509 sizer.Add(self.text_ctrl, 1, wx.EXPAND)
499 sizer.Add(self.text_ctrl, 1, wx.EXPAND)
@@ -525,6 +515,7 b' class IPShellWidget(wx.Panel):'
525 def stateDoExecuteLine(self):
515 def stateDoExecuteLine(self):
526 #print >>sys.__stdout__,"command:",self.getCurrentLine()
516 #print >>sys.__stdout__,"command:",self.getCurrentLine()
527 line=self.text_ctrl.getCurrentLine()
517 line=self.text_ctrl.getCurrentLine()
518 self.text_ctrl.write('\n')
528 self.IP.doExecute((line.replace('\t',' '*4)).encode('cp1252'))
519 self.IP.doExecute((line.replace('\t',' '*4)).encode('cp1252'))
529 self.updateHistoryTracker(self.text_ctrl.getCurrentLine())
520 self.updateHistoryTracker(self.text_ctrl.getCurrentLine())
530 self.setCurrentState('WAIT_END_OF_EXECUTION')
521 self.setCurrentState('WAIT_END_OF_EXECUTION')
@@ -550,10 +541,7 b' class IPShellWidget(wx.Panel):'
550 self.text_ctrl.setPrompt(self.IP.getPrompt())
541 self.text_ctrl.setPrompt(self.IP.getPrompt())
551 self.text_ctrl.setIndentation(self.IP.getIndentation())
542 self.text_ctrl.setIndentation(self.IP.getIndentation())
552 self.text_ctrl.setPromptCount(self.IP.getPromptCount())
543 self.text_ctrl.setPromptCount(self.IP.getPromptCount())
553 rv = self.cout.getvalue()
544 self.text_ctrl.showPrompt()
554 if rv: rv = rv.strip('\n')
555 self.text_ctrl.showReturned(rv)
556 self.cout.truncate(0)
557 self.IP.initHistoryIndex()
545 self.IP.initHistoryIndex()
558 self.setCurrentState('IDLE')
546 self.setCurrentState('IDLE')
559
547
@@ -640,8 +628,11 b' class IPShellWidget(wx.Panel):'
640 self.pager_state = 'DONE'
628 self.pager_state = 'DONE'
641 self.stateShowPrompt()
629 self.stateShowPrompt()
642 return
630 return
643
631
644 #scroll_position = self.text_ctrl.GetScrollPos(wx.VERTICAL)
632 # if self.cur_state == 'WAIT_END_OF_EXECUTION':
633 # print self.cur_state
634 # self.text_ctrl.write('.')
635
645 if self.cur_state == 'IDLE':
636 if self.cur_state == 'IDLE':
646 if event.KeyCode == wx.WXK_UP:
637 if event.KeyCode == wx.WXK_UP:
647 history = self.IP.historyBack()
638 history = self.IP.historyBack()
@@ -669,7 +660,7 b' class IPShellWidget(wx.Panel):'
669
660
670 return
661 return
671 event.Skip()
662 event.Skip()
672
663
673 #------------------------ Hook Section -----------------------------------
664 #------------------------ Hook Section -----------------------------------
674 def updateHistoryTracker(self,command_line):
665 def updateHistoryTracker(self,command_line):
675 '''
666 '''
@@ -36,8 +36,7 b' class MyFrame(wx.Frame):'
36
36
37 self.ipython_panel = IPShellWidget(self,background_color = "BLACK")
37 self.ipython_panel = IPShellWidget(self,background_color = "BLACK")
38
38
39 #self.ipython_panel = WxIPythonViewPanel(self,
39 #self.ipython_panel = IPShellWidget(self,background_color = "WHITE")
40 # background_color = "WHITE")
41
40
42 self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)
41 self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)
43 self.ipython_panel.setStatusTrackerHook(self.updateStatus)
42 self.ipython_panel.setStatusTrackerHook(self.updateStatus)
General Comments 0
You need to be logged in to leave comments. Login now