diff --git a/IPython/gui/wx/ipshell_nonblocking.py b/IPython/gui/wx/ipshell_nonblocking.py index a8e88ed..4afa5cf 100644 --- a/IPython/gui/wx/ipshell_nonblocking.py +++ b/IPython/gui/wx/ipshell_nonblocking.py @@ -171,7 +171,8 @@ class NonBlockingIPShell(object): #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 + #we replace the ipython default shell command caller + #by our shell handler self._IP.set_hook('shell_hook', self._shell) #we replace the ipython default input command caller by our method @@ -210,7 +211,7 @@ class NonBlockingIPShell(object): sys.excepthook = excepthook - #----------------------- Thread management section ---------------------- + #----------------------- Thread management section ---------------------- def do_execute(self, line): """ Tell the thread to process the 'line' command @@ -219,8 +220,9 @@ class NonBlockingIPShell(object): self._line_to_execute = line if self._threading: - #we launch the ipython line execution in a thread to make it interruptible - #with include it in self namespace to be able to call ce.raise_exc(KeyboardInterrupt) + #we launch the ipython line execution in a thread to make it + #interruptible with include it in self namespace to be able + #to call ce.raise_exc(KeyboardInterrupt) self.ce = _CodeExecutor(self) self.ce.start() else: @@ -234,7 +236,7 @@ class NonBlockingIPShell(object): except KeyboardInterrupt: pass - #----------------------- IPython management section ---------------------- + #----------------------- IPython management section ---------------------- def get_threading(self): """ Returns threading status, is set to True, then each command sent to @@ -501,7 +503,8 @@ class NonBlockingIPShell(object): else: self._IP.write(str(self._IP.outputcache.prompt_out).strip()) self._iter_more = self._IP.push(line) - if (self._IP.SyntaxTB.last_syntax_error and self._IP.rc.autoedit_syntax): + if (self._IP.SyntaxTB.last_syntax_error and \ + self._IP.rc.autoedit_syntax): self._IP.edit_syntax_error() if self._iter_more: self._prompt = str(self._IP.outputcache.prompt2).strip() @@ -524,7 +527,8 @@ class NonBlockingIPShell(object): @type cmd: string ''' stdin, stdout = os.popen4(cmd) - result = stdout.read().decode('cp437').encode(locale.getpreferredencoding()) + result = stdout.read().decode('cp437').\ + encode(locale.getpreferredencoding()) #we use print command because the shell command is called #inside IPython instance and thus is redirected to thread cout #"\x01\x1b[1;36m\x02" <-- add colour to the text... diff --git a/IPython/gui/wx/ipython_history.py b/IPython/gui/wx/ipython_history.py index 5053886..91f8769 100644 --- a/IPython/gui/wx/ipython_history.py +++ b/IPython/gui/wx/ipython_history.py @@ -29,17 +29,21 @@ class IPythonHistoryPanel(wx.Panel): self.filter_magic = wx.CheckBox(self, -1, "%: Magic keys") self.options={'filter_empty':{'value':'True', - 'checkbox':self.filter_empty,'True':True,'False':False, - 'setfunc':lambda x:None}, + 'checkbox':self.filter_empty, \ + 'True':True,'False':False, + 'setfunc':lambda x:None}, 'filter_doc':{'value':'True', - 'checkbox':self.filter_doc,'True':True,'False':False, - 'setfunc':lambda x:None}, + 'checkbox':self.filter_doc, \ + 'True':True,'False':False, + 'setfunc':lambda x:None}, 'filter_cmd':{'value':'True', - 'checkbox':self.filter_cmd,'True':True,'False':False, - 'setfunc':lambda x:None}, + 'checkbox':self.filter_cmd, \ + 'True':True,'False':False, + 'setfunc':lambda x:None}, 'filter_magic':{'value':'True', - 'checkbox':self.filter_magic,'True':True,'False':False, - 'setfunc':lambda x:None}, + 'checkbox':self.filter_magic, \ + 'True':True,'False':False, + 'setfunc':lambda x:None}, } self.reloadOptions(self.options) @@ -199,51 +203,81 @@ class PythonSTC(stc.StyledTextCtrl): self.SetLayoutCache(stc.STC_CACHE_PAGE) # Setup a margin to hold fold markers - #self.SetFoldFlags(16) ### WHAT IS THIS VALUE? WHAT ARE THE OTHER FLAGS? DOES IT MATTER? + #self.SetFoldFlags(16) + ### WHAT IS THIS VALUE? WHAT ARE THE OTHER FLAGS? DOES IT MATTER? self.SetMarginType(2, stc.STC_MARGIN_SYMBOL) self.SetMarginMask(2, stc.STC_MASK_FOLDERS) self.SetMarginSensitive(2, True) self.SetMarginWidth(2, 12) if self.fold_symbols == 0: - # Arrow pointing right for contracted folders, arrow pointing down for expanded - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_ARROWDOWN, "black", "black") - self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_ARROW, "black", "black") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_EMPTY, "black", "black") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_EMPTY, "black", "black") - self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_EMPTY, "white", "black") - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_EMPTY, "white", "black") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_EMPTY, "white", "black") + # Arrow pointing right for contracted folders, + # arrow pointing down for expanded + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, \ + stc.STC_MARK_ARROWDOWN, "black", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDER, \ + stc.STC_MARK_ARROW, "black", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, \ + stc.STC_MARK_EMPTY, "black", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, \ + stc.STC_MARK_EMPTY, "black", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, \ + stc.STC_MARK_EMPTY, "white", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, \ + stc.STC_MARK_EMPTY, "white", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, \ + stc.STC_MARK_EMPTY, "white", "black") elif self.fold_symbols == 1: # Plus for contracted folders, minus for expanded - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_MINUS, "white", "black") - self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_PLUS, "white", "black") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_EMPTY, "white", "black") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_EMPTY, "white", "black") - self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_EMPTY, "white", "black") - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_EMPTY, "white", "black") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_EMPTY, "white", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, \ + stc.STC_MARK_MINUS, "white", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDER, \ + stc.STC_MARK_PLUS, "white", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, \ + stc.STC_MARK_EMPTY, "white", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, \ + stc.STC_MARK_EMPTY, "white", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, \ + stc.STC_MARK_EMPTY, "white", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, \ + stc.STC_MARK_EMPTY, "white", "black") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, \ + stc.STC_MARK_EMPTY, "white", "black") elif self.fold_symbols == 2: # Like a flattened tree control using circular headers and curved joins - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_CIRCLEMINUS, "white", "#404040") - self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_CIRCLEPLUS, "white", "#404040") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_VLINE, "white", "#404040") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_LCORNERCURVE, "white", "#404040") - self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_CIRCLEPLUSCONNECTED, "white", "#404040") - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_CIRCLEMINUSCONNECTED, "white", "#404040") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNERCURVE, "white", "#404040") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, \ + stc.STC_MARK_CIRCLEMINUS, "white", "#404040") + self.MarkerDefine(stc.STC_MARKNUM_FOLDER, \ + stc.STC_MARK_CIRCLEPLUS, "white", "#404040") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, \ + stc.STC_MARK_VLINE, "white", "#404040") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, \ + stc.STC_MARK_LCORNERCURVE, "white", "#404040") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, \ + stc.STC_MARK_CIRCLEPLUSCONNECTED, "white", "#404040") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, \ + stc.STC_MARK_CIRCLEMINUSCONNECTED, "white", "#404040") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, \ + stc.STC_MARK_TCORNERCURVE, "white", "#404040") elif self.fold_symbols == 3: # Like a flattened tree control using square headers - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_BOXMINUS, "white", "#808080") - self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_BOXPLUS, "white", "#808080") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_VLINE, "white", "#808080") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_LCORNER, "white", "#808080") - self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_BOXPLUSCONNECTED, "white", "#808080") - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_BOXMINUSCONNECTED, "white", "#808080") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNER, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, \ + stc.STC_MARK_BOXMINUS, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDER, \ + stc.STC_MARK_BOXPLUS, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, \ + stc.STC_MARK_VLINE, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, \ + stc.STC_MARK_LCORNER, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, \ + stc.STC_MARK_BOXPLUSCONNECTED, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, \ + stc.STC_MARK_BOXMINUSCONNECTED, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, \ + stc.STC_MARK_TCORNER, "white", "#808080") self.Bind(stc.EVT_STC_UPDATEUI, self.OnUpdateUI) @@ -363,7 +397,7 @@ class PythonSTC(stc.StyledTextCtrl): if braceAtCaret < 0: charAfter = self.GetCharAt(caretPos) styleAfter = self.GetStyleAt(caretPos) - + if charAfter and chr(charAfter) in "[]{}()" and styleAfter == stc.STC_P_OPERATOR: braceAtCaret = caretPos diff --git a/IPython/gui/wx/ipython_view.py b/IPython/gui/wx/ipython_view.py index cce5e21..2f09242 100644 --- a/IPython/gui/wx/ipython_view.py +++ b/IPython/gui/wx/ipython_view.py @@ -633,8 +633,6 @@ class IPShellWidget(wx.Panel): self.setCurrentState('WAIT_END_OF_EXECUTION') def evtStateExecuteDone(self,evt): - if(self.text_ctrl.getCursorPos()!=0): - self.text_ctrl.removeCurrentLine() self.doc = self.IP.get_doc_text() self.help = self.IP.get_help_text() if self.doc: @@ -648,6 +646,8 @@ class IPShellWidget(wx.Panel): self.setCurrentState('SHOW_DOC') self.pager(self.help) else: + if(self.text_ctrl.getCursorPos()!=0): + self.text_ctrl.removeCurrentLine() self.stateShowPrompt() def stateShowPrompt(self):