summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llfloaterluadebug.cpp41
-rw-r--r--indra/newview/llfloaterluadebug.h2
2 files changed, 36 insertions, 7 deletions
diff --git a/indra/newview/llfloaterluadebug.cpp b/indra/newview/llfloaterluadebug.cpp
index 58639490db..b2c001817f 100644
--- a/indra/newview/llfloaterluadebug.cpp
+++ b/indra/newview/llfloaterluadebug.cpp
@@ -37,6 +37,9 @@
#include "llfloaterimnearbychat.h"
#include "llluamanager.h"
+#include "llsdutil.h"
+#include "lua_function.h"
+#include "stringize.h"
LLFloaterLUADebug::LLFloaterLUADebug(const LLSD &key)
@@ -74,9 +77,9 @@ void LLFloaterLUADebug::onExecuteClicked()
mResultOutput->setValue("");
std::string cmd = mLineInput->getText();
- LLLUAmanager::runScriptLine(cmd, [this](std::string msg)
- {
- mResultOutput->insertText(msg);
+ LLLUAmanager::runScriptLine(cmd, [this](int count, const LLSD& result)
+ {
+ completion(count, result);
});
}
@@ -104,10 +107,34 @@ void LLFloaterLUADebug::runSelectedScript(const std::vector<std::string> &filena
if (!filepath.empty())
{
mScriptPath->setText(filepath);
- LLLUAmanager::runScriptFile(filepath, [this](std::string msg)
- {
- mResultOutput->insertText(msg);
- });
+ LLLUAmanager::runScriptFile(filepath, [this](int count, const LLSD& result)
+ {
+ completion(count, result);
+ });
}
}
+void LLFloaterLUADebug::completion(int count, const LLSD& result)
+{
+ if (count < 0)
+ {
+ // error: show error message
+ mResultOutput->insertText("*** ");
+ mResultOutput->insertText(result.asString());
+ return;
+ }
+ if (count == 1)
+ {
+ // single result
+ mResultOutput->insertText(stringize(result));
+ return;
+ }
+ // 0 or multiple results
+ const char* sep = "";
+ for (const auto& item : llsd::inArray(result))
+ {
+ mResultOutput->insertText(sep);
+ mResultOutput->insertText(stringize(item));
+ sep = ", ";
+ }
+}
diff --git a/indra/newview/llfloaterluadebug.h b/indra/newview/llfloaterluadebug.h
index 1e26828c83..2dc59c5894 100644
--- a/indra/newview/llfloaterluadebug.h
+++ b/indra/newview/llfloaterluadebug.h
@@ -56,6 +56,8 @@ class LLFloaterLUADebug :
void runSelectedScript(const std::vector<std::string> &filenames);
private:
+ void completion(int count, const LLSD& result);
+
LLTempBoundListener mOutConnection;
LLTextEditor* mResultOutput;