Skip to content
Permalink
Browse files

Move font, margin and caret code to baseclass

  • Loading branch information
rduivenvoorde committed Aug 27, 2020
1 parent ab83e57 commit 354b9598ecf9cf438641130288c57b921ad3be94
@@ -56,6 +56,25 @@ class QgsQsciScintillaBase(QsciScintilla):
def __init__(self, parent=None):
super(QgsQsciScintillaBase, self).__init__(parent)

# Enable non-ascii chars
self.setUtf8(True)

# Set the default font
font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
self.setFont(font)
self.setMarginsFont(font)

# Margin 0 is used for line numbers (editor and output)
self.setMarginWidth(0, "00000")
# Margin 1 is used for the '>>>' prompt (console input)
self.setMarginWidth(1, "0")
self.setMarginType(1, 5) # TextMarginRightJustified=5
# Margin 2 is used for the 'folding' (editor)
self.setMarginWidth(2, "0")

self.setCaretLineVisible(True)
self.setCaretWidth(2)

self.iconRun = QgsApplication.getThemeIcon("console/mIconRunConsole.svg")
self.iconRunScript = QgsApplication.getThemeIcon("mActionStart.svg")
self.iconUndo = QgsApplication.getThemeIcon("mActionUndo.svg")
@@ -92,20 +92,6 @@ def __init__(self, parent=None):

self.settings = QgsSettings()

# Enable non-ascii chars for editor
self.setUtf8(True)

# Set the default font
font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
self.setFont(font)
self.setMarginsFont(font)
# Margin 0 is used for line numbers
fontmetrics = QFontMetrics(font)
self.setMarginWidth(0, fontmetrics.width("0000") + 5)
self.setMarginLineNumbers(0, True)
self.setCaretLineVisible(True)
self.setCaretWidth(2)

self.markerDefine(QgsApplication.getThemePixmap("console/iconSyntaxErrorConsole.svg"),
self.MARKER_NUM)

@@ -114,29 +114,14 @@ def __init__(self, parent=None):
self.infoBar.setSizePolicy(sizePolicy)
self.layout.addWidget(self.infoBar, 0, 0, 1, 1)

# Enable non-ascii chars for editor
self.setUtf8(True)

sys.stdout = writeOut(self, sys.stdout)
sys.stderr = writeOut(self, sys.stderr, "_traceback")

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

# Set the default font
font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
self.setFont(font)
self.setMarginsFont(font)
# Margin 0 is used for line numbers
self.setMarginWidth(0, 0)
self.setMarginWidth(1, 0)
self.setMarginWidth(2, 0)
self.setMarginsFont(font)
self.setMarginWidth(1, "00000")
self.setMarginLineNumbers(1, True)
self.setCaretLineVisible(True)
self.setCaretWidth(0)
self.setCaretWidth(0) # NO (blinking) caret in the output

self.setMinimumHeight(120)

@@ -58,23 +58,10 @@ def __init__(self, parent=None):

self.settings = QgsSettings()

# Enable non-ascii chars for editor
self.setUtf8(True)

self.new_input_line = True

# Set the default font
font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
self.setFont(font)
self.setMarginsFont(font)
# Margin 0 is used for line numbers
self.setMarginWidth(0, 0)
self.setMarginWidth(1, 0)
self.setMarginWidth(2, 0)
self.setMarginsFont(font)
self.setMarginWidth(1, "00000")
self.setMarginType(1, 5)
self.setCaretLineVisible(False)
self.setMarginLineNumbers(0, False) # NO linenumbers for the input line

self.buffer = []

@@ -94,9 +81,6 @@ def __init__(self, parent=None):
# the current position
self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

# Current line visible with special background color
self.setCaretWidth(2)

self.refreshSettingsShell()

# Don't want to see the horizontal scrollbar at all

0 comments on commit 354b959

Please sign in to comment.
You can’t perform that action at this time.