Created
May 16, 2013 20:31
-
-
Save slarosa/5594862 to your computer and use it in GitHub Desktop.
patch_console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/python/console/console_editor.py b/python/console/console_editor.py | |
index cdf79cb..06c5342 100644 | |
--- a/python/console/console_editor.py | |
+++ b/python/console/console_editor.py | |
@@ -602,11 +602,12 @@ class Editor(QsciScintilla): | |
return True | |
def keyPressEvent(self, e): | |
- t = unicode(e.text()) | |
- ## Close bracket automatically | |
- if t in self.opening: | |
- i = self.opening.index(t) | |
- self.insert(self.closing[i]) | |
+ if self.settings.value("pythonConsole/autoCloseBracketEditor", True).toBool(): | |
+ 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) | |
def focusInEvent(self, e): | |
diff --git a/python/console/console_output.py b/python/console/console_output.py | |
index 1e4f614..d038f67 100644 | |
--- a/python/console/console_output.py | |
+++ b/python/console/console_output.py | |
@@ -148,6 +148,10 @@ class ShellOutputScintilla(QsciScintilla): | |
font = QFont(loadFont) | |
font.setFixedPitch(True) | |
font.setPointSize(fontSize) | |
+ font.setStyleHint(QFont.TypeWriter) | |
+ font.setStretch(QFont.SemiCondensed) | |
+ font.setLetterSpacing(QFont.PercentageSpacing, 87.0) | |
+ font.setBold(False) | |
self.lexer.setDefaultFont(font) | |
self.lexer.setColor(Qt.red, 1) | |
diff --git a/python/console/console_sci.py b/python/console/console_sci.py | |
index c7ac593..f8b3563 100644 | |
--- a/python/console/console_sci.py | |
+++ b/python/console/console_sci.py | |
@@ -381,21 +381,26 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter): | |
self.recolor() | |
elif e.modifiers() & (Qt.ControlModifier | Qt.MetaModifier) and \ | |
- e.key() == Qt.Key_V: | |
+ e.key() == Qt.Key_V: | |
self.paste() | |
e.accept() | |
- | |
+ | |
+ elif e.modifiers() & Qt.ShiftModifier and e.key() == Qt.Key_Insert: | |
+ self.paste() | |
+ e.accept() | |
+ | |
elif e.key() == Qt.Key_Down and not self.isListActive(): | |
self.showPrevious() | |
elif e.key() == Qt.Key_Up and not self.isListActive(): | |
self.showNext() | |
## TODO: press event for auto-completion file directory | |
else: | |
- t = unicode(e.text()) | |
- ## Close bracket automatically | |
- if t in self.opening: | |
- i = self.opening.index(t) | |
- self.insert(self.closing[i]) | |
+ if self.settings.value("pythonConsole/autoCloseBracket", True).toBool(): | |
+ 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) | |
def contextMenuEvent(self, e): | |
@@ -494,10 +499,6 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter): | |
self.writeCMD(cmd) | |
import webbrowser | |
self.updateHistory(cmd) | |
- line, pos = self.getCursorPosition() | |
- selCmdLenght = self.text(line).length() | |
- self.setSelection(line, 0, line, selCmdLenght) | |
- self.removeSelectedText() | |
if cmd in ('_save', '_clear', '_clearAll', '_pyqgis', '_api'): | |
if cmd == '_save': | |
self.writeHistoryFile() | |
diff --git a/python/console/console_settings.py b/python/console/console_settings.py | |
index ff0dede..20d7e3d 100644 | |
--- a/python/console/console_settings.py | |
+++ b/python/console/console_settings.py | |
@@ -129,20 +129,16 @@ class optionsDialog(QDialog, Ui_SettingsDialogPythonConsole): | |
#for i in range(0, len(fontFamily)): | |
#self.comboBox.addItem(fontFamily[i]) | |
settings = QSettings() | |
- self.fontComboBox.setCurrentIndex(settings.value("pythonConsole/fontfamilyindex").toInt()[0]) | |
- self.fontComboBoxEditor.setCurrentIndex(settings.value("pythonConsole/fontfamilyindexEditor").toInt()[0]) | |
+ self.fontComboBox.setCurrentFont(QFont(settings.value("pythonConsole/fontfamilytext", "Monospace").toString())) | |
+ self.fontComboBoxEditor.setCurrentFont(QFont(settings.value("pythonConsole/fontfamilytext", "Monospace").toString())) | |
def saveSettings(self): | |
settings = QSettings() | |
settings.setValue("pythonConsole/preloadAPI", QVariant(self.preloadAPI.isChecked())) | |
settings.setValue("pythonConsole/autoSaveScript", QVariant(self.autoSaveScript.isChecked())) | |
- fontFamilyIndex = self.fontComboBox.currentIndex() | |
- settings.setValue("pythonConsole/fontfamilyindex", QVariant(fontFamilyIndex)) | |
fontFamilyText = self.fontComboBox.currentText() | |
settings.setValue("pythonConsole/fontfamilytext", QVariant(fontFamilyText)) | |
- fontFamilyIndexEditor = self.fontComboBoxEditor.currentIndex() | |
- settings.setValue("pythonConsole/fontfamilyindexEditor", QVariant(fontFamilyIndexEditor)) | |
fontFamilyTextEditor = self.fontComboBoxEditor.currentText() | |
settings.setValue("pythonConsole/fontfamilytextEditor", QVariant(fontFamilyTextEditor)) | |
@@ -176,6 +172,8 @@ class optionsDialog(QDialog, Ui_SettingsDialogPythonConsole): | |
settings.setValue("pythonConsole/autoCompleteEnabledEditor", QVariant(self.autoCompleteEnabledEditor.isChecked())) | |
settings.setValue("pythonConsole/autoCompleteEnabled", QVariant(self.autoCompleteEnabled.isChecked())) | |
settings.setValue("pythonConsole/enableObjectInsp", QVariant(self.enableObjectInspector.isChecked())) | |
+ settings.setValue("pythonConsole/autoCloseBracket", QVariant(self.autoCloseBracket.isChecked())) | |
+ settings.setValue("pythonConsole/autoCloseBracketEditor", QVariant(self.autoCloseBracketEditor.isChecked())) | |
def restoreSettings(self): | |
settings = QSettings() | |
@@ -198,6 +196,8 @@ class optionsDialog(QDialog, Ui_SettingsDialogPythonConsole): | |
self.autoCompleteEnabledEditor.setChecked(settings.value("pythonConsole/autoCompleteEnabledEditor", True).toBool()) | |
self.autoCompleteEnabled.setChecked(settings.value("pythonConsole/autoCompleteEnabled", True).toBool()) | |
self.enableObjectInspector.setChecked(settings.value("pythonConsole/enableObjectInsp", False).toBool()) | |
+ self.autoCloseBracketEditor.setChecked(settings.value("pythonConsole/autoCloseBracketEditor", True).toBool()) | |
+ self.autoCloseBracket.setChecked(settings.value("pythonConsole/autoCloseBracket", True).toBool()) | |
if settings.value("pythonConsole/autoCompleteSource") == 'fromDoc': | |
self.autoCompFromDoc.setChecked(True) | |
diff --git a/python/console/console_settings.ui b/python/console/console_settings.ui | |
index 3c38761..e835186 100644 | |
--- a/python/console/console_settings.ui | |
+++ b/python/console/console_settings.ui | |
@@ -59,7 +59,7 @@ | |
<x>0</x> | |
<y>0</y> | |
<width>543</width> | |
- <height>622</height> | |
+ <height>692</height> | |
</rect> | |
</property> | |
<layout class="QGridLayout" name="gridLayout_2"> | |
@@ -132,7 +132,7 @@ | |
</item> | |
</layout> | |
</item> | |
- <item row="3" column="0"> | |
+ <item row="4" column="0"> | |
<widget class="QgsCollapsibleGroupBox" name="groupBoxAutoCompletionEditor"> | |
<property name="title"> | |
<string>Autocompletion</string> | |
@@ -226,6 +226,20 @@ | |
</item> | |
</layout> | |
</item> | |
+ <item row="3" column="0"> | |
+ <widget class="QCheckBox" name="autoCloseBracketEditor"> | |
+ <property name="text"> | |
+ <string>Close bracket automatically</string> | |
+ </property> | |
+ </widget> | |
+ </item> | |
+ <item row="2" column="0"> | |
+ <widget class="Line" name="line_2"> | |
+ <property name="orientation"> | |
+ <enum>Qt::Horizontal</enum> | |
+ </property> | |
+ </widget> | |
+ </item> | |
</layout> | |
</widget> | |
</item> | |
@@ -248,7 +262,7 @@ | |
<string>Console</string> | |
</property> | |
<layout class="QGridLayout" name="gridLayout_9"> | |
- <item row="0" column="0"> | |
+ <item row="1" column="0"> | |
<layout class="QHBoxLayout" name="horizontalLayout"> | |
<item> | |
<widget class="QLabel" name="label"> | |
@@ -304,7 +318,7 @@ | |
</item> | |
</layout> | |
</item> | |
- <item row="1" column="0"> | |
+ <item row="3" column="0"> | |
<widget class="QgsCollapsibleGroupBox" name="groupBoxAutoCompletion"> | |
<property name="title"> | |
<string>Autocompletion</string> | |
@@ -313,6 +327,13 @@ | |
<bool>true</bool> | |
</property> | |
<layout class="QGridLayout" name="gridLayout_8"> | |
+ <item row="3" column="0"> | |
+ <widget class="QCheckBox" name="autoCloseBracket"> | |
+ <property name="text"> | |
+ <string>Close bracket automatically</string> | |
+ </property> | |
+ </widget> | |
+ </item> | |
<item row="0" column="0"> | |
<layout class="QHBoxLayout" name="horizontalLayout_4"> | |
<item> | |
@@ -398,6 +419,13 @@ | |
</item> | |
</layout> | |
</item> | |
+ <item row="2" column="0"> | |
+ <widget class="Line" name="line"> | |
+ <property name="orientation"> | |
+ <enum>Qt::Horizontal</enum> | |
+ </property> | |
+ </widget> | |
+ </item> | |
</layout> | |
</widget> | |
</item> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment