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