Skip to content

Commit

Permalink
22.3.24 Some fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tablacus committed Mar 24, 2022
1 parent be69ba6 commit 0f1013b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
47 changes: 18 additions & 29 deletions Debug/script/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,7 @@ async function EditMenus() {
document.F.Menus_Key.value = a2.length > 1 ? await GetKeyName(a2.pop()) : "";
document.F.Menus_Name.value = a2.join("\\t");
document.F.Menus_Filter.value = a[1];
const p = await api.CreateObject("Object");
p.s = a[2];
await MainWindow.OptionDecode(a[3], p);
document.F.Menus_Path.value = await p.s;
document.F.Menus_Path.value = await MainWindow.OptionDecode(a[3], a[2]);
SetType(document.F.Menus_Type, a[3]);
document.F.Icon.value = a[4] || "";
document.F.IconSize.value = a[6] || "";
Expand All @@ -636,10 +633,7 @@ EditX = async function (mode, form) {
ClearX(mode);
const a = g_x[mode][g_x[mode].selectedIndex].value.split(g_sep);
form[mode + mode].value = a[0];
const p = await api.CreateObject("Object");
p.s = a[1];
await MainWindow.OptionDecode(a[2], p);
form[mode + "Path"].value = await p.s;
form[mode + "Path"].value = await MainWindow.OptionDecode(a[2], a[1]);
SetType(form[mode + "Type"], a[2]);
if (SameText(mode, "key")) {
SetKeyShift();
Expand Down Expand Up @@ -701,10 +695,7 @@ async function ReplaceMenus() {
if (document.F.Menus_Key.value.length) {
s += "\\t" + await GetKeyKeyG(document.F.Menus_Key.value);
}
const p = await api.CreateObject("Object");
p.s = document.F.Menus_Path.value;
await MainWindow.OptionEncode(o[o.selectedIndex].value, p);
SetMenus(sel, [s, document.F.Menus_Filter.value, await p.s, o[o.selectedIndex].value, document.F.Icon.value, org, document.F.IconSize.value]);
SetMenus(sel, [s, document.F.Menus_Filter.value, await MainWindow.OptionEncode(o[o.selectedIndex].value, document.F.Menus_Path.value), o[o.selectedIndex].value, document.F.Icon.value, org, document.F.IconSize.value]);
g_Chg.Menus = true;
}

Expand All @@ -722,11 +713,8 @@ async function ReplaceX(mode, form) {
}
const sel = g_x[mode][g_x[mode].selectedIndex];
const o = form[mode + "Type"];
const p = await api.CreateObject("Object");
p.s = form[mode + "Path"].value;
await MainWindow.OptionEncode(o[o.selectedIndex].value, p);
const o2 = form[mode + "Name"];
SetData(sel, [form[mode + mode].value, await p.s, o[o.selectedIndex].value, o2 ? await GetSourceText(o2.value) : ""]);
SetData(sel, [form[mode + mode].value, await MainWindow.OptionEncode(o[o.selectedIndex].value, form[mode + "Path"].value), o[o.selectedIndex].value, o2 ? await GetSourceText(o2.value) : ""]);
g_Chg[mode] = true;
g_bChanged = true;
}
Expand Down Expand Up @@ -954,7 +942,7 @@ async function SaveMenus() {
}

async function GetKeyKeyEx(s) {
const n = await GetKeyKey(s);
const n = await MainWindow.GetKeyKey(s);
return n & 0xff ? "$" + n.toString(16) : s;
}

Expand Down Expand Up @@ -2078,7 +2066,7 @@ InitLocation = function () {
IsChanged = function () {
return g_bChanged || g_Chg.Data;
};

const TEOk1 = window.TEOk;
TEOk = async function () {
if (window.SaveLocation) {
await SaveLocation();
Expand Down Expand Up @@ -2111,7 +2099,13 @@ InitLocation = function () {
}
}
}
if (bConfigChanged) {
if (TEOk1) {
if ("string" === typeof TEOk1) {
MainWindow.InvokeUI(TEOk1);
} else {
TEOk1();
}
} else if (bConfigChanged) {
te.Data.bReload = true;
MainWindow.RunEvent1("ConfigChanged", "Addons");
}
Expand Down Expand Up @@ -2250,13 +2244,11 @@ function RefX(Id, bMultiLine, oButton, bFilesOnly, Filter, f) {
const optId = oType ? oType[oType.selectedIndex].value : "exec";
const r = await MainWindow.OptionRef(optId, o.value, pt);
if ("string" === typeof r) {
const p = await api.CreateObject("Object");
p.s = r;
await MainWindow.OptionDecode(optId, p);
if (bMultiLine && await api.GetKeyState(VK_CONTROL) < 0 && await api.ILCreateFromPath(await p.s)) {
AddPath(Id, await p.s, f);
const ps = await MainWindow.OptionDecode(optId, r);
if (bMultiLine && await api.GetKeyState(VK_CONTROL) < 0 && await api.ILCreateFromPath(ps)) {
AddPath(Id, ps, f);
} else {
SetValue(o, await p.s);
SetValue(o, ps);
}
}
return;
Expand Down Expand Up @@ -2448,11 +2440,8 @@ TestX = function (id, f) {
f = document.F;
}
const o = f[id + "Type"];
const p = await api.CreateObject("Object");
p.s = f[id + "Path"].value;
await MainWindow.OptionEncode(o[o.selectedIndex].value, p);
await MainWindow.InvokeUI("window.focus");
await MainWindow.Exec(await te.Ctrl(CTRL_FV), await p.s, o[o.selectedIndex].value);
await MainWindow.Exec(await te.Ctrl(CTRL_FV), await MainWindow.OptionEncode(o[o.selectedIndex].value, f[id + "Path"].value), o[o.selectedIndex].value);
focus();
});
}
Expand Down
36 changes: 24 additions & 12 deletions Debug/script/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ g_.IconChg = [

AboutTE = function (n) {
if (n == 0) {
return te.Version < 20220318 ? te.Version : 20220321;
return te.Version < 20220318 ? te.Version : 20220324;
}
if (n == 1) {
const v = AboutTE(0);
Expand Down Expand Up @@ -232,8 +232,7 @@ OpenDialog = function (path, bFilesOnly) {

ChooseFolder = function (path, pt, uFlags) {
if (!pt) {
pt = api.Memory("POINT");
api.GetCursorPos(pt);
pt = api.GetCursorPos();
}
let FolderItem = api.ILCreateFromPath(path);
FolderItem = FolderMenu.Open(FolderItem.IsFolder ? FolderItem : ssfDRIVES, pt.x, pt.y);
Expand Down Expand Up @@ -1631,7 +1630,7 @@ GetKeyKey = function (strKey) {
if (nShift) {
return nShift;
}
strKey = strKey.toUpperCase();
strKey = (strKey || "").toUpperCase();
for (let j = 0; j < MainWindow.g_.KeyState.length; ++j) {
const s = MainWindow.g_.KeyState[j][0].toUpperCase() + "+";
const i = strKey.indexOf(s);
Expand Down Expand Up @@ -3097,11 +3096,27 @@ OptionRef = function (Id, s, pt) {
}

OptionDecode = function (Id, p) {
return MainWindow.RunEvent3("OptionDecode", Id, p);
if (/^object$|^function$/.test(typeof p)) {
return MainWindow.RunEvent3("OptionDecode", Id, p);
}
if ("string" === typeof p) {
const o = api.CreateObject("Object");
o.s = p;
MainWindow.RunEvent3("OptionDecode", Id, o);
return o.s;
}
}

OptionEncode = function (Id, p) {
return MainWindow.RunEvent3("OptionEncode", Id, p);
if (/^object$|^function$/.test(typeof p)) {
return MainWindow.RunEvent3("OptionEncode", Id, p);
}
if ("string" === typeof p) {
const o = api.CreateObject("Object");
o.s = p;
MainWindow.RunEvent3("OptionEncode", Id, o);
return o.s;
}
}

EscapeUpdateFile = function (s) {
Expand Down Expand Up @@ -3166,8 +3181,7 @@ PopupContextMenu = function (Item, FV, pt) {
ContextMenu.QueryContextMenu(hMenu, 0, 1, 0x7FFF, uCMF);
RemoveCommand(hMenu, ContextMenu, "delete");
if (!pt) {
pt = api.Memory("POINT");
api.GetCursorPos(pt);
pt = api.GetCursorPos();
}
const nVerb = api.TrackPopupMenuEx(hMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, te.hwnd, null, ContextMenu);
if (nVerb) {
Expand Down Expand Up @@ -3653,8 +3667,7 @@ FolderMenu = {
const path = api.GetDisplayNameOf(FolderItem, SHGDN_FORADDRESSBAR | SHGDN_FORPARSING);
const bVirtual = FolderItem.Unavailable || api.ILIsParent(1, FolderItem, false);
if (MainWindow.g_menu_button == 2 || /popup/i.test(wFlags)) {
const pt = api.Memory("POINT");
api.GetCursorPos(pt);
const pt = api.GetCursorPos();
if (bVirtual) {
if (!confirmOk(path, TITLE, MB_OK | MB_ICONINFORMATION)) {
return;
Expand Down Expand Up @@ -3714,8 +3727,7 @@ FolderMenu = {
Location: function (o) {
let pt;
if (window.chrome) {
pt = api.Memory("POINT");
api.GetCursorPos(pt);
pt = api.GetCursorPos();
} else {
pt = GetPos(o, 9);
pt.x += o.offsetWidth;
Expand Down
3 changes: 1 addition & 2 deletions Debug/script/sync1.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,7 @@ g_basic = {
Exec: function (Ctrl, s, type, hwnd, pt) {
const fn = g_basic.CmdI(type, s);
if (!pt) {
pt = api.Memory("POINT");
api.GetCursorPos(pt);
pt = api.GetCursorPos();
}
if (fn) {
InvokeFunc(fn, [Ctrl, pt]);
Expand Down
2 changes: 1 addition & 1 deletion Debug/script/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ SyncExec = async function (cb, o, n) {
let pt;
if (n) {
pt = await GetPosEx(o, n);
} else if (o.target || o.srcElement) {
} else if (o && (o.target || o.srcElement)) {
pt = await api.Memory("POINT");
pt.x = o.screenX * ui_.Zoom;
pt.y = o.screenY * ui_.Zoom;
Expand Down

0 comments on commit 0f1013b

Please sign in to comment.