mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
- Script: Fixed that Unicode characters were not correctly displayed
- About Log: 20 last log items are now displayed on launch - LOG_DEBUG messages are ignored from plugins only when not in Debug mode
This commit is contained in:
@ -78,7 +78,7 @@ void LuaManager::ReportErrors(lua_State* L)
|
||||
}
|
||||
|
||||
std::wstring str = L"Script: ";
|
||||
str += ConvertToWide(error.c_str());
|
||||
str += ConvertUTF8ToWide(error.c_str());
|
||||
Log(LOG_ERROR, str.c_str());
|
||||
}
|
||||
|
||||
@ -100,9 +100,19 @@ void LuaManager::LuaLog(int nLevel, const char* format, ... )
|
||||
|
||||
_set_invalid_parameter_handler(oldHandler);
|
||||
|
||||
std::wstring str = ConvertToWide(buffer);
|
||||
std::wstring str = ConvertUTF8ToWide(buffer);
|
||||
Log(nLevel, str.c_str());
|
||||
va_end(args);
|
||||
|
||||
delete [] buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void LuaManager::PushWide(lua_State* L, const WCHAR* str)
|
||||
{
|
||||
lua_pushstring(L, ConvertToUTF8(str).c_str());
|
||||
}
|
||||
|
||||
std::wstring LuaManager::ToWide(lua_State* L, int narg)
|
||||
{
|
||||
return ConvertUTF8ToWide(lua_tostring(L, narg));
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "lua.hpp"
|
||||
#include "tolua++.h"
|
||||
#include "LuaPush.h"
|
||||
|
||||
class LuaManager
|
||||
{
|
||||
@ -32,6 +31,9 @@ public:
|
||||
static void ReportErrors(lua_State* L);
|
||||
static void LuaLog(int nLevel, const char* format, ... );
|
||||
|
||||
static void PushWide(lua_State* L, const WCHAR* str);
|
||||
static std::wstring ToWide(lua_State* L, int narg);
|
||||
|
||||
protected:
|
||||
static int c_RefCount;
|
||||
static lua_State* c_State;
|
||||
|
@ -1,50 +0,0 @@
|
||||
#include "../StdAfx.h"
|
||||
#include "LuaPush.h"
|
||||
|
||||
#include "../Litestep.h"
|
||||
|
||||
void push_wstring(lua_State* L, const std::wstring& value)
|
||||
{
|
||||
push_wchar(L, value.c_str());
|
||||
}
|
||||
|
||||
void push_wchar(lua_State* L, const WCHAR* value)
|
||||
{
|
||||
std::string str = ConvertToAscii(value);
|
||||
lua_pushstring(L, str.c_str());
|
||||
}
|
||||
|
||||
std::wstring to_wstring(lua_State* L, int arg, void* type)
|
||||
{
|
||||
return ConvertToWide(lua_tostring(L,arg));
|
||||
}
|
||||
|
||||
const WCHAR* to_wchar(lua_State* L, int arg, void* type)
|
||||
{
|
||||
// We have a static wstring here so we can keep a copy of the string
|
||||
// passed in alive while its being passed around.
|
||||
// This isn't exactly safe, but we shouldn't really have to worry as
|
||||
// Rainmeter isn't threaded.
|
||||
static std::wstring str;
|
||||
str = ConvertToWide(lua_tostring(L,arg));
|
||||
|
||||
return str.c_str();
|
||||
}
|
||||
|
||||
int is_wstring(lua_State* L, int lo, const char* type, int def, tolua_Error* err)
|
||||
{
|
||||
return is_wchar(L,lo,type,def,err);
|
||||
}
|
||||
|
||||
int is_wchar(lua_State* L, int lo, const char* type, int def, tolua_Error* err)
|
||||
{
|
||||
if (def && lua_gettop(L)<abs(lo))
|
||||
return 1;
|
||||
if (lua_isnil(L,lo) || lua_isstring(L,lo))
|
||||
return 1;
|
||||
|
||||
err->index = lo;
|
||||
err->array = 0;
|
||||
err->type = type;
|
||||
return 0;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#ifndef __LUAPUSH_H__
|
||||
#define __LUAPUSH_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#include "lua.hpp"
|
||||
#include "tolua++.h"
|
||||
|
||||
std::wstring to_wstring(lua_State* L, int arg, void* type);
|
||||
void push_wstring(lua_State* L, const std::wstring& value);
|
||||
int is_wstring(lua_State* L, int lo, const char* type, int def, tolua_Error* err);
|
||||
|
||||
void push_wchar(lua_State* L, const WCHAR* value);
|
||||
const WCHAR* to_wchar(lua_State* L, int arg, void* type);
|
||||
int is_wchar(lua_State* L, int lo, const char* type, int def, tolua_Error* err);
|
||||
|
||||
#endif
|
@ -176,7 +176,7 @@ int LuaScript::RunFunctionWithReturn(const char* funcName, double& numValue, std
|
||||
else if (type == LUA_TSTRING)
|
||||
{
|
||||
const char* str = lua_tostring(m_State, -1);
|
||||
strValue = ConvertToWide(str);
|
||||
strValue = ConvertUTF8ToWide(str);
|
||||
numValue = strtod(str, NULL);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ static int Measure_GetName(lua_State* L)
|
||||
{
|
||||
CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0);
|
||||
const WCHAR* val = (const WCHAR*)self->GetName();
|
||||
push_wchar(L, val);
|
||||
LuaManager::PushWide(L, val);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -18,8 +18,7 @@ static int Measure_GetOption(lua_State* L)
|
||||
CMeterWindow* meterWindow = self->GetMeterWindow();
|
||||
CConfigParser& parser = meterWindow->GetParser();
|
||||
|
||||
const char* arg = (const char*)tolua_tostring(L, 2, 0);
|
||||
std::wstring strTmp = ConvertToWide(arg);
|
||||
std::wstring strTmp = LuaManager::ToWide(L, 2);
|
||||
strTmp = parser.GetValue(self->GetName(), strTmp, L"");
|
||||
|
||||
parser.SetBuiltInVariable(L"CURRENTSECTION", self->GetName()); // Set temporarily
|
||||
@ -27,7 +26,7 @@ static int Measure_GetOption(lua_State* L)
|
||||
parser.SetBuiltInVariable(L"CURRENTSECTION", L""); // Reset
|
||||
parser.ReplaceMeasures(strTmp);
|
||||
|
||||
push_wchar(L, strTmp.c_str());
|
||||
LuaManager::PushWide(L, strTmp.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -101,7 +100,7 @@ static int Measure_GetStringValue(lua_State* L)
|
||||
bool percentual = (bool)tolua_toboolean(L, 5, false);
|
||||
|
||||
const WCHAR* val = self->GetStringValue(autoScale, scale, decimals, percentual);
|
||||
push_wchar(L, val);
|
||||
LuaManager::PushWide(L, val);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ static int Meter_GetName(lua_State* L)
|
||||
{
|
||||
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
|
||||
const WCHAR* val = (const WCHAR*)self->GetName();
|
||||
push_wchar(L, val);
|
||||
LuaManager::PushWide(L, val);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -16,8 +17,7 @@ static int Meter_GetOption(lua_State* L)
|
||||
CMeterWindow* meterWindow = self->GetMeterWindow();
|
||||
CConfigParser& parser = meterWindow->GetParser();
|
||||
|
||||
const char* arg = (const char*)tolua_tostring(L, 2, 0);
|
||||
std::wstring strTmp = ConvertToWide(arg);
|
||||
std::wstring strTmp = LuaManager::ToWide(L, 2);
|
||||
strTmp = parser.GetValue(self->GetName(), strTmp, L"");
|
||||
|
||||
parser.SetBuiltInVariable(L"CURRENTSECTION", self->GetName()); // Set temporarily
|
||||
@ -25,7 +25,7 @@ static int Meter_GetOption(lua_State* L)
|
||||
parser.SetBuiltInVariable(L"CURRENTSECTION", L""); // Reset
|
||||
parser.ReplaceMeasures(strTmp);
|
||||
|
||||
push_wchar(L, strTmp.c_str());
|
||||
LuaManager::PushWide(L, strTmp.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@ static int MeterString_Update(lua_State* L)
|
||||
static int MeterString_SetText(lua_State* L)
|
||||
{
|
||||
CMeterString* self = (CMeterString*)tolua_tousertype(L, 1, 0);
|
||||
const WCHAR* text = to_wchar(L, 2, 0);
|
||||
self->SetText(text);
|
||||
std::wstring str = LuaManager::ToWide(L, 2);
|
||||
self->SetText(str.c_str());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ static int MeterWindow_GetSkinName(lua_State* L)
|
||||
{
|
||||
CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0);
|
||||
const std::wstring& val = self->GetSkinName();
|
||||
push_wstring(L, val);
|
||||
LuaManager::PushWide(L, val.c_str());
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -38,7 +38,7 @@ static int MeterWindow_GetSkinIniFile(lua_State* L)
|
||||
{
|
||||
CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0);
|
||||
const std::wstring& val = self->GetSkinIniFile();
|
||||
push_wchar(L, val.c_str());
|
||||
LuaManager::PushWide(L, val.c_str());
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -82,10 +82,10 @@ static int MeterWindow_GetY(lua_State* L)
|
||||
static int MeterWindow_MakePathAbsolute(lua_State* L)
|
||||
{
|
||||
CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0);
|
||||
const std::wstring path = to_wstring(L, 2, 0);
|
||||
const std::wstring path = LuaManager::ToWide(L, 2);
|
||||
|
||||
std::wstring val = self->MakePathAbsolute(path);
|
||||
push_wstring(L, val);
|
||||
LuaManager::PushWide(L, val.c_str());
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -93,7 +93,7 @@ static int MeterWindow_MakePathAbsolute(lua_State* L)
|
||||
static int MeterWindow_GetMeter(lua_State* L)
|
||||
{
|
||||
CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0);
|
||||
const std::wstring meterName = to_wstring(L, 2, 0);
|
||||
const std::wstring meterName = LuaManager::ToWide(L, 2);
|
||||
|
||||
CMeter* meter = self->GetMeter(meterName);
|
||||
if (!meter)
|
||||
@ -120,7 +120,7 @@ static int MeterWindow_GetMeter(lua_State* L)
|
||||
static int MeterWindow_GetMeasure(lua_State* L)
|
||||
{
|
||||
CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0);
|
||||
const std::wstring measureName = to_wstring(L, 2, 0);
|
||||
const std::wstring measureName = LuaManager::ToWide(L, 2);
|
||||
|
||||
CMeasure* val = self->GetMeasure(measureName);
|
||||
tolua_pushusertype(L, (void*)val, "CMeasure");
|
||||
@ -131,13 +131,11 @@ static int MeterWindow_GetMeasure(lua_State* L)
|
||||
static int MeterWindow_GetVariable(lua_State* L)
|
||||
{
|
||||
CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0);
|
||||
const char* arg = (const char*)tolua_tostring(L, 2, 0);
|
||||
std::wstring strTmp = ConvertToWide(arg);
|
||||
std::wstring strTmp = LuaManager::ToWide(L, 2);
|
||||
|
||||
if (self->GetParser().GetVariable(strTmp, strTmp))
|
||||
{
|
||||
std::string val = ConvertToAscii(strTmp.c_str());
|
||||
tolua_pushstring(L, val.c_str());
|
||||
LuaManager::PushWide(L, strTmp.c_str());
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -149,12 +147,10 @@ static int MeterWindow_GetVariable(lua_State* L)
|
||||
static int MeterWindow_ReplaceVariables(lua_State* L)
|
||||
{
|
||||
CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0);
|
||||
const char* arg = (const char*)tolua_tostring(L, 2, 0);
|
||||
std::wstring strTmp = ConvertToWide(arg);
|
||||
std::wstring strTmp = LuaManager::ToWide(L, 2);
|
||||
|
||||
self->GetParser().ReplaceVariables(strTmp);
|
||||
std::string val = ConvertToAscii(strTmp.c_str());
|
||||
tolua_pushstring(L, val.c_str());
|
||||
LuaManager::PushWide(L, strTmp.c_str());
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -162,8 +158,7 @@ static int MeterWindow_ReplaceVariables(lua_State* L)
|
||||
static int MeterWindow_Bang(lua_State* L)
|
||||
{
|
||||
CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0);
|
||||
const char* arg = (const char*)tolua_tostring(L, 2, 0);
|
||||
std::wstring strTmp = ConvertToWide(arg);
|
||||
std::wstring strTmp = LuaManager::ToWide(L, 2);
|
||||
|
||||
CConfigParser& parser = self->GetParser();
|
||||
parser.ReplaceVariables(strTmp);
|
||||
|
Reference in New Issue
Block a user