diff options
| author | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-12-28 12:30:48 +0100 | 
|---|---|---|
| committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-12-28 12:30:48 +0100 | 
| commit | 16beb55484c20b8b1e92afdf5720fa3860d77309 (patch) | |
| tree | ffb199f4c77247f1abef8091a5fc4ad459ecb224 /src | |
| parent | 0ee75305070f79b12cbfa5a31b17c543d0517428 (diff) | |
Show error line in red in the editor.
Diffstat (limited to 'src')
| -rw-r--r-- | src/codeeditor.cc | 14 | ||||
| -rw-r--r-- | src/codeeditor.h | 2 | ||||
| -rw-r--r-- | src/luascript.cc | 5 | ||||
| -rw-r--r-- | src/luascript.h | 1 | ||||
| -rw-r--r-- | src/mainwindow.cc | 2 | 
5 files changed, 24 insertions, 0 deletions
| diff --git a/src/codeeditor.cc b/src/codeeditor.cc index d639953..6d2dd2e 100644 --- a/src/codeeditor.cc +++ b/src/codeeditor.cc @@ -129,6 +129,16 @@ void CodeEditor::highlightCurrentLine()  void CodeEditor::runningLine(int lineno)  {  	lineNumber = lineno; +	errorLineNumber = 0; // no error +	repaint(); +} + +void CodeEditor::errorLine(QString file, int lineno, QString msg) +{ +	(void)file; +	(void)msg; +	lineNumber = 0; +	errorLineNumber = lineno;  	repaint();  } @@ -152,6 +162,10 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)  			{  				painter.setPen(Qt::green);  			} +			else if(blockNumber + 1 == errorLineNumber) +			{ +				painter.setPen(Qt::red); +			}  			else  			{  				painter.setPen(Qt::black); diff --git a/src/codeeditor.h b/src/codeeditor.h index a470a52..f25cdbf 100644 --- a/src/codeeditor.h +++ b/src/codeeditor.h @@ -67,6 +67,7 @@ protected:  public slots:  	void runningLine(int lineno); +	void errorLine(QString file, int lineno, QString msg);  private slots:  	void updateLineNumberAreaWidth(int newBlockCount); @@ -76,6 +77,7 @@ private slots:  private:  	QWidget *lineNumberArea;  	int lineNumber; +	int errorLineNumber{0};  };  class LineNumberArea diff --git a/src/luascript.cc b/src/luascript.cc index dce5e2c..0619228 100644 --- a/src/luascript.cc +++ b/src/luascript.cc @@ -448,6 +448,11 @@ void LUAScript::run()  	catch(Exception &e)  	{  		printf("LUA Error: %s\n", e.msg.c_str()); +		QStringList pieces = QString(e.msg.c_str()).split(":"); +		if(pieces.size() >= 3) +		{ +			emit errorLine(pieces[0], pieces[1].toUInt(), pieces[2]); +		}  	}  	cleanup();  	lua_stopped = true; diff --git a/src/luascript.h b/src/luascript.h index b88e023..ab89a60 100644 --- a/src/luascript.h +++ b/src/luascript.h @@ -78,6 +78,7 @@ public slots:  signals:  	void reset();  	void lineChanged(int lineno); +	void errorLine(QString file, int lineno, QString error);  protected:  	lua_State *L; diff --git a/src/mainwindow.cc b/src/mainwindow.cc index cfaece1..7e08c46 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -61,6 +61,8 @@ MainWindow::MainWindow(QString p)  	l = new LUAScript(*out);  	connect(l, SIGNAL(lineChanged(int)), editor, SLOT(runningLine(int))); +	connect(l, SIGNAL(errorLine(QString, int, QString)), +	        editor, SLOT(errorLine(QString, int, QString)));  	// Setup menu  	QMenu* fileMenu = menuBar()->addMenu(tr("&File")); | 
