##// END OF EJS Templates
Cleaning up lignes longer than 80 characters.
Gael Varoquaux -
Show More
@@ -106,7 +106,8 b' class WxConsoleView(stc.StyledTextCtrl):'
106 '1;34': [12,'LIGHT BLUE'], '1;35': [13,'MEDIUM VIOLET RED'],
106 '1;34': [12,'LIGHT BLUE'], '1;35': [13,'MEDIUM VIOLET RED'],
107 '1;36': [14,'LIGHT STEEL BLUE'], '1;37': [15,'YELLOW']}
107 '1;36': [14,'LIGHT STEEL BLUE'], '1;37': [15,'YELLOW']}
108
108
109 def __init__(self,parent,prompt,intro="",background_color="BLACK",pos=wx.DefaultPosition, ID = -1, size=wx.DefaultSize,
109 def __init__(self,parent,prompt,intro="",background_color="BLACK",
110 pos=wx.DefaultPosition, ID = -1, size=wx.DefaultSize,
110 style=0):
111 style=0):
111 '''
112 '''
112 Initialize console view.
113 Initialize console view.
@@ -122,9 +123,10 b' class WxConsoleView(stc.StyledTextCtrl):'
122 '''
123 '''
123 stc.StyledTextCtrl.__init__(self, parent, ID, pos, size, style)
124 stc.StyledTextCtrl.__init__(self, parent, ID, pos, size, style)
124
125
125 ####### Scintilla configuration ##################################################
126 ####### Scintilla configuration ###################################
126
127
127 # Ctrl + B or Ctrl + N can be used to zoomin/zoomout the text inside the widget
128 # Ctrl + B or Ctrl + N can be used to zoomin/zoomout the text inside
129 # the widget
128 self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN)
130 self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN)
129 self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
131 self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
130
132
@@ -186,12 +188,16 b' class WxConsoleView(stc.StyledTextCtrl):'
186 self.SetCaretForeground("WHITE")
188 self.SetCaretForeground("WHITE")
187 self.ANSI_STYLES = self.ANSI_STYLES_BLACK
189 self.ANSI_STYLES = self.ANSI_STYLES_BLACK
188
190
189 self.StyleSetSpec(stc.STC_STYLE_DEFAULT, "fore:%s,back:%s,size:%d,face:%s" % (self.ANSI_STYLES['0;30'][1],
191 self.StyleSetSpec(stc.STC_STYLE_DEFAULT,
190 self.background_color,
192 "fore:%s,back:%s,size:%d,face:%s"
191 faces['size'], faces['mono']))
193 % (self.ANSI_STYLES['0;30'][1],
194 self.background_color,
195 faces['size'], faces['mono']))
192 self.StyleClearAll()
196 self.StyleClearAll()
193 self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT, "fore:#FF0000,back:#0000FF,bold")
197 self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT,
194 self.StyleSetSpec(stc.STC_STYLE_BRACEBAD, "fore:#000000,back:#FF0000,bold")
198 "fore:#FF0000,back:#0000FF,bold")
199 self.StyleSetSpec(stc.STC_STYLE_BRACEBAD,
200 "fore:#000000,back:#FF0000,bold")
195
201
196 for style in self.ANSI_STYLES.values():
202 for style in self.ANSI_STYLES.values():
197 self.StyleSetSpec(style[0], "bold,fore:%s" % style[1])
203 self.StyleSetSpec(style[0], "bold,fore:%s" % style[1])
@@ -207,7 +213,6 b' class WxConsoleView(stc.StyledTextCtrl):'
207 self.showPrompt()
213 self.showPrompt()
208
214
209 self.Bind(wx.EVT_KEY_DOWN, self._onKeypress, self)
215 self.Bind(wx.EVT_KEY_DOWN, self._onKeypress, self)
210 #self.Bind(stc.EVT_STC_UPDATEUI, self.OnUpdateUI)
211
216
212 def write(self, text):
217 def write(self, text):
213 '''
218 '''
@@ -481,7 +486,8 b' class WxIPythonViewPanel(wx.Panel):'
481 ask_exit_handler = ask_exit_handler)
486 ask_exit_handler = ask_exit_handler)
482 ### IPython wx console view instanciation ###
487 ### IPython wx console view instanciation ###
483 #If user didn't defined an intro text, we create one for him
488 #If user didn't defined an intro text, we create one for him
484 #If you really wnat an empty intrp just call wxIPythonViewPanel with intro=''
489 #If you really wnat an empty intrp just call wxIPythonViewPanel
490 #with intro=''
485 if intro == None:
491 if intro == None:
486 welcome_text = "Welcome to WxIPython Shell.\n\n"
492 welcome_text = "Welcome to WxIPython Shell.\n\n"
487 welcome_text+= self.IP.getBanner()
493 welcome_text+= self.IP.getBanner()
@@ -505,34 +511,13 b' class WxIPythonViewPanel(wx.Panel):'
505 #and we focus on the widget :)
511 #and we focus on the widget :)
506 self.SetFocus()
512 self.SetFocus()
507
513
508 ### below are the thread communication variable ###
509 # the IPython thread is managed via unidirectional communication.
510 # It's a thread slave that can't interact by itself with the GUI.
511 # When the GUI event loop is done runStateMachine() is called and the thread sate is then
512 # managed.
513
514 #Initialize the state machine #kept for information
515 #self.states = ['IDLE',
516 # 'DO_EXECUTE_LINE',
517 # 'WAIT_END_OF_EXECUTION',
518 # 'SHOW_DOC',
519 # 'SHOW_PROMPT']
520
521 self.cur_state = 'IDLE'
514 self.cur_state = 'IDLE'
522 self.pager_state = 'DONE'
515 self.pager_state = 'DONE'
523 #wx.CallAfter(self.runStateMachine)
524
516
525 # This creates a new Event class and a EVT binder function
526 #(self.AskExitEvent, EVT_ASK_EXIT) = wx.lib.newevent.NewEvent()
527 #(self.AddButtonEvent, EVT_ADDBUTTON_EXIT) = wx.lib.newevent.NewEvent()
528
529
530 #self.Bind(wx.EVT_IDLE, self.runStateMachine)
531
532 def __del__(self):
517 def __del__(self):
533 WxConsoleView.__del__()
518 WxConsoleView.__del__()
534
519
535 #---------------------------- IPython Thread Management ---------------------------------------
520 #---------------------- IPython Thread Management ------------------------
536 def stateDoExecuteLine(self):
521 def stateDoExecuteLine(self):
537 #print >>sys.__stdout__,"command:",self.getCurrentLine()
522 #print >>sys.__stdout__,"command:",self.getCurrentLine()
538 self.doExecuteLine(self.text_ctrl.getCurrentLine())
523 self.doExecuteLine(self.text_ctrl.getCurrentLine())
@@ -571,55 +556,8 b' class WxIPythonViewPanel(wx.Panel):'
571 self.cout.truncate(0)
556 self.cout.truncate(0)
572 self.IP.initHistoryIndex()
557 self.IP.initHistoryIndex()
573 self.cur_state = 'IDLE'
558 self.cur_state = 'IDLE'
574
559
575 ## def runStateMachine(self,event):
560 #------------------------ IPython pager ----------------------------------
576 ## #print >>sys.__stdout__,"state:",self.cur_state
577 ## self.updateStatusTracker(self.cur_state)
578 ##
579 ## #if self.cur_state == 'DO_EXECUTE_LINE':
580 ## # self.doExecuteLine()
581 ##
582 ## if self.cur_state == 'WAIT_END_OF_EXECUTION':
583 ## if self.IP.isExecuteDone():
584 ## #self.button = self.IP.getAddButton()
585 ## #if self.IP.getAskExit():
586 ## # evt = self.AskExitEvent()
587 ## # wx.PostEvent(self, evt)
588 ## # self.IP.clearAskExit()
589 ## self.doc = self.IP.getDocText()
590 ## if self.doc:
591 ## self.pager_state = 'INIT'
592 ## self.cur_state = 'SHOW_DOC'
593 ## #if self.button:
594 ## #self.IP.doExecute('print "cool"')#self.button['func'])
595 ## #self.updateHistoryTracker(self.text_ctrl.getCurrentLine())
596 ##
597 ## # self.button['func']='print "cool!"'
598 ## # self.add_button_handler(self.button)
599 ## # self.IP.shortcutProcessed()
600 ##
601 ## else:
602 ## self.cur_state = 'SHOW_PROMPT'
603 ##
604 ## if self.cur_state == 'SHOW_PROMPT':
605 ## self.text_ctrl.setPrompt(self.IP.getPrompt())
606 ## self.text_ctrl.setIndentation(self.IP.getIndentation())
607 ## self.text_ctrl.setPromptCount(self.IP.getPromptCount())
608 ## rv = self.cout.getvalue()
609 ## if rv: rv = rv.strip('\n')
610 ## self.text_ctrl.showReturned(rv)
611 ## self.cout.truncate(0)
612 ## self.IP.initHistoryIndex()
613 ## self.cur_state = 'IDLE'
614 ##
615 ## if self.cur_state == 'SHOW_DOC':
616 ## self.pager(self.doc)
617 ## if self.pager_state == 'DONE':
618 ## self.cur_state = 'SHOW_PROMPT'
619 ##
620 ## event.Skip()
621
622 #---------------------------- IPython pager ---------------------------------------
623 def pager(self,text):#,start=0,screen_lines=0,pager_cmd = None):
561 def pager(self,text):#,start=0,screen_lines=0,pager_cmd = None):
624 if self.pager_state == 'WAITING':
562 if self.pager_state == 'WAITING':
625 #print >>sys.__stdout__,"PAGER waiting"
563 #print >>sys.__stdout__,"PAGER waiting"
@@ -681,7 +619,7 b' class WxIPythonViewPanel(wx.Panel):'
681 self.pager_state = 'DONE'
619 self.pager_state = 'DONE'
682 self.stateShowPrompt()
620 self.stateShowPrompt()
683
621
684 #---------------------------- Key Handler --------------------------------------------
622 #------------------------ Key Handler ------------------------------------
685 def keyPress(self, event):
623 def keyPress(self, event):
686 '''
624 '''
687 Key press callback with plenty of shell goodness, like history,
625 Key press callback with plenty of shell goodness, like history,
@@ -741,7 +679,7 b' class WxIPythonViewPanel(wx.Panel):'
741 return
679 return
742 event.Skip()
680 event.Skip()
743
681
744 #---------------------------- Hook Section --------------------------------------------
682 #------------------------ Hook Section -----------------------------------
745 def updateHistoryTracker(self,command_line):
683 def updateHistoryTracker(self,command_line):
746 '''
684 '''
747 Default history tracker (does nothing)
685 Default history tracker (does nothing)
@@ -753,6 +691,7 b' class WxIPythonViewPanel(wx.Panel):'
753 Define a new history tracker
691 Define a new history tracker
754 '''
692 '''
755 self.updateHistoryTracker = func
693 self.updateHistoryTracker = func
694
756 def updateStatusTracker(self,status):
695 def updateStatusTracker(self,status):
757 '''
696 '''
758 Default status tracker (does nothing)
697 Default status tracker (does nothing)
@@ -90,8 +90,7 b' class NonBlockingIPShell(object):'
90 via raise_exc()
90 via raise_exc()
91 '''
91 '''
92
92
93 def __init__(self,argv
93 def __init__(self,argv=[],user_ns={},user_global_ns=None,
94 =[],user_ns={},user_global_ns=None,
95 cin=None, cout=None, cerr=None,
94 cin=None, cout=None, cerr=None,
96 ask_exit_handler=None):
95 ask_exit_handler=None):
97 '''
96 '''
General Comments 0
You need to be logged in to leave comments. Login now