Show More
@@ -70,8 +70,8 b' class IPythonHistoryPanel(wx.Panel):' | |||||
70 | add = False |
|
70 | add = False | |
71 | if self.filter_magic.GetValue() == True and history_line[0] == '%': |
|
71 | if self.filter_magic.GetValue() == True and history_line[0] == '%': | |
72 | add = False |
|
72 | add = False | |
73 |
|
|
73 | if add: | |
74 |
|
|
74 | self.text_ctrl.AppendText(history_line+'\n') | |
75 |
|
75 | |||
76 |
|
76 | |||
77 | #---------------------------------------------------------------------- |
|
77 | #---------------------------------------------------------------------- |
@@ -375,7 +375,7 b' class WxConsoleView(stc.StyledTextCtrl):' | |||||
375 | @return: Return True if event as been catched. |
|
375 | @return: Return True if event as been catched. | |
376 | @rtype: boolean |
|
376 | @rtype: boolean | |
377 | ''' |
|
377 | ''' | |
378 |
|
378 | |||
379 | if event.GetKeyCode() == wx.WXK_HOME: |
|
379 | if event.GetKeyCode() == wx.WXK_HOME: | |
380 | if event.Modifiers == wx.MOD_NONE: |
|
380 | if event.Modifiers == wx.MOD_NONE: | |
381 | self.moveCursorOnNewValidKey() |
|
381 | self.moveCursorOnNewValidKey() | |
@@ -399,9 +399,9 b' class WxConsoleView(stc.StyledTextCtrl):' | |||||
399 |
|
399 | |||
400 | elif event.GetKeyCode() == wx.WXK_BACK: |
|
400 | elif event.GetKeyCode() == wx.WXK_BACK: | |
401 | self.moveCursorOnNewValidKey() |
|
401 | self.moveCursorOnNewValidKey() | |
402 |
|
|
402 | if self.getCursorPos() > self.getCurrentPromptStart(): | |
403 | self.removeFromTo(self.getCursorPos()-1,self.getCursorPos()) |
|
403 | self.removeFromTo(self.getCursorPos()-1,self.getCursorPos()) | |
404 |
|
|
404 | return True | |
405 |
|
405 | |||
406 | if skip: |
|
406 | if skip: | |
407 | if event.GetKeyCode() not in [wx.WXK_PAGEUP,wx.WXK_PAGEDOWN] and event.Modifiers == wx.MOD_NONE: |
|
407 | if event.GetKeyCode() not in [wx.WXK_PAGEUP,wx.WXK_PAGEDOWN] and event.Modifiers == wx.MOD_NONE: | |
@@ -609,7 +609,7 b' class WxIPythonViewPanel(wx.Panel):' | |||||
609 | ## if rv: rv = rv.strip('\n') |
|
609 | ## if rv: rv = rv.strip('\n') | |
610 | ## self.text_ctrl.showReturned(rv) |
|
610 | ## self.text_ctrl.showReturned(rv) | |
611 | ## self.cout.truncate(0) |
|
611 | ## self.cout.truncate(0) | |
612 |
## |
|
612 | ## self.IP.initHistoryIndex() | |
613 | ## self.cur_state = 'IDLE' |
|
613 | ## self.cur_state = 'IDLE' | |
614 | ## |
|
614 | ## | |
615 | ## if self.cur_state == 'SHOW_DOC': |
|
615 | ## if self.cur_state == 'SHOW_DOC': | |
@@ -622,64 +622,64 b' class WxIPythonViewPanel(wx.Panel):' | |||||
622 | #---------------------------- IPython pager --------------------------------------- |
|
622 | #---------------------------- IPython pager --------------------------------------- | |
623 | def pager(self,text):#,start=0,screen_lines=0,pager_cmd = None): |
|
623 | def pager(self,text):#,start=0,screen_lines=0,pager_cmd = None): | |
624 | if self.pager_state == 'WAITING': |
|
624 | if self.pager_state == 'WAITING': | |
625 |
|
|
625 | #print >>sys.__stdout__,"PAGER waiting" | |
626 |
|
|
626 | return | |
627 |
|
627 | |||
628 |
|
|
628 | if self.pager_state == 'INIT': | |
629 |
|
|
629 | #print >>sys.__stdout__,"PAGER state:",self.pager_state | |
630 |
|
|
630 | self.pager_lines = text[7:].split('\n') | |
631 |
|
|
631 | self.pager_nb_lines = len(self.pager_lines) | |
632 |
|
|
632 | self.pager_index = 0 | |
633 |
|
|
633 | self.pager_do_remove = False | |
634 |
|
|
634 | self.text_ctrl.write('\n') | |
635 |
|
|
635 | self.pager_state = 'PROCESS_LINES' | |
636 |
|
636 | |||
637 |
|
|
637 | if self.pager_state == 'INIT_HELP': | |
638 |
|
|
638 | #print >>sys.__stdout__,"HELP PAGER state:",self.pager_state | |
639 |
|
|
639 | self.pager_lines = text[:].split('\n') | |
640 |
|
|
640 | self.pager_nb_lines = len(self.pager_lines) | |
641 |
|
|
641 | self.pager_index = 0 | |
642 |
|
|
642 | self.pager_do_remove = False | |
643 |
|
|
643 | self.text_ctrl.write('\n') | |
644 |
|
|
644 | self.pager_state = 'PROCESS_LINES' | |
645 |
|
645 | |||
646 |
|
|
646 | if self.pager_state == 'PROCESS_LINES': | |
647 |
|
|
647 | #print >>sys.__stdout__,"PAGER state:",self.pager_state | |
648 |
|
|
648 | if self.pager_do_remove == True: | |
649 |
|
|
649 | self.text_ctrl.removeCurrentLine() | |
650 |
|
|
650 | self.pager_do_remove = False | |
651 |
|
651 | |||
652 |
|
|
652 | if self.pager_nb_lines > 10: | |
653 |
|
|
653 | #print >>sys.__stdout__,"PAGER processing 10 lines" | |
654 |
|
|
654 | if self.pager_index > 0: | |
655 |
|
|
655 | self.text_ctrl.write(">\x01\x1b[1;36m\x02"+self.pager_lines[self.pager_index]+'\n') | |
656 | else: |
|
656 | else: | |
657 |
|
|
657 | self.text_ctrl.write("\x01\x1b[1;36m\x02 "+self.pager_lines[self.pager_index]+'\n') | |
658 |
|
658 | |||
659 |
|
|
659 | for line in self.pager_lines[self.pager_index+1:self.pager_index+9]: | |
660 |
|
|
660 | self.text_ctrl.write("\x01\x1b[1;36m\x02 "+line+'\n') | |
661 |
|
|
661 | self.pager_index += 10 | |
662 |
|
|
662 | self.pager_nb_lines -= 10 | |
663 |
|
|
663 | self.text_ctrl.write("--- Push Enter to continue or 'Q' to quit---") | |
664 |
|
|
664 | self.pager_do_remove = True | |
665 |
|
|
665 | self.pager_state = 'WAITING' | |
666 | return |
|
666 | return | |
667 |
|
|
667 | else: | |
668 |
|
|
668 | #print >>sys.__stdout__,"PAGER processing last lines" | |
669 |
|
|
669 | if self.pager_nb_lines > 0: | |
670 | if self.pager_index > 0: |
|
670 | if self.pager_index > 0: | |
671 |
|
|
671 | self.text_ctrl.write(">\x01\x1b[1;36m\x02"+self.pager_lines[self.pager_index]+'\n') | |
672 | else: |
|
672 | else: | |
673 |
|
|
673 | self.text_ctrl.write("\x01\x1b[1;36m\x02 "+self.pager_lines[self.pager_index]+'\n') | |
674 |
|
674 | |||
675 | self.pager_index += 1 |
|
675 | self.pager_index += 1 | |
676 | self.pager_nb_lines -= 1 |
|
676 | self.pager_nb_lines -= 1 | |
677 |
|
|
677 | if self.pager_nb_lines > 0: | |
678 |
|
|
678 | for line in self.pager_lines[self.pager_index:]: | |
679 |
|
|
679 | self.text_ctrl.write("\x01\x1b[1;36m\x02 "+line+'\n') | |
680 |
|
|
680 | self.pager_nb_lines = 0 | |
681 |
|
|
681 | self.pager_state = 'DONE' | |
682 |
|
|
682 | self.stateShowPrompt() | |
683 |
|
683 | |||
684 | #---------------------------- Key Handler -------------------------------------------- |
|
684 | #---------------------------- Key Handler -------------------------------------------- | |
685 | def keyPress(self, event): |
|
685 | def keyPress(self, event): | |
@@ -687,7 +687,7 b' class WxIPythonViewPanel(wx.Panel):' | |||||
687 | Key press callback with plenty of shell goodness, like history, |
|
687 | Key press callback with plenty of shell goodness, like history, | |
688 | autocompletions, etc. |
|
688 | autocompletions, etc. | |
689 | ''' |
|
689 | ''' | |
690 |
|
690 | |||
691 | if event.GetKeyCode() == ord('C'): |
|
691 | if event.GetKeyCode() == ord('C'): | |
692 | if event.Modifiers == wx.MOD_CONTROL: |
|
692 | if event.Modifiers == wx.MOD_CONTROL: | |
693 | if self.cur_state == 'WAIT_END_OF_EXECUTION': |
|
693 | if self.cur_state == 'WAIT_END_OF_EXECUTION': | |
@@ -713,7 +713,7 b' class WxIPythonViewPanel(wx.Panel):' | |||||
713 | return |
|
713 | return | |
714 |
|
714 | |||
715 | #scroll_position = self.text_ctrl.GetScrollPos(wx.VERTICAL) |
|
715 | #scroll_position = self.text_ctrl.GetScrollPos(wx.VERTICAL) | |
716 |
|
|
716 | if self.cur_state == 'IDLE': | |
717 | if event.KeyCode == wx.WXK_UP: |
|
717 | if event.KeyCode == wx.WXK_UP: | |
718 | history = self.IP.historyBack() |
|
718 | history = self.IP.historyBack() | |
719 | self.text_ctrl.writeHistory(history) |
|
719 | self.text_ctrl.writeHistory(history) | |
@@ -740,7 +740,7 b' class WxIPythonViewPanel(wx.Panel):' | |||||
740 |
|
740 | |||
741 | return |
|
741 | return | |
742 | event.Skip() |
|
742 | event.Skip() | |
743 |
|
743 | |||
744 | #---------------------------- Hook Section -------------------------------------------- |
|
744 | #---------------------------- Hook Section -------------------------------------------- | |
745 | def updateHistoryTracker(self,command_line): |
|
745 | def updateHistoryTracker(self,command_line): | |
746 | ''' |
|
746 | ''' |
@@ -136,14 +136,14 b' class NonBlockingIPShell(object):' | |||||
136 | shell_class=IPython.Shell.InteractiveShell) |
|
136 | shell_class=IPython.Shell.InteractiveShell) | |
137 |
|
137 | |||
138 | #we replace IPython default encoding by wx locale encoding |
|
138 | #we replace IPython default encoding by wx locale encoding | |
139 |
|
|
139 | loc = locale.getpreferredencoding() | |
140 |
|
|
140 | if loc: | |
141 |
|
|
141 | self._IP.stdin_encoding = loc | |
142 | #we replace the ipython default pager by our pager |
|
142 | #we replace the ipython default pager by our pager | |
143 | self._IP.set_hook('show_in_pager',self._pager) |
|
143 | self._IP.set_hook('show_in_pager',self._pager) | |
144 |
|
144 | |||
145 | #we replace the ipython default shell command caller by our shell handler |
|
145 | #we replace the ipython default shell command caller by our shell handler | |
146 |
|
|
146 | self._IP.set_hook('shell_hook',self._shell) | |
147 |
|
147 | |||
148 | #we replace the ipython default input command caller by our method |
|
148 | #we replace the ipython default input command caller by our method | |
149 | IPython.iplib.raw_input_original = self._raw_input |
|
149 | IPython.iplib.raw_input_original = self._raw_input | |
@@ -311,10 +311,10 b' class NonBlockingIPShell(object):' | |||||
311 | ''' |
|
311 | ''' | |
312 | history = '' |
|
312 | history = '' | |
313 | #the below while loop is used to suppress empty history lines |
|
313 | #the below while loop is used to suppress empty history lines | |
314 |
|
|
314 | while((history == '' or history == '\n') and self._history_level >0): | |
315 |
|
|
315 | if self._history_level>=1: | |
316 |
|
|
316 | self._history_level -= 1 | |
317 |
|
|
317 | history = self._getHistory() | |
318 | return history |
|
318 | return history | |
319 |
|
319 | |||
320 | def historyForward(self): |
|
320 | def historyForward(self): | |
@@ -324,18 +324,18 b' class NonBlockingIPShell(object):' | |||||
324 | @return: The command string. |
|
324 | @return: The command string. | |
325 | @rtype: string |
|
325 | @rtype: string | |
326 | ''' |
|
326 | ''' | |
327 |
|
|
327 | history = '' | |
328 |
|
|
328 | #the below while loop is used to suppress empty history lines | |
329 |
|
|
329 | while((history == '' or history == '\n') and self._history_level <= self._getHistoryMaxIndex()): | |
330 |
|
|
330 | if self._history_level < self._getHistoryMaxIndex(): | |
331 |
|
|
331 | self._history_level += 1 | |
332 |
|
|
332 | history = self._getHistory() | |
333 | else: |
|
333 | else: | |
334 |
|
|
334 | if self._history_level == self._getHistoryMaxIndex(): | |
335 |
|
|
335 | history = self._getHistory() | |
336 | self._history_level += 1 |
|
336 | self._history_level += 1 | |
337 | else: |
|
337 | else: | |
338 | history = '' |
|
338 | history = '' | |
339 | return history |
|
339 | return history | |
340 |
|
340 | |||
341 | def initHistoryIndex(self): |
|
341 | def initHistoryIndex(self): |
@@ -48,7 +48,7 b' class MyFrame(wx.Frame):' | |||||
48 | # main panels |
|
48 | # main panels | |
49 | self._mgr.AddPane(self.ipython_panel , wx.CENTER, "IPython Shell") |
|
49 | self._mgr.AddPane(self.ipython_panel , wx.CENTER, "IPython Shell") | |
50 | self._mgr.AddPane(self.history_panel , wx.RIGHT, "IPython history") |
|
50 | self._mgr.AddPane(self.history_panel , wx.RIGHT, "IPython history") | |
51 |
|
|
51 | ||
52 | # now we specify some panel characteristics |
|
52 | # now we specify some panel characteristics | |
53 | self._mgr.GetPane(self.ipython_panel).CaptionVisible(True); |
|
53 | self._mgr.GetPane(self.ipython_panel).CaptionVisible(True); | |
54 | self._mgr.GetPane(self.history_panel).CaptionVisible(True); |
|
54 | self._mgr.GetPane(self.history_panel).CaptionVisible(True); |
General Comments 0
You need to be logged in to leave comments.
Login now