Skip to content
Permalink
Browse files

Fix duplicate margins show in python console

  • Loading branch information
nyalldawson committed Oct 5, 2020
1 parent 968cecb commit bb8cb8b6b0721cd9021730e1f6100bb5d01e1a8a
Showing with 17 additions and 10 deletions.
  1. +0 −8 python/console/console_base.py
  2. +9 −0 python/console/console_sci.py
  3. +2 −2 src/gui/qgscodeeditor.cpp
  4. +6 −0 src/gui/qgscodeeditorpython.cpp
@@ -32,14 +32,6 @@ class QgsPythonConsoleBase(QgsCodeEditorPython):
def __init__(self, parent=None):
super().__init__(parent)

# 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")

def setLexers(self):
self.api = QsciAPIs(self.lexer())
checkBoxAPI = self.settings.value("pythonConsole/preloadAPI", True, type=bool)
@@ -135,6 +135,15 @@ def refreshSettingsShell(self):

self.setCaretLineVisible(False)
self.setMarginLineNumbers(0, False) # NO linenumbers for the input line
self.setMarginWidth(0, 0)
# margin 2 is the folding
self.setMarginWidth(2, 0)
# Margin 1 is used for the '>>>' prompt (console input)
self.setMarginLineNumbers(1, True)
self.setMarginWidth(1, "00000")
self.setMarginType(1, 5) # TextMarginRightJustified=5
self.setFoldMarginColors(self.color(QgsCodeEditor.ColorRole.Background),
self.color(QgsCodeEditor.ColorRole.Background))

def showHistory(self):
if not self.historyDlg.isVisible():
@@ -237,9 +237,9 @@ void QgsCodeEditor::setMarginVisible( bool margin )
{
QFont marginFont = lexerFont();
marginFont.setPointSize( 10 );
setMarginLineNumbers( 1, true );
setMarginLineNumbers( 0, true );
setMarginsFont( marginFont );
setMarginWidth( 1, QStringLiteral( "00000" ) );
setMarginWidth( 0, QStringLiteral( "00000" ) );
setMarginsForegroundColor( lexerColor( ColorRole::MarginForeground ) );
setMarginsBackgroundColor( lexerColor( ColorRole::MarginBackground ) );
}
@@ -130,6 +130,12 @@ void QgsCodeEditorPython::initializeLexer()
setLexer( pyLexer );

setMarginVisible( true );

// Margin 2 is used for the 'folding'
setMarginWidth( 2, "0" );
setMarginsForegroundColor( lexerColor( ColorRole::MarginForeground ) );
setMarginsBackgroundColor( lexerColor( ColorRole::MarginBackground ) );

setFoldingVisible( true );
setIndentationsUseTabs( false );
setIndentationGuides( true );

0 comments on commit bb8cb8b

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