Compare commits

..
11 changed files with 351 additions and 111 deletions

No files matched your search

+7 -1
View File
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.24)
project(KSwitcher VERSION 0.6.97 LANGUAGES CXX RC)
project(KSwitcher VERSION 0.6.99 LANGUAGES CXX RC)
if(NOT WIN32)
message(FATAL_ERROR "KSwitcher uses native Windows APIs")
endif()
@@ -149,6 +149,12 @@ add_test(NAME files-activation-and-refresh
-File "${CMAKE_CURRENT_SOURCE_DIR}/tests/files_activation.ps1"
-Executable "$<TARGET_FILE:KSwitcherFiles>" -Fixture "$<TARGET_FILE:KSwitcherFilesActivationFixture>")
set_tests_properties(files-activation-and-refresh PROPERTIES RUN_SERIAL TRUE TIMEOUT 120)
add_test(NAME files-system-open
COMMAND "${KSWITCHER_POWERSHELL}" -NoProfile -ExecutionPolicy Bypass
-File "${CMAKE_CURRENT_SOURCE_DIR}/tests/files_activation.ps1"
-Executable "$<TARGET_FILE:KSwitcherFiles>" -Fixture "$<TARGET_FILE:KSwitcherFilesActivationFixture>"
-SystemOpenOnly)
set_tests_properties(files-system-open PROPERTIES RUN_SERIAL TRUE TIMEOUT 60)
find_program(KSWITCHER_NODE NAMES node)
if(KSWITCHER_NODE)
add_executable(KSwitcherFilesMarkdownLanFixture WIN32 tests/files_markdown_lan.cpp
+10 -2
View File
@@ -32,18 +32,26 @@ Warning і початковий фокус на No.
окремим процесом. BAT і CMD виконуються в поточній сесії вбудованого
термінала, а їхній вивід з’являється під панелями. Щоб відкрити файл із
панелі LAN, спочатку скопіюй його до локальної папки.
- Коли командний рядок порожній, Shift+Enter відкриває поточний локальний
елемент через Windows.
Папка відкривається у Провіднику, файл виконує свою стандартну дію Windows.
- У головному вікні клавіатурний фокус залишається в командному рядку.
Tab перемикає активну панель, клік вибирає рядок, а стрілки вгору й вниз,
Page Up і Page Down пересувають курсор у панелі навіть під час набору команди.
Стрілки вліво й вправо переходять до першого й останнього рядків, коли
командний рядок порожній.
Клік оновлює підсвічування рядків курсора без перемальовування всієї панелі.
Меню й діалоги тимчасово приймають фокус. Ctrl+V і Shift+Insert вставляють
текст із буфера обміну в позицію курсора або замінюють виділення.
Enter запускає введену команду або відкриває поточний елемент, якщо рядок
порожній. Escape очищає рядок.
Enter і Shift+Enter спочатку виконують введену команду. Коли рядок
порожній, Enter відкриває поточний елемент. Якщо панелі приховано,
Enter передає порожній рядок у термінал. Escape очищає рядок.
Промпт і текст команди вирівняні по спільній базовій лінії.
- **F8 Delete** у нижньому рядку клавіш викликає той самий діалог видалення,
що й клавіша F8.
- У нижньому рядку, як у FAR, позначення клавіш сірі на чорному тлі,
а назви дій темні на бірюзових сегментах.
- У віддаленій панелі Enter запускає введену команду PowerShell на
спареному ПК в поточному каталозі цієї панелі. Вивід і код завершення
з’являються в терміналі Files як текст. Службовий прогрес PowerShell
Binary file not shown.
+12
View File
@@ -1,5 +1,17 @@
# Latest Windows release
## v0.6.99 — 2026-11-16
In KSwitcher Files, Enter and Shift+Enter run the command in the command line, including when the file panes are hidden. With visible panes and an empty command line, the keys act on the selected item. A command reveals the terminal output if it was hidden. This release replaces v0.6.98.
**Українською.** У KSwitcher Files Enter і Shift+Enter виконують команду з командного рядка, зокрема коли файлові панелі приховані. Коли панелі видимі й рядок порожній, клавіші діють на вибраний елемент. Якщо вивід термінала приховано, команда відкриває його. Цей реліз замінює v0.6.98.
## v0.6.98 — 2026-11-16
In Files, Enter opens folders in the current pane, uses the Windows default action for local files, and runs BAT and CMD in the embedded terminal. Shift+Enter opens local folders in File Explorer and passes files, including BAT and CMD, to Windows. It preserves the draft command. Left and Right clear the previous cursor highlight when jumping to the first or last row. The FAR-style key bar uses gray key labels on black and dark action names on teal.
**Українською.** У Files Enter відкриває папки в поточній панелі, викликає стандартну дію Windows для локальних файлів, а BAT і CMD запускає у вбудованому терміналі. Shift+Enter відкриває локальні папки у Провіднику й передає файли, зокрема BAT і CMD, Windows. Чернетка команди зберігається. Стрілки вліво й вправо скидають старе підсвічування при переході до першого чи останнього рядка. Нижній рядок клавіш у стилі FAR має сірі позначення клавіш на чорному тлі й темні назви дій на бірюзовому.
## v0.6.97 — 2026-11-16
KSwitcher Files clears the highlight from the previous cursor row after a selection change and highlights the new row. It keeps the targeted repaint introduced in v0.6.96. This release replaces v0.6.96.
+1 -1
View File
@@ -1 +1 @@
25ed8a7d3920b1d85f09271f8882e79953e80916c49af673ddcc4a3af5437437 KSwitcher-win-x64.zip
c154e3b6d8042e83965850d395b2c0e7504a0abe5cbf98e0dc7db3988a8b9900 KSwitcher-win-x64.zip
+70 -70
View File
@@ -1,166 +1,166 @@
{
"schema": 1,
"files": [
{
"sha256": "b3ea22fe674be884f48475dd39d1841bef5b1598b3e36de9623755f779eb075e",
"path": "KSwitcher.exe",
"size": 2361856
"sha256": "dc44f9115be52e8642c349ffc737e00e57a6d758e918da6426bac9256720b0bf",
"size": 2361856,
"path": "KSwitcher.exe"
},
{
"sha256": "6c2ff14c22eeee192234b239f6bcdd54c53a195c12c016094d9295fc2d6ea6db",
"path": "KSwitcher.Config.exe",
"size": 2359808
"sha256": "4cd23521c58a85381819886cd42e8fbbca1941152247a7e199763676447777cf",
"size": 2359808,
"path": "KSwitcher.Config.exe"
},
{
"sha256": "ef3599f85c20f98eed827231a4ff279359126127d5e3e1b6525dee4b259cbd9e",
"path": "KSwitcher.Screenshot.exe",
"size": 3337216
"sha256": "ed3ccea0262caf8fef7c1f0098d7646f7e6239f9c44f3ae538ed819272bcdd7d",
"size": 3337216,
"path": "KSwitcher.Screenshot.exe"
},
{
"sha256": "b42acaa23b069307e532d4f403d318555512a30fca1d7400f4955e2cc15824cc",
"path": "KSwitcher.Files.exe",
"size": 3736576
"sha256": "abde48d42d1bd4a5968a682a688fab201bd16fcb21d11271c88dc3c0a349ad43",
"size": 3738112,
"path": "KSwitcher.Files.exe"
},
{
"sha256": "d3fce90bdeecb08596e377dea6a316354dd8949e32ff09b89d51be00c14e21b6",
"path": "WebView2Loader.dll",
"size": 194912
"size": 194912,
"path": "WebView2Loader.dll"
},
{
"sha256": "e256f01188af527e4d06d21d06fbf785ae9c50d4b328bf03cbe0ba7f0aa4228f",
"path": "terminal/addon-fit-LICENSE.txt",
"size": 1103
"size": 1103,
"path": "terminal/addon-fit-LICENSE.txt"
},
{
"sha256": "ba3ea256ce0620a0992a197d6c9baea64823fc93d8da07a9e366ca9943c18527",
"path": "terminal/addon-fit.js",
"size": 1521
"size": 1521,
"path": "terminal/addon-fit.js"
},
{
"sha256": "084d97a727b778fb10d31adcd557ee7840a38377ed60e0ef0f3ece93b349b1ef",
"path": "terminal/index.html",
"size": 527
"size": 527,
"path": "terminal/index.html"
},
{
"sha256": "792c48c5a849a15fdf9e37e8bcf9e6d1dd13b32b46c642a748a0a46a9919d473",
"path": "terminal/markdown-it-LICENSE.txt",
"size": 1073
"size": 1073,
"path": "terminal/markdown-it-LICENSE.txt"
},
{
"sha256": "391f2aa638e75e6c7859d0a5c5650ef0956722a45998f17e05b83bc655778e1e",
"path": "terminal/markdown-it.js",
"size": 100786
"size": 100786,
"path": "terminal/markdown-it.js"
},
{
"sha256": "27d3c6d39325d4995162911c352a8e20603513445683ceb0409e628949c39237",
"path": "terminal/markdown.html",
"size": 2212
"size": 2212,
"path": "terminal/markdown.html"
},
{
"sha256": "dbf9a062364dcc90b59fd98eb0adb0f153ed95accf26e28f7be9cce8c13ae324",
"path": "terminal/markdown.js",
"size": 6534
"size": 6534,
"path": "terminal/markdown.js"
},
{
"sha256": "ec9fb67dcb25eccc416ed56e1aab819222c805a2a4bfe4cb19e7556bf2ffde80",
"path": "terminal/mermaid-LICENSE.txt",
"size": 1089
"size": 1089,
"path": "terminal/mermaid-LICENSE.txt"
},
{
"sha256": "336df803d87a38b70a01e736e666c8f7601d2ce42f5e47c8fafe5d721074b9a3",
"path": "terminal/mermaid.js",
"size": 5537838
"size": 5537838,
"path": "terminal/mermaid.js"
},
{
"sha256": "0f3edde02b30e7b0f76d0cc88daae5791d720a4b74cf8b34e7c0b4dbe0cf9c9d",
"path": "terminal/terminal.js",
"size": 4478
"size": 4478,
"path": "terminal/terminal.js"
},
{
"sha256": "b569f629d00f2626a8100df2a1798210535621e42164dfd426a6fe5aac7b0ccd",
"path": "terminal/xterm-LICENSE.txt",
"size": 1261
"size": 1261,
"path": "terminal/xterm-LICENSE.txt"
},
{
"sha256": "854a7c0fb70e8b1a083c16797ab827299fb18744f5ad34f227b48337e33293c6",
"path": "terminal/xterm.css",
"size": 7112
"size": 7112,
"path": "terminal/xterm.css"
},
{
"sha256": "14903579ff54664cd72f8e8699e6961a6272c21863ec1c3b118cdc8af5d4a972",
"path": "terminal/xterm.js",
"size": 488663
"size": 488663,
"path": "terminal/xterm.js"
},
{
"sha256": "d3c81140cce01c26bf6cbf52aa40e0825e1fa35b9a91d1387170a65d2597082c",
"path": "LICENSE",
"size": 4401
"size": 4401,
"path": "LICENSE"
},
{
"sha256": "61e08da79c44061654015ce6b0c4061c23ee1dd18237fbf09e9bfda3c0ea2831",
"path": "json-LICENSE.txt",
"size": 1096
"size": 1096,
"path": "json-LICENSE.txt"
},
{
"sha256": "185c5a37521316e940ead89cbf0b1ba5862d810c7c966e6c6a14a4a515b23625",
"path": "files-text-license.txt",
"size": 883
"size": 883,
"path": "files-text-license.txt"
},
{
"sha256": "fca41227e9b38bf061298d69806ea66fb00086ae03aec49665e4f68ed2c3f8e9",
"path": "README.md",
"size": 94357
"size": 94357,
"path": "README.md"
},
{
"sha256": "2c13d3ed4761e679c352fb1ade24a1ec3060ad2862376ede801cdee5fcc3bada",
"path": "LAN-PREVIEW.md",
"size": 11418
"size": 11418,
"path": "LAN-PREVIEW.md"
},
{
"sha256": "d0c022b27b9fbc2ff7b6b8bec723cc1adc4eef517202f9ff77eed5d8bea3acb9",
"path": "dictionaries/en.txt",
"size": 732485
"size": 732485,
"path": "dictionaries/en.txt"
},
{
"sha256": "0bdfb0201d1803634f268cdff0993b8349d2c70e956a06dbb667c8dd65254ec5",
"path": "dictionaries/LICENSE-CC-BY-SA-4.0.txt",
"size": 20566
"size": 20566,
"path": "dictionaries/LICENSE-CC-BY-SA-4.0.txt"
},
{
"sha256": "3017bf44d3be9d9dfab21bd6778aa52b7947e61acf9ce2bc86b41d6e949ac311",
"path": "dictionaries/README.md",
"size": 2265
"size": 2265,
"path": "dictionaries/README.md"
},
{
"sha256": "80e6b6a27815973535f7facb636c597eb845dfee45cfabfc4e9b3341b9332849",
"path": "dictionaries/ru.txt",
"size": 1109134
"size": 1109134,
"path": "dictionaries/ru.txt"
},
{
"sha256": "98e5b3fe7304e37705c9e5ff48b0b399ccb16e806736d21f09921b99e5f2a408",
"path": "dictionaries/sources.json",
"size": 1280
"size": 1280,
"path": "dictionaries/sources.json"
},
{
"sha256": "d30e990d6ec2983c04f3644a3c61c6c668e8c542323f5931916fdd55b916eebf",
"path": "dictionaries/uk.txt",
"size": 940799
"size": 940799,
"path": "dictionaries/uk.txt"
},
{
"sha256": "a34b5161a8315af037e1ec71d816bfc688f7c364141d4ee2347cf0515ef0c82a",
"path": "tools/README.txt",
"size": 993
"size": 993,
"path": "tools/README.txt"
},
{
"sha256": "6ef5cf64708d62b7fc63c3c793cc99188a513433ff4774cae01dc014f6664376",
"path": "tools/StayHere.exe",
"size": 134656
"size": 134656,
"path": "tools/StayHere.exe"
},
{
"sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413",
"path": "tools/StayHere-README.md",
"size": 2796
"size": 2796,
"path": "tools/StayHere-README.md"
}
],
"version": "0.6.97"
"version": "0.6.99",
"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,97,0
PRODUCTVERSION 0,6,97,0
FILEVERSION 0,6,99,0
PRODUCTVERSION 0,6,99,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.97"
VALUE "FileVersion", "0.6.99"
END
END
BLOCK "VarFileInfo"
+75 -19
View File
@@ -1241,6 +1241,23 @@ bool submitTerminalCommand(const Panel &panel,const std::wstring &value)
return true;
}
void runCommandLine()
{
const auto value=terminalInputText();
if(!submitTerminalCommand(panels[active],value)) return;
if(value.find_first_not_of(L" \t\r\n")!=value.npos)
{
rememberCommand(value);
if(!terminalVisible && terminalRows==0)
{
terminalRows=5;
layout(GetParent(terminalInput));
}
}
terminalHistoryIndex=terminalHistory.size();
SetWindowTextW(terminalInput,L"");
}
LRESULT CALLBACK terminalInputKeys(HWND input,UINT message,WPARAM wp,LPARAM lp,UINT_PTR,DWORD_PTR)
{
if(message==WM_COPY || (message==WM_CHAR && wp==3))
@@ -1281,20 +1298,6 @@ LRESULT CALLBACK terminalInputKeys(HWND input,UINT message,WPARAM wp,LPARAM lp,U
SendMessageW(input,EM_REPLACESEL,TRUE,reinterpret_cast<LPARAM>(L""));
return 0;
}
if(message==WM_CHAR && wp==VK_RETURN)
{
if(!terminalVisible && !GetWindowTextLengthW(input))
{
SendMessageW(panels[active].list,WM_KEYDOWN,VK_RETURN,lp);
return 0;
}
const auto value=terminalInputText();
if(!submitTerminalCommand(panels[active],value)) return 0;
if(value.find_first_not_of(L" \t\r\n")!=std::wstring::npos) rememberCommand(value);
terminalHistoryIndex=terminalHistory.size();
SetWindowTextW(input,L"");
return 0;
}
if(message==WM_KEYDOWN && !terminalVisible && wp==VK_TAB)
{
activatePanel(1-active);
@@ -2061,6 +2064,14 @@ void chooseDrive(int index,bool fromMenu)
RedrawWindow(owner,nullptr,nullptr,RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_UPDATENOW);
}
void openPanelPathWithSystem(const Panel &panel,const fs::path &path,const wchar_t *verb,
const wchar_t *failureMessage)
{
if (reinterpret_cast<INT_PTR>(ShellExecuteW(GetParent(panel.list), verb, path.c_str(), nullptr,
panel.directory.c_str(), SW_SHOWNORMAL)) <= 32)
setStatus(failureMessage);
}
void openPanelFile(const Panel &panel, const fs::path &file, const wchar_t *verb, const wchar_t *failureMessage)
{
if(panel.peer)
@@ -2090,9 +2101,21 @@ void openPanelFile(const Panel &panel, const fs::path &file, const wchar_t *verb
return;
}
if(!verb && isExtension(L".exe")) verb=L"open";
if (reinterpret_cast<INT_PTR>(ShellExecuteW(GetParent(panel.list), verb, file.c_str(), nullptr,
panel.directory.c_str(), SW_SHOWNORMAL)) <= 32)
setStatus(failureMessage);
openPanelPathWithSystem(panel,file,verb,failureMessage);
}
void openSelectedWithSystem(const Panel &panel)
{
const auto row=currentPanelRow(panel);
if(row==LB_ERR) return;
if(panel.peer)
{
setStatus(L"Select a local item before opening it with Windows.");
return;
}
const bool folder=panel.sizes[row]==L"Folder" || panel.sizes[row]==L"Up";
openPanelPathWithSystem(panel,panel.rows[row],folder?L"explore":nullptr,
folder?L"Cannot open the selected folder in File Explorer.":L"Cannot open the selected file.");
}
#include "files_dialog_input.inl"
@@ -4486,8 +4509,11 @@ LRESULT CALLBACK panelKeys(HWND window, UINT message, WPARAM wp, LPARAM lp, UINT
showFileDetails(panel);
return 0;
}
if (message == WM_KEYDOWN && (wp == VK_LEFT || wp == VK_RIGHT))
return scrollList(window, message, wp == VK_LEFT ? VK_HOME : VK_END, lp);
if(message==WM_KEYDOWN)
{
if(wp==VK_LEFT) wp=VK_HOME;
else if(wp==VK_RIGHT) wp=VK_END;
}
if(message==WM_SETFOCUS) activatePanel(static_cast<int>(index));
if(message==WM_CHAR && wp>=32 && wp!=127)
{
@@ -5162,6 +5188,19 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
GetWindowTextW(item.hwndItem,label,64);
text=label;
}
if(std::find(std::begin(commands),std::end(commands),item.hwndItem)!=std::end(commands))
{
const auto separator=text.find(L' ');
auto key=text.substr(0,separator);
if(key.starts_with(L'F') && key.size()>1) key.erase(0,1);
auto shortcut=item.rcItem, action=item.rcItem;
shortcut.right=std::min(shortcut.right,shortcut.left+static_cast<LONG>(key.size())*cellWidth+8);
action.left=shortcut.right;
paintText(item.hDC,shortcut,key.c_str(),RGB(184,184,184),RGB(0,0,0));
if(action.left<action.right)
paintText(item.hDC,action,text.c_str()+separator+1,colors[Selection],colors[Footer]);
return TRUE;
}
auto background=item.CtlType==ODT_BUTTON?Footer:item.hwndItem==picker?Dialog:PanelBlue;
auto foreground=colors[Text];
if(item.hwndItem==picker && commandPicker && item.itemID<commandActions.size() && commandActions[item.itemID]<0)
@@ -5483,6 +5522,23 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR, int show)
if(message.hwnd==window && message.message>=WM_KEYFIRST && message.message<=WM_KEYLAST &&
GetFocus()==terminalInput)
message.hwnd=terminalInput;
if(message.message==WM_KEYDOWN && message.wParam==VK_RETURN &&
!(GetKeyState(VK_CONTROL)&0x8000) &&
!(GetKeyState(VK_MENU)&0x8000) && !(GetKeyState(VK_LWIN)&0x8000) &&
!(GetKeyState(VK_RWIN)&0x8000) && !copyInProgress &&
!commandHistoryWindow && !FilesModalDialog::activeFor(window) &&
!IsWindowVisible(menuBar) && !IsWindowVisible(picker) &&
(message.hwnd==terminalInput || message.hwnd==panels[0].list || message.hwnd==panels[1].list))
{
if(!(message.lParam & (1LL<<30)))
{
closePanelSearch();
if(terminalVisible || GetWindowTextLengthW(terminalInput)) runCommandLine();
else if(GetKeyState(VK_SHIFT)&0x8000) openSelectedWithSystem(panels[active]);
else enter(panels[active]);
}
continue;
}
if(!copyInProgress && handlePanelSearchKey(window,message)) continue;
if(!copyInProgress && !commandHistoryWindow && !FilesModalDialog::activeFor(window) && !terminalVisible &&
message.message==WM_SYSKEYDOWN && (message.wParam==VK_F3 || message.wParam==VK_F4) &&
+1 -1
View File
@@ -2,7 +2,7 @@
#include "platform.h"
namespace ks
{
inline constexpr wchar_t AppVersion[] = L"0.6.97";
inline constexpr wchar_t AppVersion[] = L"0.6.99";
inline constexpr UINT UpdateMessage = WM_APP + 7;
inline constexpr UINT UpdateCheckIntervalMs = 6 * 60 * 60 * 1000;
inline constexpr UINT UpdateNotificationRetryMs = 5 * 60 * 1000;
+73 -2
View File
@@ -1,6 +1,7 @@
param(
[Parameter(Mandatory)][string]$Executable,
[Parameter(Mandatory)][string]$Fixture
[Parameter(Mandatory)][string]$Fixture,
[switch]$SystemOpenOnly
)
$ErrorActionPreference = 'Stop'
Add-Type @"
@@ -149,7 +150,7 @@ try {
Copy-Item -LiteralPath "$source\WebView2Loader.dll", "$source\terminal" -Destination $app -Recurse
$program = Join-Path $leftDir 'Test program.exe'
Copy-Item -LiteralPath $Fixture -Destination $program
$document = Join-Path $rightDir "Test document$extension"
$document = Join-Path $(if($SystemOpenOnly){$leftDir}else{$rightDir}) "Test document$extension"
[IO.File]::WriteAllText($document, 'Document fixture')
$association = $classes.CreateSubKey($extension)
$association.SetValue('', $progId)
@@ -179,6 +180,76 @@ try {
$output = [FilesActivationUi]::GetDlgItem($window, 145)
$inputBox = [FilesActivationUi]::FindWindowEx($window, [IntPtr]::Zero, 'Edit', $null)
if($SystemOpenOnly) {
$keys = New-Object -ComObject WScript.Shell
$explorer = New-Object -ComObject Shell.Application
$existingExplorerWindows = @($explorer.Windows() | ForEach-Object { $_.HWND })
Wait-Until 'Files ready for Shift+Enter' {
[FilesActivationUi]::Activate($window) -and [FilesActivationUi]::Focus($window) -eq $inputBox
}
$folderRow=Find-Row $left '[Test folder]'
if($folderRow -lt 0){throw 'The folder fixture is missing.'}
[void][FilesActivationUi]::Send($left,0x186,[IntPtr]$folderRow,[IntPtr]::Zero)
$keys.SendKeys('+{ENTER}')
$folderWindow = $null
Wait-Until 'Shift+Enter opening the selected folder in Explorer' {
$script:folderWindow = $explorer.Windows() | Where-Object {
$_.Document.Folder.Self.Path -eq "$leftDir\Test folder"
} | Select-Object -First 1
$null -ne $script:folderWindow
}
if($folderWindow.HWND -notin $existingExplorerWindows){$folderWindow.Quit()}
if((Read-Text ([FilesActivationUi]::GetDlgItem($window,142))) -ne $leftDir){
throw 'Shift+Enter changed the folder in the Files panel.'
}
Wait-Until 'Files active for the registered document test' { [FilesActivationUi]::Activate($window) }
$documentRow=Find-Row $left ([IO.Path]::GetFileName($document))
if($documentRow -lt 0){throw 'The document fixture is missing.'}
[void][FilesActivationUi]::Send($left,0x186,[IntPtr]$documentRow,[IntPtr]::Zero)
Wait-Until 'Files command line focused for document Shift+Enter' {
[FilesActivationUi]::Focus($window) -eq $inputBox
}
$keys.SendKeys('+{ENTER}')
Wait-Until 'Shift+Enter invoking the default Windows file association' {
(Test-Path -LiteralPath "$document.opened") -and [IO.File]::ReadAllText("$document.opened") -eq 'opened'
}
Wait-Until 'Files active for plain Enter' { [FilesActivationUi]::Activate($window) }
[void][FilesActivationUi]::Write($inputBox,0x0C,[IntPtr]::Zero,'')
Remove-Item -LiteralPath "$document.opened"
$keys.SendKeys('{ENTER}')
Wait-Until 'plain Enter invoking the default Windows file association' {
(Test-Path -LiteralPath "$document.opened") -and [IO.File]::ReadAllText("$document.opened") -eq 'opened'
}
Write-Output 'Verified Shift+Enter opens folders in Explorer. Both Enter and Shift+Enter invoke the default file action.'
Remove-Item -LiteralPath "$document.opened"
foreach($case in @(
@{Name='enter-panes'; Keys='{ENTER}'},
@{Name='shift-enter-panes'; Keys='+{ENTER}'},
@{Name='enter-terminal'; Keys='{ENTER}'; HidePanes=$true},
@{Name='shift-enter-terminal'; Keys='+{ENTER}'}
)) {
Wait-Until 'Files command line active' {
[FilesActivationUi]::Activate($window) -and [FilesActivationUi]::Focus($window) -eq $inputBox
}
if($case.HidePanes){
$keys.SendKeys('^o')
Wait-Until 'file panes hidden' { ![FilesActivationUi]::IsWindowVisible($left) }
}
$marker=Join-Path $root "$($case.Name).txt"
$command="[IO.File]::AppendAllText('$($marker.Replace("'","''"))','executed')"
[void][FilesActivationUi]::Write($inputBox,0x0C,[IntPtr]::Zero,$command)
$keys.SendKeys($case.Keys)
Wait-Until "$($case.Name) running the command" {
(Test-Path -LiteralPath $marker) -and [IO.File]::ReadAllText($marker) -ceq 'executed'
}
if((Read-Text $inputBox) -or (Test-Path -LiteralPath "$document.opened")){
throw "$($case.Name) did not give the command line priority."
}
}
Write-Output 'Verified command-line priority for Enter and Shift+Enter with panels visible and hidden.'
return
}
Select-Row $left '..'
[void][FilesActivationUi]::Send($right, 0x186, [IntPtr]::Zero, [IntPtr]::Zero)
[void][FilesActivationUi]::Write($inputBox, 0x0C, [IntPtr]::Zero, 'draft command')
+99 -12
View File
@@ -1,4 +1,4 @@
param([Parameter(Mandatory)][string]$Executable)
param([Parameter(Mandatory)][string]$Executable,[switch]$KeyboardCursorOnly)
$ErrorActionPreference='Stop'
Add-Type -AssemblyName System.Drawing
Add-Type @"
@@ -104,6 +104,14 @@ function Click-PanelRow($Panel, $Row) {
Post $Panel 0x201 1 $point
Post $Panel 0x202 0 $point
}
function Read-PanelHighlights($Trace, $Start) {
$highlight=@{}
Get-Content -LiteralPath $Trace | Select-Object -Skip $Start |
ForEach-Object { if($_ -match '^\d+ panel-draw ([01]) (\d+) ([01]) '){
$highlight["$($Matches[1])/$($Matches[2])"]=$Matches[3]
} }
return $highlight
}
function Assert-FarCheckbox($Dialog, [int]$Id, $NextControl) {
$checkbox=[SearchArrowTest]::GetDlgItem($Dialog,$Id)
Post $Dialog 0x28 $checkbox 1
@@ -223,16 +231,41 @@ $scratch=Join-Path ([IO.Path]::GetDirectoryName((Resolve-Path -LiteralPath $Exec
New-Item -ItemType Directory -Path $scratch | Out-Null
$fixture = Join-Path $scratch ('files-editor-ui-' + [Guid]::NewGuid().ToString('N') + '.cs')
[IO.File]::WriteAllText($fixture, "public class Test {`r`n}`r`n")
foreach($name in 'A.txt','B.txt','C.txt','D.txt'){
[IO.File]::WriteAllText((Join-Path $scratch $name),'Cursor test fixture')
}
$rightFixture=Join-Path $scratch 'Right fixture'
New-Item -ItemType Directory -Path $rightFixture | Out-Null
foreach($name in 'A.txt','B.txt','C.txt','D.txt'){
[IO.File]::WriteAllText((Join-Path $rightFixture $name),'Cursor test fixture')
}
$copy=Join-Path $scratch 'KSwitcher.Files.search-arrow-test.exe'
Copy-Item -LiteralPath $Executable -Destination $copy
$process = Start-Process -FilePath $copy -ArgumentList '--terminal-trace' -PassThru -WindowStyle Normal
$paintTrace = Join-Path ([IO.Path]::GetTempPath()) "KSwitcher.Files.terminal-trace-$($process.Id).log"
$profile=[Microsoft.Win32.Registry]::CurrentUser.CreateSubKey('Software\KSwitcher\Files')
$keysToRestore='LeftPath','RightPath','LeftCursor','RightCursor','WindowPlacement'
$saved=@{}
foreach($name in $keysToRestore){
if($name -in $profile.GetValueNames()){
$saved[$name]=@($profile.GetValue($name),$profile.GetValueKind($name))
}
}
$process=$null
$paintTrace=$null
try {
$profile.SetValue('LeftPath',$scratch)
$profile.SetValue('RightPath',$rightFixture)
$profile.DeleteValue('LeftCursor',$false)
$profile.DeleteValue('RightCursor',$false)
$process=Start-Process -FilePath $copy -ArgumentList '--terminal-trace' -PassThru -WindowStyle Normal
$paintTrace=Join-Path ([IO.Path]::GetTempPath()) "KSwitcher.Files.terminal-trace-$($process.Id).log"
$previousDpi=[SearchArrowTest]::SetThreadDpiAwarenessContext([IntPtr](-4))
$main = Wait-Until { Find-Window 'KSwitcher.Files' $process.Id }
$leftPanel=[SearchArrowTest]::GetDlgItem($main,102)
$rightPanel=[SearchArrowTest]::GetDlgItem($main,103)
foreach($check in @(@{Panel=$leftPanel; Index=0},@{Panel=$rightPanel; Index=1},@{Panel=$rightPanel; Index=1})) {
$clicks=if(!$KeyboardCursorOnly){
@(@{Panel=$leftPanel; Index=0},@{Panel=$rightPanel; Index=1},@{Panel=$rightPanel; Index=1})
}
foreach($check in $clicks) {
$before=[SearchArrowTest]::Send($check.Panel,0x188,0,0).ToInt32()
$top=[SearchArrowTest]::Send($check.Panel,0x18E,0,0).ToInt32()
$row=if($before -eq $top){$top+1}else{$top}
@@ -242,11 +275,7 @@ try {
Click-PanelRow $check.Panel $row
[void](Wait-Until { [SearchArrowTest]::Send($check.Panel,0x188,0,0).ToInt32() -eq $row })
Start-Sleep -Milliseconds 150
$highlight=@{}
Get-Content -LiteralPath $paintTrace | Select-Object -Skip $lineCount |
ForEach-Object { if($_ -match '^\d+ panel-draw ([01]) (\d+) ([01]) '){
$highlight["$($Matches[1])/$($Matches[2])"]=$Matches[3]
} }
$highlight=Read-PanelHighlights $paintTrace $lineCount
$draws=@($highlight.Keys)
if("$($check.Index)/$row" -notin $draws -or $draws.Count -gt 3){
throw "Clicking a row repainted unrelated file rows. Drawn rows: $draws"
@@ -256,7 +285,7 @@ try {
throw 'The new row must be painted active and the previous visible row must lose its highlight.'
}
}
Write-Output 'Verified file clicks repaint only cursor rows in the active pane and when changing panes.'
if($clicks){Write-Output 'Verified file clicks repaint only cursor rows in the active pane and when changing panes.'}
Post $main 0x111 132
$commandMenu=Wait-Until {
$list=[SearchArrowTest]::GetDlgItem($main,121)
@@ -308,10 +337,63 @@ try {
}
$fixtureRow=[SearchArrowTest]::SendText($panel,0x1A2,-1,([IO.Path]::GetFileName($fixture))).ToInt32()
Click-PanelRow $panel $fixtureRow
[void](Wait-Until { [SearchArrowTest]::Send($panel,0x188,0,0).ToInt32() -eq $fixtureRow })
$inputBox=[SearchArrowTest]::FindWindowEx($main,0,'Edit',[NullString]::Value)
[void](Wait-Until { [SearchArrowTest]::FocusedControl($main) -eq $inputBox })
[void][SearchArrowTest]::SendText($inputBox,0xC,0,'')
$last=[SearchArrowTest]::Send($panel,0x18B,0,0).ToInt32()-1
$keys=@(
@{Name='Left'; Code=37; Row=0}
@{Name='Right'; Code=39; Row=$last}
@{Name='Left'; Code=37; Row=0}
@{Name='Down'; Code=40; Row=1}
@{Name='Up'; Code=38; Row=0}
@{Name='End'; Code=35; Row=$last}
@{Name='Home'; Code=36; Row=0}
@{Name='Page Down'; Code=34; Row=$last}
@{Name='Page Up'; Code=33; Row=0}
)
foreach($key in $keys){
$previous=[SearchArrowTest]::Send($panel,0x188,0,0).ToInt32()
Start-Sleep -Milliseconds 100
$lineCount=@(Get-Content -LiteralPath $paintTrace).Count
Post $inputBox 0x100 $key.Code
try {
[void](Wait-Until { [SearchArrowTest]::Send($panel,0x188,0,0).ToInt32() -eq $key.Row })
} catch {
$actual=[SearchArrowTest]::Send($panel,0x188,0,0).ToInt32()
throw "$($key.Name) selected row $actual, expected row $($key.Row)."
}
Start-Sleep -Milliseconds 150
$highlight=Read-PanelHighlights $paintTrace $lineCount
if($highlight["0/$($key.Row)"] -ne '1' -or $highlight["0/$previous"] -ne '0'){
throw "$($key.Name) left the previous row highlighted or did not paint the new row active."
}
}
Write-Output 'Verified cursor highlighting after arrows, Home, End, Page Up and Page Down from the command line.'
if($KeyboardCursorOnly){return}
Click-PanelRow $panel $fixtureRow
$deleteButton=[SearchArrowTest]::GetDlgItem($main,117)
$deleteLabel=[Text.StringBuilder]::new(64)
[void][SearchArrowTest]::GetText($deleteButton,0xD,$deleteLabel.Capacity,$deleteLabel)
if($deleteLabel.ToString() -cne 'F8 Delete'){throw 'The F8 Delete key bar button is missing.'}
$bounds=Read-Bounds $deleteButton
$windowBounds=Read-Bounds $main
$bitmap=[Drawing.Bitmap]::new($windowBounds.Right-$windowBounds.Left,$windowBounds.Bottom-$windowBounds.Top)
try {
$graphics=[Drawing.Graphics]::FromImage($bitmap)
try {
$dc=$graphics.GetHdc()
try { if(![SearchArrowTest]::PrintWindow($main,$dc,0)){throw 'Could not render the Files window.'} }
finally { $graphics.ReleaseHdc($dc) }
} finally {$graphics.Dispose()}
$y=$bounds.Top-$windowBounds.Top+1
$cap=$bitmap.GetPixel(($bounds.Left-$windowBounds.Left+1),$y)
$action=$bitmap.GetPixel(($bounds.Right-$windowBounds.Left-2),$y)
if($cap.ToArgb() -ne [Drawing.Color]::Black.ToArgb() -or $action.ToArgb() -eq $cap.ToArgb()){
throw 'The key bar no longer separates its dark key cap from the action segment.'
}
} finally {$bitmap.Dispose()}
Post $deleteButton 0xF5 0
$deleteDialog=Wait-Until { Find-Window '#32770' $process.Id 6 }
Post $deleteDialog 0x111 2
@@ -737,12 +819,17 @@ try {
if (!$process.WaitForExit(5000)) { throw 'Files did not exit after its last window closed.' }
}
finally {
if (!$process.HasExited) {
if ($process -and !$process.HasExited) {
Stop-Process -Id $process.Id
[void]$process.WaitForExit(5000)
}
if ($previousDpi) { [void][SearchArrowTest]::SetThreadDpiAwarenessContext($previousDpi) }
if(Test-Path -LiteralPath $paintTrace){Remove-Item -LiteralPath $paintTrace -Force}
if($paintTrace -and (Test-Path -LiteralPath $paintTrace)){Remove-Item -LiteralPath $paintTrace -Force}
foreach($name in $keysToRestore){
if($saved.ContainsKey($name)){$profile.SetValue($name,$saved[$name][0],$saved[$name][1])}
else{$profile.DeleteValue($name,$false)}
}
$profile.Dispose()
$resolved=(Resolve-Path -LiteralPath $scratch).Path
$root=(Resolve-Path -LiteralPath (Split-Path -Parent $scratch)).Path
if ([IO.Path]::GetDirectoryName($resolved) -eq $root -and (Split-Path -Leaf $resolved) -like 'search-arrow-test-*') {