Browse Source

Fix regression with context windows, and error message

master
boisso 7 years ago
parent
commit
f1f37bada2
  1. 27
      k-meleon/macros2/functions.h
  2. 4
      k-meleon/macros2/macros.cpp
  3. 7
      k-meleon/macros2/object.h

27
k-meleon/macros2/functions.h

@ -262,15 +262,16 @@
Value open(FunctionData* data)
{
checkArgs(__FUNCTION__, data, 1, 2);
if (!data->getstr(1).length()) return Value();
int w = OPEN_NORMAL;
if (data->getstr(2).length()) {
if (data->getstr(2).compare("window") == 0)
w = OPEN_NEW;
else if (data->getstr(2).compare("bgwindow") == 0)
w = OPEN_BACKGROUND;
else if (data->getstr(2).compare("tab") == 0)
else if (data->getstr(2).compare("new") == 0 || data->getstr(2).compare("tab") == 0)
w = OPEN_NEWTAB;
else if (data->getstr(2).compare("bgtab") == 0)
else if (data->getstr(2).compare("bgnew") == 0 || data->getstr(2).compare("bgtab") == 0)
w = OPEN_BACKGROUNDTAB;
// Compatibility
else if (data->getstr(2).compare("ID_OPEN_LINK_IN_NEW_WINDOW") == 0)
@ -332,7 +333,7 @@
else if (!strcmpi(type, "int")) preftype = PREF_INT;
else if (!strcmpi(type, "string")) preftype = PREF_UNISTRING;
else {
parseError(WRONGTYPE, "setpref", type);
parseError(WRONGTYPE, "setpref", type, 0, 0, data->stat);
return false;
}
@ -370,7 +371,7 @@
else if (!strcmpi(type, "int")) preftype = PREF_INT;
else if (!strcmpi(type, "string")) preftype = PREF_UNISTRING;
else {
parseError(WRONGTYPE, "getpref", type);
parseError(WRONGTYPE, "getpref", type, 0, 0, data->stat);
return "";
}
@ -419,7 +420,7 @@
else if (!strcmpi(type, "int")) preftype = PREF_INT;
else if (!strcmpi(type, "string")) preftype = PREF_UNISTRING;
else {
parseError(WRONGTYPE, "getpref", type);
parseError(WRONGTYPE, "getpref", type, 0, 0, data->stat);
return "";
}
@ -509,7 +510,11 @@
Value id(FunctionData* data)
{
checkArgs(__FUNCTION__, data, 1);
return kPlugin.kFuncs->RunCommand(data->c.hWnd, data->getstr(1));
HWND current = kPlugin.kFuncs->GetCurrent(data->c.hWnd);
bool r = kPlugin.kFuncs->RunCommand(data->c.hWnd, data->getstr(1));
if (current == data->c.hWnd) // Allow cmd like ID_TAB_NEXT to change context
data->setWin(kPlugin.kFuncs->GetCurrent(data->c.hWnd));
return r;
}
Value plugin(FunctionData* data)
@ -787,7 +792,7 @@
if (!strcmpi(data->getstr(4), "int")) preftype = PREF_INT;
else if (!strcmpi(data->getstr(4), "string")) preftype = PREF_STRING;
else {
parseError(WRONGTYPE, "PluginMsgEx", data->getstr(4));
parseError(WRONGTYPE, "PluginMsgEx", data->getstr(4), 0, 0, data->stat);
return "";
}
std::string strRet;
@ -1342,7 +1347,7 @@
item.type = MENU_PLUGIN;
}
else {
parseError(WRONGARGS, "setmenu", menutype, 2, data->nparam);
parseError(WRONGARGS, "setmenu", menutype, 2, data->nparam, data->stat);
return "0";
}
@ -1631,7 +1636,7 @@
return kPlugin.kFuncs->SetButton(data->getstr(1), kPlugin.kFuncs->GetID(data->getstr(2)), &b);
}*/
#define MAX_TIMERS 10
#define MAX_TIMERS 25
#define OFFSET_TIMERS 1000
typedef struct TimerStruct {
@ -1677,8 +1682,10 @@
if (!timers[i].idEvent)
break;
if (i >= MAX_TIMERS)
if (i >= MAX_TIMERS) {
DoError("No timer available.", data->stat);
return 0;
}
if (data->c.hWnd && !IsWindow(data->c.hWnd))
return 0;

4
k-meleon/macros2/macros.cpp

@ -237,7 +237,7 @@ public:
FunctionData fd;
fd.nparam = 0;
fd.c = context;
fd.setContext(&context);
fd.stat = currentStat;
std::string args;
@ -520,7 +520,7 @@ long DoMessage(const char *to, const char *from, const char *subject, long data1
Create((HWND)data1);
}
else if (strcmp(subject, "CreateTab") == 0) {
ExecuteMacro((HWND)data1, "OnOpenTab", false);
ExecuteMacro(data2?(HWND)data2:(HWND)data1, "OnOpenTab", false);
}
else if (strcmp(subject, "DestroyTab") == 0) {
ExecuteMacro(data2?(HWND)data2:(HWND)data1, "OnCloseTab", false);

7
k-meleon/macros2/object.h

@ -28,6 +28,7 @@ struct FunctionData;
typedef struct {
HWND hWnd;
HWND hTab;
MacroFile* origmf;
MacroFile* mf;
} Context;
@ -253,6 +254,7 @@ class Statement;
typedef struct FunctionData
{
Context* pc;
Context c;
unsigned short nparam;
Value* params;
@ -261,8 +263,9 @@ typedef struct FunctionData
Value getarg(unsigned short i) {return i>0&&i<=nparam ? *(params+i-1) : Value();}
MString getstr(unsigned short i, const char* def = "") {return i>0&&i<=nparam ? (params+i-1)->strval() : def;}
int getint(unsigned short i, int def = 0) {return i>0&&i<=nparam ? (params+i-1)->intval() : def;}
int getbool(unsigned short i, int def = 0) {return i>0&&i<=nparam ? (params+i-1)->boolval() : def;}
int getbool(unsigned short i, int def = 0) {return i>0&&i<=nparam ? (params+i-1)->boolval() : def;}
void setContext(Context* ac) {pc = ac; c = *ac;}
void setWin(HWND h) {pc->hWnd = h;}
} FunctionData;

Loading…
Cancel
Save