Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[pyqgis-console] added more settings for fonts color
  • Loading branch information
slarosa committed Sep 19, 2013
1 parent 6595f5f commit 049edb2
Show file tree
Hide file tree
Showing 6 changed files with 797 additions and 457 deletions.
4 changes: 2 additions & 2 deletions python/console/console.py
Expand Up @@ -687,8 +687,8 @@ def openSettings(self):
self.options.exec_()

def prefChanged(self):
self.shell.settingsShell()
self.shellOut.refreshLexerProperties()
self.shell.refreshSettingsShell()
self.shellOut.refreshSettingsOutput()
self.tabEditorWidget.refreshSettingsEditor()

def callWidgetMessageBar(self, text):
Expand Down
16 changes: 15 additions & 1 deletion python/console/console_editor.py
Expand Up @@ -109,7 +109,7 @@ def __init__(self, parent=None):
self.setMarginsForegroundColor(QColor("#3E3EE3"))
self.setMarginsBackgroundColor(QColor("#f9f9f9"))
self.setCaretLineVisible(True)
self.setCaretLineBackgroundColor(QColor("#fcf3ed"))
self.setCaretWidth(2)

self.markerDefine(QgsApplication.getThemePixmap("console/iconSyntaxErrorConsole.png"),
self.MARKER_NUM)
Expand Down Expand Up @@ -199,6 +199,11 @@ def settingsEditor(self):
else:
self.setAutoCompletionSource(self.AcsNone)

caretLineColorEditor = self.settings.value("pythonConsole/caretLineColorEditor", QColor("#fcf3ed"))
cursorColorEditor = self.settings.value("pythonConsole/cursorColorEditor", QColor(Qt.black))
self.setCaretLineBackgroundColor(caretLineColorEditor)
self.setCaretForegroundColor(cursorColorEditor)

def autoCompleteKeyBinding(self):
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSourceEditor", 'fromAPI')
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabledEditor", True, type=bool)
Expand Down Expand Up @@ -233,13 +238,22 @@ def setLexers(self):
self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColorEditor", QColor(Qt.black))))
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColorEditor", QColor(Qt.gray))), 1)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColorEditor", QColor(Qt.darkGreen))), 5)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColorEditor", QColor(Qt.blue))), 8)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColorEditor", QColor(Qt.darkGray))), 9)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/decorFontColorEditor", QColor(Qt.darkBlue))), 15)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentBlockFontColorEditor", QColor(Qt.gray))), 12)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/singleQuoteFontColorEditor", QColor(Qt.blue))), 4)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/doubleQuoteFontColorEditor", QColor(Qt.blue))), 3)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleSingleQuoteFontColorEditor", QColor(Qt.blue))), 6)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleDoubleQuoteFontColorEditor", QColor(Qt.blue))), 7)
self.lexer.setFont(font, 1)
self.lexer.setFont(font, 3)
self.lexer.setFont(font, 4)

for style in range(0, 33):
paperColor = QColor(self.settings.value("pythonConsole/paperBackgroundColorEditor", QColor(Qt.white)))
self.lexer.setPaper(paperColor, style)

self.api = QsciAPIs(self.lexer)
chekBoxAPI = self.settings.value("pythonConsole/preloadAPI", True, type=bool)
chekBoxPreparedAPI = self.settings.value("pythonConsole/usePreparedAPIFile", False, type=bool)
Expand Down
20 changes: 17 additions & 3 deletions python/console/console_output.py
Expand Up @@ -99,7 +99,7 @@ def __init__(self, parent=None):
sys.stderr = writeOut(self, sys.stderr, "_traceback")

self.insertInitText()
self.setLexers()
self.refreshSettingsOutput()
self.setReadOnly(True)

# Set the default font
Expand All @@ -120,7 +120,7 @@ def __init__(self, parent=None):
self.setMarginsForegroundColor(QColor("#3E3EE3"))
self.setMarginsBackgroundColor(QColor("#f9f9f9"))
self.setCaretLineVisible(True)
self.setCaretLineBackgroundColor(QColor("#fcf3ed"))
self.setCaretWidth(0)

self.setMinimumHeight(120)

Expand Down Expand Up @@ -149,8 +149,13 @@ def insertInitText(self):
else:
initText = self.setText(txtInit + '\n')

def refreshLexerProperties(self):
def refreshSettingsOutput(self):
# Set Python lexer
self.setLexers()
caretLineColor = self.settings.value("pythonConsole/caretLineColor", QColor("#fcf3ed"))
cursorColor = self.settings.value("pythonConsole/cursorColor", QColor(Qt.black))
self.setCaretLineBackgroundColor(caretLineColor)
self.setCaretForegroundColor(cursorColor)

def setLexers(self):
self.lexer = QsciLexerPython()
Expand All @@ -169,15 +174,24 @@ def setLexers(self):
self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColor", QColor(Qt.black))))
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColor", QColor(Qt.gray))), 1)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColor", QColor(Qt.darkGreen))), 5)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColor", QColor(Qt.blue))), 8)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColor", QColor(Qt.darkGray))), 9)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/decorFontColor", QColor(Qt.darkBlue))), 15)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentBlockFontColor", QColor(Qt.gray))), 12)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/singleQuoteFontColor", QColor(Qt.blue))), 4)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/doubleQuoteFontColor", QColor(Qt.blue))), 3)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleSingleQuoteFontColor", QColor(Qt.blue))), 6)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleDoubleQuoteFontColor", QColor(Qt.blue))), 7)
self.lexer.setColor(QColor(Qt.red), 14)
self.lexer.setFont(font, 1)
self.lexer.setFont(font, 2)
self.lexer.setFont(font, 3)
self.lexer.setFont(font, 4)

for style in range(0, 33):
paperColor = QColor(self.settings.value("pythonConsole/paperBackgroundColor", QColor(Qt.white)))
self.lexer.setPaper(paperColor, style)

self.setLexer(self.lexer)

def clearConsole(self):
Expand Down
16 changes: 14 additions & 2 deletions python/console/console_sci.py
Expand Up @@ -82,7 +82,7 @@ def __init__(self, parent=None):
# Current line visible with special background color
self.setCaretWidth(2)

self.settingsShell()
self.refreshSettingsShell()

# Don't want to see the horizontal scrollbar at all
# Use raw message to Scintilla here (all messages are documented
Expand Down Expand Up @@ -113,7 +113,7 @@ def __init__(self, parent=None):
self.newShortcutCAS.activated.connect(self.autoCompleteKeyBinding)
self.newShortcutCSS.activated.connect(self.showHistory)

def settingsShell(self):
def refreshSettingsShell(self):
# Set Python lexer
self.setLexers()
threshold = self.settings.value("pythonConsole/autoCompThreshold", 2, type=int)
Expand All @@ -130,6 +130,9 @@ def settingsShell(self):
else:
self.setAutoCompletionSource(self.AcsNone)

cursorColor = self.settings.value("pythonConsole/cursorColor", QColor(Qt.black))
self.setCaretForegroundColor(cursorColor)

def showHistory(self):
if not self.historyDlg.isVisible():
self.historyDlg.show()
Expand Down Expand Up @@ -185,13 +188,22 @@ def setLexers(self):
self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColor", QColor(Qt.black))))
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColor", QColor(Qt.gray))), 1)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColor", QColor(Qt.darkGreen))), 5)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColor", QColor(Qt.blue))), 8)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColor", QColor(Qt.darkGray))), 9)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/decorFontColor", QColor(Qt.darkBlue))), 15)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentBlockFontColor", QColor(Qt.gray))), 12)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/singleQuoteFontColor", QColor(Qt.blue))), 4)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/doubleQuoteFontColor", QColor(Qt.blue))), 3)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleSingleQuoteFontColor", QColor(Qt.blue))), 6)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleDoubleQuoteFontColor", QColor(Qt.blue))), 7)
self.lexer.setFont(font, 1)
self.lexer.setFont(font, 3)
self.lexer.setFont(font, 4)

for style in range(0, 33):
paperColor = QColor(self.settings.value("pythonConsole/paperBackgroundColor", QColor(Qt.white)))
self.lexer.setPaper(paperColor, style)

self.api = QsciAPIs(self.lexer)
chekBoxAPI = self.settings.value("pythonConsole/preloadAPI", True, type=bool)
chekBoxPreparedAPI = self.settings.value("pythonConsole/usePreparedAPIFile", False, type=bool)
Expand Down

0 comments on commit 049edb2

Please sign in to comment.