Lua: statusmessage() now clears remainder of line

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1820 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2011-07-16 19:15:08 +00:00
parent 51ddfe4f86
commit f2316f12e2

View File

@ -58,6 +58,7 @@ char * Bound_script[10];
#include <float.h> // for DBL_MAX #include <float.h> // for DBL_MAX
#include <unistd.h> // chdir() #include <unistd.h> // chdir()
#include <limits.h> //for INT_MIN #include <limits.h> //for INT_MIN
#include <string.h> // strncpy()
/// ///
/// Number of characters for name in fileselector. /// Number of characters for name in fileselector.
@ -1261,18 +1262,28 @@ int L_UpdateScreen(lua_State* L)
int L_StatusMessage(lua_State* L) int L_StatusMessage(lua_State* L)
{ {
const char* msg; const char* msg;
char* msg2; char msg2[25];
int nb_args = lua_gettop(L); int len;
LUA_ARG_LIMIT(1,"statusmessage"); int nb_args = lua_gettop(L);
LUA_ARG_LIMIT(1,"statusmessage");
LUA_ARG_STRING(1, "statusmessage", msg); LUA_ARG_STRING(1, "statusmessage", msg);
msg2 = strdup(msg); len=strlen(msg);
if(strlen(msg)>24) if (len<=24)
msg2[24] = 0; // Cut off long messages {
Print_in_menu(msg2,0); strcpy(msg2, msg);
free(msg2); // fill remainder with spaces
return 0; for (;len<24;len++)
msg2[len]=' ';
msg2[24]='\0';
}
else
{
strncpy(msg2, msg, 24);
}
Print_in_menu(msg2,0);
return 0;
} }