X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Ftheme.cpp;h=9506294dcea2c11c3d5367a1bed4bd3c7fba45fc;hb=948d715655a84b93d8292e64731ea3c32b45deb7;hp=c6cf4515805ad83be506f783d26df92b30ebc103;hpb=db2997d7290315086635ec914137b80f855cee37;p=nageru diff --git a/nageru/theme.cpp b/nageru/theme.cpp index c6cf451..9506294 100644 --- a/nageru/theme.cpp +++ b/nageru/theme.cpp @@ -1878,3 +1878,24 @@ void Theme::theme_menu_entry_clicked(int lua_ref) abort(); } } + +string Theme::format_status_line(const string &disk_space_left_text, double file_length_seconds) +{ + lock_guard lock(m); + lua_getglobal(L, "format_status_line"); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); + return disk_space_left_text; + } + + lua_pushstring(L, disk_space_left_text.c_str()); + lua_pushnumber(L, file_length_seconds); + if (lua_pcall(L, 2, 1, 0) != 0) { + fprintf(stderr, "error running function format_status_line(): %s\n", lua_tostring(L, -1)); + abort(); + } + string text = checkstdstring(L, 1); + lua_pop(L, 1); + assert(lua_gettop(L) == 0); + return text; +}