From d660f7f2b023a71e90df27f1c51ba009a2d30301 Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Sun, 25 Mar 2018 07:50:05 -0400 Subject: [PATCH] Add support for setting status bar text from Lua --- automation/v4-docs/misc.txt | 8 ++++++++ src/auto4_lua.cpp | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/automation/v4-docs/misc.txt b/automation/v4-docs/misc.txt index 9c656f0e4..5b96d3519 100644 --- a/automation/v4-docs/misc.txt +++ b/automation/v4-docs/misc.txt @@ -40,3 +40,11 @@ Returns: 2 values, all numbers. 2. End of the selection, in milliseconds. --- + +Setting the main frame's status bar text + +function aegisub.set_status_bar_text(text) + +Returns: 0 values + +--- diff --git a/src/auto4_lua.cpp b/src/auto4_lua.cpp index b952b2e7c..6c131902e 100644 --- a/src/auto4_lua.cpp +++ b/src/auto4_lua.cpp @@ -44,6 +44,7 @@ #include "audio_timing.h" #include "command/command.h" #include "compat.h" +#include "frame_main.h" #include "include/aegisub/context.h" #include "options.h" #include "project.h" @@ -52,6 +53,7 @@ #include "video_controller.h" #include "utils.h" +#include #include #include #include @@ -270,6 +272,19 @@ namespace { return 2; } + int lua_set_status_text(lua_State *L) + { + const agi::Context *c = get_context(L); + if (!c || !c->frame) { + lua_pushnil(L); + return 1; + } + std::string text = check_string(L, 1); + lua_pop(L, 1); + agi::dispatch::Main().Async([=] { c->frame->StatusTimeout(to_wx(text)); }); + return 0; + } + int project_properties(lua_State *L) { const agi::Context *c = get_context(L); @@ -473,6 +488,7 @@ namespace { set_field(L, "gettext"); set_field(L, "project_properties"); set_field(L, "get_audio_selection"); + set_field(L, "set_status_text"); // store aegisub table to globals lua_settable(L, LUA_GLOBALSINDEX);