##// END OF EJS Templates
Changed tabs to whitespace in the wx frontend...
Gael Varoquaux -
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 if add:
73 if add:
74 self.text_ctrl.AppendText(history_line+'\n')
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 if self.getCursorPos() > self.getCurrentPromptStart():
402 if self.getCursorPos() > self.getCurrentPromptStart():
403 self.removeFromTo(self.getCursorPos()-1,self.getCursorPos())
403 self.removeFromTo(self.getCursorPos()-1,self.getCursorPos())
404 return True
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 ## self.IP.initHistoryIndex()
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 #print >>sys.__stdout__,"PAGER waiting"
625 #print >>sys.__stdout__,"PAGER waiting"
626 return
626 return
627
627
628 if self.pager_state == 'INIT':
628 if self.pager_state == 'INIT':
629 #print >>sys.__stdout__,"PAGER state:",self.pager_state
629 #print >>sys.__stdout__,"PAGER state:",self.pager_state
630 self.pager_lines = text[7:].split('\n')
630 self.pager_lines = text[7:].split('\n')
631 self.pager_nb_lines = len(self.pager_lines)
631 self.pager_nb_lines = len(self.pager_lines)
632 self.pager_index = 0
632 self.pager_index = 0
633 self.pager_do_remove = False
633 self.pager_do_remove = False
634 self.text_ctrl.write('\n')
634 self.text_ctrl.write('\n')
635 self.pager_state = 'PROCESS_LINES'
635 self.pager_state = 'PROCESS_LINES'
636
636
637 if self.pager_state == 'INIT_HELP':
637 if self.pager_state == 'INIT_HELP':
638 #print >>sys.__stdout__,"HELP PAGER state:",self.pager_state
638 #print >>sys.__stdout__,"HELP PAGER state:",self.pager_state
639 self.pager_lines = text[:].split('\n')
639 self.pager_lines = text[:].split('\n')
640 self.pager_nb_lines = len(self.pager_lines)
640 self.pager_nb_lines = len(self.pager_lines)
641 self.pager_index = 0
641 self.pager_index = 0
642 self.pager_do_remove = False
642 self.pager_do_remove = False
643 self.text_ctrl.write('\n')
643 self.text_ctrl.write('\n')
644 self.pager_state = 'PROCESS_LINES'
644 self.pager_state = 'PROCESS_LINES'
645
645
646 if self.pager_state == 'PROCESS_LINES':
646 if self.pager_state == 'PROCESS_LINES':
647 #print >>sys.__stdout__,"PAGER state:",self.pager_state
647 #print >>sys.__stdout__,"PAGER state:",self.pager_state
648 if self.pager_do_remove == True:
648 if self.pager_do_remove == True:
649 self.text_ctrl.removeCurrentLine()
649 self.text_ctrl.removeCurrentLine()
650 self.pager_do_remove = False
650 self.pager_do_remove = False
651
651
652 if self.pager_nb_lines > 10:
652 if self.pager_nb_lines > 10:
653 #print >>sys.__stdout__,"PAGER processing 10 lines"
653 #print >>sys.__stdout__,"PAGER processing 10 lines"
654 if self.pager_index > 0:
654 if self.pager_index > 0:
655 self.text_ctrl.write(">\x01\x1b[1;36m\x02"+self.pager_lines[self.pager_index]+'\n')
655 self.text_ctrl.write(">\x01\x1b[1;36m\x02"+self.pager_lines[self.pager_index]+'\n')
656 else:
656 else:
657 self.text_ctrl.write("\x01\x1b[1;36m\x02 "+self.pager_lines[self.pager_index]+'\n')
657 self.text_ctrl.write("\x01\x1b[1;36m\x02 "+self.pager_lines[self.pager_index]+'\n')
658
658
659 for line in self.pager_lines[self.pager_index+1:self.pager_index+9]:
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')
660 self.text_ctrl.write("\x01\x1b[1;36m\x02 "+line+'\n')
661 self.pager_index += 10
661 self.pager_index += 10
662 self.pager_nb_lines -= 10
662 self.pager_nb_lines -= 10
663 self.text_ctrl.write("--- Push Enter to continue or 'Q' to quit---")
663 self.text_ctrl.write("--- Push Enter to continue or 'Q' to quit---")
664 self.pager_do_remove = True
664 self.pager_do_remove = True
665 self.pager_state = 'WAITING'
665 self.pager_state = 'WAITING'
666 return
666 return
667 else:
667 else:
668 #print >>sys.__stdout__,"PAGER processing last lines"
668 #print >>sys.__stdout__,"PAGER processing last lines"
669 if self.pager_nb_lines > 0:
669 if self.pager_nb_lines > 0:
670 if self.pager_index > 0:
670 if self.pager_index > 0:
671 self.text_ctrl.write(">\x01\x1b[1;36m\x02"+self.pager_lines[self.pager_index]+'\n')
671 self.text_ctrl.write(">\x01\x1b[1;36m\x02"+self.pager_lines[self.pager_index]+'\n')
672 else:
672 else:
673 self.text_ctrl.write("\x01\x1b[1;36m\x02 "+self.pager_lines[self.pager_index]+'\n')
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 if self.pager_nb_lines > 0:
677 if self.pager_nb_lines > 0:
678 for line in self.pager_lines[self.pager_index:]:
678 for line in self.pager_lines[self.pager_index:]:
679 self.text_ctrl.write("\x01\x1b[1;36m\x02 "+line+'\n')
679 self.text_ctrl.write("\x01\x1b[1;36m\x02 "+line+'\n')
680 self.pager_nb_lines = 0
680 self.pager_nb_lines = 0
681 self.pager_state = 'DONE'
681 self.pager_state = 'DONE'
682 self.stateShowPrompt()
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 if self.cur_state == 'IDLE':
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 loc = locale.getpreferredencoding()
139 loc = locale.getpreferredencoding()
140 if loc:
140 if loc:
141 self._IP.stdin_encoding = loc
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 self._IP.set_hook('shell_hook',self._shell)
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 while((history == '' or history == '\n') and self._history_level >0):
314 while((history == '' or history == '\n') and self._history_level >0):
315 if self._history_level>=1:
315 if self._history_level>=1:
316 self._history_level -= 1
316 self._history_level -= 1
317 history = self._getHistory()
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 history = ''
327 history = ''
328 #the below while loop is used to suppress empty history lines
328 #the below while loop is used to suppress empty history lines
329 while((history == '' or history == '\n') and self._history_level <= self._getHistoryMaxIndex()):
329 while((history == '' or history == '\n') and self._history_level <= self._getHistoryMaxIndex()):
330 if self._history_level < self._getHistoryMaxIndex():
330 if self._history_level < self._getHistoryMaxIndex():
331 self._history_level += 1
331 self._history_level += 1
332 history = self._getHistory()
332 history = self._getHistory()
333 else:
333 else:
334 if self._history_level == self._getHistoryMaxIndex():
334 if self._history_level == self._getHistoryMaxIndex():
335 history = self._getHistory()
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