void printCall(QScriptContext *context, ActionTools::ConsoleWidget::Type type) { QApplication::processEvents();//Call this to prevent UI freeze when calling print often QScriptValue calleeData = context->callee().data(); Executer *executer = qobject_cast<Executer *>(calleeData.toQObject()); QString message; ScriptAgent *agent = executer->scriptAgent(); if(!agent) return; for(int argumentIndex = 0; argumentIndex < context->argumentCount(); ++argumentIndex) message += context->argument(argumentIndex).toString(); switch(executer->scriptAgent()->context()) { case ScriptAgent::Parameters: executer->consoleWidget()->addScriptParameterLine(message, agent->currentParameter(), agent->currentLine(), agent->currentColumn(), type); break; case ScriptAgent::Actions: { ActionTools::ActionInstance *currentAction = executer->script()->actionAt(executer->currentActionIndex()); qint64 currentActionRuntimeId = -1; if(currentAction) currentActionRuntimeId = currentAction->runtimeId(); executer->consoleWidget()->addUserLine(message, currentActionRuntimeId, context->engine()->globalObject().property("currentParameter").toString(), context->engine()->globalObject().property("currentSubParameter").toString(), agent->currentLine(), agent->currentColumn(), context->backtrace(), type); } break; default: return; } }
QScriptValue clearConsoleFunction(QScriptContext *context, QScriptEngine *engine) { if(!Executer::isExecuterRunning()) return QScriptValue(); QApplication::processEvents();//Call this to prevent UI freeze when calling clear often QScriptValue calleeData = context->callee().data(); Executer *executer = qobject_cast<Executer *>(calleeData.toQObject()); executer->consoleWidget()->clearExceptSeparators(); return engine->undefinedValue(); }