diff -r d001bc703c29 -r aedc309827c7 eric6/QScintilla/Shell.py --- a/eric6/QScintilla/Shell.py Wed Sep 25 18:25:43 2019 +0200 +++ b/eric6/QScintilla/Shell.py Wed Sep 25 18:37:35 2019 +0200 @@ -18,8 +18,10 @@ from PyQt5.QtCore import pyqtSignal, QFileInfo, Qt, QEvent from PyQt5.QtGui import QClipboard, QPalette, QFont -from PyQt5.QtWidgets import QDialog, QInputDialog, QApplication, QMenu, \ - QWidget, QHBoxLayout, QVBoxLayout, QShortcut, QSizePolicy +from PyQt5.QtWidgets import ( + QDialog, QInputDialog, QApplication, QMenu, QWidget, QHBoxLayout, + QVBoxLayout, QShortcut, QSizePolicy +) from PyQt5.Qsci import QsciScintilla from E5Gui.E5Application import e5App @@ -367,8 +369,9 @@ QsciScintilla.SCI_CANCEL: self.__QScintillaCancel, } - self.__historyNavigateByCursor = \ + self.__historyNavigateByCursor = ( Preferences.getShell("HistoryNavigateByCursor") + ) self.__queuedText = '' self.__blockTextProcessing = False @@ -582,8 +585,10 @@ calltipsStyle = Preferences.getEditor("CallTipsStyle") if calltipsStyle == QsciScintilla.CallTipsNoContext: self.setCallTipsStyle(QsciScintilla.CallTipsNoContext) - elif calltipsStyle == \ - QsciScintilla.CallTipsNoAutoCompletionContext: + elif ( + calltipsStyle == + QsciScintilla.CallTipsNoAutoCompletionContext + ): self.setCallTipsStyle( QsciScintilla.CallTipsNoAutoCompletionContext) else: @@ -631,9 +636,10 @@ self.__setMargin0() self.__setAutoCompletion(self.clientType) self.__setCallTips(self.clientType) - self.racEnabled = \ - Preferences.getShell("AutoCompletionEnabled") and \ + self.racEnabled = ( + Preferences.getShell("AutoCompletionEnabled") and (cap & HasCompleter) > 0 + ) if self.clientType not in self.__historyLists: # load history list @@ -653,8 +659,10 @@ """ if index is None: # determine based on history style - if self.clientType and \ - self.__historyStyle == ShellHistoryStyle.WindowsStyle: + if ( + self.clientType and + self.__historyStyle == ShellHistoryStyle.WindowsStyle + ): idx = int(Preferences.Prefs.settings.value( "Shell/HistoryIndexes/" + self.clientType, -1)) if idx >= len(self.__history): @@ -666,8 +674,10 @@ self.__histidx = index if self.__histidx >= len(self.__history): self.__histidx = -1 - if self.clientType and \ - self.__historyStyle == ShellHistoryStyle.WindowsStyle: + if ( + self.clientType and + self.__historyStyle == ShellHistoryStyle.WindowsStyle + ): Preferences.Prefs.settings.setValue( "Shell/HistoryIndexes/" + self.clientType, self.__histidx) @@ -869,8 +879,10 @@ """ self .__clientError() - if not self.__windowed and \ - Preferences.getDebugger("ShowExceptionInShell"): + if ( + not self.__windowed and + Preferences.getDebugger("ShowExceptionInShell") + ): if exceptionType: if stackTrace: self.__write( @@ -903,8 +915,10 @@ """ self .__clientError() - if not self.__windowed and \ - Preferences.getDebugger("ShowExceptionInShell"): + if ( + not self.__windowed and + Preferences.getDebugger("ShowExceptionInShell") + ): if message is None: self.__write(self.tr("Unspecified syntax error.\n")) else: @@ -1300,8 +1314,7 @@ ac = self.isListActive() super(Shell, self).keyPressEvent(ev) self.incrementalSearchActive = True - if ac and \ - self.racEnabled: + if ac and self.racEnabled: self.dbs.remoteCompletion(self.completionText + txt) else: self.__insertTextNoEcho(txt) @@ -1608,8 +1621,10 @@ if buf.startswith(sys.ps2): buf = buf.replace(sys.ps2, "") if buf and self.incrementalSearchActive: - if self.incrementalSearchString and \ - buf.startswith(self.incrementalSearchString): + if ( + self.incrementalSearchString and + buf.startswith(self.incrementalSearchString) + ): idx, found = self.__rsearchHistory( self.incrementalSearchString, self.__histidx) if found and idx >= 0: @@ -1651,8 +1666,10 @@ if buf.startswith(sys.ps2): buf = buf.replace(sys.ps2, "") if buf and self.incrementalSearchActive: - if self.incrementalSearchString and \ - buf.startswith(self.incrementalSearchString): + if ( + self.incrementalSearchString and + buf.startswith(self.incrementalSearchString) + ): idx, found = self.__searchHistory( self.incrementalSearchString, self.__histidx) if found and idx >= 0: @@ -1753,8 +1770,10 @@ self.__setHistoryIndex(index=-1) elif self.__historyStyle == ShellHistoryStyle.WindowsStyle: if historyIndex is None: - if self.__histidx - 1 > 0 and \ - cmd != self.__history[self.__histidx - 1]: + if ( + self.__histidx - 1 > 0 and + cmd != self.__history[self.__histidx - 1] + ): self.__setHistoryIndex(index=-1) else: self.__setHistoryIndex(historyIndex) @@ -1771,8 +1790,9 @@ self.dbs.startClient( False, forProject=True, workingDir=self.__project.getProjectPath()) - self.__currentWorkingDirectory = \ + self.__currentWorkingDirectory = ( self.__project.getProjectPath() + ) else: self.dbs.startClient( False, venvName=self.__currentVenv, @@ -1798,8 +1818,10 @@ else: cmd = '' elif cmd in ['envs', 'environments']: - venvs = e5App().getObject("VirtualEnvManager")\ + venvs = ( + e5App().getObject("VirtualEnvManager") .getVirtualenvNames() + ) s = self.tr('Available Virtual Environments:\n{0}\n').format( '\n'.join("- {0}".format(venv) for venv in sorted(venvs)) ) @@ -1812,8 +1834,10 @@ self.__write(s) self.__clientStatement(False) return - elif cmd in ["quit", "quit()", "exit", "exit()"] and \ - self.__windowed: + elif ( + cmd in ["quit", "quit()", "exit", "exit()"] and + self.__windowed + ): # call main window quit() self.vm.quit() return @@ -1891,8 +1915,10 @@ idx = 0 else: idx = startIdx + 1 - while idx < len(self.__history) and \ - not self.__history[idx].startswith(txt): + while ( + idx < len(self.__history) and + not self.__history[idx].startswith(txt) + ): idx += 1 found = (idx < len(self.__history) and self.__history[idx].startswith(txt)) @@ -1914,8 +1940,10 @@ idx = len(self.__history) - 1 else: idx = startIdx - 1 - while idx >= 0 and \ - not self.__history[idx].startswith(txt): + while ( + idx >= 0 and + not self.__history[idx].startswith(txt) + ): idx -= 1 found = idx >= 0 and self.__history[idx].startswith(txt) return idx, found @@ -1976,8 +2004,9 @@ venvName = action.text() if venvName == self.tr("Project"): if self.__project.isOpen(): - self.__currentWorkingDirectory = \ + self.__currentWorkingDirectory = ( self.__project.getProjectPath() + ) self.dbs.startClient(False, forProject=True, workingDir=self.__currentWorkingDirectory) else: @@ -2003,15 +2032,16 @@ # do the history related stuff self.__maxHistoryEntries = Preferences.getShell("MaxHistoryEntries") for key in list(self.__historyLists.keys()): - self.__historyLists[key] = \ + self.__historyLists[key] = ( self.__historyLists[key][-self.__maxHistoryEntries:] + ) self.__historyStyle = Preferences.getShell("HistoryStyle") self.__historyWrap = Preferences.getShell("HistoryWrap") self.__setHistoryIndex() if not self.__windowed: self.hmenu.menuAction().setEnabled(self.isHistoryEnabled()) - self.__historyNavigateByCursor = \ - Preferences.getShell("HistoryNavigateByCursor") + self.__historyNavigateByCursor = Preferences.getShell( + "HistoryNavigateByCursor") self.historyStyleChanged.emit(self.__historyStyle) # do stdout /stderr stuff @@ -2069,8 +2099,10 @@ @param event the drag enter event (QDragEnterEvent) """ - self.inDragDrop = event.mimeData().hasUrls() or \ + self.inDragDrop = ( + event.mimeData().hasUrls() or event.mimeData().hasText() + ) if self.inDragDrop: event.acceptProposedAction() else: