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:
parent
51ddfe4f86
commit
f2316f12e2
@ -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.
|
||||||
@ -1262,16 +1263,26 @@ 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 len;
|
||||||
int nb_args = lua_gettop(L);
|
int nb_args = lua_gettop(L);
|
||||||
LUA_ARG_LIMIT(1,"statusmessage");
|
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
|
{
|
||||||
|
strcpy(msg2, msg);
|
||||||
|
// fill remainder with spaces
|
||||||
|
for (;len<24;len++)
|
||||||
|
msg2[len]=' ';
|
||||||
|
msg2[24]='\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strncpy(msg2, msg, 24);
|
||||||
|
}
|
||||||
Print_in_menu(msg2,0);
|
Print_in_menu(msg2,0);
|
||||||
free(msg2);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user