Compare commits

...
Author SHA1 Message Date
agrynco 5bca97f864 Record the v0.6.116 package manifest and checksum 2026-11-17 20:26:36 +02:00
agrynco 0d714147ea Prepare KSwitcher v0.6.116 with cancellable folder scans 2026-11-17 20:26:09 +02:00
agrynco a0aeb62270 Release KSwitcher v0.6.115 (#61)
Add Shift+F4, prevent editor flicker, and record file launches as short start commands.
2026-11-17 17:30:07 +02:00
14 changed files with 259 additions and 82 deletions

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.24)
project(KSwitcher VERSION 0.6.115 LANGUAGES CXX RC)
project(KSwitcher VERSION 0.6.116 LANGUAGES CXX RC)
if(NOT WIN32)
message(FATAL_ERROR "KSwitcher uses native Windows APIs")
endif()
+13 -6
View File
@@ -37,8 +37,10 @@ Warning і початковий фокус на No.
окремим процесом. BAT і CMD виконуються в поточній сесії вбудованого
термінала, а їхній вивід з’являється під панелями. Щоб відкрити файл із
панелі LAN, спочатку скопіюй його до локальної папки.
Після успішного відкриття локального файла через Windows дія
`start 'шлях до файла'` з’являється у виводі термінала й історії команд.
Після успішного відкриття локального файла через Windows його шлях
з’являється у виводі термінала й списку історії. Коли термінал неактивний,
його курсор приховано. При виборі
з історії у командний рядок підставляється команда, яка повторює відкриття.
- Коли командний рядок порожній, Shift+Enter відкриває поточний локальний
елемент через Windows.
Папка відкривається у Провіднику, файл виконує свою стандартну дію Windows.
@@ -138,10 +140,15 @@ Warning і початковий фокус на No.
лише до шляхів із пробілами. Для `..` вставляється шлях батьківської папки.
- Ctrl+Enter вставляє лише назву файла або папки під курсором активної панелі
за тими ж правилами вставлення й лапок. Рядок `..` пропускається.
- Локальні й LAN-каталоги скануються у фоновому потоці. Під час переходу
активна панель показує «Loading folder…» і зберігає попередній список до
завершення сканування. Після переходу оновлюються шлях і список цієї панелі
та командний рядок. Сусідня панель не перемальовується через цей перехід.
- Локальні й LAN-каталоги скануються у фоновому потоці. Рядок стану активної
панелі показує «Reading» з лічильником прочитаних файлів і папок та
підказкою [Esc].
До завершення читання панель зберігає попередній список. Escape зупиняє
сканування активної панелі й відкриває прочитану частину папки. Якщо
папку ще не вдалося відкрити, попередній список залишається. Ctrl+R
повторює сканування, щоб отримати повний список. Після переходу
оновлюються шлях і список цієї панелі та командний рядок. Сусідня
панель не перемальовується через цей перехід.
Якщо надійшов новіший запит, результат попереднього
сканування пропускається. Після підтвердження UAC очікування списку
від підвищеного процесу теж відбувається у фоні.
+1 -2
View File
@@ -999,8 +999,7 @@ Keep `v0.4.2` as the last legacy `vX.Y.Z` release. Publish full packages as
`release-vX.Y.Z` (stable, not prerelease), including `release-files.json`,
`KSwitcher-win-x64.zip` and `SHA256SUMS.txt`. Never publish a manifest package under a
legacy version tag: clients that have not installed the bridge would select it.
Keep the compatibility bridge in the first 100 releases returned by Gitea while
supporting old clients; their immutable update code only reads that page.
Legacy clients only read the first 100 releases returned by Gitea. The bridge is now outside that page. For v0.3.x–v0.4.1, follow the manual bridge installation instructions above.
### Editors that omit copied trailing spaces
+11 -1
View File
@@ -1,5 +1,15 @@
# Latest Windows release
## v0.6.116 — 2026-11-17
- Files displays a live count while reading a folder. **Esc** stops the scan and shows the entries already read. **Ctrl+R** reads the folder again. Mouse selection works beyond the first 65,536 rows.
- Files shows the path of files opened through Windows in the terminal and command history. Choosing a history entry still inserts the command that reopens the file. The embedded terminal hides its inactive cursor.
**Українською.**
- Files показує лічильник під час читання папки. **Esc** зупиняє читання й показує вже прочитані записи. **Ctrl+R** перечитує папку. Вибір мишею працює після перших 65 536 рядків.
- Files показує шлях до файла, відкритого через Windows, у терміналі й історії команд. Вибір запису історії підставляє команду для повторного відкриття. Вбудований термінал приховує курсор, коли він неактивний.
## v0.6.115 — 2026-11-17
- **Shift+F4** opens or creates a file in the active local panel. Leave the name blank for a generated `New_File_…txt` name. After editing a draft, **Esc → Save** opens options for the file name, encoding, BOM, and line endings.
@@ -488,7 +498,7 @@ Use **Test mouse buttons here** to check which events Windows delivers. Mouse pr
## Upgrade
Choose **Update** in the tray menu. Legacy v0.3.0–v0.4.1 clients first receive the v0.4.2 compatibility bridge, then the current full release. v0.2.3 and earlier require manual installation.
Choose **Update** in the tray menu. For v0.3.x–v0.4.1, install the [v0.4.2 bridge](https://gitea.hrynco.com/hrynco/hrynco-kswitcher/releases/tag/v0.4.2) manually first. Close KSwitcher and its editors, extract the bridge ZIP into the installation folder while keeping personal data, dictionaries, and tools, then start v0.4.2 and choose **Update**. v0.2.3 and earlier require manual installation.
For a manual upgrade, exit KSwitcher and its configurator and screenshot editors, then extract the entire **KSwitcher-win-x64.zip** into its installation folder. Verify it with **SHA256SUMS.txt**. Keep personal data, customized dictionaries and tools. Keep the three KSwitcher executables together.
+1 -1
View File
@@ -1 +1 @@
debcdf6dbb7d7dc959e094d4e39d6c7655efff453f90d13b69b0d7f1c406072c KSwitcher-win-x64.zip
5a885ca54c703dd82a5ce82b6fdbe919337f30ca08daeb6c8958f7e36832aef2 KSwitcher-win-x64.zip
+38 -38
View File
@@ -1,166 +1,166 @@
{
"schema": 1,
"version": "0.6.115",
"version": "0.6.116",
"files": [
{
"sha256": "e50dfca08dfc1e4149c43303cf303d1860410b263901dd39ba621d5d175142cd",
"path": "KSwitcher.exe",
"sha256": "b7c7f60c0a1e598359f3bd3775fca67fa2eaf9ebcc41f96da0034b3a92687863",
"size": 2479104
},
{
"sha256": "2ec390faaddad72ee59f819cf54f3f0aafa463b637180e7f877034b7352d474a",
"path": "KSwitcher.Config.exe",
"sha256": "96a956ab0498269244371355b1549cc89e29d5d9175e36e39d8bef8ab53f6a5f",
"size": 2458112
},
{
"sha256": "149ef86ea46f8c2b01b1d806a4770d7226cffc1b55059fa3ef63233d90b17e96",
"path": "KSwitcher.Screenshot.exe",
"sha256": "d001683200e1d86caaf96e8c37f004ab2717f8acaad8c172350581792026540d",
"size": 3060224
},
{
"sha256": "85b7aa5e99a4e60d49193de077c6067afb53fbadcc724504167855732d787543",
"path": "KSwitcher.Files.exe",
"size": 4229120
"sha256": "cc1bea0d8d7aafe23e7a3be72177123963c7b3d250be93840850953a2aa547a6",
"size": 4232704
},
{
"sha256": "d3fce90bdeecb08596e377dea6a316354dd8949e32ff09b89d51be00c14e21b6",
"path": "WebView2Loader.dll",
"sha256": "d3fce90bdeecb08596e377dea6a316354dd8949e32ff09b89d51be00c14e21b6",
"size": 194912
},
{
"sha256": "e256f01188af527e4d06d21d06fbf785ae9c50d4b328bf03cbe0ba7f0aa4228f",
"path": "terminal/addon-fit-LICENSE.txt",
"sha256": "e256f01188af527e4d06d21d06fbf785ae9c50d4b328bf03cbe0ba7f0aa4228f",
"size": 1103
},
{
"sha256": "ba3ea256ce0620a0992a197d6c9baea64823fc93d8da07a9e366ca9943c18527",
"path": "terminal/addon-fit.js",
"sha256": "ba3ea256ce0620a0992a197d6c9baea64823fc93d8da07a9e366ca9943c18527",
"size": 1521
},
{
"sha256": "084d97a727b778fb10d31adcd557ee7840a38377ed60e0ef0f3ece93b349b1ef",
"path": "terminal/index.html",
"sha256": "084d97a727b778fb10d31adcd557ee7840a38377ed60e0ef0f3ece93b349b1ef",
"size": 527
},
{
"sha256": "792c48c5a849a15fdf9e37e8bcf9e6d1dd13b32b46c642a748a0a46a9919d473",
"path": "terminal/markdown-it-LICENSE.txt",
"sha256": "792c48c5a849a15fdf9e37e8bcf9e6d1dd13b32b46c642a748a0a46a9919d473",
"size": 1073
},
{
"sha256": "391f2aa638e75e6c7859d0a5c5650ef0956722a45998f17e05b83bc655778e1e",
"path": "terminal/markdown-it.js",
"sha256": "391f2aa638e75e6c7859d0a5c5650ef0956722a45998f17e05b83bc655778e1e",
"size": 100786
},
{
"sha256": "e5381c35fb254b558c8b869746e2e575c8ed53600611ac90597ed2dd80fa321c",
"path": "terminal/markdown.html",
"sha256": "e5381c35fb254b558c8b869746e2e575c8ed53600611ac90597ed2dd80fa321c",
"size": 3530
},
{
"sha256": "55c905afaf074e3253267a7c48a5ebca14edd7f15449fd85c0a884c34da22763",
"path": "terminal/markdown.js",
"sha256": "55c905afaf074e3253267a7c48a5ebca14edd7f15449fd85c0a884c34da22763",
"size": 15014
},
{
"sha256": "ec9fb67dcb25eccc416ed56e1aab819222c805a2a4bfe4cb19e7556bf2ffde80",
"path": "terminal/mermaid-LICENSE.txt",
"sha256": "ec9fb67dcb25eccc416ed56e1aab819222c805a2a4bfe4cb19e7556bf2ffde80",
"size": 1089
},
{
"sha256": "336df803d87a38b70a01e736e666c8f7601d2ce42f5e47c8fafe5d721074b9a3",
"path": "terminal/mermaid.js",
"sha256": "336df803d87a38b70a01e736e666c8f7601d2ce42f5e47c8fafe5d721074b9a3",
"size": 5537838
},
{
"sha256": "0557d251962301940785690a3fc49475dd166bb7d0bd0417dc3279d1f1b3a98a",
"path": "terminal/terminal.js",
"size": 5033
"sha256": "8268049507da54079422db2b4d90b41cd0a1e99b5946b675173ea3543de27f0b",
"size": 5065
},
{
"sha256": "b569f629d00f2626a8100df2a1798210535621e42164dfd426a6fe5aac7b0ccd",
"path": "terminal/xterm-LICENSE.txt",
"sha256": "b569f629d00f2626a8100df2a1798210535621e42164dfd426a6fe5aac7b0ccd",
"size": 1261
},
{
"sha256": "854a7c0fb70e8b1a083c16797ab827299fb18744f5ad34f227b48337e33293c6",
"path": "terminal/xterm.css",
"sha256": "854a7c0fb70e8b1a083c16797ab827299fb18744f5ad34f227b48337e33293c6",
"size": 7112
},
{
"sha256": "14903579ff54664cd72f8e8699e6961a6272c21863ec1c3b118cdc8af5d4a972",
"path": "terminal/xterm.js",
"sha256": "14903579ff54664cd72f8e8699e6961a6272c21863ec1c3b118cdc8af5d4a972",
"size": 488663
},
{
"sha256": "d3c81140cce01c26bf6cbf52aa40e0825e1fa35b9a91d1387170a65d2597082c",
"path": "LICENSE",
"sha256": "d3c81140cce01c26bf6cbf52aa40e0825e1fa35b9a91d1387170a65d2597082c",
"size": 4401
},
{
"sha256": "61e08da79c44061654015ce6b0c4061c23ee1dd18237fbf09e9bfda3c0ea2831",
"path": "json-LICENSE.txt",
"sha256": "61e08da79c44061654015ce6b0c4061c23ee1dd18237fbf09e9bfda3c0ea2831",
"size": 1096
},
{
"sha256": "185c5a37521316e940ead89cbf0b1ba5862d810c7c966e6c6a14a4a515b23625",
"path": "files-text-license.txt",
"sha256": "185c5a37521316e940ead89cbf0b1ba5862d810c7c966e6c6a14a4a515b23625",
"size": 883
},
{
"sha256": "fcbd14b6190dc2a3575a4bc4be7229540c647022cb038d33ec4ac22176c67a9e",
"path": "README.md",
"size": 95289
"sha256": "ea5016c6fa29a98bf9ebf103fcf27f1be091842ad3228b167d18b053fda767d8",
"size": 95317
},
{
"sha256": "1233d6a0ed76564dd034f178a9f65db076244a819137f74dc9f2c27df9d3c930",
"path": "LAN-PREVIEW.md",
"sha256": "1233d6a0ed76564dd034f178a9f65db076244a819137f74dc9f2c27df9d3c930",
"size": 11577
},
{
"sha256": "d0c022b27b9fbc2ff7b6b8bec723cc1adc4eef517202f9ff77eed5d8bea3acb9",
"path": "dictionaries/en.txt",
"sha256": "d0c022b27b9fbc2ff7b6b8bec723cc1adc4eef517202f9ff77eed5d8bea3acb9",
"size": 732485
},
{
"sha256": "0bdfb0201d1803634f268cdff0993b8349d2c70e956a06dbb667c8dd65254ec5",
"path": "dictionaries/LICENSE-CC-BY-SA-4.0.txt",
"sha256": "0bdfb0201d1803634f268cdff0993b8349d2c70e956a06dbb667c8dd65254ec5",
"size": 20566
},
{
"sha256": "3017bf44d3be9d9dfab21bd6778aa52b7947e61acf9ce2bc86b41d6e949ac311",
"path": "dictionaries/README.md",
"sha256": "3017bf44d3be9d9dfab21bd6778aa52b7947e61acf9ce2bc86b41d6e949ac311",
"size": 2265
},
{
"sha256": "80e6b6a27815973535f7facb636c597eb845dfee45cfabfc4e9b3341b9332849",
"path": "dictionaries/ru.txt",
"sha256": "80e6b6a27815973535f7facb636c597eb845dfee45cfabfc4e9b3341b9332849",
"size": 1109134
},
{
"sha256": "98e5b3fe7304e37705c9e5ff48b0b399ccb16e806736d21f09921b99e5f2a408",
"path": "dictionaries/sources.json",
"sha256": "98e5b3fe7304e37705c9e5ff48b0b399ccb16e806736d21f09921b99e5f2a408",
"size": 1280
},
{
"sha256": "d30e990d6ec2983c04f3644a3c61c6c668e8c542323f5931916fdd55b916eebf",
"path": "dictionaries/uk.txt",
"sha256": "d30e990d6ec2983c04f3644a3c61c6c668e8c542323f5931916fdd55b916eebf",
"size": 940799
},
{
"sha256": "a34b5161a8315af037e1ec71d816bfc688f7c364141d4ee2347cf0515ef0c82a",
"path": "tools/README.txt",
"sha256": "a34b5161a8315af037e1ec71d816bfc688f7c364141d4ee2347cf0515ef0c82a",
"size": 993
},
{
"sha256": "9aa1710226ee70d49b6a02fed41411f5f70c16422a76ee079e67d2eb3a53c5d2",
"path": "tools/StayHere.exe",
"sha256": "c893d20af87a53cad90306951b80342c553d1cb188291a0377c3f28bd014b2c0",
"size": 133120
},
{
"sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413",
"path": "tools/StayHere-README.md",
"sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413",
"size": 2796
}
]
],
"schema": 1
}
+3 -3
View File
@@ -9,8 +9,8 @@ IDC_SCREENSHOT_PENCIL CURSOR "icons/lucide/pencil.cur"
1 RT_MANIFEST "app.manifest"
201 RCDATA "update.ps1"
1 VERSIONINFO
FILEVERSION 0,6,115,0
PRODUCTVERSION 0,6,115,0
FILEVERSION 0,6,116,0
PRODUCTVERSION 0,6,116,0
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
BEGIN
@@ -20,7 +20,7 @@ BEGIN
BEGIN
VALUE "FileDescription", "KSwitcher — native keyboard and clipboard utility"
VALUE "ProductName", "KSwitcher"
VALUE "FileVersion", "0.6.115"
VALUE "FileVersion", "0.6.116"
END
END
BLOCK "VarFileInfo"
+1
View File
@@ -3,6 +3,7 @@ const terminal = new Terminal({
fontFamily: 'Consolas, monospace',
fontSize: 16,
cursorBlink: false,
cursorInactiveStyle: 'none',
disableStdin: true,
theme: { background: '#181818', foreground: '#e8e8e8' },
});
+17
View File
@@ -2,6 +2,23 @@ constexpr std::array<WORD,2> defaultHistoryKeys{MAKEWORD('E',HOTKEYF_CONTROL),MA
auto commandHistoryKeys=defaultHistoryKeys;
constexpr size_t commandHistoryLimit=1000;
std::wstring commandHistoryLabel(const std::wstring &command)
{
constexpr std::wstring_view prefix=L"start '";
if(!command.starts_with(prefix) || command.size()<=prefix.size() || command.back()!=L'\'')
return command;
const std::wstring_view literal(command.data()+prefix.size(),command.size()-prefix.size()-1);
std::wstring path;
for(size_t i=0;i<literal.size();++i)
{
const auto character=literal[i];
if(character==L'\'' || character==L'\u2018' || character==L'\u2019')
if(++i==literal.size() || literal[i]!=character) return command;
path+=character;
}
return fs::path(path).is_absolute()?path:command;
}
bool validHistoryKeys(const std::array<WORD,2> &keys)
{
if(keys[0]==keys[1]) return false;
+4 -3
View File
@@ -69,7 +69,7 @@ void populateCommandHistory(HWND dialog)
{
return std::all_of(words.begin(),words.end(),[&](const auto &word){return text.find(word)!=text.npos;});
};
if(containsAll(command+L" "+entry.date))
if(containsAll(command+L" "+historyLower(commandHistoryLabel(entry.command))+L" "+entry.date))
{
matches[0].push_back(index);
continue;
@@ -91,7 +91,7 @@ void populateCommandHistory(HWND dialog)
if(first || date!=lastDate) add(date,-1);
first=false;
lastDate=date;
const auto row=add(entry.command,index);
const auto row=add(commandHistoryLabel(entry.command),index);
if(row>=0 && (words.empty() || selected==LB_ERR)) selected=row;
}
}
@@ -159,8 +159,9 @@ void sizeCommandHistory(HWND dialog,HWND list)
LONG longest{};
for(const auto &entry:terminalHistory)
{
const auto label=commandHistoryLabel(entry.command);
SIZE size{};
if(GetTextExtentPoint32W(dc,entry.command.c_str(),static_cast<int>(entry.command.size()),&size))
if(GetTextExtentPoint32W(dc,label.c_str(),static_cast<int>(label.size()),&size))
longest=std::max(longest,size.cx);
}
SelectObject(dc,previous);
+95 -24
View File
@@ -214,7 +214,8 @@ DWORD launchElevatedFolder(HWND owner,const fs::path &directory,ElevatedFolderLi
DWORD readElevatedFolder(const ElevatedFolderListing &session,const fs::path &directory,
std::vector<fs::path> &folders,std::vector<fs::path> &files,
std::map<fs::path,FolderEntryMetadata> &metadata,std::stop_token stop)
std::map<fs::path,FolderEntryMetadata> &metadata,
std::atomic_size_t &entriesRead,std::stop_token stop)
{
bool connected=false;
bool finished=false;
@@ -251,6 +252,7 @@ DWORD readElevatedFolder(const ElevatedFolderListing &session,const fs::path &di
const auto path=directory/child;
(entry.attributes&FILE_ATTRIBUTE_DIRECTORY?folders:files).push_back(path);
metadata.emplace(path,entry);
entriesRead.store(folders.size()+files.size(),std::memory_order_relaxed);
continue;
}
}
@@ -361,6 +363,7 @@ struct Panel
std::optional<ScanRequest> scanRequest;
std::future<std::unique_ptr<ScanResult>> scan;
std::stop_source scanStop;
std::shared_ptr<std::atomic_size_t> scanEntriesRead;
bool scanSuperseded{};
std::map<fs::path,uint64_t> timestamps;
std::vector<fs::path> rows;
@@ -1116,6 +1119,29 @@ void setStatus(const std::wstring &message)
SetWindowTextW(status, message.c_str());
}
bool showDirectoryScanProgress(Panel &panel)
{
if(!panel.scanRequest) return false;
const auto entries=panel.scanEntriesRead ? panel.scanEntriesRead->load(std::memory_order_relaxed) : 0;
auto message=panel.scanSuperseded ? std::wstring(L"Waiting to read…") :
panel.scanStop.stop_requested() ? L"Stopping… "+std::to_wstring(entries) :
L"Reading "+std::to_wstring(entries)+L" [Esc]";
wchar_t displayed[96]{};
GetWindowTextW(status,displayed,std::size(displayed));
if(message!=displayed) setStatus(message);
panel.scanRequest->statusRevision=statusRevision;
return true;
}
bool stopDirectoryScan()
{
auto &panel=panels[active];
if(terminalVisible || !panel.scanRequest || panel.scanSuperseded || !panel.scan.valid()) return false;
panel.scanStop.request_stop();
showDirectoryScanProgress(panel);
return true;
}
void showTerminal(HWND owner,bool show)
{
terminalVisible=show;
@@ -1271,7 +1297,7 @@ void showCompletion(HWND owner,const CompletionQuery &query,const Json &reply={}
static_cast<int>(query.line.size()),TRUE)!=CSTR_EQUAL ||
!seen.insert(command).second)
continue;
completionItems.push_back({command,command,0,query.line.size()});
completionItems.push_back({commandHistoryLabel(command),command,0,query.line.size()});
}
}
appendPowerShellCompletions(query,reply,seen);
@@ -1744,6 +1770,7 @@ LRESULT CALLBACK terminalInputKeys(HWND input,UINT message,WPARAM wp,LPARAM lp,U
if(message==WM_CHAR && wp==VK_TAB && !terminalVisible) return 0;
if(message==WM_CHAR && wp==VK_ESCAPE)
{
if(stopDirectoryScan()) return 0;
if(remoteCommandRunning && !GetWindowTextLengthW(input))
{
remoteCommandThread.request_stop();
@@ -1798,6 +1825,7 @@ LRESULT CALLBACK terminalInputKeys(HWND input,UINT message,WPARAM wp,LPARAM lp,U
void showFileDetails(const Panel &panel)
{
if(&panel==&panels[active] && showDirectoryScanProgress(panels[active])) return;
auto row=SendMessageW(panel.list,LB_GETCURSEL,0,0);
if(!panel.wide || !showDetails || row<0 || static_cast<size_t>(row)>=panel.rows.size())
{
@@ -1839,24 +1867,29 @@ void showFileDetails(const Panel &panel)
setStatus(details);
}
std::unique_ptr<Panel::ScanResult> scanDirectory(const Panel::ScanRequest &request,std::stop_token stop)
std::unique_ptr<Panel::ScanResult> scanDirectory(const Panel::ScanRequest &request,
std::atomic_size_t &entriesRead,std::stop_token stop)
{
auto result=std::make_unique<Panel::ScanResult>();
auto &[watch,folders,files,metadata,timestamps,error,opened,failure]=*result;
const auto &directory=request.directory;
const auto &peer=request.peer;
if(stop.stop_requested()) return result;
if(stop.stop_requested())
{
error=ERROR_CANCELLED;
return result;
}
if(request.elevated)
{
error=readElevatedFolder(*request.elevated,directory,folders,files,metadata,stop);
opened=error==ERROR_SUCCESS;
error=readElevatedFolder(*request.elevated,directory,folders,files,metadata,entriesRead,stop);
opened=error==ERROR_SUCCESS || (error==ERROR_CANCELLED && !metadata.empty());
if(opened)
{
watch.start(directory);
if(error==ERROR_SUCCESS) watch.start(directory);
std::sort(folders.begin(),folders.end());
std::sort(files.begin(),files.end());
}
else failure=error==ERROR_ACCESS_DENIED?L"Windows denied access after elevation: "+directory.wstring():
else if(error!=ERROR_CANCELLED) failure=error==ERROR_ACCESS_DENIED?L"Windows denied access after elevation: "+directory.wstring():
L"Could not read folder as administrator ("+std::to_wstring(error)+L"): "+directory.wstring();
return result;
}
@@ -1875,24 +1908,36 @@ std::unique_ptr<Panel::ScanResult> scanDirectory(const Panel::ScanRequest &reque
try
{
FilesConnection host(&*peer);
listFiles(host,directory,[&](const fs::path &path,const FileInfo &info)
const bool complete=listFiles(host,directory,[&](const fs::path &path,const FileInfo &info)
{
if(stop.stop_requested()) return false;
(info.attributes&FILE_ATTRIBUTE_DIRECTORY?folders:files).push_back(path);
metadata.emplace(path,FolderEntryMetadata{info.attributes,info.size});
timestamps.emplace(path,info.modified);
entriesRead.store(folders.size()+files.size(),std::memory_order_relaxed);
return true;
});
opened=true;
if(!complete) error=ERROR_CANCELLED;
}
catch(const std::system_error &e){result->failure=peer->name+L" — "+fileError(e);}
catch(const std::exception &){result->failure=L"Cannot open folder on "+peer->name;}
if(!opened && stop.stop_requested())
{
error=ERROR_CANCELLED;
opened=!metadata.empty();
failure.clear();
}
}
if(search!=INVALID_HANDLE_VALUE)
{
do
{
if(stop.stop_requested()) return result;
if(stop.stop_requested())
{
error=ERROR_CANCELLED;
break;
}
const std::wstring_view name(data.cFileName);
if(name==L"." || name==L"..") continue;
const auto path=directory/name;
@@ -1900,9 +1945,11 @@ std::unique_ptr<Panel::ScanResult> scanDirectory(const Panel::ScanRequest &reque
(data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY?folders:files).push_back(path);
metadata.emplace(path,FolderEntryMetadata{data.dwFileAttributes,size});
timestamps.emplace(path,(uint64_t(data.ftLastWriteTime.dwHighDateTime)<<32)|data.ftLastWriteTime.dwLowDateTime);
entriesRead.store(folders.size()+files.size(),std::memory_order_relaxed);
} while(FindNextFileW(search,&data));
error=GetLastError();
if(error!=ERROR_CANCELLED) error=GetLastError();
}
else if(!peer && stop.stop_requested()) error=ERROR_CANCELLED;
std::sort(folders.begin(), folders.end());
std::sort(files.begin(), files.end());
return result;
@@ -1918,12 +1965,18 @@ bool applyDirectoryScan(Panel &panel,Panel::ScanRequest request,Panel::ScanResul
(peer?peer->id:std::string{})?panel.directory:fs::path{};
const bool sameDirectory=previousDirectory==directory;
auto &[nextWatch,folders,files,metadata,timestamps,error,opened,failure]=scan;
const bool partial=error==ERROR_CANCELLED;
if(!failure.empty())
{
setStatus(failure);
return false;
}
if (!scan.opened && error!=ERROR_FILE_NOT_FOUND)
if(partial && !opened)
{
if(&panel==&panels[active]) setStatus(L"Reading stopped before the folder opened.");
return false;
}
if (!opened && error!=ERROR_FILE_NOT_FOUND)
{
const bool denied=error==ERROR_ACCESS_DENIED;
setStatus(denied ? L"Access denied: " + directory.wstring() :
@@ -1949,7 +2002,6 @@ bool applyDirectoryScan(Panel &panel,Panel::ScanRequest request,Panel::ScanResul
return false;
}
rememberElevationApproval=rememberElevationApproval || remember;
setStatus(L"Loading folder…");
request.statusRevision=statusRevision;
request.elevated=std::move(elevated);
panel.scanRequest=std::move(request);
@@ -1980,7 +2032,8 @@ bool applyDirectoryScan(Panel &panel,Panel::ScanRequest request,Panel::ScanResul
panel.folderSizeQuery={};
panel.folderSizes.clear();
}
if(!sameDirectory || panel.watch.handle==INVALID_HANDLE_VALUE)
if(partial) panel.watch.reset();
else if(!sameDirectory || panel.watch.handle==INVALID_HANDLE_VALUE)
{
panel.watch.reset();
std::swap(panel.watch.handle,nextWatch.handle);
@@ -1991,8 +2044,14 @@ bool applyDirectoryScan(Panel &panel,Panel::ScanRequest request,Panel::ScanResul
panel.dimmed.clear();
panel.marked.clear();
panel.fileExtensionLength=panel.folderExtensionLength=0;
SendMessageW(panel.list, LB_RESETCONTENT, 0, 0);
const auto rowCount = folders.size() + files.size() + directory.has_relative_path();
panel.rows.reserve(rowCount);
panel.sizes.reserve(rowCount);
panel.dimmed.reserve(rowCount);
panel.marked.reserve(rowCount);
const bool visible=IsWindowVisible(panel.list);
if(visible) SendMessageW(panel.list,WM_SETREDRAW,FALSE,0);
SendMessageW(panel.list, LB_RESETCONTENT, 0, 0);
SendMessageW(panel.list, LB_INITSTORAGE, rowCount, 0);
auto add = [&](const fs::path &path, const std::wstring &label, bool folder)
{
@@ -2038,8 +2097,11 @@ bool applyDirectoryScan(Panel &panel,Panel::ScanRequest request,Panel::ScanResul
if(sameDirectory) SendMessageW(panel.list,LB_SETTOPINDEX,previousTop,0);
SendMessageW(panel.list,LB_SETCURSEL,selected-panel.rows.begin(),0);
}
if(visible) SendMessageW(panel.list,WM_SETREDRAW,TRUE,0);
InvalidateRect(panel.list,nullptr,FALSE);
if(error!=ERROR_SUCCESS && error!=ERROR_NO_MORE_FILES && error!=ERROR_FILE_NOT_FOUND)
if(partial && &panel==&panels[active])
setStatus(L"Partial: "+std::to_wstring(folders.size()+files.size()));
else if(!partial && error!=ERROR_SUCCESS && error!=ERROR_NO_MORE_FILES && error!=ERROR_FILE_NOT_FOUND)
setStatus(L"Some entries could not be read.");
else if(updateDetails && &panel==&panels[active]) showFileDetails(panel);
return true;
@@ -2048,9 +2110,13 @@ bool applyDirectoryScan(Panel &panel,Panel::ScanRequest request,Panel::ScanResul
void startDirectoryScan(Panel &panel)
{
panel.scanStop=std::stop_source{};
panel.scanEntriesRead=std::make_shared<std::atomic_size_t>(0);
const auto owner=GetParent(panel.list);
std::packaged_task<std::unique_ptr<Panel::ScanResult>()> task(
[request=*panel.scanRequest,stop=panel.scanStop.get_token()] {return scanDirectory(request,stop);});
[request=*panel.scanRequest,entries=panel.scanEntriesRead,stop=panel.scanStop.get_token()]
{
return scanDirectory(request,*entries,stop);
});
auto future=task.get_future();
std::thread([task=std::move(task),owner]() mutable
{
@@ -2059,21 +2125,20 @@ void startDirectoryScan(Panel &panel)
}).detach();
panel.scan=std::move(future);
panel.scanSuperseded=false;
if(&panel==&panels[active]) showDirectoryScanProgress(panel);
}
void openOn(Panel &panel,const fs::path &directory,bool offerElevation,std::optional<FilesPeer> peer,
fs::path selection={},fs::path fallback={})
{
if(directory.empty()) return;
if(&panel==&panels[active] && (directory!=panel.directory ||
(peer?peer->id:std::string{})!=(panel.peer?panel.peer->id:std::string{})))
setStatus(L"Loading folder…");
panel.scanRequest=Panel::ScanRequest{directory,std::move(selection),std::move(fallback),
std::move(peer),offerElevation,statusRevision};
if(panel.scan.valid())
{
panel.scanSuperseded=true;
panel.scanStop.request_stop();
if(&panel==&panels[active]) showDirectoryScanProgress(panel);
}
else startDirectoryScan(panel);
}
@@ -2092,12 +2157,14 @@ void collectDirectoryScans()
}
auto request=std::move(*panel.scanRequest);
panel.scanRequest.reset();
panel.scanEntriesRead.reset();
bool applied=false;
const auto fallback=request.fallback;
try
{
auto result=panel.scan.get();
applied=applyDirectoryScan(panel,std::move(request),*result);
if(result->error==ERROR_CANCELLED) continue;
}
catch(const std::exception &) {setStatus(L"Could not read the folder.");}
if(!applied && !fallback.empty()) openOn(panel,fallback,false,{});
@@ -2778,7 +2845,7 @@ void openPanelFile(const Panel &panel, const fs::path &file, const wchar_t *verb
terminalHistoryIndex=terminalHistory.size();
const auto owner=GetParent(panel.list);
if(!ensureTerminalView(owner)) return;
appendTerminalOutput(ks::utf8(L"\r\n"+command+L"\r\n"));
appendTerminalOutput(ks::utf8(L"\r\n"+file.native()+L"\r\n"));
if(!terminalVisible && terminalRows==0)
{
terminalRows=5;
@@ -5479,9 +5546,13 @@ LRESULT CALLBACK panelKeys(HWND window, UINT message, WPARAM wp, LPARAM lp, UINT
activatePanel(index);
return 0;
}
const auto hit=SendMessageW(window,LB_ITEMFROMPOINT,0,lp);
const auto row=static_cast<LRESULT>(LOWORD(hit));
const POINT point{GET_X_LPARAM(lp),GET_Y_LPARAM(lp)};
// LB_ITEMFROMPOINT only returns the low 16 bits of the row index.
const auto hit=SendMessageW(window,LB_ITEMFROMPOINT,0,lp);
const auto top=SendMessageW(window,LB_GETTOPINDEX,0,0);
constexpr LRESULT rowRange=1<<16;
auto row=(top&~(rowRange-1))|LOWORD(hit);
if(row<top) row+=rowRange;
RECT bounds{};
const bool rowHit=!HIWORD(hit) && row<count &&
SendMessageW(window,LB_GETITEMRECT,row,reinterpret_cast<LPARAM>(&bounds))!=LB_ERR &&
@@ -5490,7 +5561,6 @@ LRESULT CALLBACK panelKeys(HWND window, UINT message, WPARAM wp, LPARAM lp, UINT
const auto target=rowHit?row:point.y>=0 && message==WM_LBUTTONDOWN?count-1:previous;
if(target!=previous && index!=active)
{
const auto top=SendMessageW(window,LB_GETTOPINDEX,0,0);
// The native list can repaint during selection. Activate it only after moving the cursor.
const bool visible=IsWindowVisible(window);
if(visible) SendMessageW(window,WM_SETREDRAW,FALSE,0);
@@ -5946,6 +6016,7 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
{
collectDirectoryScans();
refreshChangedPanels();
showDirectoryScanProgress(panels[active]);
}
collectFolderSizes();
return 0;
+1 -1
View File
@@ -2,7 +2,7 @@
#include "platform.h"
namespace ks
{
inline constexpr wchar_t AppVersion[] = L"0.6.115";
inline constexpr wchar_t AppVersion[] = L"0.6.116";
inline constexpr UINT UpdateMessage = WM_APP + 7;
inline constexpr UINT UpdateCheckIntervalMs = 6 * 60 * 60 * 1000;
inline constexpr UINT UpdateNotificationRetryMs = 5 * 60 * 1000;
+71 -2
View File
@@ -3,6 +3,7 @@ param(
[Parameter(Mandatory)][string]$Fixture,
[switch]$SystemOpenOnly,
[switch]$TerminalOnly,
[int]$ScanEntries = 0,
[string]$Node='node'
)
$ErrorActionPreference = 'Stop'
@@ -12,6 +13,10 @@ using System.Text;
using System.Runtime.InteropServices;
public static class FilesActivationUi {
public static void CreateScanFiles(string directory, int count) {
for (int i = 0; i < count; i++)
using (System.IO.File.Create(System.IO.Path.Combine(directory, i.ToString("D6") + ".txt"))) {}
}
[StructLayout(LayoutKind.Sequential)]
public struct Rect { public int Left, Top, Right, Bottom; }
[StructLayout(LayoutKind.Sequential)]
@@ -202,7 +207,7 @@ $extension = ".ksfiles$unique"
$progId = "KSwitcher.Files.Test.$unique"
$saved = @{}
$profileValues = 'LeftPath', 'RightPath', 'LeftCursor', 'RightCursor', 'LeftWide', 'RightWide',
'ShowDetails', 'StatusFields', 'CommandHistory', 'WindowPlacement'
'ShowDetails', 'StatusFields', 'CommandHistory', 'CommandHistoryKey', 'PreviousCommandKey', 'WindowPlacement'
$process = $null
$trace = $null
$webviewFlags=$env:WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS
@@ -263,6 +268,13 @@ function startTerminalFixture() {
$env:WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS="--remote-debugging-port=$port"
$env:WEBVIEW2_USER_DATA_FOLDER=Join-Path $root 'webview'
}
if($SystemOpenOnly) {
$profile.SetValue('PreviousCommandKey',0x0245,'DWord')
$profile.SetValue('CommandHistoryKey',0x0477,'DWord')
}
if ($ScanEntries) {
[FilesActivationUi]::CreateScanFiles("$leftDir\Test folder", $ScanEntries)
}
$process = Start-Process -FilePath $testExe -ArgumentList '--terminal-output-trace' -PassThru
$trace = Join-Path ([IO.Path]::GetTempPath()) "KSwitcher.Files.terminal-trace-$($process.Id).log"
Wait-Until 'Files window' { $process.Refresh(); $process.MainWindowHandle -ne [IntPtr]::Zero }
@@ -273,6 +285,49 @@ function startTerminalFixture() {
$output = [FilesActivationUi]::GetDlgItem($window, 145)
$inputBox = [FilesActivationUi]::FindWindowEx($window, [IntPtr]::Zero, 'Edit', $null)
if ($ScanEntries) {
Wait-Until 'visible Files window' { [FilesActivationUi]::Activate($window) }
Wait-Until 'folder fixture row' { (Find-Row $left '[Test folder]') -ge 0 }
$folderRow = Find-Row $left '[Test folder]'
[void][FilesActivationUi]::Send($left, 0x186, [IntPtr]$folderRow, [IntPtr]::Zero)
Press-Enter $inputBox
Wait-Until 'nonzero folder scan progress' {
[FilesActivationUi]::IsWindowVisible($status) -and
(Read-Text $status) -match '^Reading ([1-9][0-9]*) \[Esc\]$'
}
$progress = Read-Text $status
[void][FilesActivationUi]::PostMessage($inputBox, 0x100, [IntPtr]27, [IntPtr]::Zero)
Wait-Until 'partial folder result' { (Read-Text $status) -match '^Partial: \d+$' }
$partial = [FilesActivationUi]::Send($left, 0x18B, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32() - 1
$partialStatus = Read-Text $status
if ($partial -le 0 -or $partial -ge $ScanEntries -or
$partialStatus -ne "Partial: $partial" -or
(Read-Text ([FilesActivationUi]::GetDlgItem($window,142))) -ne "$leftDir\Test folder") {
throw "Unexpected partial listing of $partial entries."
}
$keys = New-Object -ComObject WScript.Shell
$fullScan = [Diagnostics.Stopwatch]::StartNew()
$keys.SendKeys('^r')
Wait-Until 'complete folder result after Ctrl+R' {
[FilesActivationUi]::Send($left, 0x18B, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32() -eq $ScanEntries + 1
}
$fullScan.Stop()
Write-Output "$progress. $partialStatus. Full scan: $ScanEntries files in $($fullScan.ElapsedMilliseconds) ms."
$target = 65536
[void][FilesActivationUi]::Send($left, 0x197, [IntPtr]$target, [IntPtr]::Zero)
if ([FilesActivationUi]::Send($left, 0x18E, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32() -ne $target) {
throw "Could not scroll row $target to the top."
}
$point = [IntPtr]((2 -shl 16) -bor 6)
[void][FilesActivationUi]::PostMessage($left, 0x201, [IntPtr]1, $point)
[void][FilesActivationUi]::PostMessage($left, 0x202, [IntPtr]::Zero, $point)
Wait-Until 'mouse selection past the 16-bit row limit' {
[FilesActivationUi]::Send($left, 0x188, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32() -eq $target
}
Write-Output "Clicked row $target after scrolling it to the top."
return
}
if($SystemOpenOnly) {
$keys = New-Object -ComObject WScript.Shell
$explorer = New-Object -ComObject Shell.Application
@@ -318,8 +373,22 @@ function startTerminalFixture() {
$history=$profile.GetValue('CommandHistory')
[FilesActivationUi]::IsWindowVisible($output) -and $history -and
([Text.Encoding]::Unicode.GetString($history).Split([char]0) -ccontains $command) -and
(Select-String -LiteralPath $trace -SimpleMatch "start '$($document.Substring(0,12))" -Quiet)
(Select-String -LiteralPath $trace -Pattern ('^'+[regex]::Escape($document.Substring(0,24))) -Quiet)
}
Wait-Until 'Files active for command history' { [FilesActivationUi]::Activate($window) }
$keys.SendKeys('%{F8}')
$historyDialog=[IntPtr]::Zero
Wait-Until 'command history showing only the opened file path' {
$script:historyDialog=[FilesActivationUi]::GetForegroundWindow()
$list=[FilesActivationUi]::GetDlgItem($historyDialog,324)
$list -ne [IntPtr]::Zero -and (Find-Row $list $document) -ge 0
}
$historyList=[FilesActivationUi]::GetDlgItem($historyDialog,324)
$historyRow=Find-Row $historyList $document
[void][FilesActivationUi]::Send($historyList,0x186,[IntPtr]$historyRow,[IntPtr]::Zero)
[void][FilesActivationUi]::PostMessage($historyDialog,0x111,[IntPtr]1,[IntPtr]::Zero)
Wait-Until 'selecting the history path restoring a runnable command' { (Read-Text $inputBox) -ceq $command }
[void][FilesActivationUi]::Write($inputBox,0x0C,[IntPtr]::Zero,'')
Write-Output 'Verified Shift+Enter opens folders in Explorer. Both Enter and Shift+Enter invoke the default file action.'
Remove-Item -LiteralPath "$document.opened"
}
+2
View File
@@ -85,6 +85,8 @@ try {
})()`), 'the terminal output fixture');
assert.equal(selection, 'terminal-output-copy-fixture');
} else if (terminalScenario) {
assert.equal(await evaluate('terminal.options.cursorInactiveStyle'), 'none');
assert.equal(await evaluate('document.querySelectorAll(".xterm-cursor-outline").length'), 0);
await evaluate('document.querySelector(".xterm-helper-textarea").focus()');
const key = scenario === 'terminal-copy'
? { key:'Insert', code:'Insert', modifiers:2, windowsVirtualKeyCode:45 }