Show More
@@ -106,7 +106,8 b' class WxConsoleView(stc.StyledTextCtrl):' | |||
|
106 | 106 | '1;34': [12,'LIGHT BLUE'], '1;35': [13,'MEDIUM VIOLET RED'], |
|
107 | 107 | '1;36': [14,'LIGHT STEEL BLUE'], '1;37': [15,'YELLOW']} |
|
108 | 108 | |
|
109 |
def __init__(self,parent,prompt,intro="",background_color="BLACK", |
|
|
109 | def __init__(self,parent,prompt,intro="",background_color="BLACK", | |
|
110 | pos=wx.DefaultPosition, ID = -1, size=wx.DefaultSize, | |
|
110 | 111 | style=0): |
|
111 | 112 | ''' |
|
112 | 113 | Initialize console view. |
@@ -122,9 +123,10 b' class WxConsoleView(stc.StyledTextCtrl):' | |||
|
122 | 123 | ''' |
|
123 | 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 |
|
|
128 | # Ctrl + B or Ctrl + N can be used to zoomin/zoomout the text inside | |
|
129 | # the widget | |
|
128 | 130 | self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) |
|
129 | 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 | 188 | self.SetCaretForeground("WHITE") |
|
187 | 189 | self.ANSI_STYLES = self.ANSI_STYLES_BLACK |
|
188 | 190 | |
|
189 |
self.StyleSetSpec(stc.STC_STYLE_DEFAULT, |
|
|
191 | self.StyleSetSpec(stc.STC_STYLE_DEFAULT, | |
|
192 | "fore:%s,back:%s,size:%d,face:%s" | |
|
193 | % (self.ANSI_STYLES['0;30'][1], | |
|
190 | 194 |
|
|
191 | 195 |
|
|
192 | 196 | self.StyleClearAll() |
|
193 |
self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT, |
|
|
194 | self.StyleSetSpec(stc.STC_STYLE_BRACEBAD, "fore:#000000,back:#FF0000,bold") | |
|
197 | self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT, | |
|
198 | "fore:#FF0000,back:#0000FF,bold") | |
|
199 | self.StyleSetSpec(stc.STC_STYLE_BRACEBAD, | |
|
200 | "fore:#000000,back:#FF0000,bold") | |
|
195 | 201 | |
|
196 | 202 | for style in self.ANSI_STYLES.values(): |
|
197 | 203 | self.StyleSetSpec(style[0], "bold,fore:%s" % style[1]) |
@@ -207,7 +213,6 b' class WxConsoleView(stc.StyledTextCtrl):' | |||
|
207 | 213 | self.showPrompt() |
|
208 | 214 | |
|
209 | 215 | self.Bind(wx.EVT_KEY_DOWN, self._onKeypress, self) |
|
210 | #self.Bind(stc.EVT_STC_UPDATEUI, self.OnUpdateUI) | |
|
211 | 216 | |
|
212 | 217 | def write(self, text): |
|
213 | 218 | ''' |
@@ -481,7 +486,8 b' class WxIPythonViewPanel(wx.Panel):' | |||
|
481 | 486 | ask_exit_handler = ask_exit_handler) |
|
482 | 487 | ### IPython wx console view instanciation ### |
|
483 | 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 |
|
|
489 | #If you really wnat an empty intrp just call wxIPythonViewPanel | |
|
490 | #with intro='' | |
|
485 | 491 | if intro == None: |
|
486 | 492 | welcome_text = "Welcome to WxIPython Shell.\n\n" |
|
487 | 493 | welcome_text+= self.IP.getBanner() |
@@ -505,34 +511,13 b' class WxIPythonViewPanel(wx.Panel):' | |||
|
505 | 511 | #and we focus on the widget :) |
|
506 | 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 | 514 | self.cur_state = 'IDLE' |
|
522 | 515 | self.pager_state = 'DONE' |
|
523 | #wx.CallAfter(self.runStateMachine) | |
|
524 | ||
|
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 | 516 | |
|
532 | 517 | def __del__(self): |
|
533 | 518 | WxConsoleView.__del__() |
|
534 | 519 | |
|
535 |
#---------------------- |
|
|
520 | #---------------------- IPython Thread Management ------------------------ | |
|
536 | 521 | def stateDoExecuteLine(self): |
|
537 | 522 | #print >>sys.__stdout__,"command:",self.getCurrentLine() |
|
538 | 523 | self.doExecuteLine(self.text_ctrl.getCurrentLine()) |
@@ -572,54 +557,7 b' class WxIPythonViewPanel(wx.Panel):' | |||
|
572 | 557 | self.IP.initHistoryIndex() |
|
573 | 558 | self.cur_state = 'IDLE' |
|
574 | 559 | |
|
575 | ## def runStateMachine(self,event): | |
|
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 --------------------------------------- | |
|
560 | #------------------------ IPython pager ---------------------------------- | |
|
623 | 561 | def pager(self,text):#,start=0,screen_lines=0,pager_cmd = None): |
|
624 | 562 | if self.pager_state == 'WAITING': |
|
625 | 563 | #print >>sys.__stdout__,"PAGER waiting" |
@@ -681,7 +619,7 b' class WxIPythonViewPanel(wx.Panel):' | |||
|
681 | 619 | self.pager_state = 'DONE' |
|
682 | 620 | self.stateShowPrompt() |
|
683 | 621 | |
|
684 |
#------------------------ |
|
|
622 | #------------------------ Key Handler ------------------------------------ | |
|
685 | 623 | def keyPress(self, event): |
|
686 | 624 | ''' |
|
687 | 625 | Key press callback with plenty of shell goodness, like history, |
@@ -741,7 +679,7 b' class WxIPythonViewPanel(wx.Panel):' | |||
|
741 | 679 | return |
|
742 | 680 | event.Skip() |
|
743 | 681 | |
|
744 |
#------------------------ |
|
|
682 | #------------------------ Hook Section ----------------------------------- | |
|
745 | 683 | def updateHistoryTracker(self,command_line): |
|
746 | 684 | ''' |
|
747 | 685 | Default history tracker (does nothing) |
@@ -753,6 +691,7 b' class WxIPythonViewPanel(wx.Panel):' | |||
|
753 | 691 | Define a new history tracker |
|
754 | 692 | ''' |
|
755 | 693 | self.updateHistoryTracker = func |
|
694 | ||
|
756 | 695 | def updateStatusTracker(self,status): |
|
757 | 696 | ''' |
|
758 | 697 | Default status tracker (does nothing) |
General Comments 0
You need to be logged in to leave comments.
Login now