diff --git a/automation/v4-docs/gui.txt b/automation/v4-docs/gui.txt index 1ec617805..f913e7040 100644 --- a/automation/v4-docs/gui.txt +++ b/automation/v4-docs/gui.txt @@ -55,3 +55,12 @@ Returns: 0 values --- +Determining whether there are unsaved changes + +function aegisub.gui.is_modified() + +Returns: 1 boolean + 1. Whether the current file has unsaved changes. + +--- + diff --git a/src/auto4_lua.cpp b/src/auto4_lua.cpp index bba6e6aeb..cb51c8e49 100644 --- a/src/auto4_lua.cpp +++ b/src/auto4_lua.cpp @@ -319,6 +319,12 @@ namespace { return 0; } + int lua_is_modified(lua_State *L) + { + push_value(L, get_context(L)->subsController->IsModified()); + return 1; + } + int project_properties(lua_State *L) { const agi::Context *c = get_context(L); @@ -523,11 +529,12 @@ namespace { set_field(L, "project_properties"); set_field(L, "get_audio_selection"); set_field(L, "set_status_text"); - lua_createtable(L, 0, 4); + lua_createtable(L, 0, 5); set_field(L, "get_cursor"); set_field(L, "set_cursor"); set_field(L, "get_selection"); set_field(L, "set_selection"); + set_field(L, "is_modified"); lua_setfield(L, -2, "gui"); // store aegisub table to globals