diff options
author | nat-goodspeed <nat@lindenlab.com> | 2024-02-15 11:47:16 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-15 11:47:16 -0500 |
commit | de72b1d573897c24e307f63b071fd5f02ce851c1 (patch) | |
tree | 270b33a014a7b138f4ab35b2176038309ed4f0f7 /indra/newview | |
parent | 9b1796df73f2d4fa19517f390258f798c10bff1e (diff) | |
parent | d583fb8badd8060c0f74bcb6e99bb6e7d08a67d0 (diff) |
Merge pull request #798 from secondlife/helpcmd
Add help() function to Lua "builtins."
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloaterluadebug.cpp | 8 | ||||
-rw-r--r-- | indra/newview/llluamanager.cpp | 29 |
2 files changed, 5 insertions, 32 deletions
diff --git a/indra/newview/llfloaterluadebug.cpp b/indra/newview/llfloaterluadebug.cpp index 7d56d8e618..3ebe40f80b 100644 --- a/indra/newview/llfloaterluadebug.cpp +++ b/indra/newview/llfloaterluadebug.cpp @@ -57,7 +57,7 @@ BOOL LLFloaterLUADebug::postBuild() .listen("LLFloaterLUADebug", [mResultOutput=mResultOutput](const LLSD& data) { - mResultOutput->insertText(data.asString()); + mResultOutput->pasteTextWithLinebreaks(data.asString()); mResultOutput->addLineBreakChar(true); return false; }); @@ -122,13 +122,13 @@ void LLFloaterLUADebug::completion(int count, const LLSD& result) { // error: show error message mResultOutput->insertText("*** "); - mResultOutput->insertText(result.asString()); + mResultOutput->pasteTextWithLinebreaks(result.asString()); return; } if (count == 1) { // single result - mResultOutput->insertText(stringize(result)); + mResultOutput->pasteTextWithLinebreaks(stringize(result)); return; } // 0 or multiple results @@ -136,7 +136,7 @@ void LLFloaterLUADebug::completion(int count, const LLSD& result) for (const auto& item : llsd::inArray(result)) { mResultOutput->insertText(sep); - mResultOutput->insertText(stringize(item)); + mResultOutput->pasteTextWithLinebreaks(stringize(item)); sep = ", "; } } diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp index d58ee5ca5f..c6a900aa81 100644 --- a/indra/newview/llluamanager.cpp +++ b/indra/newview/llluamanager.cpp @@ -197,34 +197,7 @@ lua_function(listen_events, // back to the main thread from a coroutine thread? lua_State* mainthread{ L }; - luaL_checkstack(mainthread, 1, nullptr); - LuaListener::ptr_t listener; - // Does the main thread already have a LuaListener stored in the registry? - // That is, has this Lua chunk already called listen_events()? - auto keytype{ lua_getfield(mainthread, LUA_REGISTRYINDEX, "event.listener") }; - llassert(keytype == LUA_TNIL || keytype == LUA_TNUMBER); - if (keytype == LUA_TNUMBER) - { - // We do already have a LuaListener. Retrieve it. - int isint; - listener = LuaListener::getInstance(lua_tointegerx(mainthread, -1, &isint)); - // pop the int "event.listener" key - lua_pop(mainthread, 1); - // Nobody should have destroyed this LuaListener instance! - llassert(isint && listener); - } - else - { - // pop the nil "event.listener" key - lua_pop(mainthread, 1); - // instantiate a new LuaListener, binding the mainthread state -- but - // use a no-op deleter: we do NOT want to delete this new LuaListener - // on return from listen_events()! - listener.reset(new LuaListener(mainthread), [](LuaListener*){}); - // set its key in the field where we'll look for it later - lua_pushinteger(mainthread, listener->getKey()); - lua_setfield(mainthread, LUA_REGISTRYINDEX, "event.listener"); - } + auto listener{ LuaState::obtainListener(mainthread) }; // Now that we've found or created our LuaListener, store the passed Lua // function as the callback. Beware: our caller passed the function on L's |