]> git.sesse.net Git - nageru/blobdiff - nageru/theme.cpp
Make it possible for the theme to override the status line.
[nageru] / nageru / theme.cpp
index c6cf4515805ad83be506f783d26df92b30ebc103..9506294dcea2c11c3d5367a1bed4bd3c7fba45fc 100644 (file)
@@ -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<mutex> 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;
+}