lua: Function returning if the file is modified

This commit is contained in:
arch1t3cht 2022-08-08 00:57:16 +02:00
parent feab1a5663
commit bde149fd30
2 changed files with 17 additions and 1 deletions

View File

@ -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.
---

View File

@ -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<project_properties>(L, "project_properties");
set_field<lua_get_audio_selection>(L, "get_audio_selection");
set_field<lua_set_status_text>(L, "set_status_text");
lua_createtable(L, 0, 4);
lua_createtable(L, 0, 5);
set_field<lua_get_text_cursor>(L, "get_cursor");
set_field<lua_set_text_cursor>(L, "set_cursor");
set_field<lua_get_text_selection>(L, "get_selection");
set_field<lua_set_text_selection>(L, "set_selection");
set_field<lua_is_modified>(L, "is_modified");
lua_setfield(L, -2, "gui");
// store aegisub table to globals