Skip to content
Browse files

indicate incomplete input

  • Loading branch information...
1 parent 8323688 commit 1584e3a97d1247b71603def3ce1a8b7128dd4c65 Thomas Gahr committed Jul 17, 2012
Showing with 12 additions and 12 deletions.
  1. +12 −12 gui/codewidget.cpp
View
24 gui/codewidget.cpp
@@ -62,7 +62,7 @@ CodeWidget::CodeWidget(Qling* qling)
void CodeWidget::processCode(const QString& str)
{
-// static int lastIndent=0;
+ static int lastIndent=0;
QTextCursor cursor=m_codeOutput->textCursor();
//user might've selected some text so clear selection
@@ -73,21 +73,21 @@ void CodeWidget::processCode(const QString& str)
//submit code
//int indent = m_metaProcessor->process(str.toStdString().c_str());
- m_qling->processUserInput(str);
+ int indent=m_qling->processUserInput(str);
-// QTextCharFormat format=cursor.charFormat();
+ QTextCharFormat format=cursor.charFormat();
QString indentString;
-// if(indent > 0){
-// //use yellow background to mark code that is part of incomplete input
-// format.setBackground(Qt::yellow);
-// for(int i=0;i<qMin(lastIndent,indent);++i)
-// indentString+=QString(" ");
-// }else if(lastIndent>0)
-// format.setBackground(palette().base());
-// lastIndent=indent;
+ if(indent > 0){
+ //use yellow background to mark code that is part of incomplete input
+ format.setBackground(Qt::yellow);
+ for(int i=0;i<qMin(lastIndent,indent);++i)
+ indentString+=QString(" ");
+ }else if(lastIndent>0)
+ format.setBackground(palette().base());
+ lastIndent=indent;
- cursor.insertText(indentString+str+QString("\n")/*,format*/);
+ cursor.insertText(indentString+str+QString("\n"),format);
m_codeOutput->verticalScrollBar()->setValue(m_codeOutput->verticalScrollBar()->maximum());
}

0 comments on commit 1584e3a

Please sign in to comment.
Something went wrong with that request. Please try again.