Skip to content
Permalink
Browse files

Cleanup raw margin manipulation used to hide holding controls, use pr…

…oper methods
  • Loading branch information
nyalldawson committed Oct 13, 2020
1 parent 66226f6 commit 8d3e028d152f0142e3d36493b5b59d84b5a78253
@@ -149,16 +149,18 @@ def insertInitText(self):
else:
self.setText(txtInit + '\n')

def initializeLexer(self):
super().initializeLexer()
self.setFoldingVisible(False)
self.setEdgeMode(QsciScintilla.EdgeNone)

def refreshSettingsOutput(self):
# Set Python lexer
self.initializeLexer()
self.setReadOnly(True)

self.setCaretWidth(0) # NO (blinking) caret in the output

self.setFoldingVisible(False)
self.setEdgeMode(QsciScintilla.EdgeNone)

def clearConsole(self):
self.setText('')
self.insertInitText()
@@ -107,6 +107,18 @@ def __init__(self, parent=None):
self.newShortcutCAS.activated.connect(self.autoComplete)
self.newShortcutCSS.activated.connect(self.showHistory)

def initializeLexer(self):
super().initializeLexer()
self.setCaretLineVisible(False)
self.setLineNumbersVisible(False) # NO linenumbers for the input line
self.setFoldingVisible(False)
# Margin 1 is used for the '>>>' prompt (console input)
self.setMarginLineNumbers(1, True)
self.setMarginWidth(1, "00000")
self.setMarginType(1, 5) # TextMarginRightJustified=5
self.setMarginsBackgroundColor(self.color(QgsCodeEditorColorScheme.ColorRole.Background))
self.setEdgeMode(QsciScintilla.EdgeNone)

def _setMinimumHeight(self):
font = self.lexer().defaultFont(0)
fm = QFontMetrics(font)
@@ -120,17 +132,6 @@ def refreshSettingsShell(self):
# Sets minimum height for input area based of font metric
self._setMinimumHeight()

self.setCaretLineVisible(False)
self.setLineNumbersVisible(False) # NO linenumbers for the input line
self.setMarginWidth(QgsCodeEditor.FoldingControls, 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.setMarginsBackgroundColor(self.color(QgsCodeEditorColorScheme.ColorRole.Background))
self.setFoldingVisible(False)
self.setEdgeMode(QsciScintilla.EdgeNone)

def showHistory(self):
if not self.historyDlg.isVisible():
self.historyDlg.show()
@@ -96,11 +96,17 @@ Returns whether line numbers are visible in the editor.

void setFoldingVisible( bool folding );
%Docstring
Set folding visible state
Set whether the folding controls are visible in the editor.

:param folding: Set folding in the editor
.. seealso:: :py:func:`foldingVisible`
%End

bool foldingVisible();
%Docstring
Returns ``True`` if the folding controls are visible in the editor.

.. seealso:: :py:func:`setFoldingVisible`
%End

void insertText( const QString &text );
%Docstring
@@ -230,9 +230,9 @@ void QgsCodeEditor::setSciWidget()
setMatchedBraceBackgroundColor( lexerColor( QgsCodeEditorColorScheme::ColorRole::MatchedBraceBackground ) );

setLineNumbersVisible( false );
setFoldingVisible( false );

setMarginWidth( QgsCodeEditor::MarginRole::ErrorIndicators, 0 );
setMarginWidth( QgsCodeEditor::MarginRole::FoldingControls, 0 );

setMarginsForegroundColor( lexerColor( QgsCodeEditorColorScheme::ColorRole::MarginForeground ) );
setMarginsBackgroundColor( lexerColor( QgsCodeEditorColorScheme::ColorRole::MarginBackground ) );
@@ -311,11 +311,15 @@ void QgsCodeEditor::setFoldingVisible( bool folding )
mFolding = folding;
if ( folding )
{
setMarginWidth( QgsCodeEditor::MarginRole::FoldingControls, "0" );
setMarginsForegroundColor( lexerColor( QgsCodeEditorColorScheme::ColorRole::MarginForeground ) );
setMarginsBackgroundColor( lexerColor( QgsCodeEditorColorScheme::ColorRole::MarginBackground ) );
setFolding( QsciScintilla::PlainFoldStyle );
}
else
{
setFolding( QsciScintilla::NoFoldStyle );
setMarginWidth( QgsCodeEditor::MarginRole::FoldingControls, 0 );
}
}

@@ -107,10 +107,15 @@ class GUI_EXPORT QgsCodeEditor : public QsciScintilla
bool lineNumbersVisible() const;

/**
* Set folding visible state
* \param folding Set folding in the editor
* Set whether the folding controls are visible in the editor.
* \see foldingVisible()
*/
void setFoldingVisible( bool folding );

/**
* Returns TRUE if the folding controls are visible in the editor.
* \see setFoldingVisible()
*/
bool foldingVisible() { return mFolding; }

/**
@@ -169,12 +169,6 @@ void QgsCodeEditorPython::initializeLexer()
}

setLineNumbersVisible( true );

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

setFoldingVisible( true );
setIndentationsUseTabs( false );
setIndentationGuides( true );
@@ -203,7 +203,7 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )

setExpectedOutputFormat( QString() );
mFunctionBuilderHelp->setLineNumbersVisible( false );
mFunctionBuilderHelp->setMarginWidth( QgsCodeEditor::MarginRole::FoldingControls, 0 );
mFunctionBuilderHelp->setFoldingVisible( false );
mFunctionBuilderHelp->setEdgeMode( QsciScintilla::EdgeNone );
mFunctionBuilderHelp->setEdgeColumn( 0 );
mFunctionBuilderHelp->setReadOnly( true );

0 comments on commit 8d3e028

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