Skip to content

Commit

Permalink
Some more code to base class
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 16, 2022
1 parent b5f8f97 commit 0636d84
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 54 deletions.
12 changes: 0 additions & 12 deletions python/console/console_sci.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,6 @@ def __init__(self, parent=None):
self.sessionHistoryCleared.connect(self.on_session_history_cleared)
self.persistentHistoryCleared.connect(self.on_persistent_history_cleared)

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)
Expand Down
24 changes: 1 addition & 23 deletions src/app/rstats/qgsrstatsconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ QgsRStatsConsole::QgsRStatsConsole( QWidget *parent, QgsRStatsRunner *runner )

mOutput = new QgsCodeEditorR( nullptr, QgsCodeEditor::Mode::OutputDisplay );
splitter->addWidget( mOutput );
mInputEdit = new QgsInteractiveRWidget();
mInputEdit = new QgsCodeEditorR( nullptr, QgsCodeEditor::Mode::CommandInput );
mInputEdit->setInterpreter( mRunner );
mInputEdit->setHistoryFilePath( QgsApplication::qgisSettingsDirPath() + QStringLiteral( "/r_console_history.txt" ) );

Expand Down Expand Up @@ -104,25 +104,3 @@ QgsRStatsConsole::~QgsRStatsConsole()

delete mDockableWidgetHelper;
}

QgsInteractiveRWidget::QgsInteractiveRWidget( QWidget *parent )
: QgsCodeEditorR( parent, QgsCodeEditor::Mode::CommandInput )
{
QgsInteractiveRWidget::initializeLexer();

QgsInteractiveRWidget::updatePrompt();
}

void QgsInteractiveRWidget::initializeLexer()
{
QgsCodeEditorR::initializeLexer();

setCaretLineVisible( false );
setLineNumbersVisible( false ); // NO linenumbers for the input line
// Margin 1 is used for the '>' prompt (console input)
setMarginLineNumbers( 1, true );
setMarginWidth( 1, "00" );
setMarginType( 1, QsciScintilla::MarginType::TextMarginRightJustified );
setMarginsBackgroundColor( color( QgsCodeEditorColorScheme::ColorRole::Background ) );
setEdgeMode( QsciScintilla::EdgeNone );
}
20 changes: 1 addition & 19 deletions src/app/rstats/qgsrstatsconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,6 @@ class QTextBrowser;
class QgsDockableWidgetHelper;


class QgsInteractiveRWidget : public QgsCodeEditorR
{
Q_OBJECT
public:

QgsInteractiveRWidget( QWidget *parent = nullptr );

protected:

void initializeLexer() override;

private:

bool mMore = false;



};

class QgsRStatsConsole: public QWidget
{
Expand All @@ -55,7 +37,7 @@ class QgsRStatsConsole: public QWidget
private:

QgsRStatsRunner *mRunner = nullptr;
QgsInteractiveRWidget *mInputEdit = nullptr;
QgsCodeEditorR *mInputEdit = nullptr;
QgsCodeEditorR *mOutput = nullptr;
QgsDockableWidgetHelper *mDockableWidgetHelper = nullptr;

Expand Down
12 changes: 12 additions & 0 deletions src/gui/codeeditors/qgscodeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,18 @@ void QgsCodeEditor::runPostLexerConfigurationTasks()
SendScintilla( SCI_MARKERSETBACK, SC_MARKNUM_FOLDER, lexerColor( QgsCodeEditorColorScheme::ColorRole::FoldIconForeground ) );
SendScintilla( SCI_STYLESETFORE, STYLE_INDENTGUIDE, lexerColor( QgsCodeEditorColorScheme::ColorRole::IndentationGuide ) );
SendScintilla( SCI_STYLESETBACK, STYLE_INDENTGUIDE, lexerColor( QgsCodeEditorColorScheme::ColorRole::IndentationGuide ) );

if ( mMode == QgsCodeEditor::Mode::CommandInput )
{
setCaretLineVisible( false );
setLineNumbersVisible( false ); // NO linenumbers for the input line
// Margin 1 is used for the '>' prompt (console input)
setMarginLineNumbers( 1, true );
setMarginWidth( 1, "00000" );
setMarginType( 1, QsciScintilla::MarginType::TextMarginRightJustified );
setMarginsBackgroundColor( color( QgsCodeEditorColorScheme::ColorRole::Background ) );
setEdgeMode( QsciScintilla::EdgeNone );
}
}

void QgsCodeEditor::setSciWidget()
Expand Down

0 comments on commit 0636d84

Please sign in to comment.