Get color from term.errorColor.
@@ -188,6 +188,19 @@ int premake_init(lua_State* L)
}
+static int getErrorColor(lua_State* L)
+{
+ int color;
+
+ lua_getglobal(L, "term");
+ lua_pushstring(L, "errorColor");
+ lua_gettable(L, -2);
+ color = luaL_checkinteger(L, -1);
+ lua_pop(L, 2);
+
+ return color;
+}
+
int premake_execute(lua_State* L, int argc, const char** argv, const char* script)
{
@@ -210,7 +223,7 @@ int premake_execute(lua_State* L, int argc, const char** argv, const char* scrip
/* Find and run the main Premake bootstrapping script */
if (run_premake_main(L, script) != OKAY) {
int color = term_doGetTextColor();
- term_dosetTextColor(12);
+ term_dosetTextColor(getErrorColor(L));
printf(ERROR_MESSAGE, lua_tostring(L, -1));
term_dosetTextColor(color);
return !OKAY;
@@ -229,7 +242,7 @@ int premake_execute(lua_State* L, int argc, const char** argv, const char* scrip
lua_getglobal(L, "_premake_main");
if (lua_pcall(L, 0, 1, iErrFunc) != OKAY) {
int color = term_doGetTextColor();
- term_dosetTextColor(12);
+ term_dosetTextColor(getErrorColor(L));
printf(ERROR_MESSAGE, lua_tostring(L, -1));
term_dosetTextColor(color);
return !OKAY;
