1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-14 11:59:50 +03:00

Allow longer toolsname on wide screens (#6805)

This commit is contained in:
3djc 2019-09-18 17:55:51 +02:00 committed by Bertrand Songis
parent a7bec62dcf
commit c60d3858d2
4 changed files with 11 additions and 8 deletions

View file

@ -49,7 +49,7 @@ void addRadioModuleTool(uint8_t index, const char * label, bool (* tool)(event_t
#if defined(LUA) #if defined(LUA)
void addRadioScriptTool(uint8_t index, const char * path) void addRadioScriptTool(uint8_t index, const char * path)
{ {
char toolName[TOOL_NAME_MAXLEN + 1]; char toolName[RADIO_TOOL_NAME_MAXLEN + 1];
const char * label; const char * label;
char * ext = (char *)getFileExtension(path); char * ext = (char *)getFileExtension(path);
if (readToolName(toolName, path)) { if (readToolName(toolName, path)) {

View file

@ -46,15 +46,13 @@ void addRadioModuleTool(uint8_t index, const char * label, void (* tool)(event_t
} }
} }
#define TOOL_NAME_MAXLEN 16
#if defined(LUA) #if defined(LUA)
void addRadioScriptTool(uint8_t index, const char * path) void addRadioScriptTool(uint8_t index, const char * path)
{ {
char toolName[TOOL_NAME_MAXLEN + 1]; char toolName[RADIO_TOOL_NAME_MAXLEN + 1];
if (!readToolName(toolName, path)) { if (!readToolName(toolName, path)) {
strAppendFilename(toolName, getBasename(path), TOOL_NAME_MAXLEN); strAppendFilename(toolName, getBasename(path), RADIO_TOOL_NAME_MAXLEN);
} }
if (addRadioTool(index, toolName)) { if (addRadioTool(index, toolName)) {

View file

@ -1150,11 +1150,11 @@ bool readToolName(char * toolName, const char * filename)
return false; return false;
uint8_t len = end - start; uint8_t len = end - start;
if (len > TOOL_NAME_MAXLEN) if (len > RADIO_TOOL_NAME_MAXLEN)
return false; return false;
strncpy(toolName, start, len); strncpy(toolName, start, len);
memclear(toolName + len, TOOL_NAME_MAXLEN + 1 - len); memclear(toolName + len, RADIO_TOOL_NAME_MAXLEN + 1 - len);
return true; return true;
} }

View file

@ -171,7 +171,12 @@ void registerBitmapClass(lua_State * L);
void luaSetInstructionsLimit(lua_State* L, int count); void luaSetInstructionsLimit(lua_State* L, int count);
int luaLoadScriptFileToState(lua_State * L, const char * filename, const char * mode); int luaLoadScriptFileToState(lua_State * L, const char * filename, const char * mode);
#define TOOL_NAME_MAXLEN 16 #if LCD_W > 350
#define RADIO_TOOL_NAME_MAXLEN 40
#else
#define RADIO_TOOL_NAME_MAXLEN 16
#endif
bool readToolName(char * toolName, const char * filename); bool readToolName(char * toolName, const char * filename);
bool isRadioScriptTool(const char * filename); bool isRadioScriptTool(const char * filename);