From 6ddd5ed6573a000e67d51ee7075c707d996aa539 2008-03-23 14:22:41 From: Gael Varoquaux Date: 2008-03-23 14:22:41 Subject: [PATCH] Changed tabs to whitespace in the wx frontend (took me a while to figure this out, I couldn't even understand what the blocks where supposed to be) --- diff --git a/IPython/gui/wx/ipython_history.py b/IPython/gui/wx/ipython_history.py index 90d7570..1794b6f 100644 --- a/IPython/gui/wx/ipython_history.py +++ b/IPython/gui/wx/ipython_history.py @@ -70,8 +70,8 @@ class IPythonHistoryPanel(wx.Panel): add = False if self.filter_magic.GetValue() == True and history_line[0] == '%': add = False - if add: - self.text_ctrl.AppendText(history_line+'\n') + if add: + self.text_ctrl.AppendText(history_line+'\n') #---------------------------------------------------------------------- diff --git a/IPython/gui/wx/ipython_view.py b/IPython/gui/wx/ipython_view.py index 130d31a..75681f5 100644 --- a/IPython/gui/wx/ipython_view.py +++ b/IPython/gui/wx/ipython_view.py @@ -375,7 +375,7 @@ class WxConsoleView(stc.StyledTextCtrl): @return: Return True if event as been catched. @rtype: boolean ''' - + if event.GetKeyCode() == wx.WXK_HOME: if event.Modifiers == wx.MOD_NONE: self.moveCursorOnNewValidKey() @@ -399,9 +399,9 @@ class WxConsoleView(stc.StyledTextCtrl): elif event.GetKeyCode() == wx.WXK_BACK: self.moveCursorOnNewValidKey() - if self.getCursorPos() > self.getCurrentPromptStart(): + if self.getCursorPos() > self.getCurrentPromptStart(): self.removeFromTo(self.getCursorPos()-1,self.getCursorPos()) - return True + return True if skip: if event.GetKeyCode() not in [wx.WXK_PAGEUP,wx.WXK_PAGEDOWN] and event.Modifiers == wx.MOD_NONE: @@ -609,7 +609,7 @@ class WxIPythonViewPanel(wx.Panel): ## if rv: rv = rv.strip('\n') ## self.text_ctrl.showReturned(rv) ## self.cout.truncate(0) -## self.IP.initHistoryIndex() +## self.IP.initHistoryIndex() ## self.cur_state = 'IDLE' ## ## if self.cur_state == 'SHOW_DOC': @@ -622,64 +622,64 @@ class WxIPythonViewPanel(wx.Panel): #---------------------------- IPython pager --------------------------------------- def pager(self,text):#,start=0,screen_lines=0,pager_cmd = None): if self.pager_state == 'WAITING': - #print >>sys.__stdout__,"PAGER waiting" - return - - if self.pager_state == 'INIT': - #print >>sys.__stdout__,"PAGER state:",self.pager_state - self.pager_lines = text[7:].split('\n') - self.pager_nb_lines = len(self.pager_lines) - self.pager_index = 0 - self.pager_do_remove = False - self.text_ctrl.write('\n') - self.pager_state = 'PROCESS_LINES' - - if self.pager_state == 'INIT_HELP': - #print >>sys.__stdout__,"HELP PAGER state:",self.pager_state - self.pager_lines = text[:].split('\n') - self.pager_nb_lines = len(self.pager_lines) - self.pager_index = 0 - self.pager_do_remove = False - self.text_ctrl.write('\n') - self.pager_state = 'PROCESS_LINES' - - if self.pager_state == 'PROCESS_LINES': - #print >>sys.__stdout__,"PAGER state:",self.pager_state - if self.pager_do_remove == True: - self.text_ctrl.removeCurrentLine() - self.pager_do_remove = False - - if self.pager_nb_lines > 10: - #print >>sys.__stdout__,"PAGER processing 10 lines" - if self.pager_index > 0: - self.text_ctrl.write(">\x01\x1b[1;36m\x02"+self.pager_lines[self.pager_index]+'\n') - else: - self.text_ctrl.write("\x01\x1b[1;36m\x02 "+self.pager_lines[self.pager_index]+'\n') - - for line in self.pager_lines[self.pager_index+1:self.pager_index+9]: - self.text_ctrl.write("\x01\x1b[1;36m\x02 "+line+'\n') - self.pager_index += 10 - self.pager_nb_lines -= 10 - self.text_ctrl.write("--- Push Enter to continue or 'Q' to quit---") - self.pager_do_remove = True - self.pager_state = 'WAITING' - return - else: - #print >>sys.__stdout__,"PAGER processing last lines" - if self.pager_nb_lines > 0: - if self.pager_index > 0: - self.text_ctrl.write(">\x01\x1b[1;36m\x02"+self.pager_lines[self.pager_index]+'\n') - else: - self.text_ctrl.write("\x01\x1b[1;36m\x02 "+self.pager_lines[self.pager_index]+'\n') - - self.pager_index += 1 + #print >>sys.__stdout__,"PAGER waiting" + return + + if self.pager_state == 'INIT': + #print >>sys.__stdout__,"PAGER state:",self.pager_state + self.pager_lines = text[7:].split('\n') + self.pager_nb_lines = len(self.pager_lines) + self.pager_index = 0 + self.pager_do_remove = False + self.text_ctrl.write('\n') + self.pager_state = 'PROCESS_LINES' + + if self.pager_state == 'INIT_HELP': + #print >>sys.__stdout__,"HELP PAGER state:",self.pager_state + self.pager_lines = text[:].split('\n') + self.pager_nb_lines = len(self.pager_lines) + self.pager_index = 0 + self.pager_do_remove = False + self.text_ctrl.write('\n') + self.pager_state = 'PROCESS_LINES' + + if self.pager_state == 'PROCESS_LINES': + #print >>sys.__stdout__,"PAGER state:",self.pager_state + if self.pager_do_remove == True: + self.text_ctrl.removeCurrentLine() + self.pager_do_remove = False + + if self.pager_nb_lines > 10: + #print >>sys.__stdout__,"PAGER processing 10 lines" + if self.pager_index > 0: + self.text_ctrl.write(">\x01\x1b[1;36m\x02"+self.pager_lines[self.pager_index]+'\n') + else: + self.text_ctrl.write("\x01\x1b[1;36m\x02 "+self.pager_lines[self.pager_index]+'\n') + + for line in self.pager_lines[self.pager_index+1:self.pager_index+9]: + self.text_ctrl.write("\x01\x1b[1;36m\x02 "+line+'\n') + self.pager_index += 10 + self.pager_nb_lines -= 10 + self.text_ctrl.write("--- Push Enter to continue or 'Q' to quit---") + self.pager_do_remove = True + self.pager_state = 'WAITING' + return + else: + #print >>sys.__stdout__,"PAGER processing last lines" + if self.pager_nb_lines > 0: + if self.pager_index > 0: + self.text_ctrl.write(">\x01\x1b[1;36m\x02"+self.pager_lines[self.pager_index]+'\n') + else: + self.text_ctrl.write("\x01\x1b[1;36m\x02 "+self.pager_lines[self.pager_index]+'\n') + + self.pager_index += 1 self.pager_nb_lines -= 1 - if self.pager_nb_lines > 0: - for line in self.pager_lines[self.pager_index:]: - self.text_ctrl.write("\x01\x1b[1;36m\x02 "+line+'\n') - self.pager_nb_lines = 0 - self.pager_state = 'DONE' - self.stateShowPrompt() + if self.pager_nb_lines > 0: + for line in self.pager_lines[self.pager_index:]: + self.text_ctrl.write("\x01\x1b[1;36m\x02 "+line+'\n') + self.pager_nb_lines = 0 + self.pager_state = 'DONE' + self.stateShowPrompt() #---------------------------- Key Handler -------------------------------------------- def keyPress(self, event): @@ -687,7 +687,7 @@ class WxIPythonViewPanel(wx.Panel): Key press callback with plenty of shell goodness, like history, autocompletions, etc. ''' - + if event.GetKeyCode() == ord('C'): if event.Modifiers == wx.MOD_CONTROL: if self.cur_state == 'WAIT_END_OF_EXECUTION': @@ -713,7 +713,7 @@ class WxIPythonViewPanel(wx.Panel): return #scroll_position = self.text_ctrl.GetScrollPos(wx.VERTICAL) - if self.cur_state == 'IDLE': + if self.cur_state == 'IDLE': if event.KeyCode == wx.WXK_UP: history = self.IP.historyBack() self.text_ctrl.writeHistory(history) @@ -740,7 +740,7 @@ class WxIPythonViewPanel(wx.Panel): return event.Skip() - + #---------------------------- Hook Section -------------------------------------------- def updateHistoryTracker(self,command_line): ''' diff --git a/IPython/gui/wx/non_blocking_ip_shell.py b/IPython/gui/wx/non_blocking_ip_shell.py index c973fb5..52c92e7 100644 --- a/IPython/gui/wx/non_blocking_ip_shell.py +++ b/IPython/gui/wx/non_blocking_ip_shell.py @@ -136,14 +136,14 @@ class NonBlockingIPShell(object): shell_class=IPython.Shell.InteractiveShell) #we replace IPython default encoding by wx locale encoding - loc = locale.getpreferredencoding() - if loc: - self._IP.stdin_encoding = loc + loc = locale.getpreferredencoding() + if loc: + self._IP.stdin_encoding = loc #we replace the ipython default pager by our pager self._IP.set_hook('show_in_pager',self._pager) #we replace the ipython default shell command caller by our shell handler - self._IP.set_hook('shell_hook',self._shell) + self._IP.set_hook('shell_hook',self._shell) #we replace the ipython default input command caller by our method IPython.iplib.raw_input_original = self._raw_input @@ -311,10 +311,10 @@ class NonBlockingIPShell(object): ''' history = '' #the below while loop is used to suppress empty history lines - while((history == '' or history == '\n') and self._history_level >0): - if self._history_level>=1: - self._history_level -= 1 - history = self._getHistory() + while((history == '' or history == '\n') and self._history_level >0): + if self._history_level>=1: + self._history_level -= 1 + history = self._getHistory() return history def historyForward(self): @@ -324,18 +324,18 @@ class NonBlockingIPShell(object): @return: The command string. @rtype: string ''' - history = '' - #the below while loop is used to suppress empty history lines - while((history == '' or history == '\n') and self._history_level <= self._getHistoryMaxIndex()): - if self._history_level < self._getHistoryMaxIndex(): - self._history_level += 1 - history = self._getHistory() - else: - if self._history_level == self._getHistoryMaxIndex(): - history = self._getHistory() - self._history_level += 1 - else: - history = '' + history = '' + #the below while loop is used to suppress empty history lines + while((history == '' or history == '\n') and self._history_level <= self._getHistoryMaxIndex()): + if self._history_level < self._getHistoryMaxIndex(): + self._history_level += 1 + history = self._getHistory() + else: + if self._history_level == self._getHistoryMaxIndex(): + history = self._getHistory() + self._history_level += 1 + else: + history = '' return history def initHistoryIndex(self): diff --git a/IPython/gui/wx/wxIPython.py b/IPython/gui/wx/wxIPython.py index 8027c9d..9cf8668 100644 --- a/IPython/gui/wx/wxIPython.py +++ b/IPython/gui/wx/wxIPython.py @@ -48,7 +48,7 @@ class MyFrame(wx.Frame): # main panels self._mgr.AddPane(self.ipython_panel , wx.CENTER, "IPython Shell") self._mgr.AddPane(self.history_panel , wx.RIGHT, "IPython history") - + # now we specify some panel characteristics self._mgr.GetPane(self.ipython_panel).CaptionVisible(True); self._mgr.GetPane(self.history_panel).CaptionVisible(True);