35 changes: 26 additions & 9 deletions python/console/console_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def settingsEditor(self):
self.setLexers()
threshold = self.settings.value("pythonConsole/autoCompThresholdEditor", 2, type=int)
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSourceEditor", 'fromAPI')
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabledEditor", True)
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabledEditor", True, type=bool)
self.setAutoCompletionThreshold(threshold)
if autoCompEnabled:
if radioButtonSource == 'fromDoc':
Expand All @@ -198,8 +198,8 @@ def settingsEditor(self):
self.setAutoCompletionSource(self.AcsNone)

def autoCompleteKeyBinding(self):
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSourceEditor")
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabledEditor")
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSourceEditor", 'fromAPI')
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabledEditor", True, type=bool)
if autoCompEnabled:
if radioButtonSource == 'fromDoc':
self.autoCompleteFromDocument()
Expand Down Expand Up @@ -240,7 +240,7 @@ def setLexers(self):
if chekBoxAPI:
self.api.loadPrepared( QgsApplication.pkgDataPath() + "/python/qsci_apis/pyqgis_master.pap" )
else:
apiPath = self.settings.value("pythonConsole/userAPI")
apiPath = self.settings.value("pythonConsole/userAPI", [])
for i in range(0, len(apiPath)):
self.api.load(unicode(apiPath[i]))
self.api.prepare()
Expand Down Expand Up @@ -372,7 +372,7 @@ def contextMenuEvent(self, e):
if QApplication.clipboard().text():
pasteAction.setEnabled(True)
if self.settings.value("pythonConsole/enableObjectInsp",
False):
False, type=bool):
showCodeInspection.setEnabled(True)
action = menu.exec_(self.mapToGlobal(e.pos()))

Expand Down Expand Up @@ -642,13 +642,30 @@ def syntaxCheck(self, filename=None, fromContextMenu=True):
return True

def keyPressEvent(self, e):
if self.settings.value("pythonConsole/autoCloseBracketEditor", True):
if self.settings.value("pythonConsole/autoCloseBracketEditor", True, type=bool):
startLine, _, endLine, _ = self.getSelection()
t = unicode(e.text())
## Close bracket automatically
if t in self.opening:
i = self.opening.index(t)
self.insert(self.closing[i])
QsciScintilla.keyPressEvent(self, e)
if self.hasSelectedText():
self.beginUndoAction()
selText = self.selectedText()
self.removeSelectedText()
if startLine == endLine:
self.insert(self.opening[i] + selText + self.closing[i])
return
elif startLine < endLine and self.opening[i] in ("'", '"'):
self.insert("'''" + selText + "'''")
return
else:
self.insert(self.closing[i])
self.endUndoAction()
else:
self.insert(self.closing[i])
QsciScintilla.keyPressEvent(self, e)
else:
QsciScintilla.keyPressEvent(self, e)

def focusInEvent(self, e):
pathfile = self.parent.path
Expand Down Expand Up @@ -852,7 +869,7 @@ def __init__(self, parent):

# Restore script of the previuos session
self.settings = QSettings()
tabScripts = self.settings.value("pythonConsole/tabScripts")
tabScripts = self.settings.value("pythonConsole/tabScripts", [])
self.restoreTabList = tabScripts

if self.restoreTabList:
Expand Down
20 changes: 13 additions & 7 deletions python/console/console_sci.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def settingsShell(self):
threshold = self.settings.value("pythonConsole/autoCompThreshold", 2, type=int)
self.setAutoCompletionThreshold(threshold)
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSource", 'fromAPI')
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabled", True)
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabled", True, type=bool)
if autoCompEnabled:
if radioButtonSource == 'fromDoc':
self.setAutoCompletionSource(self.AcsDocument)
Expand All @@ -135,8 +135,8 @@ def showHistory(self):
self.historyDlg.activateWindow()

def autoCompleteKeyBinding(self):
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSource")
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabled")
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSource", 'fromAPI')
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabled", True, type=bool)
if autoCompEnabled:
if radioButtonSource == 'fromDoc':
self.autoCompleteFromDocument()
Expand Down Expand Up @@ -192,7 +192,7 @@ def setLexers(self):
if chekBoxAPI:
self.api.loadPrepared( QgsApplication.pkgDataPath() + "/python/qsci_apis/pyqgis_master.pap" )
else:
apiPath = self.settings.value("pythonConsole/userAPI")
apiPath = self.settings.value("pythonConsole/userAPI", [])
for i in range(0, len(apiPath)):
self.api.load(unicode(apiPath[i]))
self.api.prepare()
Expand Down Expand Up @@ -349,7 +349,7 @@ def showNext(self):
#self.SendScintilla(QsciScintilla.SCI_DELETEBACK)

def keyPressEvent(self, e):
startLine, _, endLine, _ = self.getSelection()
startLine, startPos, endLine, _ = self.getSelection()

# handle invalid cursor position and multiline selections
if not self.is_cursor_on_edition_zone() or startLine < endLine:
Expand Down Expand Up @@ -406,12 +406,18 @@ def keyPressEvent(self, e):
self.showNext()
## TODO: press event for auto-completion file directory
else:
if self.settings.value("pythonConsole/autoCloseBracket", True):
if self.settings.value("pythonConsole/autoCloseBracket", True, type=bool):
t = unicode(e.text())
## Close bracket automatically
if t in self.opening:
i = self.opening.index(t)
self.insert(self.closing[i])
if self.hasSelectedText() and startPos != 0:
selText = self.selectedText()
self.removeSelectedText()
self.insert(self.opening[i] + selText + self.closing[i])
return
else:
self.insert(self.closing[i])
QsciScintilla.keyPressEvent(self, e)

def contextMenuEvent(self, e):
Expand Down
7 changes: 0 additions & 7 deletions python/console/help/CMakeLists.txt

This file was deleted.

13 changes: 0 additions & 13 deletions python/console/help/i18n/README

This file was deleted.

27 changes: 0 additions & 27 deletions python/console/help/i18n/de_DE.properties

This file was deleted.

40 changes: 0 additions & 40 deletions python/console/help/i18n/en_US.properties

This file was deleted.

41 changes: 0 additions & 41 deletions python/console/help/i18n/it_IT.properties

This file was deleted.

40 changes: 0 additions & 40 deletions python/console/help/i18n/ru_RU.properties

This file was deleted.

Loading