Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ea4f6f914 | ||
|
|
36f0b6ef8e | ||
|
|
3aafc1f937 | ||
|
|
6215675cb4 | ||
|
|
56c6257465 | ||
|
|
64b03a2168 | ||
|
|
36baeeb081 |
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(KSwitcher VERSION 0.6.90 LANGUAGES CXX RC)
|
||||
project(KSwitcher VERSION 0.6.93 LANGUAGES CXX RC)
|
||||
if(NOT WIN32)
|
||||
message(FATAL_ERROR "KSwitcher uses native Windows APIs")
|
||||
endif()
|
||||
|
||||
+11
@@ -67,8 +67,14 @@ Warning і початковий фокус на No.
|
||||
лише до шляхів із пробілами. Для `..` вставляється шлях батьківської папки.
|
||||
- Ctrl+Enter вставляє лише назву файла або папки під курсором активної панелі
|
||||
за тими ж правилами вставлення й лапок. Рядок `..` пропускається.
|
||||
- Ctrl+R перечитує поточну папку активної панелі. Позиція курсора й позначки
|
||||
зберігаються для наявних елементів, а підраховані через F3 розміри папок
|
||||
скидаються. F2 також виконує цю дію.
|
||||
- Ctrl+C копіює весь введений у командний рядок текст, навіть коли виділено
|
||||
лише його частину.
|
||||
- Ctrl+Insert копіює імена позначених файлів і папок активної панелі в порядку
|
||||
відображення, по одному на рядок. Якщо позначок немає, копіюється ім’я під
|
||||
курсором. Шляхи й рядок `..` пропускаються.
|
||||
|
||||
- Ctrl+E підставляє останню команду. Повторне натискання
|
||||
підставляє старішу, доки не досягне початку історії. Alt+F8 відкриває історію
|
||||
@@ -129,6 +135,11 @@ Warning і початковий фокус на No.
|
||||
відкриваються в окремих немодальних вікнах із власними кнопками на панелі
|
||||
завдань Windows. При повторному відкритті Files пропонує перейти до вже
|
||||
відкритого вікна. Закриття менеджера залишає вікна файлів відкритими.
|
||||
- Коли курсор на папці, F3 у фоні підраховує сумарний розмір файлів у ній
|
||||
та вкладених папках. Якщо позначено папки, розмір рахується для кожної з
|
||||
них окремо. Результат видно в колонці Size у широкому режимі та в рядку
|
||||
стану, коли там увімкнено розмір. Це працює і в LAN-панелі. Посилання й
|
||||
junction не обходяться. Недоступний вміст позначається як частковий результат.
|
||||
- F3 і F4 працюють і на панелі LAN. Файл завантажується у тимчасову копію
|
||||
на диску у фоновому режимі. Збереження передає зміни назад на віддалений ПК.
|
||||
Якщо розмір або час зміни віддаленого файла відрізняється від відкритої
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,23 @@
|
||||
# Latest Windows release
|
||||
|
||||
## v0.6.93 — 2026-11-16
|
||||
|
||||
In Files, Ctrl+R refreshes the active pane as in FAR Manager. The menu and key bar show Ctrl+R. F2 also refreshes the pane. Refresh preserves marks and the cursor where possible, and clears folder sizes calculated with F3.
|
||||
|
||||
**Українською.** У Files Ctrl+R перечитує активну панель, як у FAR Manager. Комбінація показана в меню та рядку клавіш. F2 також перечитує панель. Перечитування зберігає позначки й курсор для наявних елементів і скидає розміри папок, підраховані через F3.
|
||||
|
||||
## v0.6.92 — 2026-11-16
|
||||
|
||||
In Files, F3 on a folder measures file sizes throughout the directory tree. If folders are marked, Files measures each marked folder separately. Results appear in the Size column in Wide mode. F3 on a file opens the viewer even when folders are marked. Folder sizing runs in the background and supports LAN panes.
|
||||
|
||||
**Українською.** У Files F3 на папці підраховує сумарний розмір файлів у всьому дереві. Якщо позначено папки, Files рахує розмір кожної окремо. Результат з’являється в колонці Size у широкому режимі. F3 на файлі відкриває переглядач, навіть коли позначено папки. Підрахунок виконується у фоні й підтримує LAN-панелі.
|
||||
|
||||
## v0.6.91 — 2026-11-16
|
||||
|
||||
Ctrl+Insert copies the marked file and folder names from the active pane, one per line. Without marks, it copies the name under the cursor. LAN Files retries opening TCP 45885 if the port is busy at startup, and Change drive retries failed drive queries. A remote update request waits for an in-progress update check. The updater identifies and closes companion processes from its installation, including Files running from an update backup, and records confirmed exits in the journal.
|
||||
|
||||
**Українською.** Ctrl+Insert копіює імена позначених файлів і папок активної панелі, по одному на рядок. Якщо позначок немає, копіюється ім’я під курсором. LAN Files повторює відкриття TCP 45885, якщо порт зайнятий під час старту, а Change drive повторює невдалі запити дисків. Запит віддаленого оновлення чекає завершення поточної перевірки. Оновлювач визначає й закриває процеси своєї інсталяції, зокрема Files із резервної папки, і записує підтверджене завершення в журнал.
|
||||
|
||||
## v0.6.90 — 2026-11-16
|
||||
|
||||
Files groups Commands into navigation, viewing and editing, and remote PC actions. The remote group appears in an active LAN pane. Shared notices fit their contents and show a scrollbar only when needed. Remote hibernation and update confirmations use a compact red warning with No focused by default.
|
||||
|
||||
@@ -1 +1 @@
|
||||
67db5adc069f847aa1d9987e4043dfd488b03ae15444a99b007774ac01556461 KSwitcher-win-x64.zip
|
||||
21b9e32cfbd5e5cc8898d675a3b53e4b510a427dbeb2c26a957d104f1154dc05 KSwitcher-win-x64.zip
|
||||
+13
-13
@@ -1,24 +1,24 @@
|
||||
{
|
||||
"version": "0.6.90",
|
||||
"schema": 1,
|
||||
"files": [
|
||||
{
|
||||
"size": 2465792,
|
||||
"sha256": "7f6d0d1508a324ccc793455f6667084dcd1003cbc472dca9f6262c014068f99b",
|
||||
"size": 2467840,
|
||||
"sha256": "3ad872f175c26ec2e9e06f9c5edf54f817fb281174d3be84d3286f9c38796b6e",
|
||||
"path": "KSwitcher.exe"
|
||||
},
|
||||
{
|
||||
"size": 2445824,
|
||||
"sha256": "2ae249c373b6f8a8f232daffae84738751d9aad7d1f39bd7335fb379a415e50c",
|
||||
"size": 2446848,
|
||||
"sha256": "e7465f15c46278841ed0764f3ac699b95423c3490c375d5481bbf85c100dbf34",
|
||||
"path": "KSwitcher.Config.exe"
|
||||
},
|
||||
{
|
||||
"size": 3052544,
|
||||
"sha256": "bd1fca6c5dfa35ac2ae4afab5becb67ed7701d011ce6e671a05340f0634150e2",
|
||||
"size": 3053568,
|
||||
"sha256": "e7b2f32b0138b3a3af7f648c5d6cfb17f952f48440ae69fcf7803a58b0ee32f6",
|
||||
"path": "KSwitcher.Screenshot.exe"
|
||||
},
|
||||
{
|
||||
"size": 3675136,
|
||||
"sha256": "bbcddc17a1cd69824a8cbdff7301854739c295b6b4fb27227acb00d375a9ab3a",
|
||||
"size": 3686912,
|
||||
"sha256": "1a570823393e2c3e2198408ab44f83bf4456849b9eaa85a0ca52f63f1cb5326e",
|
||||
"path": "KSwitcher.Files.exe"
|
||||
},
|
||||
{
|
||||
@@ -42,8 +42,8 @@
|
||||
"path": "terminal/index.html"
|
||||
},
|
||||
{
|
||||
"size": 4268,
|
||||
"sha256": "fb302b2902fea6a815a8266811f350d1e4c108ca88fafd49e6eddcbfff90a5e5",
|
||||
"size": 4478,
|
||||
"sha256": "0f3edde02b30e7b0f76d0cc88daae5791d720a4b74cf8b34e7c0b4dbe0cf9c9d",
|
||||
"path": "terminal/terminal.js"
|
||||
},
|
||||
{
|
||||
@@ -123,7 +123,7 @@
|
||||
},
|
||||
{
|
||||
"size": 133120,
|
||||
"sha256": "9e914d996864d7f982ba50e481381d673e4e84ee7ad5d1f477f0898aa1816256",
|
||||
"sha256": "db68aff204ab8c69ded43914e397fda151dce4fdc01f8ac1900db07393a97712",
|
||||
"path": "tools/StayHere.exe"
|
||||
},
|
||||
{
|
||||
@@ -132,5 +132,5 @@
|
||||
"path": "tools/StayHere-README.md"
|
||||
}
|
||||
],
|
||||
"schema": 1
|
||||
"version": "0.6.93"
|
||||
}
|
||||
+3
-3
@@ -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,90,0
|
||||
PRODUCTVERSION 0,6,90,0
|
||||
FILEVERSION 0,6,93,0
|
||||
PRODUCTVERSION 0,6,93,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.90"
|
||||
VALUE "FileVersion", "0.6.93"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -61,6 +61,12 @@ terminal.attachCustomKeyEventHandler(event => {
|
||||
else if (event.key === 'Enter') {
|
||||
if (!event.repeat) bridge.postMessage('insert-name');
|
||||
}
|
||||
else if (event.key === 'Insert') {
|
||||
if (!event.repeat) bridge.postMessage('copy-panel-names');
|
||||
}
|
||||
else if (event.code === 'KeyR') {
|
||||
if (!event.repeat) bridge.postMessage('refresh-panel');
|
||||
}
|
||||
else return true;
|
||||
event.preventDefault();
|
||||
return false;
|
||||
|
||||
+30
-1
@@ -415,16 +415,45 @@ function Write-UpdateJournal([string]$Message) {
|
||||
[Text.UTF8Encoding]::new($false))
|
||||
}
|
||||
function Stop-UpdateCompanions([string]$Directory) {
|
||||
if (!('KSwitcherUpdateProcessImage' -as [type])) {
|
||||
Add-Type @'
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
public static class KSwitcherUpdateProcessImage {
|
||||
[DllImport("kernel32.dll")] static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
|
||||
[DllImport("kernel32.dll", CharSet=CharSet.Unicode)]
|
||||
static extern bool QueryFullProcessImageName(IntPtr process, int flags, StringBuilder image, ref int length);
|
||||
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
|
||||
|
||||
public static string Read(int pid) {
|
||||
var process = OpenProcess(0x1000, false, pid);
|
||||
if (process == IntPtr.Zero) return null;
|
||||
try {
|
||||
var length = 32768;
|
||||
var image = new StringBuilder(length);
|
||||
return QueryFullProcessImageName(process, 0, image, ref length) ? image.ToString() : null;
|
||||
} finally { CloseHandle(process); }
|
||||
}
|
||||
}
|
||||
'@
|
||||
}
|
||||
$root = [IO.Path]::GetFullPath($Directory).TrimEnd('\')
|
||||
$prefix = [regex]::Escape($root + '\')
|
||||
$pattern = '^' + $prefix + '(?:\.kswitcher-update-[0-9a-f]{32}\\backup\\)?KSwitcher\.(?:Config|Screenshot|Files)\.exe$'
|
||||
foreach ($process in @(Get-Process 'KSwitcher.Config','KSwitcher.Screenshot','KSwitcher.Files' -ErrorAction SilentlyContinue)) {
|
||||
if ($process.Path -notmatch $pattern) { continue }
|
||||
$image = [KSwitcherUpdateProcessImage]::Read($process.Id)
|
||||
if (!$image -and !$process.HasExited) {
|
||||
Write-UpdateJournal "Could not identify $($process.ProcessName) (PID $($process.Id))."
|
||||
}
|
||||
if ($image -notmatch $pattern) { continue }
|
||||
Write-UpdateJournal "Closing $($process.ProcessName) (PID $($process.Id))."
|
||||
if (!$process.HasExited) {
|
||||
try { $process.Kill() } catch { if (!$process.HasExited) { throw } }
|
||||
if (!$process.WaitForExit(10000)) { throw "Could not close $($process.ProcessName) (PID $($process.Id))." }
|
||||
}
|
||||
Write-UpdateJournal "Closed $($process.ProcessName) (PID $($process.Id))."
|
||||
}
|
||||
}
|
||||
if ($Library) { return }
|
||||
|
||||
+13
-1
@@ -3010,7 +3010,13 @@ LRESULT CALLBACK App::windowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
case LanUpdateRequestedMessage:
|
||||
if (!lan::remoteUpdateAllowed()) return 0;
|
||||
if (app->updateRunning)
|
||||
log(L"LAN update request ignored because an update is already running.");
|
||||
{
|
||||
if (!app->installingUpdate)
|
||||
{
|
||||
app->lanUpdatePending = true;
|
||||
log(L"LAN update queued behind an update check.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log(L"Starting unattended KSwitcher update requested over LAN.");
|
||||
@@ -3030,6 +3036,12 @@ LRESULT CALLBACK App::windowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
// The helper has verified and staged the package; it waits for process exit.
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
else if (std::exchange(app->lanUpdatePending, false) && lan::remoteUpdateAllowed() &&
|
||||
result->state != L"current")
|
||||
{
|
||||
log(L"Starting queued unattended KSwitcher update.");
|
||||
app->checkUpdate(false, true);
|
||||
}
|
||||
else if (result->state == L"available")
|
||||
{
|
||||
app->availableUpdate = result->version;
|
||||
|
||||
@@ -155,7 +155,7 @@ class App
|
||||
std::vector<SyncConflict> pendingSyncConflicts;
|
||||
Bytes syncSnapshot;
|
||||
std::wstring syncStatus = L"Not connected.";
|
||||
bool updateRunning{}, installingUpdate{};
|
||||
bool updateRunning{}, installingUpdate{}, lanUpdatePending{};
|
||||
std::wstring availableUpdate, notifiedUpdate;
|
||||
bool (*updateNotifier)(const std::wstring &){};
|
||||
bool stop{};
|
||||
|
||||
@@ -12,7 +12,7 @@ bool validHistoryKeys(const std::array<WORD,2> &keys)
|
||||
const bool function=key>=VK_F1 && key<=VK_F12;
|
||||
if(!letter && !function) return false;
|
||||
if(modifiers==HOTKEYF_CONTROL)
|
||||
return (letter && key!='C' && key!='F' && key!='V' && key!='X' && key!='A' && key!='Z' && key!='Y') || function;
|
||||
return (letter && key!='C' && key!='F' && key!='R' && key!='V' && key!='X' && key!='A' && key!='Z' && key!='Y') || function;
|
||||
if(modifiers==HOTKEYF_ALT) return function && key!=VK_F1 && key!=VK_F2 && key!=VK_F4 && key!=VK_F10;
|
||||
return false;
|
||||
});
|
||||
|
||||
+213
-46
@@ -247,6 +247,49 @@ DWORD requestElevatedFolder(HWND owner,const fs::path &directory,
|
||||
}
|
||||
return ERROR_TIMEOUT;
|
||||
}
|
||||
struct FolderSize
|
||||
{
|
||||
uint64_t bytes{};
|
||||
bool partial{};
|
||||
};
|
||||
using FolderSizes=std::map<fs::path,FolderSize>;
|
||||
|
||||
FolderSize measureFolder(FilesConnection &host,const fs::path &root,std::stop_token stop)
|
||||
{
|
||||
FolderSize size;
|
||||
std::vector<fs::path> pending{root};
|
||||
while(!pending.empty() && !stop.stop_requested())
|
||||
{
|
||||
const auto directory=std::move(pending.back());
|
||||
pending.pop_back();
|
||||
try
|
||||
{
|
||||
const auto info=statFile(host,directory);
|
||||
if(!info || !(info->attributes&FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
size.partial=true;
|
||||
continue;
|
||||
}
|
||||
if(info->attributes&FILE_ATTRIBUTE_REPARSE_POINT)
|
||||
{
|
||||
if(directory==root) size.partial=true;
|
||||
continue;
|
||||
}
|
||||
listFiles(host,directory,[&](const fs::path &path,const FileInfo &entry)
|
||||
{
|
||||
if(stop.stop_requested()) return false;
|
||||
if(entry.attributes&FILE_ATTRIBUTE_REPARSE_POINT) return true;
|
||||
if(entry.attributes&FILE_ATTRIBUTE_DIRECTORY) pending.push_back(path);
|
||||
else if(entry.size>UINT64_MAX-size.bytes) size.partial=true;
|
||||
else size.bytes+=entry.size;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
catch(const std::exception &) {size.partial=true;}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
struct Panel
|
||||
{
|
||||
HWND path{}, list{}, heading{};
|
||||
@@ -274,6 +317,9 @@ struct Panel
|
||||
std::vector<std::wstring> sizes;
|
||||
std::vector<bool> dimmed;
|
||||
std::vector<bool> marked;
|
||||
FolderSizes folderSizes;
|
||||
std::future<FolderSizes> folderSizeQuery;
|
||||
std::stop_source folderSizeStop;
|
||||
std::set<fs::path> transferResults;
|
||||
size_t fileExtensionLength{}, folderExtensionLength{};
|
||||
bool wide{};
|
||||
@@ -345,8 +391,7 @@ struct DriveChoice { FilesPeer peer; fs::path path; };
|
||||
std::vector<DriveQuery> driveQueries;
|
||||
std::map<LRESULT,DriveChoice> remoteDriveRows;
|
||||
constexpr UINT_PTR driveQueryTimer=3;
|
||||
bool refreshDriveAddresses{};
|
||||
ULONGLONG driveOpened{};
|
||||
ULONGLONG nextDriveRefresh{},driveRefreshDeadline{};
|
||||
int drivePickerWidth{};
|
||||
int pickerPanel{};
|
||||
std::wstring panelSearchPrefix;
|
||||
@@ -844,10 +889,14 @@ void layout(HWND window)
|
||||
ShowWindow(terminalOutput,showOutput?SW_SHOWNA:SW_HIDE);
|
||||
ShowWindow(status,terminalVisible?SW_HIDE:SW_SHOWNA);
|
||||
terminalView.layout(terminalOutput,showOutput,terminalBottom-4);
|
||||
constexpr int refreshExtra=4;
|
||||
for (int i = 0; i < static_cast<int>(std::size(commands)); ++i)
|
||||
{
|
||||
const int count=static_cast<int>(std::size(commands));
|
||||
place(commands[i],i*width/count,height-textHeight,(i+1)*width/count-i*width/count,textHeight);
|
||||
constexpr int unit=10;
|
||||
const int total=static_cast<int>(std::size(commands))*unit+refreshExtra;
|
||||
const int left=i?(i*unit+refreshExtra)*width/total:0;
|
||||
const int right=((i+1)*unit+refreshExtra)*width/total;
|
||||
place(commands[i],left,height-textHeight,right-left,textHeight);
|
||||
}
|
||||
if(IsWindowVisible(panelSearchPopup)) placePanelSearch(window);
|
||||
RedrawWindow(window,nullptr,nullptr,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
|
||||
@@ -905,6 +954,41 @@ LRESULT currentPanelRow(const Panel &panel)
|
||||
return row>=0 && static_cast<size_t>(row)<panel.rows.size()?row:LB_ERR;
|
||||
}
|
||||
|
||||
std::vector<fs::path> selectedPanelPaths(const Panel &panel)
|
||||
{
|
||||
std::vector<fs::path> paths;
|
||||
for(size_t i=0;i<panel.rows.size();++i)
|
||||
if(panel.marked[i] && panel.sizes[i]!=L"Up") paths.push_back(panel.rows[i]);
|
||||
if(paths.empty())
|
||||
{
|
||||
const auto row=currentPanelRow(panel);
|
||||
if(row!=LB_ERR && panel.sizes[row]!=L"Up") paths.push_back(panel.rows[row]);
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
void copyPanelNames(HWND owner)
|
||||
{
|
||||
const auto paths=selectedPanelPaths(panels[active]);
|
||||
if(paths.empty()) return;
|
||||
std::wstring names;
|
||||
for(const auto &path:paths)
|
||||
{
|
||||
if(!names.empty()) names+=L"\r\n";
|
||||
names+=path.filename().native();
|
||||
}
|
||||
try { ks::writeClipboard(owner,ks::textClip(names)); }
|
||||
catch(const std::exception &) { setStatus(L"Could not copy file names."); }
|
||||
}
|
||||
|
||||
void refreshPanel(Panel &panel)
|
||||
{
|
||||
panel.folderSizeStop.request_stop();
|
||||
panel.folderSizeQuery={};
|
||||
panel.folderSizes.clear();
|
||||
open(panel,panel.directory,false);
|
||||
}
|
||||
|
||||
std::wstring powerShellPath(const fs::path &path)
|
||||
{
|
||||
std::wstring quoted=L"'";
|
||||
@@ -986,6 +1070,8 @@ bool ensureTerminalView(HWND owner)
|
||||
else if(message==L"insert-path") insertCurrentPanelPath();
|
||||
else if(message==L"insert-name") insertCurrentPanelPath(true);
|
||||
else if(message==L"copy-command-line") SendMessageW(terminalInput,WM_COPY,0,0);
|
||||
else if(message==L"copy-panel-names") copyPanelNames(owner);
|
||||
else if(message==L"refresh-panel") refreshPanel(panels[active]);
|
||||
else if(message==L"toggle") showTerminal(owner,!terminalVisible);
|
||||
else if(!terminalVisible && (message==L"grow" || message==L"shrink"))
|
||||
{
|
||||
@@ -1233,7 +1319,11 @@ void showFileDetails(const Panel &panel)
|
||||
if(statusFields&2)
|
||||
{
|
||||
const auto &size=panel.sizes[row];
|
||||
details+=L" "+(size==L"Folder" || size==L"Up"?size:formatSize(std::stoull(size)));
|
||||
const auto measured=panel.folderSizes.find(path);
|
||||
if(size==L"Folder" && measured!=panel.folderSizes.end())
|
||||
details+=L" "+formatSize(measured->second.bytes)+(measured->second.partial?L" (partial)":L"");
|
||||
else
|
||||
details+=L" "+(size==L"Folder" || size==L"Up"?size:formatSize(std::stoull(size)));
|
||||
}
|
||||
std::wstring timestamp=date;
|
||||
if((statusFields&4) && timestamp.size()>=12) details+=timestamp.substr(0,12);
|
||||
@@ -1333,6 +1423,12 @@ void openOn(Panel &panel,const fs::path &directory,bool offerElevation,std::opti
|
||||
}
|
||||
panel.directory = directory;
|
||||
panel.peer=std::move(peer);
|
||||
if(!sameDirectory)
|
||||
{
|
||||
panel.folderSizeStop.request_stop();
|
||||
panel.folderSizeQuery={};
|
||||
panel.folderSizes.clear();
|
||||
}
|
||||
if(!sameDirectory || nextWatch.handle!=INVALID_HANDLE_VALUE)
|
||||
{
|
||||
panel.watch.reset();
|
||||
@@ -1416,6 +1512,61 @@ void refreshChangedPanels()
|
||||
}
|
||||
}
|
||||
|
||||
void calculateFolderSizes(Panel &panel,LRESULT current)
|
||||
{
|
||||
if(panel.folderSizeQuery.valid())
|
||||
{
|
||||
setStatus(L"Calculating folder sizes...");
|
||||
return;
|
||||
}
|
||||
std::vector<fs::path> folders;
|
||||
for(size_t i=0;i<panel.rows.size();++i)
|
||||
if(panel.marked[i] && panel.sizes[i]==L"Folder") folders.push_back(panel.rows[i]);
|
||||
if(folders.empty()) folders.push_back(panel.rows[current]);
|
||||
|
||||
panel.folderSizeStop=std::stop_source{};
|
||||
std::packaged_task<FolderSizes()> task(
|
||||
[folders=std::move(folders),peer=panel.peer,stop=panel.folderSizeStop.get_token()]
|
||||
{
|
||||
FolderSizes results;
|
||||
try
|
||||
{
|
||||
FilesConnection host(peer?&*peer:nullptr);
|
||||
for(const auto &folder:folders)
|
||||
{
|
||||
if(stop.stop_requested()) break;
|
||||
results.emplace(folder,measureFolder(host,folder,stop));
|
||||
}
|
||||
}
|
||||
catch(const std::exception &)
|
||||
{
|
||||
for(const auto &folder:folders) results.try_emplace(folder,FolderSize{0,true});
|
||||
}
|
||||
return results;
|
||||
});
|
||||
panel.folderSizeQuery=task.get_future();
|
||||
try {std::thread(std::move(task)).detach();}
|
||||
catch(const std::system_error &error)
|
||||
{
|
||||
panel.folderSizeQuery={};
|
||||
setStatus(fileError(error));
|
||||
return;
|
||||
}
|
||||
setStatus(L"Calculating folder sizes...");
|
||||
}
|
||||
|
||||
void collectFolderSizes()
|
||||
{
|
||||
for(auto &panel:panels)
|
||||
{
|
||||
if(!panel.folderSizeQuery.valid() ||
|
||||
panel.folderSizeQuery.wait_for(std::chrono::seconds(0))!=std::future_status::ready) continue;
|
||||
for(const auto &[path,size]:panel.folderSizeQuery.get()) panel.folderSizes.insert_or_assign(path,size);
|
||||
InvalidateRect(panel.list,nullptr,FALSE);
|
||||
if(&panel==&panels[active]) showFileDetails(panel);
|
||||
}
|
||||
}
|
||||
|
||||
void openSelectedText(const Panel &panel, bool edit, bool external);
|
||||
INT_PTR confirmTextSave(HWND owner);
|
||||
INT_PTR paintTextDialog(HWND window, UINT message, WPARAM wp, LPARAM lp, const wchar_t *caption);
|
||||
@@ -1712,7 +1863,7 @@ void showRemoteDrives(bool focus=false,int initialRow=0)
|
||||
add(query.peer.name);
|
||||
if(query.pending.valid()) add(L" Loading drives...");
|
||||
else if(!query.error.empty()) add(L" "+query.error);
|
||||
else if(query.peer.address.empty()) add(refreshDriveAddresses?L" Looking for PC...":L" Offline");
|
||||
else if(query.peer.address.empty()) add(nextDriveRefresh?L" Looking for PC...":L" Offline");
|
||||
else if(query.drives.empty()) add(L" No drives");
|
||||
for(const auto &entry:query.drives)
|
||||
{
|
||||
@@ -1739,26 +1890,30 @@ void pollDriveQueries(HWND owner)
|
||||
return;
|
||||
}
|
||||
bool changed=false, pending=false;
|
||||
if(refreshDriveAddresses && GetTickCount64()-driveOpened>=500)
|
||||
const auto now=GetTickCount64();
|
||||
if(nextDriveRefresh && now>=nextDriveRefresh)
|
||||
{
|
||||
refreshDriveAddresses=false;
|
||||
nextDriveRefresh=now<driveRefreshDeadline?now+2000:0;
|
||||
queryDrivePeers();
|
||||
for(const auto &peer:drivePeers)
|
||||
if(std::none_of(driveQueries.begin(),driveQueries.end(),[&](const DriveQuery &query){return query.peer.id==peer.id;}))
|
||||
{
|
||||
auto entry=std::find_if(driveQueries.begin(),driveQueries.end(),[&](const DriveQuery &query)
|
||||
{return query.peer.id==peer.id;});
|
||||
if(entry==driveQueries.end())
|
||||
{
|
||||
auto &query=driveQueries.emplace_back();
|
||||
query.peer=peer;
|
||||
startDriveQuery(query);
|
||||
}
|
||||
for(auto &query:driveQueries)
|
||||
if(query.peer.address.empty())
|
||||
for(const auto &peer:drivePeers)
|
||||
if(peer.id==query.peer.id && !peer.address.empty())
|
||||
{
|
||||
query.peer=peer;
|
||||
startDriveQuery(query);
|
||||
break;
|
||||
}
|
||||
else if(!entry->pending.valid() && (entry->peer.address!=peer.address ||
|
||||
entry->peer.address.empty() || !entry->error.empty()))
|
||||
{
|
||||
entry->peer=peer;
|
||||
entry->drives=Json::array();
|
||||
entry->error.clear();
|
||||
startDriveQuery(*entry);
|
||||
}
|
||||
}
|
||||
changed=true;
|
||||
}
|
||||
for(auto &query:driveQueries)
|
||||
@@ -1772,7 +1927,8 @@ void pollDriveQueries(HWND owner)
|
||||
try {query.drives=query.pending.get();}
|
||||
catch(const std::system_error &e)
|
||||
{
|
||||
ks::log(L"LAN Files drive query failed: Windows error "+std::to_wstring(e.code().value()));
|
||||
ks::log(L"LAN Files drive query for "+query.peer.name+L" ("+ks::wide(query.peer.address)+
|
||||
L") failed: Windows error "+std::to_wstring(e.code().value()));
|
||||
if(e.code()==std::error_code(WSAETIMEDOUT,std::system_category()))
|
||||
query.error=L"Connection timed out";
|
||||
else
|
||||
@@ -1785,8 +1941,12 @@ void pollDriveQueries(HWND owner)
|
||||
}
|
||||
changed=true;
|
||||
}
|
||||
if(!pending && drivePeerLookupError.empty() &&
|
||||
std::none_of(driveQueries.begin(),driveQueries.end(),[](const DriveQuery &query)
|
||||
{return query.peer.address.empty() || !query.error.empty();}))
|
||||
nextDriveRefresh=0;
|
||||
if(changed) showRemoteDrives();
|
||||
if(!pending && !refreshDriveAddresses) KillTimer(owner,driveQueryTimer);
|
||||
if(!pending && !nextDriveRefresh) KillTimer(owner,driveQueryTimer);
|
||||
}
|
||||
|
||||
void chooseDrive(int index,bool fromMenu)
|
||||
@@ -1806,8 +1966,9 @@ void chooseDrive(int index,bool fromMenu)
|
||||
query.peer=peer;
|
||||
startDriveQuery(query);
|
||||
}
|
||||
refreshDriveAddresses=true;
|
||||
driveOpened=GetTickCount64();
|
||||
const auto now=GetTickCount64();
|
||||
nextDriveRefresh=now+500;
|
||||
driveRefreshDeadline=now+20000;
|
||||
const DWORD disks=GetLogicalDrives();
|
||||
int selected=0;
|
||||
int textWidth=0;
|
||||
@@ -3523,14 +3684,8 @@ void copySelection(HWND owner,Panel &source,Panel &destination,bool move)
|
||||
request.otherDirectory=destination.directory;
|
||||
request.sourcePeer=source.peer?&*source.peer:nullptr;
|
||||
request.otherPeer=request.destinationPeer=destination.peer?&*destination.peer:nullptr;
|
||||
for(size_t i=0;i<source.rows.size();++i)
|
||||
if(source.marked[i]) request.sources.push_back(source.rows[i]);
|
||||
if(request.sources.empty())
|
||||
{
|
||||
const auto row=SendMessageW(source.list,LB_GETCURSEL,0,0);
|
||||
if(row<0 || static_cast<size_t>(row)>=source.rows.size() || source.sizes[row]==L"Up") return;
|
||||
request.sources.push_back(source.rows[row]);
|
||||
}
|
||||
request.sources=selectedPanelPaths(source);
|
||||
if(request.sources.empty()) return;
|
||||
const auto result=FilesModalDialog::run(GetModuleHandleW(nullptr),MAKEINTRESOURCEW(102),owner,copyDialog,
|
||||
reinterpret_cast<LPARAM>(&request));
|
||||
if(result==-1) setStatus(L"Could not open the Copy dialog.");
|
||||
@@ -3834,15 +3989,8 @@ bool pumpDeletion(HWND window,bool &canceled)
|
||||
void deleteSelection(HWND owner,Panel &panel,bool permanent)
|
||||
{
|
||||
if(copyInProgress) return;
|
||||
std::vector<fs::path> paths;
|
||||
for(size_t i=0;i<panel.rows.size();++i)
|
||||
if(panel.marked[i] && panel.sizes[i]!=L"Up") paths.push_back(panel.rows[i]);
|
||||
if(paths.empty())
|
||||
{
|
||||
const auto row=SendMessageW(panel.list,LB_GETCURSEL,0,0);
|
||||
if(row<0 || static_cast<size_t>(row)>=panel.rows.size() || panel.sizes[row]==L"Up") return;
|
||||
paths.push_back(panel.rows[row]);
|
||||
}
|
||||
auto paths=selectedPanelPaths(panel);
|
||||
if(paths.empty()) return;
|
||||
const auto shown=std::min<size_t>(paths.size(),10);
|
||||
std::wstring entries;
|
||||
for(size_t i=0;i<shown;++i)
|
||||
@@ -4288,11 +4436,18 @@ LRESULT CALLBACK panelKeys(HWND window, UINT message, WPARAM wp, LPARAM lp, UINT
|
||||
{
|
||||
if(wp==VK_TAB) { activatePanel(static_cast<int>(1-index)); SetFocus(terminalInput); return 0; }
|
||||
if (wp == VK_RETURN) { enter(panels[index]); return 0; }
|
||||
if (wp == VK_F2) { open(panels[index], panels[index].directory); return 0; }
|
||||
if (wp == VK_F2)
|
||||
{
|
||||
refreshPanel(panels[index]);
|
||||
return 0;
|
||||
}
|
||||
if (wp == VK_F10) { SendMessageW(GetParent(window), WM_CLOSE, 0, 0); return 0; }
|
||||
if (wp == VK_F3 || wp == VK_F4)
|
||||
{
|
||||
openSelectedText(panels[index],wp==VK_F4,false);
|
||||
auto &panel=panels[index];
|
||||
const auto row=currentPanelRow(panel);
|
||||
if(wp==VK_F3 && row!=LB_ERR && panel.sizes[row]==L"Folder") calculateFolderSizes(panel,row);
|
||||
else openSelectedText(panel,wp==VK_F4,false);
|
||||
return 0;
|
||||
}
|
||||
if (wp == VK_F5 || wp == VK_F6)
|
||||
@@ -4380,7 +4535,7 @@ void openMenu(HWND window, int index)
|
||||
else if(index==1) rows={L"Copy\tF5",L"Move\tF6",L"Make folder\tF7",L"Exit\tF10"};
|
||||
else if(index==2)
|
||||
{
|
||||
rows={L"Refresh\tF2",L"View\tF3",L"Edit\tF4",L"Folder shortcuts",
|
||||
rows={L"Refresh panel\tCtrl+R",L"View\tF3",L"Edit\tF4",L"Folder shortcuts",
|
||||
L"View externally\tAlt+F3",L"Edit externally\tAlt+F4"};
|
||||
if(panels[active].peer)
|
||||
{
|
||||
@@ -4622,7 +4777,7 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
|
||||
updateTerminalOutput();
|
||||
return 0;
|
||||
}
|
||||
if(wp==directoryWatchTimer) { refreshChangedPanels(); return 0; }
|
||||
if(wp==directoryWatchTimer) { refreshChangedPanels(); collectFolderSizes(); return 0; }
|
||||
if(wp!=transferHighlightTimer) break;
|
||||
++transferHighlightPhase;
|
||||
for(auto &panel:panels)
|
||||
@@ -4674,7 +4829,7 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
|
||||
SetTimer(window,directoryWatchTimer,200,nullptr);
|
||||
if (!mono || !blue || !teal || !menuBar || !picker || !pickerFrame || !status || !panelSearchPopup) return -1;
|
||||
SendMessageW(status, WM_SETFONT, reinterpret_cast<WPARAM>(mono), FALSE);
|
||||
const wchar_t *labels[]{L"F2 Refresh", L"F3 View", L"F4 Edit", L"F5 Copy", L"F6 Move", L"F7 Mkdir", L"F10 Exit"};
|
||||
const wchar_t *labels[]{L"Ctrl+R Refresh", L"F3 View", L"F4 Edit", L"F5 Copy", L"F6 Move", L"F7 Mkdir", L"F10 Exit"};
|
||||
for (int i = 0; i < static_cast<int>(std::size(commands)); ++i)
|
||||
commands[i] = CreateWindowW(L"BUTTON", labels[i], WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
|
||||
0, 0, 0, 0, window, reinterpret_cast<HMENU>(110 + static_cast<INT_PTR>(i)), instance, nullptr);
|
||||
@@ -5098,7 +5253,14 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
|
||||
paintText(item.hDC,name,text.c_str(),foreground,rowBackground,false,rowFont);
|
||||
const auto &amount=panel.sizes[item.itemID];
|
||||
auto visible=amount;
|
||||
if(amount!=L"Folder" && amount!=L"Up")
|
||||
const auto measured=folder?panel.folderSizes.find(panel.rows[item.itemID]):panel.folderSizes.end();
|
||||
if(measured!=panel.folderSizes.end())
|
||||
{
|
||||
const auto partial=measured->second.partial;
|
||||
visible=formatSize(measured->second.bytes,static_cast<size_t>(sizeWidth)-(partial?1:0));
|
||||
if(partial) visible+=L"+";
|
||||
}
|
||||
else if(amount!=L"Folder" && amount!=L"Up")
|
||||
visible=formatSize(std::stoull(amount),static_cast<size_t>(sizeWidth));
|
||||
paintText(item.hDC,size,visible.c_str(),foreground,rowBackground,true);
|
||||
RECT line{size.left,size.top,size.left+1,size.bottom};
|
||||
@@ -5168,6 +5330,7 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
|
||||
DestroyWindow(window);
|
||||
return 0;
|
||||
case WM_DESTROY:
|
||||
for(auto &panel:panels) panel.folderSizeStop.request_stop();
|
||||
KillTimer(window,terminalTimer);
|
||||
KillTimer(window,directoryWatchTimer);
|
||||
for(auto &panel:panels) panel.watch.reset();
|
||||
@@ -5329,12 +5492,16 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR, int show)
|
||||
{
|
||||
const bool ctrl=(GetKeyState(VK_CONTROL)&0x8000)!=0;
|
||||
const bool shift=(GetKeyState(VK_SHIFT)&0x8000)!=0;
|
||||
if(ctrl && !shift && (message.wParam=='F' || message.wParam=='C' || message.wParam==VK_RETURN))
|
||||
if(ctrl && !shift &&
|
||||
(message.wParam=='F' || message.wParam=='C' || message.wParam=='R' ||
|
||||
message.wParam==VK_RETURN || message.wParam==VK_INSERT))
|
||||
{
|
||||
if(!(message.lParam & (1LL<<30)))
|
||||
{
|
||||
if(message.wParam=='F') insertCurrentPanelPath();
|
||||
else if(message.wParam=='R') refreshPanel(panels[active]);
|
||||
else if(message.wParam==VK_RETURN) insertCurrentPanelPath(true);
|
||||
else if(message.wParam==VK_INSERT) copyPanelNames(window);
|
||||
else SendMessageW(terminalInput,WM_COPY,0,0);
|
||||
}
|
||||
continue;
|
||||
|
||||
+7
-3
@@ -305,10 +305,15 @@ struct LanService::Impl
|
||||
std::lock_guard lock(mutex);
|
||||
if(shareInput&&trusted.contains(target)&&peers.contains(target))send(socket,peers.at(target).address,packet);
|
||||
});
|
||||
const bool filesListening=files.port()!=0;
|
||||
if(!filesListening) diagnosticEvent(L"LAN Files could not listen on TCP 45885.");
|
||||
bool filesListening=files.port()!=0;
|
||||
while(!stopping)
|
||||
{
|
||||
files.poll();
|
||||
if(filesListening!=(files.port()!=0))
|
||||
{
|
||||
filesListening=files.port()!=0;
|
||||
nextHello=0;
|
||||
}
|
||||
auto now=GetTickCount64();bool clipboardActive=false;
|
||||
std::vector<lan::InputEndpoint> endpoints;
|
||||
{
|
||||
@@ -346,7 +351,6 @@ struct LanService::Impl
|
||||
{std::lock_guard lock(inputMutex);out.swap(inputOut);}
|
||||
if(abortInput.exchange(false)){hub.disconnect();out.clear();}
|
||||
hub.poll(endpoints,out,in,now);
|
||||
files.poll();
|
||||
auto readyPeers=hub.ready();inputConnected=!readyPeers.empty();
|
||||
{std::lock_guard lock(inputMutex);inputReady=std::move(readyPeers);
|
||||
for(auto &frame:in){
|
||||
|
||||
+27
-13
@@ -1031,30 +1031,43 @@ struct FilesListener::Impl
|
||||
HostAction hibernate,update;
|
||||
WinSocket listener;
|
||||
std::vector<std::unique_ptr<Client>> clients;
|
||||
uint16_t boundPort{};
|
||||
uint16_t requestedPort{},boundPort{};
|
||||
ULONGLONG nextBind{};
|
||||
DWORD lastBindError{};
|
||||
Impl(std::string id,PairKey lookup,uint16_t port,TerminalPermission permission,HostAction hibernateAction,
|
||||
HostAction updateAction):
|
||||
local(std::move(id)),key(std::move(lookup)),terminalPermission(std::move(permission)),
|
||||
hibernate(std::move(hibernateAction)),update(std::move(updateAction))
|
||||
hibernate(std::move(hibernateAction)),update(std::move(updateAction)),requestedPort(port)
|
||||
{
|
||||
listener.value=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
|
||||
if(listener.value==INVALID_SOCKET) return;
|
||||
bindListener();
|
||||
}
|
||||
void bindListener()
|
||||
{
|
||||
nextBind=GetTickCount64()+1000;
|
||||
WinSocket candidate{socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)};
|
||||
BOOL exclusive=TRUE;
|
||||
u_long mode=1;
|
||||
sockaddr_in address{};
|
||||
address.sin_family=AF_INET;
|
||||
address.sin_port=htons(port);
|
||||
if(setsockopt(listener.value,SOL_SOCKET,SO_EXCLUSIVEADDRUSE,reinterpret_cast<const char*>(&exclusive),sizeof(exclusive)) ||
|
||||
ioctlsocket(listener.value,FIONBIO,&mode) ||
|
||||
bind(listener.value,reinterpret_cast<sockaddr*>(&address),sizeof(address)) ||
|
||||
listen(listener.value,8))
|
||||
address.sin_port=htons(requestedPort);
|
||||
int length=sizeof(address);
|
||||
if(candidate.value==INVALID_SOCKET ||
|
||||
setsockopt(candidate.value,SOL_SOCKET,SO_EXCLUSIVEADDRUSE,reinterpret_cast<const char*>(&exclusive),sizeof(exclusive)) ||
|
||||
ioctlsocket(candidate.value,FIONBIO,&mode) ||
|
||||
bind(candidate.value,reinterpret_cast<sockaddr*>(&address),sizeof(address)) ||
|
||||
listen(candidate.value,8) ||
|
||||
getsockname(candidate.value,reinterpret_cast<sockaddr*>(&address),&length))
|
||||
{
|
||||
closesocket(std::exchange(listener.value,INVALID_SOCKET));
|
||||
const auto error=static_cast<DWORD>(WSAGetLastError());
|
||||
if(requestedPort==FilesPort && lastBindError!=error)
|
||||
log(L"LAN Files TCP 45885 unavailable; retrying. Windows error "+std::to_wstring(error));
|
||||
lastBindError=error;
|
||||
return;
|
||||
}
|
||||
int length=sizeof(address);
|
||||
if(!getsockname(listener.value,reinterpret_cast<sockaddr*>(&address),&length))
|
||||
boundPort=ntohs(address.sin_port);
|
||||
listener.value=std::exchange(candidate.value,INVALID_SOCKET);
|
||||
boundPort=ntohs(address.sin_port);
|
||||
if(requestedPort==FilesPort) log(L"LAN Files listener ready on TCP 45885.");
|
||||
lastBindError=0;
|
||||
}
|
||||
void serve(SOCKET socket)
|
||||
{
|
||||
@@ -1089,6 +1102,7 @@ struct FilesListener::Impl
|
||||
void poll()
|
||||
{
|
||||
std::erase_if(clients,[](const auto &client){return client->done.load();});
|
||||
if(listener.value==INVALID_SOCKET && GetTickCount64()>=nextBind) bindListener();
|
||||
if(listener.value==INVALID_SOCKET || clients.size()>=16) return;
|
||||
sockaddr_in address{};
|
||||
int size=sizeof(address);
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include "platform.h"
|
||||
namespace ks
|
||||
{
|
||||
inline constexpr wchar_t AppVersion[] = L"0.6.90";
|
||||
inline constexpr wchar_t AppVersion[] = L"0.6.93";
|
||||
inline constexpr UINT UpdateMessage = WM_APP + 7;
|
||||
inline constexpr UINT UpdateCheckIntervalMs = 6 * 60 * 60 * 1000;
|
||||
inline constexpr UINT UpdateNotificationRetryMs = 5 * 60 * 1000;
|
||||
|
||||
@@ -270,6 +270,79 @@ try {
|
||||
}
|
||||
if ([FilesActivationUi]::Focus($window) -ne $inputBox) { throw 'Deletion moved focus.' }
|
||||
Write-Output 'Both panels refreshed external creation, modification and deletion while preserving focus.'
|
||||
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
$savedClipboard=[Windows.Forms.Clipboard]::GetDataObject()
|
||||
$programName=[IO.Path]::GetFileName($program)
|
||||
$expectedNames="Test folder`r`n$programName"
|
||||
try {
|
||||
Select-Row $left '[Test folder]'
|
||||
[void][FilesActivationUi]::Send($left,0x100,[IntPtr]45,[IntPtr]::Zero)
|
||||
Select-Row $left $programName
|
||||
[void][FilesActivationUi]::Send($left,0x100,[IntPtr]45,[IntPtr]::Zero)
|
||||
Wait-Until 'Files activation for Ctrl+Insert' {
|
||||
[FilesActivationUi]::Activate($window) -and [FilesActivationUi]::Focus($window) -eq $inputBox
|
||||
}
|
||||
$shell.SendKeys('^{INSERT}')
|
||||
Wait-Until 'Ctrl+Insert copying marked names in panel order' {
|
||||
[Windows.Forms.Clipboard]::GetText() -ceq $expectedNames
|
||||
}
|
||||
Select-Row $right $fileName
|
||||
$shell.SendKeys('^{INSERT}')
|
||||
Wait-Until 'Ctrl+Insert copying the current item in the other pane' {
|
||||
[Windows.Forms.Clipboard]::GetText() -ceq $fileName
|
||||
}
|
||||
Write-Output 'Ctrl+Insert copied marked names in order and used the cursor in the other pane.'
|
||||
} finally {
|
||||
if ([Windows.Forms.Clipboard]::GetText() -cin @($expectedNames,$fileName)) {
|
||||
if ($savedClipboard) { [Windows.Forms.Clipboard]::SetDataObject($savedClipboard,$true) }
|
||||
else { [Windows.Forms.Clipboard]::Clear() }
|
||||
}
|
||||
}
|
||||
|
||||
$sizeA=Join-Path $rightDir 'Size A'
|
||||
$sizeB=Join-Path $rightDir 'Size B'
|
||||
$sizeC=Join-Path $rightDir 'Size C'
|
||||
New-Item -ItemType Directory -Path "$sizeA\nested", $sizeB, $sizeC | Out-Null
|
||||
[IO.File]::WriteAllBytes("$sizeA\file.bin",[byte[]]::new(4))
|
||||
[IO.File]::WriteAllBytes("$sizeA\nested\file.bin",[byte[]]::new(7))
|
||||
[IO.File]::WriteAllBytes("$sizeB\file.bin",[byte[]]::new(23))
|
||||
[IO.File]::WriteAllBytes("$sizeC\file.bin",[byte[]]::new(31))
|
||||
Select-Row $right '[Size A]'
|
||||
[void][FilesActivationUi]::PostMessage($right,0x100,[IntPtr]0x72,[IntPtr]::Zero)
|
||||
Wait-Until 'F3 recursive size for the current folder' { (Read-Text $status) -ceq 'Size A 11 B' }
|
||||
foreach($name in 'Size A','Size B'){
|
||||
Select-Row $right "[$name]"
|
||||
[void][FilesActivationUi]::Send($right,0x100,[IntPtr]45,[IntPtr]::Zero)
|
||||
}
|
||||
Select-Row $right '[Size C]'
|
||||
[void][FilesActivationUi]::PostMessage($right,0x100,[IntPtr]0x72,[IntPtr]::Zero)
|
||||
Wait-Until 'completion of the marked size batch' { (Read-Text $status) -ceq 'Size C Folder' }
|
||||
Select-Row $right '[Size B]'
|
||||
Wait-Until 'F3 size for a marked folder' { (Read-Text $status) -ceq 'Size B 23 B' }
|
||||
Select-Row $right '[Size C]'
|
||||
if ((Read-Text $status) -cne 'Size C Folder') { throw 'F3 measured the unmarked cursor folder.' }
|
||||
Select-Row $right $fileName
|
||||
[void][FilesActivationUi]::PostMessage($right,0x100,[IntPtr]0x72,[IntPtr]::Zero)
|
||||
$viewerTitle='Viewer '+[char]0x2014+" $document"
|
||||
Wait-Until 'F3 opening a file when folders are marked' {
|
||||
[FilesActivationUi]::FindWindowEx([IntPtr]::Zero,[IntPtr]::Zero,'KSwitcher.Files.Text',$viewerTitle) -ne [IntPtr]::Zero
|
||||
}
|
||||
$viewer=[FilesActivationUi]::FindWindowEx([IntPtr]::Zero,[IntPtr]::Zero,'KSwitcher.Files.Text',$viewerTitle)
|
||||
[void][FilesActivationUi]::PostMessage($viewer,0x10,[IntPtr]::Zero,[IntPtr]::Zero)
|
||||
Write-Output 'F3 measured the current folder recursively and measured marked folders without measuring the unmarked cursor folder.'
|
||||
|
||||
Select-Row $right '[Size B]'
|
||||
Wait-Until 'Files activation for Ctrl+R' {
|
||||
[FilesActivationUi]::Activate($window) -and [FilesActivationUi]::Focus($window) -eq $inputBox
|
||||
}
|
||||
$shell.SendKeys('^r')
|
||||
Wait-Until 'Ctrl+R clearing the measured size and retaining the current folder' {
|
||||
(Read-Text $status) -ceq 'Size B Folder' -and
|
||||
[FilesActivationUi]::Send($right,0x188,[IntPtr]::Zero,[IntPtr]::Zero).ToInt32() -eq
|
||||
(Find-Row $right '[Size B]')
|
||||
}
|
||||
Write-Output 'Ctrl+R refreshed the active pane and kept its cursor.'
|
||||
} finally {
|
||||
if ($process -and !$process.HasExited) {
|
||||
[void]$process.CloseMainWindow()
|
||||
|
||||
@@ -230,7 +230,7 @@ try {
|
||||
[void][SearchArrowTest]::GetText($commandMenu,0x189,$i,$label)
|
||||
$label.ToString()
|
||||
})
|
||||
if (($rows -join '|') -cne "Refresh`tF2|Folder shortcuts||View`tF3|Edit`tF4|View externally`tAlt+F3|Edit externally`tAlt+F4") {
|
||||
if (($rows -join '|') -cne "Refresh panel`tCtrl+R|Folder shortcuts||View`tF3|Edit`tF4|View externally`tAlt+F3|Edit externally`tAlt+F4") {
|
||||
throw 'Commands did not group local actions or showed a LAN-only section.'
|
||||
}
|
||||
Post $commandMenu 0x100 40
|
||||
|
||||
@@ -133,6 +133,27 @@ int main()
|
||||
fs::create_directory(root);
|
||||
const auto client=randomHex(16),first=randomHex(16),second=randomHex(16),key=randomHex(32);
|
||||
auto lookup=[&](const std::string &id){return id==client?key:std::string{};};
|
||||
{
|
||||
auto previous=std::make_unique<FilesListener>(first,lookup,0);
|
||||
const auto port=previous->port();
|
||||
require(port!=0,"old listener bound before restart");
|
||||
FilesListener restarting(first,lookup,port);
|
||||
require(restarting.port()==0,"new listener must not take over an occupied port");
|
||||
previous.reset();
|
||||
const auto deadline=GetTickCount64()+4000;
|
||||
while(!restarting.port() && GetTickCount64()<deadline)
|
||||
{
|
||||
restarting.poll();
|
||||
Sleep(20);
|
||||
}
|
||||
require(restarting.port()==port,"listener automatically recovers after its port becomes available");
|
||||
std::jthread pollingRestarted([&](std::stop_token stop)
|
||||
{
|
||||
while(!stop.stop_requested()){restarting.poll();Sleep(5);}
|
||||
});
|
||||
FilesConnection recovered(FilesPeer{first,"127.0.0.1",L"Recovered",port},client,key);
|
||||
checkFileReply(recovered.call({{"action","drives"}}));
|
||||
}
|
||||
std::atomic<bool> allowTerminal{};
|
||||
std::atomic<unsigned> hibernateRequests{};
|
||||
std::atomic<unsigned> updateRequests{};
|
||||
|
||||
@@ -23,10 +23,15 @@ try {
|
||||
Copy-Item -LiteralPath (Join-Path ([Environment]::SystemDirectory) 'ping.exe') -Destination $path
|
||||
$companions+=Start-Process -FilePath $path -ArgumentList '-t','127.0.0.1' -WindowStyle Hidden -PassThru
|
||||
}
|
||||
$oldFiles=Join-Path $companionRoot 'KSwitcher.Files.exe'
|
||||
$backup=Join-Path $companionRoot '.kswitcher-update-0123456789abcdef0123456789abcdef/backup'
|
||||
[IO.Directory]::CreateDirectory($backup) | Out-Null
|
||||
Move-Item -LiteralPath $oldFiles -Destination $backup
|
||||
Stop-UpdateCompanions $companionRoot
|
||||
Assert (@($companions[0..2] | Where-Object HasExited).Count -eq 3) 'unattended update closes all companions in its installation'
|
||||
Assert (!$companions[3].HasExited) 'unattended update leaves a companion from another installation running'
|
||||
Assert (@(Get-Content -LiteralPath $Journal | Where-Object { $_ -match 'LAN update: Closing KSwitcher\.' }).Count -eq 3) 'unattended update journals every companion closure'
|
||||
Assert (@(Get-Content -LiteralPath $Journal | Where-Object { $_ -match 'LAN update: Closed KSwitcher\.' }).Count -eq 3) 'unattended update confirms each companion exited'
|
||||
} finally {
|
||||
foreach ($companion in $companions) {
|
||||
if (!$companion.HasExited) { $companion.Kill(); $companion.WaitForExit() }
|
||||
|
||||
Reference in new issue
Block a user