Skip to content

Commit

Permalink
24.10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
tablacus committed Oct 4, 2024
1 parent c24c16e commit 22d324f
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 23 deletions.
9 changes: 6 additions & 3 deletions Debug/addons/undoclosetab/config.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<TablacusExplorer>
<General>
<Version>1.16</Version>
<MinVersion>2021.12.18</MinVersion>
<pubDate>Sun, 26 Dec 2021 00:00:00 GMT</pubDate>
<Version>1.18</Version>
<MinVersion>2024.8.6</MinVersion>
<pubDate>Mon, 23 Sep 2024 00:00:00 GMT</pubDate>
<Options>Common:0,5,6,7,8,9:0</Options>
<Level>2</Level>
<Creator>Gaku</Creator>
Expand All @@ -24,4 +24,7 @@
<zh>
<Name>復原已關閉分頁</Name>
</zh>
<zh_cn>
<Name>恢复已关闭的选项卡</Name>
</zh_cn>
</TablacusExplorer>
4 changes: 4 additions & 0 deletions Debug/addons/undoclosetab/lang/ja.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<text s="&amp;Undo close tab">閉じたタブを元に戻す(&amp;U)</text>
</resources>
3 changes: 3 additions & 0 deletions Debug/addons/undoclosetab/lang/zh.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<text s="&amp;Undo close tab">重新打开关闭的选项卡</text>
</resources>
3 changes: 3 additions & 0 deletions Debug/addons/undoclosetab/lang/zh_cn.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<text s="&amp;Undo close tab">重新打开关闭的选项卡</text>
</resources>
28 changes: 17 additions & 11 deletions Debug/addons/undoclosetab/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Sync.UndoCloseTab = {
const FV = GetFolderView(Ctrl, pt);
if (FV) {
Sync.UndoCloseTab.bLock = true;
while (Common.UndoCloseTab.db.length) {
const db = (Common.UndoCloseTab.db || []);
while (db.length) {
Sync.UndoCloseTab.bFail = false;
Sync.UndoCloseTab.Open(FV, 0);
if (!Sync.UndoCloseTab.bFail) {
Expand All @@ -27,36 +28,39 @@ Sync.UndoCloseTab = {
Open: function (FV, i) {
if (FV) {
const Items = Sync.UndoCloseTab.Get(i);
Common.UndoCloseTab.db.splice(i, 1);
const db = (Common.UndoCloseTab.db || []);
db.splice(i, 1);
FV.Navigate(Items, SBSP_NEWBROWSER);
InvokeUI("Addons.UndoCloseTab.Save");
}
},

Get: function (nIndex) {
Common.UndoCloseTab.db.splice(Sync.UndoCloseTab.Items, MAXINT);
let s = Common.UndoCloseTab.db[nIndex];
const db = (Common.UndoCloseTab.db || []);
db.splice(Sync.UndoCloseTab.Items, MAXINT);
let s = db[nIndex];
if ("string" === typeof s) {
const a = s.split(/\n/);
s = api.CreateObject("FolderItems");
s.Index = a.pop();
for (let i in a) {
s.AddItem(a[i]);
}
Common.UndoCloseTab.db[nIndex] = s;
db[nIndex] = s;
}
return s;
},

Load: function () {
Common.UndoCloseTab.db = api.CreateObject("Array");
const db = api.CreateObject("Array");
const xml = OpenXml("closedtabs.xml", true, false);
if (xml) {
const items = xml.getElementsByTagName('Item');
for (let i = items.length; i--;) {
Common.UndoCloseTab.db.unshift(items[i].text);
db.unshift(items[i].text);
}
}
Common.UndoCloseTab.db = db;
Sync.UndoCloseTab.ModifyDate = api.ILCreateFromPath(Sync.UndoCloseTab.CONFIG).ModifyDate;
},

Expand All @@ -67,7 +71,7 @@ Sync.UndoCloseTab = {
const xml = CreateXml();
const root = xml.createElement("TablacusExplorer");

const db = Common.UndoCloseTab.db;
const db = (Common.UndoCloseTab.db || []);
for (let i = 0; i < db.length; i++) {
const item = xml.createElement("Item");
let s = db[i];
Expand Down Expand Up @@ -97,8 +101,9 @@ AddEvent("CloseView", function (Ctrl) {
if (Sync.UndoCloseTab.bLock) {
Sync.UndoCloseTab.bFail = true;
} else if (Ctrl.History.Count) {
Common.UndoCloseTab.db.unshift(Ctrl.History);
Common.UndoCloseTab.db.splice(Sync.UndoCloseTab.Items, MAXINT);
const db = (Common.UndoCloseTab.db || []);
db.unshift(Ctrl.History);
db.splice(Sync.UndoCloseTab.Items, MAXINT);
InvokeUI("Addons.UndoCloseTab.Save");
}
}
Expand All @@ -116,7 +121,8 @@ AddEvent("ChangeNotifyItem:" + Sync.UndoCloseTab.CONFIG, function (pid) {
//Menu
if (item.getAttribute("MenuExec")) {
AddEvent(item.getAttribute("Menu"), function (Ctrl, hMenu, nPos) {
api.InsertMenu(hMenu, Sync.UndoCloseTab.nPos, MF_BYPOSITION | MF_STRING | ((Common.UndoCloseTab.db.length) ? MF_ENABLED : MF_DISABLED), ++nPos, GetText(Sync.UndoCloseTab.strName));
const db = (Common.UndoCloseTab.db || []);
api.InsertMenu(hMenu, Sync.UndoCloseTab.nPos, MF_BYPOSITION | MF_STRING | (db.length ? MF_ENABLED : MF_DISABLED), ++nPos, GetText(Sync.UndoCloseTab.strName));
ExtraMenuCommand[nPos] = Sync.UndoCloseTab.Exec;
return nPos;
});
Expand Down
16 changes: 13 additions & 3 deletions Debug/script/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ g_.Notify = {};

AboutTE = function (n) {
if (n == 0) {
return te.Version < 20240616 ? te.Version : 20240806;
return te.Version < 20240616 ? te.Version : 20241004;
}
if (n == 1) {
const v = AboutTE(0);
Expand Down Expand Up @@ -479,6 +479,16 @@ OrganizePath = function (fn, base) {
return fn;
}

SelectedParent = function (path) {
if ("string" !== typeof path) {
if (!path || !path.Count) {
return;
}
path = path.Item(0).Path;
}
return /^[A-Z]:\\.+?\\|^\\\\.+?\\/i.test(path) ? GetParentFolderName(path) : null;
}

OpenAdodbFromTextFile = function (fn, charset, base) {
fn = OrganizePath(fn, base || te.Data.Installed);
const ado = api.CreateObject("ads");
Expand Down Expand Up @@ -2572,7 +2582,7 @@ ExecMenu4 = function (Ctrl, Name, pt, hMenu, arContextMenu, nVerb, FV) {
}
}
}
if (ContextMenu.InvokeCommand(0, te.hwnd, nVerb - ContextMenu.idCmdFirst, null, null, SW_SHOWNORMAL, 0, 0) == S_OK) {
if (ContextMenu.InvokeCommand(0, te.hwnd, nVerb - ContextMenu.idCmdFirst, null, SelectedParent(ContextMenu.Items()), SW_SHOWNORMAL, 0, 0) == S_OK) {
api.DestroyMenu(hMenu);
return S_OK;
}
Expand Down Expand Up @@ -3221,7 +3231,7 @@ PopupContextMenu = function (Item, FV, pt) {
}
const nVerb = api.TrackPopupMenuEx(hMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, te.hwnd, null, ContextMenu);
if (nVerb) {
ContextMenu.InvokeCommand(0, te.hwnd, nVerb - 1, null, null, SW_SHOWNORMAL, 0, 0);
ContextMenu.InvokeCommand(0, te.hwnd, nVerb - 1, null, SelectedParent(Item), SW_SHOWNORMAL, 0, 0);
}
}
api.DestroyMenu(hMenu);
Expand Down
16 changes: 10 additions & 6 deletions Debug/script/sync1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2285,14 +2285,18 @@ te.OnDefaultCommand = function (Ctrl) {
if (ExecMenu(Ctrl, "Default", null, 2) == S_OK) {
return S_OK;
}
if (Selected.Count == 1) {
const pid = api.ILCreateFromPath(api.GetDisplayNameOf(Selected.Item(0), SHGDN_FORPARSING | SHGDN_FORADDRESSBAR));
if (pid.Enum) {
Ctrl.Navigate(pid, GetNavigateFlags(Ctrl));
return S_OK;
if (Selected.Count) {
let path = api.GetDisplayNameOf(Selected.Item(0), SHGDN_FORPARSING | SHGDN_FORADDRESSBAR);
if (Selected.Count == 1) {
const pid = api.ILCreateFromPath(path);
if (pid.Enum) {
Ctrl.Navigate(pid, GetNavigateFlags(Ctrl));
return S_OK;
}
}
return InvokeCommand(Selected, 0, te.hwnd, null, null, SelectedParent(path), SW_SHOWNORMAL, 0, 0, Ctrl, CMF_DEFAULTONLY);
}
return InvokeCommand(Selected, 0, te.hwnd, null, null, null, SW_SHOWNORMAL, 0, 0, Ctrl, CMF_DEFAULTONLY);
return S_FALSE;
}

te.OnSystemMessage = function (Ctrl, hwnd, msg, wParam, lParam) {
Expand Down

0 comments on commit 22d324f

Please sign in to comment.