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 24, 2022
1 parent 06c20f9 commit 24b777c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
27 changes: 1 addition & 26 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 @@ -105,28 +105,3 @@ QgsRStatsConsole::~QgsRStatsConsole()
delete mDockableWidgetHelper;
}

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

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 );
}

void QgsInteractiveRWidget::displayPrompt( bool more )
{
const QString prompt = !more ? ">" : "+";
SendScintilla( QsciScintilla::SCI_MARGINSETTEXT, static_cast< uintptr_t >( 0 ), prompt.toUtf8().constData() );
}
18 changes: 1 addition & 17 deletions src/app/rstats/qgsrstatsconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,6 @@ class QLineEdit;
class QTextBrowser;
class QgsDockableWidgetHelper;

class QgsInteractiveRWidget : public QgsCodeEditorR
{
Q_OBJECT
public:

QgsInteractiveRWidget( QWidget *parent = nullptr );


protected:

void keyPressEvent( QKeyEvent *event ) override;

void initializeLexer() override;

};

class QgsRStatsConsole: public QWidget
{
public:
Expand All @@ -51,7 +35,7 @@ class QgsRStatsConsole: public QWidget
private:

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

Expand Down

0 comments on commit 24b777c

Please sign in to comment.