--- a/QScintilla/Shell.py Fri Dec 22 18:26:42 2017 +0100 +++ b/QScintilla/Shell.py Fri Dec 22 19:52:58 2017 +0100 @@ -322,9 +322,13 @@ QsciScintilla.SCI_VCHOME: self.__QScintillaVCHome, QsciScintilla.SCI_LINEEND: self.__QScintillaLineEnd, + QsciScintilla.SCI_LINEUP: self.__QScintillaCursorCommand, + QsciScintilla.SCI_LINEDOWN: self.__QScintillaCursorCommand, + QsciScintilla.SCI_LINESCROLLUP: self.__QScintillaCursorCommand, + QsciScintilla.SCI_LINESCROLLDOWN: self.__QScintillaCursorCommand, + QsciScintilla.SCI_PAGEUP: self.__QScintillaAutoCompletionCommand, QsciScintilla.SCI_PAGEDOWN: self.__QScintillaAutoCompletionCommand, - QsciScintilla.SCI_CANCEL: self.__QScintillaAutoCompletionCommand, QsciScintilla.SCI_CHARLEFTEXTEND: self.__QScintillaCharLeftExtend, QsciScintilla.SCI_CHARRIGHTEXTEND: self.extendSelectionRight, @@ -335,29 +339,12 @@ QsciScintilla.SCI_CANCEL: self.__QScintillaCancel, } - self.__setupCursorKeys() + + self.__historyNavigateByCursor = \ + Preferences.getShell("HistoryNavigateByCursor") self.grabGesture(Qt.PinchGesture) - def __setupCursorKeys(self): - """ - Private method to setup the cursor up and down mode. - """ - if Preferences.getShell("HistoryNavigateByCursor"): - self.supportedEditorCommands.update({ - QsciScintilla.SCI_LINEUP: self.__QScintillaHistoryUp, - QsciScintilla.SCI_LINEDOWN: self.__QScintillaHistoryDown, - QsciScintilla.SCI_LINESCROLLUP: self.__QScintillaLineUp, - QsciScintilla.SCI_LINESCROLLDOWN: self.__QScintillaLineDown, - }) - else: - self.supportedEditorCommands.update({ - QsciScintilla.SCI_LINEUP: self.__QScintillaLineUp, - QsciScintilla.SCI_LINEDOWN: self.__QScintillaLineDown, - QsciScintilla.SCI_LINESCROLLUP: self.__QScintillaHistoryUp, - QsciScintilla.SCI_LINESCROLLDOWN: self.__QScintillaHistoryDown, - }) - def __showLanguageMenu(self): """ Private slot to prepare the language submenu. @@ -1469,6 +1456,35 @@ elif self.__isCursorOnLastLine(): self.moveCursorToEOL() + def __QScintillaCursorCommand(self, cmd): + """ + Private method to handle the cursor commands. + + @param cmd QScintilla command + """ + if self.isListActive() or self.isCallTipActive(): + if cmd in (QsciScintilla.SCI_LINEUP, QsciScintilla.SCI_LINEDOWN): + self.SendScintilla(cmd) + else: + if self.__historyNavigateByCursor: + if cmd == QsciScintilla.SCI_LINEUP: + self.__QScintillaHistoryUp(cmd) + elif cmd == QsciScintilla.SCI_LINEDOWN: + self.__QScintillaHistoryDown(cmd) + elif cmd == QsciScintilla.SCI_LINESCROLLUP: + self.__QScintillaLineUp(cmd) + elif cmd == QsciScintilla.SCI_LINESCROLLDOWN: + self.__QScintillaLineDown(cmd) + else: + if cmd == QsciScintilla.SCI_LINEUP: + self.__QScintillaLineUp(cmd) + elif cmd == QsciScintilla.SCI_LINEDOWN: + self.__QScintillaLineDown(cmd) + elif cmd == QsciScintilla.SCI_LINESCROLLUP: + self.__QScintillaHistoryUp(cmd) + elif cmd == QsciScintilla.SCI_LINESCROLLDOWN: + self.__QScintillaHistoryDown(cmd) + def __QScintillaLineUp(self, cmd): """ Private method to handle the cursor up command. @@ -1572,9 +1588,12 @@ """ Private method to handle the ESC command. """ - if self.incrementalSearchActive: - self.__resetIncrementalHistorySearch() - self.__insertHistory("") + if self.isListActive() or self.isCallTipActive(): + self.SendScintilla(QsciScintilla.SCI_CANCEL) + else: + if self.incrementalSearchActive: + self.__resetIncrementalHistorySearch() + self.__insertHistory("") def __QScintillaCharLeftExtend(self): """ @@ -1869,7 +1888,8 @@ self.__setHistoryIndex() if not self.__windowed: self.hmenu.menuAction().setEnabled(self.isHistoryEnabled()) - self.__setupCursorKeys() + self.__historyNavigateByCursor = \ + Preferences.getShell("HistoryNavigateByCursor") self.historyStyleChanged.emit(self.__historyStyle) # do stdout /stderr stuff