diff --git a/src/ScateView.cpp b/src/ScateView.cpp index d2dcc7a..135fe53 100644 --- a/src/ScateView.cpp +++ b/src/ScateView.cpp @@ -34,6 +34,7 @@ #include #include #include +#include using namespace Scate; @@ -158,13 +159,19 @@ QWidget * ScateView::createOutputView() "SC Terminal" ); - scOutView = new QTextEdit; + QFont defaultFont("monospace"); + defaultFont.setStyleHint(QFont::TypeWriter); + + scOutView = new QPlainTextEdit; scOutView->setReadOnly( true ); scOutView->document()->setMaximumBlockCount( config.readEntry( "TerminalMaxRows", 500 ) ); - scOutView->document()->setDefaultFont( config.readEntry( "TerminalFont", QFont() ) ); + scOutView->document()->setDefaultFont( config.readEntry( "TerminalFont", defaultFont ) ); + scOutView->setTabStopWidth(20); connect( plugin, SIGNAL( scSaid( const QString& ) ), this, SLOT( scSaid( const QString& ) ) ); + new PostSyntaxHighlighter(scOutView->document()); + cmdLine = new CmdLine( "Code:", 30 ); connect( cmdLine, SIGNAL( invoked( const QString&, bool ) ), plugin, SLOT( eval( const QString&, bool ) ) ); @@ -277,3 +284,14 @@ void ScateView::writeSessionConfig( KConfigBase* config, const QString& groupPre Q_UNUSED( config ); Q_UNUSED( groupPrefix ); } + +void PostSyntaxHighlighter::highlightBlock ( const QString & text ) +{ + if (text.startsWith("ERROR", Qt::CaseInsensitive)) { + QTextBlock b(currentBlock()); + QTextBlockFormat fm(b.blockFormat()); + fm.setBackground(Qt::red); + QTextCursor c(b); + c.setBlockFormat(fm); + } +} diff --git a/src/ScateView.hpp b/src/ScateView.hpp index 56464c3..61d66c5 100644 --- a/src/ScateView.hpp +++ b/src/ScateView.hpp @@ -28,8 +28,9 @@ #include #include -#include +#include #include +#include class ScatePlugin; class ScateHelpWidget; @@ -61,7 +62,7 @@ class ScateView : public Kate::PluginView, public KXMLGUIClient ScatePlugin *plugin; QWidget *outputToolView; - QTextEdit *scOutView; + QPlainTextEdit *scOutView; Scate::CmdLine *cmdLine; QWidget *helpToolView; @@ -73,4 +74,11 @@ class ScateView : public Kate::PluginView, public KXMLGUIClient QAction *aClearOutput; }; +class PostSyntaxHighlighter : QSyntaxHighlighter +{ +public: + PostSyntaxHighlighter(QTextDocument *doc) : QSyntaxHighlighter(doc) {} + void highlightBlock ( const QString & ); +}; + #endif //SCATE_VIEW_H