Compare commits
23
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1aa432355 | ||
|
|
919f8e9c7c | ||
|
|
79aeff1c8b | ||
|
|
03f5a8db7c | ||
|
|
50804185f4 | ||
|
|
a9866d6973 | ||
|
|
7b70105168 | ||
|
|
b076dcb303 | ||
|
|
8bedb9ffbd | ||
|
|
8f52bf2a8f | ||
|
|
359b9ce284 | ||
|
|
160cece79d | ||
|
|
2869d584d8 | ||
|
|
2db1d79c1d | ||
|
|
fb27ad8843 | ||
|
|
879d2adcce | ||
|
|
356f472fd2 | ||
|
|
203d9ec68d | ||
|
|
f9cbb29c07 | ||
|
|
187334aed2 | ||
|
|
f7620d164f | ||
|
|
47e10477e1 | ||
|
|
f2e403dd39 |
No files matched your search
+26
-2
@@ -1,17 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(KSwitcher VERSION 0.8.3 LANGUAGES C CXX RC)
|
||||
project(KSwitcher VERSION 0.8.8 LANGUAGES C CXX RC)
|
||||
if(NOT WIN32)
|
||||
message(FATAL_ERROR "KSwitcher uses native Windows APIs")
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
add_executable(KSwitcherFiles WIN32 src/files_main.cpp src/files_text_window.cpp
|
||||
add_executable(KSwitcherFiles WIN32 src/files_main.cpp src/files_folder_size.cpp src/files_text_window.cpp
|
||||
src/files_text_document.cpp src/files_text_language.cpp src/files_archive.cpp src/files_git_changes.cpp
|
||||
src/files_mcp.cpp resources/files.rc)
|
||||
set_property(SOURCE resources/files.rc APPEND PROPERTY OBJECT_DEPENDS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/resources/kswitcher-files.ico"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/resources/kswitcher-files-viewer.ico"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/resources/kswitcher-files-editor.ico"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/resources/files-space-analyzer-controls.inc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/resources/kswitcher-files-compare.ico")
|
||||
include(cmake/FilesTextLibraries.cmake)
|
||||
include(cmake/FilesArchiveLibraries.cmake)
|
||||
@@ -150,6 +151,14 @@ else()
|
||||
target_link_options(KSwitcherOcrTests PRIVATE -static -static-libgcc -static-libstdc++)
|
||||
endif()
|
||||
enable_testing()
|
||||
add_executable(KSwitcherFilesFolderSizeTests tests/files_folder_size.cpp src/files_folder_size.cpp)
|
||||
target_include_directories(KSwitcherFilesFolderSizeTests PRIVATE src)
|
||||
target_compile_definitions(KSwitcherFilesFolderSizeTests PRIVATE UNICODE _UNICODE NOMINMAX _WIN32_WINNT=0x0A00)
|
||||
if(NOT MSVC)
|
||||
target_link_options(KSwitcherFilesFolderSizeTests PRIVATE -static)
|
||||
endif()
|
||||
add_test(NAME files-folder-size COMMAND KSwitcherFilesFolderSizeTests)
|
||||
set_tests_properties(files-folder-size PROPERTIES SKIP_RETURN_CODE 77)
|
||||
add_executable(KSwitcherFilesTextTests tests/files_text_document.cpp src/files_text_document.cpp)
|
||||
target_include_directories(KSwitcherFilesTextTests PRIVATE src)
|
||||
target_compile_definitions(KSwitcherFilesTextTests PRIVATE UNICODE _UNICODE NOMINMAX WIN32_LEAN_AND_MEAN)
|
||||
@@ -245,6 +254,16 @@ add_test(NAME files-recent-folders-panel
|
||||
-File "${CMAKE_CURRENT_SOURCE_DIR}/tests/files_recent_folders_panel.ps1"
|
||||
-Executable "$<TARGET_FILE:KSwitcherFiles>")
|
||||
set_tests_properties(files-recent-folders-panel PROPERTIES RUN_SERIAL TRUE TIMEOUT 35)
|
||||
add_test(NAME files-drive-picker
|
||||
COMMAND "${KSWITCHER_POWERSHELL}" -NoProfile -ExecutionPolicy Bypass
|
||||
-File "${CMAKE_CURRENT_SOURCE_DIR}/tests/files_drive_shortcuts.ps1"
|
||||
-Executable "$<TARGET_FILE:KSwitcherFiles>" -FtpProfiles)
|
||||
set_tests_properties(files-drive-picker PROPERTIES RUN_SERIAL TRUE TIMEOUT 45)
|
||||
add_test(NAME files-lavender-drive-picker
|
||||
COMMAND "${KSWITCHER_POWERSHELL}" -NoProfile -ExecutionPolicy Bypass
|
||||
-File "${CMAKE_CURRENT_SOURCE_DIR}/tests/files_lavender.ps1"
|
||||
-Executable "$<TARGET_FILE:KSwitcherFiles>" -DrivePickerOnly)
|
||||
set_tests_properties(files-lavender-drive-picker PROPERTIES RUN_SERIAL TRUE TIMEOUT 25)
|
||||
add_test(NAME files-lavender
|
||||
COMMAND "${KSWITCHER_POWERSHELL}" -NoProfile -ExecutionPolicy Bypass
|
||||
-File "${CMAKE_CURRENT_SOURCE_DIR}/tests/files_lavender.ps1"
|
||||
@@ -255,6 +274,11 @@ add_test(NAME files-space-analyzer-layout
|
||||
-File "${CMAKE_CURRENT_SOURCE_DIR}/tests/files_space_analyzer_layout.ps1"
|
||||
-Executable "$<TARGET_FILE:KSwitcherFiles>")
|
||||
set_tests_properties(files-space-analyzer-layout PROPERTIES RUN_SERIAL TRUE TIMEOUT 25)
|
||||
add_test(NAME files-space-analyzer-pane
|
||||
COMMAND "${KSWITCHER_POWERSHELL}" -NoProfile -ExecutionPolicy Bypass
|
||||
-File "${CMAKE_CURRENT_SOURCE_DIR}/tests/files_space_analyzer_pane.ps1"
|
||||
-Executable "$<TARGET_FILE:KSwitcherFiles>")
|
||||
set_tests_properties(files-space-analyzer-pane PROPERTIES RUN_SERIAL TRUE TIMEOUT 30)
|
||||
find_program(KSWITCHER_NODE NAMES node)
|
||||
if(KSWITCHER_NODE)
|
||||
add_test(NAME files-terminal-enter
|
||||
|
||||
+21
-14
@@ -5,6 +5,8 @@
|
||||
власних діалогів та налаштувань. Діалоги файлових операцій мають темний
|
||||
заголовок, помітну рамку й білі поля на лавандовому тлі. Попередження мають
|
||||
червоний заголовок. За замовчуванням увімкнено Far. Гарячі клавіші діють в обох стилях.
|
||||
У Lavender меню вибору диска, меню команд, пошук панелі та підказки команд мають
|
||||
світло-лавандове тло та контрастну фіолетову рамку завтовшки 2 пікселі за масштабу 100%.
|
||||
|
||||
Far Manager є зразком для оформлення файлового менеджера. Основне вікно використовує системний заголовок Windows. Панелі, меню й діалоги операцій використовують моноширинний шрифт менеджера та оформлення в стилі Far.
|
||||
Іконка головного вікна показує дві сині панелі з бірюзовою рамкою та виділеним рядком.
|
||||
@@ -181,9 +183,10 @@ Warning і початковий фокус на No.
|
||||
переходять між першим і останнім пунктами циклічно та оминають розділювачі.
|
||||
У меню джерел горизонтальна лінія відділяє FTP від локальних дисків,
|
||||
а заголовок KSwitcher LAN відділяє LAN-ресурси від FTP, SFTP і SMB.
|
||||
Літера відкриває локальний диск, цифра 1 відкриває FTP. Для LAN-дисків
|
||||
і Wake меню показує доступні цифри 2–9 і 0. Призначена цифра зберігається
|
||||
до закриття меню, навіть коли оновлюється список LAN.
|
||||
Літера відкриває локальний диск. Цифри **1**, **2**, **3** і **4** відкривають
|
||||
FTP, SFTP, SMB і Recent folders відповідно. Для LAN-дисків і Wake доступні
|
||||
цифри 5–9 і 0. У меню лише для LAN доступні цифри 2–9 і 0.
|
||||
Призначена цифра зберігається до закриття меню, навіть коли оновлюється список LAN.
|
||||
|
||||
- Enter і подвійний клік відкривають папку в поточній панелі, а локальний
|
||||
документ — у програмі, призначеній для його типу у Windows. EXE запускається
|
||||
@@ -465,6 +468,8 @@ Warning і початковий фокус на No.
|
||||
повторює спробу в тому самому вікні. Якщо форматований перегляд недоступний
|
||||
або файл більший за 8 МіБ, F3 відкриває текстовий перегляд.
|
||||
- F3 у фоні підраховує сумарний розмір файлів у папці та її підпапках.
|
||||
На локальному NTFS підрахунок читає записи каталогів пакетами та паралельно
|
||||
обходить підпапки. Для інших файлових систем діє звичайний обхід.
|
||||
На рядку `..` F3 рахує всі папки поточного списку, а за наявності
|
||||
позначених папок в інших рядках рахує позначені папки. Без позначок
|
||||
F3 рахує папку під курсором або відкриває файл. Папки обробляються по черзі,
|
||||
@@ -601,23 +606,24 @@ Warning і початковий фокус на No.
|
||||
коли вимірювання недоступне. Якщо попереднє число є, позначка ! відрізняє
|
||||
його від свіжого результату.
|
||||
|
||||
- **Commands → Space Analyzer** показує місткість і вільне місце за даними
|
||||
Windows перед скануванням. Volume вибирає корінь тому, Folder повертає
|
||||
поточну локальну папку, Start запускає фоновий аналіз тим самим обходом,
|
||||
що й підрахунок розмірів F3. Посилання на каталоги всередині області
|
||||
сканування позначаються як link. Stop залишає часткові результати, а
|
||||
Rescan повторює аналіз із початку.
|
||||
- Дерево показує логічний розмір, зайняті байти та частку логічного розміру
|
||||
від батьківської папки. Знак + позначає частковий підрахунок. Зайняті байти
|
||||
- **Left → Space Analyzer** або **Right → Space Analyzer** відкриває аналіз
|
||||
локальної папки в цій панелі та запускає сканування. **Close** або Esc
|
||||
повертає список файлів. **Commands → Space Analyzer** відкриває діалог,
|
||||
де **Start** запускає аналіз після показу місткості та вільного простору.
|
||||
**Volume** вибирає корінь тому, а **Folder** повертає поточну локальну папку.
|
||||
**Stop** залишає часткові результати. **Rescan** запускає аналіз заново.
|
||||
- **Logical size** і **Size on disk** перемикають метрику дерева, часток
|
||||
від батьківської папки та обох графіків. Посилання позначаються як link.
|
||||
Знак + позначає частковий підрахунок. Зайняті байти
|
||||
підсумовуються за файловими записами, включно з окремими іменами для
|
||||
жорстких посилань. Службові дані файлової системи в цей підсумок не входять.
|
||||
Відсутні дані про зайняті байти позначаються в рядку стану.
|
||||
- Treemap показує дочірні елементи вибраної папки прямокутниками,
|
||||
пропорційними до їхнього логічного розміру. Дрібні елементи доступні в
|
||||
пропорційними до їхнього розміру за вибраною метрикою. Дрібні елементи доступні в
|
||||
дереві. Клік по плитці відкриває точний елемент у сусідній панелі. Стрілки
|
||||
переводять фокус між плитками, Enter відкриває плитку у фокусі.
|
||||
- Sunburst показує до трьох рівнів вкладеності секторами за логічним
|
||||
розміром. Клік по сектору та Enter у відповідному рядку списку ведуть
|
||||
- Sunburst показує до трьох рівнів вкладеності секторами за вибраною метрикою.
|
||||
Клік по сектору та Enter у відповідному рядку списку ведуть
|
||||
до одного елемента. Обраний рядок підсвічує відповідний сектор.
|
||||
- Під час аналізу всього NTFS-тому Files використовує індекс MFT за
|
||||
наявності доступу Windows. Звичайний обхід працює без такого доступу.
|
||||
@@ -642,6 +648,7 @@ Warning і початковий фокус на No.
|
||||
- Коли список LAN-дисків змінює розмір меню Change drive, рамка й список
|
||||
змінюють позицію разом. Рамка повністю перемальовується після зміни
|
||||
розміру, а список має однаковий внутрішній відступ зліва і справа.
|
||||
Смуга прокрутки має окреме місце, щоб не обрізати значення вільного місця.
|
||||
- Тайм-аут запиту дисків відображається як Connection timed out. Якщо
|
||||
ввімкнено Write log, Files записує помилки запитів пар і дисків в окремий
|
||||
журнал `data/kswitcher-files.log`. Системні помилки містять код Windows. Commands → Files log відкриває до 200 останніх записів поточного або попереднього журналу. Refresh оновлює список. Copy selected або Ctrl+C копіює дату й безпечний опис вибраного запису. Довільні текстові деталі приховано.
|
||||
|
||||
@@ -1044,6 +1044,16 @@ embedded in KSwitcher.Files.exe.
|
||||
.\tests\configuration.ps1 # Separate-process settings tests; close KSwitcher first
|
||||
```
|
||||
|
||||
To check snippet suggestions in a WebView2 app, focus a blank editable field and
|
||||
run `KSwitcherIntegration.exe --snippet-external-editor` without changing the
|
||||
foreground window. The test types `;`, checks that the popup opens without
|
||||
stealing focus, dismisses it, and removes the test character. In Dirlume, repeat
|
||||
in the Command line, the terminal at an idle prompt, and the text editor. Use
|
||||
`--insert` as the second argument to test Tab insertion in a blank text field.
|
||||
With a Dirlume build that supports KSwitcher terminal insertion, use
|
||||
`--terminal-insert` at a blank shell prompt and check that `snippet test`
|
||||
appears as an editable draft. Clear that draft without submitting it.
|
||||
|
||||
`-Test` also checks remote/own input separation, hidden Settings layout and scrolling, and updater
|
||||
package validation, file preservation and rollback in temporary fixture directories. It does not
|
||||
replace a running installation. Optional read-only network checks:
|
||||
|
||||
@@ -1,5 +1,47 @@
|
||||
# Latest Windows release
|
||||
|
||||
## v0.8.8 — 2026-11-28
|
||||
|
||||
In Lavender, **Change drive**, command menus, panel search and command suggestions use a light lavender background and a contrasting purple outline, 2 pixels thick at 100% scaling.
|
||||
|
||||
**Українською.** У Lavender меню **Change drive**, меню команд, пошук панелі й підказки команд мають світло-лавандове тло та контрастну фіолетову рамку завтовшки 2 пікселі за масштабу 100%.
|
||||
|
||||
## v0.8.7 — 2026-11-28
|
||||
|
||||
In **Change drive** (Alt+F1 or Alt+F2), press **1** for FTP, **2** for SFTP, **3** for SMB or **4** for Recent folders. The scroll bar has its own space so it does not clip the free-space column.
|
||||
|
||||
**Українською.** У **Change drive** (Alt+F1 або Alt+F2) клавіші **1**, **2**, **3** і **4** відкривають FTP, SFTP, SMB і нещодавні папки відповідно. Для смуги прокрутки відведено окреме місце, щоб не обрізати значення вільного місця.
|
||||
|
||||
## v0.8.6 — 2026-11-28
|
||||
|
||||
- **Updater.** Checking for updates requests only the latest stable Gitea release, avoiding timeouts while loading the release history. If the older updater still times out, install this release using the complete portable ZIP.
|
||||
- **Layout conversion.** Recent text selection can recover after delayed editor selection in apps such as Claude. When several layouts produce the same recent text, KSwitcher prefers the layout used to type it.
|
||||
- **Files.** Open **Space Analyzer** from **Left** or **Right** to scan in that pane. **Logical size** and **Size on disk** apply to the tree and charts. Local NTFS folder sizes use batched directory reads and parallel traversal.
|
||||
|
||||
**Українською.**
|
||||
|
||||
- **Оновлення.** KSwitcher запитує в Gitea лише останній стабільний реліз. Це усуває тайм-аут під час завантаження історії релізів. Якщо старий оновлювач і далі не відповідає, встановіть цей реліз із повного портативного ZIP.
|
||||
- **Перетворення розкладки.** KSwitcher може відновити виділення нещодавнього тексту в редакторах із затримкою виділення, зокрема в Claude. Якщо кілька розкладок дають той самий набраний текст, KSwitcher віддає перевагу розкладці, у якій його набрано.
|
||||
- **Files.** **Space Analyzer** у меню **Left** або **Right** запускає аналіз у вибраній панелі. **Logical size** і **Size on disk** діють у дереві й на графіках. Підрахунок розміру папок на NTFS використовує пакетне читання й паралельний обхід.
|
||||
|
||||
## v0.8.5 — 2026-11-28
|
||||
|
||||
- **Snippets in Dirlume.** Type `;` to see matching KSwitcher snippets in the command line, editor, other editable fields and embedded terminal. A compatible Dirlume build accepts a single-line snippet with **Tab** at a supported shell prompt and leaves the command editable. Terminal insertion excludes key actions and pauses.
|
||||
|
||||
**Українською.**
|
||||
|
||||
- **Сніпети в Dirlume.** Введіть `;`, щоб побачити підказки KSwitcher у командному рядку, редакторі, інших текстових полях і вбудованому терміналі. У сумісній збірці Dirlume клавіша **Tab** вставляє однорядковий сніпет у рядок підтримуваної оболонки й залишає команду доступною для редагування. Термінал не вставляє сніпети з клавіатурними діями або паузами.
|
||||
|
||||
## v0.8.4 — 2026-11-27
|
||||
|
||||
- **Settings.** Open **Languages → Languages for a chat** in the Settings tree to search for a chat and choose its keyboard layouts. Save changes with **Apply** or **Save**.
|
||||
- **Trusted LAN clients.** Clients such as Dirlume can ask how to handle individual file conflicts during copy or move. When supported, choose to replace, skip or cancel.
|
||||
|
||||
**Українською.**
|
||||
|
||||
- **Налаштування.** Відкрийте **Languages → Languages for a chat** у дереві Settings, щоб знайти чат і вибрати його розкладки. Застосуйте зміни кнопкою **Apply** або **Save**.
|
||||
- **Довірені клієнти LAN.** Клієнти на кшталт Dirlume можуть запитувати, як обробити окремі конфлікти файлів під час копіювання або переміщення. Якщо клієнт підтримує цю можливість, виберіть заміну, пропуск або скасування.
|
||||
|
||||
## v0.8.3 — 2026-11-26
|
||||
|
||||
- **Files.** Lavender now shows compact path segments with chevrons above both panes. The current folder has a rounded highlight. Click an ancestor to open it, the current folder to edit the path, or an ellipsis to reveal hidden folders.
|
||||
|
||||
@@ -1 +1 @@
|
||||
0726c819b43cd1508c4fa22b717ab13b0da826f5a48bbc3a4b0f10e6418d207a KSwitcher-win-x64.zip
|
||||
c0efa5d6ea85b408439d6879968f6f667a3a537c7d6ff8ced9b5c5d98e7de6e2 KSwitcher-win-x64.zip
|
||||
+80
-80
@@ -1,181 +1,181 @@
|
||||
{
|
||||
"version": "0.8.3",
|
||||
"schema": 1,
|
||||
"files": [
|
||||
{
|
||||
"sha256": "134aff7d86cdba13eecf9e32a0556e0267c0900800bd6dc1e9b005729190eb7a",
|
||||
"path": "KSwitcher.exe",
|
||||
"size": 3247616
|
||||
"sha256": "e40a89e8af4f783d76d38de7e77847727938813d5421d103e60469b83a3b9be4",
|
||||
"size": 3265536,
|
||||
"path": "KSwitcher.exe"
|
||||
},
|
||||
{
|
||||
"sha256": "7f90f6af18c9ac7f9e0f8255bfd339c49c9ea28e2da88d6b6e3443f6a867a1dd",
|
||||
"path": "KSwitcher.Config.exe",
|
||||
"size": 2849792
|
||||
"sha256": "1e86f3b6e94b619715201b30cf27b9a1db41f25cb73f7defbc1b7eccf77bb16f",
|
||||
"size": 2850304,
|
||||
"path": "KSwitcher.Config.exe"
|
||||
},
|
||||
{
|
||||
"sha256": "f010f82aba8ace45abf0b90db991804964c1ec18f783a4169add56f478c96344",
|
||||
"path": "KSwitcher.Screenshot.exe",
|
||||
"size": 3193344
|
||||
"sha256": "56f1f0cd70bc6089b8964fea8ae3b25461648ae7481404283878810ded39279b",
|
||||
"size": 3193344,
|
||||
"path": "KSwitcher.Screenshot.exe"
|
||||
},
|
||||
{
|
||||
"sha256": "caa66e3d8cddd094f1de317fb1a6410d4413f30034cdb61f130d7fcee21004bb",
|
||||
"path": "KSwitcher.Files.exe",
|
||||
"size": 6000640
|
||||
"sha256": "12007fa59dbdc0cb2354a993cd7f64a482605a3a8a91705d6030efcc6c373f12",
|
||||
"size": 6018048,
|
||||
"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": "98984c8f76bd231dab00ef54034bfc2f29b365ee0b31c05edb16ad5216bd5bc2",
|
||||
"path": "terminal/markdown.html",
|
||||
"size": 3800
|
||||
"size": 3800,
|
||||
"path": "terminal/markdown.html"
|
||||
},
|
||||
{
|
||||
"sha256": "8b5429a035ce8ce11f77a222b5ee946844fd1e2999e1bb5c8f7c030ddbb1ff96",
|
||||
"path": "terminal/markdown.js",
|
||||
"size": 18721
|
||||
"size": 18721,
|
||||
"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": "838707e2813f7d007f7f60670a78ae4a4a6c97ca9a235d623cb85e16dc50e0c7",
|
||||
"path": "terminal/terminal.js",
|
||||
"size": 6627
|
||||
"size": 6627,
|
||||
"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": "57d6d9b1f85ac93b3bc73f6f7bdf4346e896c4644d6fa461c380ae29070c029d",
|
||||
"path": "files-archive-license.txt",
|
||||
"size": 4990
|
||||
"size": 4990,
|
||||
"path": "files-archive-license.txt"
|
||||
},
|
||||
{
|
||||
"sha256": "7997c62a2f766674ceb99976485a6cf5c772309e79101a400c421d526b82f6e4",
|
||||
"path": "files-image-license.txt",
|
||||
"size": 3044
|
||||
"size": 3044,
|
||||
"path": "files-image-license.txt"
|
||||
},
|
||||
{
|
||||
"sha256": "19c254c71ee49aefbd8854ac55b05d719c5f1e4f8ef9a982324b898501b39594",
|
||||
"path": "files-sftp-license.txt",
|
||||
"size": 2064
|
||||
"size": 2064,
|
||||
"path": "files-sftp-license.txt"
|
||||
},
|
||||
{
|
||||
"sha256": "be1b3fca2a291284ab550e9e77042fb27ecf927861d2d8fb8ec4907258477f01",
|
||||
"path": "README.md",
|
||||
"size": 105515
|
||||
"sha256": "7d727e102fc77ea6942c3a68cf3564709807cafc32431505469289a1e9b7fb99",
|
||||
"size": 106600,
|
||||
"path": "README.md"
|
||||
},
|
||||
{
|
||||
"sha256": "917c2f41b3943647fdfafa911d93f72b8c6fb0d08592016ce1a698d256e038bb",
|
||||
"path": "LAN-PREVIEW.md",
|
||||
"size": 16722
|
||||
"sha256": "4eac1f410e6b544aa45756e24f4fdfe9193c6f732410656160be54ab27a0d7e4",
|
||||
"size": 17245,
|
||||
"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": "b6a36bcdc26fc6bb55083e023e2fafb60236e541e9b1b7e598c66816a3089175",
|
||||
"path": "tools/StayHere.exe",
|
||||
"size": 133120
|
||||
"sha256": "a7cb5eb8d8aeccfb477f4238c6c4c274b57772069f4afb074e2c96579b51c39f",
|
||||
"size": 133120,
|
||||
"path": "tools/StayHere.exe"
|
||||
},
|
||||
{
|
||||
"sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413",
|
||||
"path": "tools/StayHere-README.md",
|
||||
"size": 2796
|
||||
"size": 2796,
|
||||
"path": "tools/StayHere-README.md"
|
||||
}
|
||||
]
|
||||
],
|
||||
"schema": 1,
|
||||
"version": "0.8.8"
|
||||
}
|
||||
+3
-3
@@ -14,8 +14,8 @@ IDC_SCREENSHOT_PENCIL CURSOR "icons/lucide/pencil.cur"
|
||||
1 RT_MANIFEST "app.manifest"
|
||||
201 RCDATA "update.ps1"
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 0,8,3,0
|
||||
PRODUCTVERSION 0,8,3,0
|
||||
FILEVERSION 0,8,8,0
|
||||
PRODUCTVERSION 0,8,8,0
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_APP
|
||||
BEGIN
|
||||
@@ -25,7 +25,7 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "FileDescription", "KSwitcher — native keyboard and clipboard utility"
|
||||
VALUE "ProductName", "KSwitcher"
|
||||
VALUE "FileVersion", "0.8.3"
|
||||
VALUE "FileVersion", "0.8.8"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
LTEXT "", 488, 16, 15, 353, 13, SS_PATHELLIPSIS
|
||||
LTEXT "", 495, 16, 28, 353, 13, SS_ENDELLIPSIS
|
||||
CONTROL "&Tree", 502, "Button", BS_OWNERDRAW | WS_TABSTOP, 16, 43, 44, 16
|
||||
COMBOBOX 503, 16, 59, 132, 64, CBS_DROPDOWNLIST | WS_TABSTOP
|
||||
CONTROL "Vo&lume", 496, "Button", BS_OWNERDRAW | WS_TABSTOP, 16, 43, 64, 16
|
||||
CONTROL "Tree&map", 497, "Button", BS_OWNERDRAW | WS_TABSTOP, 84, 43, 64, 16
|
||||
CONTROL "S&unburst", 499, "Button", BS_OWNERDRAW | WS_TABSTOP, 152, 43, 64, 16
|
||||
LTEXT "Sunburst items", 501, 171, 43, 201, 16, NOT WS_VISIBLE
|
||||
LISTBOX 500, 171, 60, 201, 105, LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | WS_TABSTOP | WS_VSCROLL | WS_HSCROLL | NOT WS_VISIBLE
|
||||
CONTROL "", 498, "Static", SS_OWNERDRAW | SS_NOTIFY | WS_TABSTOP | NOT WS_VISIBLE, 16, 60, 353, 105
|
||||
CONTROL "", 489, "SysTreeView32", WS_TABSTOP | WS_BORDER | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS, 16, 32, 353, 131
|
||||
LTEXT "", 490, 16, 167, 353, 14, SS_ENDELLIPSIS
|
||||
LTEXT "", 491, 12, 184, 1, 1, NOT WS_VISIBLE
|
||||
CONTROL "S&top", 492, "Button", BS_OWNERDRAW | WS_TABSTOP, 22, 189, 46, 16
|
||||
CONTROL "St&art", 493, "Button", BS_OWNERDRAW | WS_TABSTOP, 72, 189, 50, 16
|
||||
CONTROL "&View", 494, "Button", BS_OWNERDRAW | WS_TABSTOP, 126, 189, 46, 16
|
||||
CONTROL "&Show in other panel", IDOK, "Button", BS_OWNERDRAW | WS_TABSTOP, 176, 189, 102, 16
|
||||
CONTROL "&Close", IDCANCEL, "Button", BS_OWNERDRAW | WS_TABSTOP, 282, 189, 50, 16
|
||||
+9
-16
@@ -577,22 +577,15 @@ STYLE DS_SETFONT | DS_CENTER | WS_POPUP
|
||||
CAPTION "Space Analyzer"
|
||||
FONT 10, "Consolas"
|
||||
BEGIN
|
||||
LTEXT "", 488, 16, 15, 353, 13, SS_PATHELLIPSIS
|
||||
LTEXT "", 495, 16, 28, 353, 13, SS_ENDELLIPSIS
|
||||
CONTROL "Vo&lume", 496, "Button", BS_OWNERDRAW | WS_TABSTOP, 16, 43, 64, 16
|
||||
CONTROL "Tree&map", 497, "Button", BS_OWNERDRAW | WS_TABSTOP, 84, 43, 64, 16
|
||||
CONTROL "S&unburst", 499, "Button", BS_OWNERDRAW | WS_TABSTOP, 152, 43, 64, 16
|
||||
LTEXT "Sunburst items", 501, 171, 43, 201, 16, NOT WS_VISIBLE
|
||||
LISTBOX 500, 171, 60, 201, 105, LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | WS_TABSTOP | WS_VSCROLL | WS_HSCROLL | NOT WS_VISIBLE
|
||||
CONTROL "", 498, "Static", SS_OWNERDRAW | SS_NOTIFY | WS_TABSTOP | NOT WS_VISIBLE, 16, 60, 353, 105
|
||||
CONTROL "", 489, "SysTreeView32", WS_TABSTOP | WS_BORDER | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS, 16, 32, 353, 131
|
||||
LTEXT "", 490, 16, 167, 353, 14, SS_ENDELLIPSIS
|
||||
LTEXT "", 491, 12, 184, 1, 1, NOT WS_VISIBLE
|
||||
CONTROL "S&top", 492, "Button", BS_OWNERDRAW | WS_TABSTOP, 22, 189, 46, 16
|
||||
CONTROL "St&art", 493, "Button", BS_OWNERDRAW | WS_TABSTOP, 72, 189, 50, 16
|
||||
CONTROL "&View", 494, "Button", BS_OWNERDRAW | WS_TABSTOP, 126, 189, 46, 16
|
||||
CONTROL "&Show in other panel", IDOK, "Button", BS_OWNERDRAW | WS_TABSTOP, 176, 189, 102, 16
|
||||
CONTROL "&Close", IDCANCEL, "Button", BS_OWNERDRAW | WS_TABSTOP, 282, 189, 50, 16
|
||||
#include "files-space-analyzer-controls.inc"
|
||||
END
|
||||
|
||||
621 DIALOGEX 0, 0, 420, 209
|
||||
STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
|
||||
EXSTYLE WS_EX_CONTROLPARENT
|
||||
FONT 10, "Consolas"
|
||||
BEGIN
|
||||
#include "files-space-analyzer-controls.inc"
|
||||
END
|
||||
|
||||
119 DIALOGEX 0, 0, 260, 197
|
||||
|
||||
@@ -239,6 +239,13 @@ function Receive-File([string]$Url,[string]$Path,[long]$Limit,[string]$ProgressL
|
||||
if ($response) { $response.Dispose() }
|
||||
}
|
||||
}
|
||||
function Receive-ReleaseMetadata([string]$Path,[string]$ProgressLabel = '') {
|
||||
try {
|
||||
Receive-File 'https://gitea.hrynco.com/api/v1/repos/hrynco/hrynco-kswitcher/releases/latest' $Path 2MB $ProgressLabel
|
||||
} catch {
|
||||
throw "Could not check the latest KSwitcher release on Gitea. $($_.Exception.GetBaseException().Message)"
|
||||
}
|
||||
}
|
||||
function Select-Release($Releases,[version]$Current) {
|
||||
$candidates = @($Releases | Where-Object { !$_.draft -and !$_.prerelease -and (Get-StableVersion $_.tag_name) } |
|
||||
Sort-Object { Get-StableVersion $_.tag_name } -Descending)
|
||||
@@ -473,7 +480,7 @@ try {
|
||||
$ready = [Threading.EventWaitHandle]::OpenExisting($ReadyEvent)
|
||||
}
|
||||
$metadata = Join-Path $WorkDirectory 'releases.json'
|
||||
Receive-File 'https://gitea.hrynco.com/api/v1/repos/hrynco/hrynco-kswitcher/releases?limit=100' $metadata 2MB
|
||||
Receive-ReleaseMetadata $metadata
|
||||
$release = Select-Release (Get-Content -LiteralPath $metadata -Raw | ConvertFrom-Json) $current
|
||||
if (!$release) {
|
||||
if ($Unattended) { Write-UpdateJournal "No newer stable release is available ($CurrentVersion)." }
|
||||
|
||||
+204
-40
@@ -45,26 +45,107 @@ GUITHREADINFO snippetGuiInfo(HWND target)
|
||||
return info;
|
||||
}
|
||||
|
||||
std::optional<RECT> accessibleSnippetCaret(HWND target)
|
||||
using Microsoft::WRL::ComPtr;
|
||||
constexpr std::wstring_view terminalSnippetTicketPrefix = L"dirlume-terminal-snippet-v1:";
|
||||
|
||||
bool snippetElementClass(IUIAutomationElement *element, std::wstring_view name)
|
||||
{
|
||||
BSTR className{};
|
||||
const bool matches = SUCCEEDED(element->get_CurrentClassName(&className)) && className && className == name;
|
||||
SysFreeString(className);
|
||||
return matches;
|
||||
}
|
||||
|
||||
ComPtr<IUIAutomationElement> focusedSnippetElement(IUIAutomation2 *automation, HWND target)
|
||||
{
|
||||
using Microsoft::WRL::ComPtr;
|
||||
ComPtr<IUIAutomation2> automation;
|
||||
if (FAILED(CoCreateInstance(CLSID_CUIAutomation8, nullptr, CLSCTX_INPROC_SERVER,
|
||||
IID_IUIAutomation2, reinterpret_cast<void **>(automation.GetAddressOf()))))
|
||||
return {};
|
||||
automation->put_ConnectionTimeout(150);
|
||||
automation->put_TransactionTimeout(150);
|
||||
ComPtr<IUIAutomationElement> focused;
|
||||
if (FAILED(automation->GetFocusedElement(&focused)) || !focused)
|
||||
return {};
|
||||
DWORD process{};
|
||||
GetWindowThreadProcessId(target, &process);
|
||||
int focusedProcess{};
|
||||
BOOL password = TRUE;
|
||||
if (!process || FAILED(focused->get_CurrentProcessId(&focusedProcess)) ||
|
||||
process != static_cast<DWORD>(focusedProcess) ||
|
||||
FAILED(focused->get_CurrentIsPassword(&password)) || password)
|
||||
if (FAILED(focused->get_CurrentIsPassword(&password)) || password ||
|
||||
!focusedTextBelongsToWindow(automation, focused.Get(), target))
|
||||
return {};
|
||||
return focused;
|
||||
}
|
||||
|
||||
ComPtr<IUIAutomation2> snippetAutomation()
|
||||
{
|
||||
ComPtr<IUIAutomation2> automation;
|
||||
if (FAILED(CoCreateInstance(CLSID_CUIAutomation8, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&automation))))
|
||||
return {};
|
||||
automation->put_ConnectionTimeout(150);
|
||||
automation->put_TransactionTimeout(150);
|
||||
return automation;
|
||||
}
|
||||
|
||||
ComPtr<IUIAutomationValuePattern> terminalSnippetInput(IUIAutomation *automation, IUIAutomationElement *focused)
|
||||
{
|
||||
// The receiver is a sibling of this terminal's focused xterm input.
|
||||
ComPtr<IUIAutomationTreeWalker> walker;
|
||||
ComPtr<IUIAutomationElement> parent, input;
|
||||
ComPtr<IUIAutomationCondition> condition;
|
||||
if (FAILED(automation->get_RawViewWalker(&walker)) || !walker ||
|
||||
FAILED(walker->GetParentElement(focused, &parent)) || !parent)
|
||||
return {};
|
||||
VARIANT className{};
|
||||
className.vt = VT_BSTR;
|
||||
className.bstrVal = SysAllocString(L"dirlume-terminal-snippet-input");
|
||||
const auto result = automation->CreatePropertyCondition(UIA_ClassNamePropertyId, className, &condition);
|
||||
VariantClear(&className);
|
||||
if (FAILED(result) || !condition ||
|
||||
FAILED(parent->FindFirst(TreeScope_Children, condition.Get(), &input)) || !input)
|
||||
return {};
|
||||
ComPtr<IUIAutomationValuePattern> value;
|
||||
input->GetCurrentPatternAs(UIA_ValuePatternId, IID_PPV_ARGS(&value));
|
||||
return value;
|
||||
}
|
||||
|
||||
std::wstring terminalSnippetTicket(IUIAutomationValuePattern *value)
|
||||
{
|
||||
if (!value) return {};
|
||||
BSTR ticket{};
|
||||
const auto result = value->get_CurrentValue(&ticket);
|
||||
const std::wstring_view text(ticket ? ticket : L"", SysStringLen(ticket));
|
||||
auto accepted = SUCCEEDED(result) && text.size() == terminalSnippetTicketPrefix.size() + 36 &&
|
||||
text.starts_with(terminalSnippetTicketPrefix) ? std::wstring(text) : std::wstring();
|
||||
SysFreeString(ticket);
|
||||
return accepted;
|
||||
}
|
||||
|
||||
std::optional<Template> terminalSnippetTemplate(const Snippet &snippet)
|
||||
{
|
||||
auto value = parseTemplate(snippet.text);
|
||||
if (value.text.empty() || value.text.size() > 8192 || !value.actions.empty() ||
|
||||
std::any_of(value.text.begin(), value.text.end(), [](wchar_t c) {
|
||||
return c < 0x20 || (c >= 0x7f && c <= 0x9f) || c == 0x2028 || c == 0x2029;
|
||||
})) return {};
|
||||
return value;
|
||||
}
|
||||
|
||||
std::optional<SnippetAnchor> accessibleSnippetCaret(HWND target)
|
||||
{
|
||||
const auto automation = snippetAutomation();
|
||||
if (!automation) return {};
|
||||
const auto focused = focusedSnippetElement(automation.Get(), target);
|
||||
if (!focused) return {};
|
||||
|
||||
// The xterm.js input follows the terminal cursor for IME. Dirlume
|
||||
// handles replacement in the active shell draft through a separate input.
|
||||
if (snippetElementClass(focused.Get(), L"xterm-helper-textarea"))
|
||||
{
|
||||
RECT cell{};
|
||||
BOOL offscreen = TRUE;
|
||||
if (SUCCEEDED(focused->get_CurrentIsOffscreen(&offscreen)) && !offscreen &&
|
||||
SUCCEEDED(focused->get_CurrentBoundingRectangle(&cell)) && cell.right > cell.left &&
|
||||
cell.bottom > cell.top)
|
||||
{
|
||||
auto ticket = lower(processName(target)) == L"dirlume" ?
|
||||
terminalSnippetTicket(terminalSnippetInput(automation.Get(), focused.Get()).Get()) : std::wstring();
|
||||
return SnippetAnchor{{cell.left, cell.top, cell.left, cell.bottom}, true, std::move(ticket)};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
ComPtr<IUIAutomationTextPattern2> pattern;
|
||||
ComPtr<IUIAutomationTextRange> range;
|
||||
BOOL active{};
|
||||
@@ -121,7 +202,7 @@ std::optional<RECT> accessibleSnippetCaret(HWND target)
|
||||
}
|
||||
}
|
||||
SafeArrayDestroy(rectangles);
|
||||
if (anchor && anchor->bottom > anchor->top) return anchor;
|
||||
if (anchor && anchor->bottom > anchor->top) return SnippetAnchor{*anchor};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -660,21 +741,18 @@ class Transaction
|
||||
}
|
||||
auto text = select(count) ? copy() : std::wstring{};
|
||||
diagnosticEvent(L"Selection initial match=" + std::to_wstring(matches(text)) + L" copied=" + diagnosticText(text));
|
||||
// Chromium editors can apply only part of a burst of Shift+Left events.
|
||||
// Extend only a verified suffix; never replace a partial or unrelated range.
|
||||
// The editor may finish applying queued Shift+Left events after copying
|
||||
// the suffix. Collapse to its right edge before trying the full range again.
|
||||
if (valid() && !matches(text) && !text.empty() &&
|
||||
(suffixMatches ? suffixMatches(text) : newlines(wordCandidate).ends_with(newlines(text))) &&
|
||||
caretSteps(text) < count)
|
||||
{
|
||||
const auto missing = count - caretSteps(text);
|
||||
diagnosticEvent(L"Selection: extending verified suffix by " + std::to_wstring(missing));
|
||||
for (size_t i = 0; i < missing; ++i)
|
||||
{
|
||||
if (!valid() || !chord(VK_LEFT, MOD_SHIFT))
|
||||
return {};
|
||||
diagnosticEvent(L"Selection recovery Shift+Left sent=" + std::to_wstring(i + 1) + L" total=" + std::to_wstring(missing));
|
||||
Sleep(25);
|
||||
}
|
||||
diagnosticEvent(L"Selection: reselecting full range after verified suffix");
|
||||
if (!finishSelection(false))
|
||||
return {};
|
||||
Sleep(25);
|
||||
if (!selectPrevious(count, [&] { return valid(); }, true))
|
||||
return {};
|
||||
text = copy();
|
||||
diagnosticEvent(L"Selection: suffix recovery match=" + std::to_wstring(matches(text)) + L" copied=" + diagnosticText(text));
|
||||
}
|
||||
@@ -1485,6 +1563,12 @@ void App::matchSnippets(HWND fg, bool expandExact)
|
||||
!snippetWordCharacter(layout->at(physicalLayout().code(previous)));
|
||||
}))
|
||||
{
|
||||
if (snippetPopupAnchor.terminal && snippetTarget == fg && snippetPopup &&
|
||||
IsWindowVisible(snippetPopup) && snippetFocus == snippetGuiInfo(fg).hwndFocus)
|
||||
{
|
||||
hideSnippetPopup();
|
||||
return;
|
||||
}
|
||||
queueSnippet(fg, i, sn.trigger.size());
|
||||
return;
|
||||
}
|
||||
@@ -1559,11 +1643,11 @@ void App::showSnippetPopup()
|
||||
if ((info.rcCaret.left || info.rcCaret.top || anchor.bottom - anchor.top >= 4) &&
|
||||
snippetCaretInside(anchor, bounds))
|
||||
{
|
||||
placeSnippetPopup(anchor);
|
||||
placeSnippetPopup({anchor});
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (snippetPopup && IsWindowVisible(snippetPopup) && snippetCaretInside(snippetPopupAnchor, bounds))
|
||||
if (snippetPopup && IsWindowVisible(snippetPopup) && snippetCaretInside(snippetPopupAnchor.bounds, bounds))
|
||||
placeSnippetPopup(snippetPopupAnchor);
|
||||
if (snippetCaretPending) return;
|
||||
snippetCaretPending = true;
|
||||
@@ -1572,6 +1656,14 @@ void App::showSnippetPopup()
|
||||
const auto receiver = window;
|
||||
enqueue([this, version, target, receiver] {
|
||||
auto caret = GetForegroundWindow() == target ? accessibleSnippetCaret(target) : std::nullopt;
|
||||
if (!caret && inputVersion == version && GetForegroundWindow() == target)
|
||||
{
|
||||
// A WebView can expose the old, empty field while the keystroke
|
||||
// that requested suggestions is still reaching its renderer.
|
||||
Sleep(45);
|
||||
if (inputVersion == version && GetForegroundWindow() == target)
|
||||
caret = accessibleSnippetCaret(target);
|
||||
}
|
||||
{
|
||||
std::lock_guard lock(stateMutex);
|
||||
snippetCaret = caret;
|
||||
@@ -1579,9 +1671,22 @@ void App::showSnippetPopup()
|
||||
PostMessageW(receiver, SnippetCaretMessage, static_cast<WPARAM>(version), 0);
|
||||
});
|
||||
}
|
||||
void App::placeSnippetPopup(RECT anchor)
|
||||
void App::placeSnippetPopup(SnippetAnchor placement)
|
||||
{
|
||||
snippetPopupAnchor = anchor;
|
||||
if (placement.terminal && placement.canInsert())
|
||||
{
|
||||
const auto previous = snippetMatches[snippetSelection];
|
||||
std::erase_if(snippetMatches, [&](size_t index) { return !terminalSnippetTemplate(settings.snippets[index]); });
|
||||
if (snippetMatches.empty())
|
||||
{
|
||||
hideSnippetPopup();
|
||||
return;
|
||||
}
|
||||
const auto selected = std::find(snippetMatches.begin(), snippetMatches.end(), previous);
|
||||
snippetSelection = selected == snippetMatches.end() ? 0 : static_cast<size_t>(selected - snippetMatches.begin());
|
||||
}
|
||||
snippetPopupAnchor = std::move(placement);
|
||||
const auto &anchor = snippetPopupAnchor.bounds;
|
||||
if (!snippetPopup)
|
||||
{
|
||||
WNDCLASSW cls{};
|
||||
@@ -1630,24 +1735,83 @@ void App::placeSnippetPopup(RECT anchor)
|
||||
InvalidateRect(snippetPopup, nullptr, FALSE);
|
||||
SetTimer(window, SnippetPopupTimer, 100, nullptr);
|
||||
}
|
||||
void App::selectSnippet(size_t row)
|
||||
bool App::selectSnippet(size_t row)
|
||||
{
|
||||
if (row >= snippetMatches.size() || !snippetPopupCurrent()) return;
|
||||
if (!snippetPopupAnchor.canInsert() || row >= snippetMatches.size() || !snippetPopupCurrent()) return false;
|
||||
const auto index = snippetMatches[row];
|
||||
const auto length = snippetPrefixLength;
|
||||
hideSnippetPopup();
|
||||
std::lock_guard lock(stateMutex);
|
||||
if (snippetPopupVersion == inputVersion && !busy)
|
||||
queueSnippet(snippetTarget, index, length, snippetFocus);
|
||||
if (!snippetPopupCurrent()) return false;
|
||||
if (!snippetPopupAnchor.terminal)
|
||||
{
|
||||
hideSnippetPopup();
|
||||
return queueSnippet(snippetTarget, index, length, snippetFocus);
|
||||
}
|
||||
const auto layout = std::find_if(layouts.begin(), layouts.end(), [&](const auto &item) {
|
||||
return item.handle == run.layout && item.convertible;
|
||||
});
|
||||
if (layout == layouts.end() || run.window != snippetTarget || run.keys.size() < length)
|
||||
return false;
|
||||
const auto replacement = terminalSnippetTemplate(settings.snippets[index]);
|
||||
if (!replacement) return false;
|
||||
std::wstring prefix;
|
||||
for (wchar_t key : std::wstring_view(run.keys).substr(run.keys.size() - length))
|
||||
prefix += layout->at(physicalLayout().code(key));
|
||||
if (prefix.empty() || prefix.find(L'\0') != prefix.npos) return false;
|
||||
|
||||
const auto ticket = snippetPopupAnchor.terminalTicket;
|
||||
const auto target = snippetTarget;
|
||||
const auto editor = snippetFocus;
|
||||
const auto request = wide(DiagnosticJson::array({utf8(ticket), utf8(prefix), utf8(replacement->text),
|
||||
replacement->text.size() - replacement->suffix.size()}).dump(-1, ' ', true, DiagnosticJson::error_handler_t::replace));
|
||||
hideSnippetPopup();
|
||||
run.reset();
|
||||
const auto version = ++inputVersion;
|
||||
typingTarget = target;
|
||||
snippetTyping = true;
|
||||
busy = true;
|
||||
enqueue([this, target, editor, version, ticket, request] {
|
||||
struct Replay
|
||||
{
|
||||
HWND window;
|
||||
~Replay() { PostMessageW(window, ReplayTypingMessage, 0, 0); }
|
||||
} replay{window};
|
||||
const auto current = [&] {
|
||||
return inputVersion == version && GetForegroundWindow() == target && snippetGuiInfo(target).hwndFocus == editor;
|
||||
};
|
||||
if (!current()) return;
|
||||
const auto automation = snippetAutomation();
|
||||
if (!automation) return;
|
||||
const auto focused = focusedSnippetElement(automation.Get(), target);
|
||||
if (!focused || !snippetElementClass(focused.Get(), L"xterm-helper-textarea")) return;
|
||||
const auto input = terminalSnippetInput(automation.Get(), focused.Get());
|
||||
if (terminalSnippetTicket(input.Get()) != ticket || !current()) return;
|
||||
BSTR payload = SysAllocStringLen(request.data(), static_cast<UINT>(request.size()));
|
||||
if (!payload) return;
|
||||
const auto sent = input->SetValue(payload);
|
||||
SysFreeString(payload);
|
||||
if (FAILED(sent)) return;
|
||||
|
||||
// Keep subsequent keystrokes ordered behind the renderer's draft edit.
|
||||
const auto until = GetTickCount64() + 200;
|
||||
while (current() && GetTickCount64() < until)
|
||||
{
|
||||
const auto reply = terminalSnippetTicket(input.Get());
|
||||
if (!reply.empty() && reply != ticket) return;
|
||||
Sleep(10);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
bool App::handleSnippetKey(DWORD vk, UINT mods)
|
||||
{
|
||||
if (!snippetPopupAnchor.canInsert() && vk != VK_ESCAPE) return false;
|
||||
const bool accept = vk == VK_TAB ||
|
||||
(vk == VK_RETURN && (snippetNavigated || snippetMatches.size() == 1));
|
||||
(!snippetPopupAnchor.terminal && vk == VK_RETURN && (snippetNavigated || snippetMatches.size() == 1));
|
||||
if (mods || (!accept && vk != VK_UP && vk != VK_DOWN && vk != VK_ESCAPE) ||
|
||||
!snippetPopup || !IsWindowVisible(snippetPopup) || !snippetPopupCurrent())
|
||||
return false;
|
||||
if (accept) selectSnippet(snippetSelection);
|
||||
if (accept) return selectSnippet(snippetSelection);
|
||||
else if (vk == VK_ESCAPE) hideSnippetPopup();
|
||||
else
|
||||
{
|
||||
@@ -1690,7 +1854,7 @@ LRESULT CALLBACK App::snippetPopupProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
{
|
||||
const LONG top = static_cast<LONG>(i - first) * app->snippetRowHeight;
|
||||
RECT row{0, top, bounds.right, top + app->snippetRowHeight};
|
||||
const bool selected = i == app->snippetSelection;
|
||||
const bool selected = app->snippetPopupAnchor.canInsert() && i == app->snippetSelection;
|
||||
if (selected) FillRect(dc, &row, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
SetTextColor(dc, GetSysColor(selected ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT));
|
||||
row.left += MulDiv(8, dpi, 96);
|
||||
@@ -3603,13 +3767,13 @@ LRESULT CALLBACK App::windowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
app->showSnippetPopup();
|
||||
return 0;
|
||||
}
|
||||
std::optional<RECT> caret;
|
||||
std::optional<SnippetAnchor> caret;
|
||||
{
|
||||
std::lock_guard lock(app->stateMutex);
|
||||
caret = app->snippetCaret;
|
||||
}
|
||||
RECT bounds{};
|
||||
if (caret && GetWindowRect(app->snippetTarget, &bounds) && snippetCaretInside(*caret, bounds))
|
||||
if (caret && GetWindowRect(app->snippetTarget, &bounds) && snippetCaretInside(caret->bounds, bounds))
|
||||
{
|
||||
app->placeSnippetPopup(*caret);
|
||||
return 0;
|
||||
|
||||
@@ -23,6 +23,13 @@ inline constexpr int Toggle = 1, Case = 2, Translit = 3, Undo = 4, ShowHistory =
|
||||
inline constexpr UINT AutoCorrectMessage = WM_APP + 6;
|
||||
inline constexpr UINT ReplayTypingMessage = WM_APP + 30;
|
||||
inline constexpr UINT CaptureHotkeyMessage = WM_APP + 5;
|
||||
struct SnippetAnchor
|
||||
{
|
||||
RECT bounds{};
|
||||
bool terminal{};
|
||||
std::wstring terminalTicket;
|
||||
bool canInsert() const { return !terminal || !terminalTicket.empty(); }
|
||||
};
|
||||
struct LastTransform
|
||||
{
|
||||
HWND window{};
|
||||
@@ -203,20 +210,20 @@ class App
|
||||
bool snippetNavigated{};
|
||||
int snippetRowHeight{};
|
||||
UINT snippetDpi{96};
|
||||
RECT snippetPopupAnchor{};
|
||||
SnippetAnchor snippetPopupAnchor{};
|
||||
bool snippetCaretPending{};
|
||||
std::optional<RECT> snippetCaret;
|
||||
std::optional<SnippetAnchor> snippetCaret;
|
||||
std::vector<std::pair<std::wstring, std::vector<std::wstring>>> snippetTriggers;
|
||||
std::vector<size_t> snippetMatches;
|
||||
std::array<bool, 256> snippetKeys{};
|
||||
void matchSnippets(HWND, bool expandExact);
|
||||
bool queueSnippet(HWND, size_t index, size_t length, HWND editor = nullptr);
|
||||
void showSnippetPopup();
|
||||
void placeSnippetPopup(RECT);
|
||||
void placeSnippetPopup(SnippetAnchor);
|
||||
void hideSnippetPopup();
|
||||
bool snippetPopupCurrent() const;
|
||||
bool handleSnippetKey(DWORD, UINT);
|
||||
void selectSnippet(size_t);
|
||||
bool selectSnippet(size_t);
|
||||
static LRESULT CALLBACK snippetPopupProc(HWND, UINT, WPARAM, LPARAM);
|
||||
std::vector<INPUT> deferredTyping;
|
||||
bool beginTypingDeferral(HWND, uint64_t, bool snippet = false);
|
||||
|
||||
+16
-6
@@ -645,15 +645,25 @@ int Run::match(const std::wstring &text, const std::vector<Layout> &layouts, con
|
||||
{
|
||||
if (text.size() != keys.size() || overflow)
|
||||
return -1;
|
||||
const auto normalized = lower(text);
|
||||
int fallback = -1;
|
||||
for (int i = 0; i < (int)layouts.size(); ++i)
|
||||
if (layouts[i].convertible)
|
||||
{
|
||||
const auto &candidate = layouts[i];
|
||||
const bool tracked = layout && candidate.handle == layout;
|
||||
if (!candidate.convertible || (!tracked && fallback >= 0))
|
||||
continue;
|
||||
|
||||
std::wstring expected;
|
||||
for (wchar_t c : keys)
|
||||
expected += c == L' ' ? L' ' : candidate.at(physical.code(c));
|
||||
if (lower(expected) == normalized)
|
||||
{
|
||||
std::wstring expected;
|
||||
for (wchar_t c : keys)
|
||||
expected += c == L' ' ? L' ' : layouts[i].at(physical.code(c));
|
||||
if (lower(expected) == lower(text))
|
||||
if (tracked)
|
||||
return i;
|
||||
fallback = i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
} // namespace ks
|
||||
@@ -0,0 +1,223 @@
|
||||
#include "files_folder_size.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <condition_variable>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <exception>
|
||||
#include <mutex>
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace ks::files
|
||||
{
|
||||
namespace
|
||||
{
|
||||
namespace fs=std::filesystem;
|
||||
|
||||
struct Directory
|
||||
{
|
||||
HANDLE handle;
|
||||
explicit Directory(const fs::path &path):handle(CreateFileW(path.c_str(),
|
||||
FILE_LIST_DIRECTORY|FILE_READ_ATTRIBUTES,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
|
||||
nullptr,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OPEN_REPARSE_POINT,nullptr)) {}
|
||||
~Directory() {if(handle!=INVALID_HANDLE_VALUE) CloseHandle(handle);}
|
||||
Directory(const Directory &)=delete;
|
||||
Directory &operator=(const Directory &)=delete;
|
||||
};
|
||||
|
||||
uint64_t directoryId(const BY_HANDLE_FILE_INFORMATION &info)
|
||||
{
|
||||
return (uint64_t(info.nFileIndexHigh)<<32)|info.nFileIndexLow;
|
||||
}
|
||||
|
||||
bool ordinaryDirectory(const BY_HANDLE_FILE_INFORMATION &info)
|
||||
{
|
||||
return (info.dwFileAttributes&(FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_REPARSE_POINT))==
|
||||
FILE_ATTRIBUTE_DIRECTORY;
|
||||
}
|
||||
|
||||
struct ScanDirectory
|
||||
{
|
||||
fs::path path;
|
||||
uint64_t id;
|
||||
};
|
||||
|
||||
constexpr size_t pageBytes=64*1024;
|
||||
using DirectoryPage=std::array<std::byte,pageBytes>;
|
||||
|
||||
// Directory records are variable length. Read the fixed fields and name only
|
||||
// after checking that both stay within the current record.
|
||||
bool readPage(const DirectoryPage &page,const fs::path &parent,FolderSize &size,
|
||||
std::vector<ScanDirectory> &children)
|
||||
{
|
||||
constexpr size_t nameOffset=offsetof(FILE_ID_EXTD_DIR_INFO,FileName);
|
||||
std::wstring name;
|
||||
for(size_t offset=0;offset<page.size();)
|
||||
{
|
||||
const auto remaining=page.size()-offset;
|
||||
if(remaining<nameOffset) return false;
|
||||
FILE_ID_EXTD_DIR_INFO entry{};
|
||||
std::memcpy(&entry,page.data()+offset,nameOffset);
|
||||
const size_t next=entry.NextEntryOffset;
|
||||
const size_t recordBytes=next?next:remaining;
|
||||
const size_t nameBytes=entry.FileNameLength;
|
||||
if(recordBytes>remaining || recordBytes<nameOffset || next%8 ||
|
||||
nameBytes%sizeof(wchar_t) || nameBytes>recordBytes-nameOffset || entry.EndOfFile.QuadPart<0)
|
||||
return false;
|
||||
if(!(entry.FileAttributes&FILE_ATTRIBUTE_REPARSE_POINT))
|
||||
{
|
||||
name.resize(nameBytes/sizeof(wchar_t));
|
||||
std::memcpy(name.data(),page.data()+offset+nameOffset,nameBytes);
|
||||
if(name!=L"." && name!=L"..")
|
||||
{
|
||||
if(name.empty() || name.find_first_of(L"\\/:")!=name.npos || name.find(L'\0')!=name.npos)
|
||||
size.partial=true;
|
||||
else if(entry.FileAttributes&FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
uint64_t id{};
|
||||
std::memcpy(&id,entry.FileId.Identifier,sizeof(id));
|
||||
children.push_back({parent/name,id});
|
||||
}
|
||||
else size.add(static_cast<uint64_t>(entry.EndOfFile.QuadPart));
|
||||
}
|
||||
}
|
||||
if(!next) return true;
|
||||
offset+=next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class PublishPage>
|
||||
DWORD enumerate(const ScanDirectory &job,DWORD volume,DirectoryPage &page,
|
||||
std::stop_token stop,const PublishPage &publish)
|
||||
{
|
||||
Directory directory(job.path);
|
||||
if(directory.handle==INVALID_HANDLE_VALUE) return GetLastError();
|
||||
BY_HANDLE_FILE_INFORMATION info{};
|
||||
if(!GetFileInformationByHandle(directory.handle,&info)) return GetLastError();
|
||||
if(!ordinaryDirectory(info) || info.dwVolumeSerialNumber!=volume || directoryId(info)!=job.id)
|
||||
return ERROR_PATH_NOT_FOUND;
|
||||
|
||||
while(!stop.stop_requested())
|
||||
{
|
||||
if(!GetFileInformationByHandleEx(directory.handle,FileIdExtdDirectoryInfo,
|
||||
page.data(),static_cast<DWORD>(page.size())))
|
||||
{
|
||||
const auto error=GetLastError();
|
||||
return error==ERROR_NO_MORE_FILES?ERROR_SUCCESS:error;
|
||||
}
|
||||
FolderSize size;
|
||||
std::vector<ScanDirectory> children;
|
||||
if(!readPage(page,job.path,size,children)) return ERROR_INVALID_DATA;
|
||||
publish(size,children);
|
||||
}
|
||||
return ERROR_CANCELLED;
|
||||
}
|
||||
|
||||
bool unsupported(DWORD error)
|
||||
{
|
||||
return error==ERROR_INVALID_FUNCTION || error==ERROR_INVALID_PARAMETER || error==ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<FolderSize> measureNtfsFolder(const fs::path &root,std::stop_token stop)
|
||||
{
|
||||
if(stop.stop_requested()) return FolderSize{};
|
||||
const auto drive=GetDriveTypeW(root.root_path().c_str());
|
||||
if(drive!=DRIVE_FIXED && drive!=DRIVE_REMOVABLE) return std::nullopt;
|
||||
// The extended path also lets descendants cross MAX_PATH while scanning.
|
||||
const auto normalized=root.lexically_normal();
|
||||
const fs::path scanPath=L"\\\\?\\"+normalized.native();
|
||||
Directory directory(scanPath);
|
||||
if(directory.handle==INVALID_HANDLE_VALUE) return std::nullopt;
|
||||
wchar_t filesystem[32]{};
|
||||
if(!GetVolumeInformationByHandleW(directory.handle,nullptr,0,nullptr,nullptr,nullptr,
|
||||
filesystem,static_cast<DWORD>(std::size(filesystem))) || std::wstring_view(filesystem)!=L"NTFS")
|
||||
return std::nullopt;
|
||||
BY_HANDLE_FILE_INFORMATION info{};
|
||||
if(!GetFileInformationByHandle(directory.handle,&info)) return std::nullopt;
|
||||
if(!ordinaryDirectory(info)) return std::nullopt;
|
||||
|
||||
// Dirlume Space Analyzer (space_analyzer/windows_walk.rs) reads NTFS
|
||||
// directory pages with a smaller worker pool on seek-sensitive storage.
|
||||
constexpr DWORD noSeekPenalty=0x04;
|
||||
FILE_STORAGE_INFO storage{};
|
||||
const unsigned limit=GetFileInformationByHandleEx(directory.handle,FileStorageInfo,&storage,sizeof(storage)) &&
|
||||
(storage.Flags&noSeekPenalty)?16:4;
|
||||
const unsigned workers=std::min(limit,std::max(1u,std::thread::hardware_concurrency()));
|
||||
|
||||
std::stop_source scanning;
|
||||
std::stop_callback cancel(stop,[&]{scanning.request_stop();});
|
||||
const auto scanStop=scanning.get_token();
|
||||
std::mutex mutex;
|
||||
std::condition_variable_any changed;
|
||||
std::vector<ScanDirectory> pending{{scanPath,directoryId(info)}};
|
||||
unsigned active{};
|
||||
bool fallback{};
|
||||
FolderSize result;
|
||||
std::exception_ptr failure;
|
||||
const auto work=[&]
|
||||
{
|
||||
try
|
||||
{
|
||||
alignas(FILE_ID_EXTD_DIR_INFO) DirectoryPage page;
|
||||
for(;;)
|
||||
{
|
||||
std::unique_lock lock(mutex);
|
||||
changed.wait(lock,scanStop,[&]{return !pending.empty() || !active;});
|
||||
if(scanStop.stop_requested() || pending.empty()) return;
|
||||
auto job=std::move(pending.back());
|
||||
pending.pop_back();
|
||||
++active;
|
||||
lock.unlock();
|
||||
bool readPage=false;
|
||||
const auto error=enumerate(job,info.dwVolumeSerialNumber,page,scanStop,
|
||||
[&](FolderSize size,std::vector<ScanDirectory> &children)
|
||||
{
|
||||
readPage=true;
|
||||
std::lock_guard publishLock(mutex);
|
||||
result.add(size.bytes);
|
||||
result.partial|=size.partial;
|
||||
for(auto &child:children) pending.push_back(std::move(child));
|
||||
if(!children.empty()) changed.notify_all();
|
||||
});
|
||||
lock.lock();
|
||||
--active;
|
||||
if(unsupported(error) ||
|
||||
(error!=ERROR_SUCCESS && error!=ERROR_CANCELLED && job.path==scanPath && !readPage))
|
||||
{
|
||||
fallback=true;
|
||||
scanning.request_stop();
|
||||
}
|
||||
else if(error!=ERROR_SUCCESS) result.partial=true;
|
||||
if(!active) changed.notify_all();
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
failure=std::current_exception();
|
||||
scanning.request_stop();
|
||||
}
|
||||
};
|
||||
std::vector<std::jthread> pool;
|
||||
pool.reserve(workers-1);
|
||||
try
|
||||
{
|
||||
for(unsigned worker=1;worker<workers;++worker) pool.emplace_back(work);
|
||||
}
|
||||
catch(const std::system_error &)
|
||||
{
|
||||
// The workers already started can finish the scan.
|
||||
}
|
||||
work();
|
||||
for(auto &worker:pool) worker.join();
|
||||
if(failure) std::rethrow_exception(failure);
|
||||
if(fallback) return std::nullopt;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <stop_token>
|
||||
|
||||
namespace ks::files
|
||||
{
|
||||
struct FolderSize
|
||||
{
|
||||
uint64_t bytes{};
|
||||
bool partial{}, failed{}, previous{};
|
||||
|
||||
void add(uint64_t amount)
|
||||
{
|
||||
if(amount>UINT64_MAX-bytes)
|
||||
{
|
||||
bytes=UINT64_MAX;
|
||||
partial=true;
|
||||
}
|
||||
else bytes+=amount;
|
||||
}
|
||||
};
|
||||
|
||||
// No result means the caller should use its ordinary directory listing.
|
||||
std::optional<FolderSize> measureNtfsFolder(const std::filesystem::path &,std::stop_token);
|
||||
}
|
||||
+3
-2
@@ -12,6 +12,7 @@ constexpr struct
|
||||
L"Press F1 on a menu item for its topic. Commands → Keyboard shortcuts lists the active scheme and lets you assign extra bindings."},
|
||||
{L"Locations and navigation",L"folder path history breadcrumbs drives recent bookmark directory unc",
|
||||
L"Use the breadcrumb in a local or remote pane to jump to an ancestor. The folder history keeps earlier locations for that pane. Choose Recent folders in Change drive to see recent locations in that panel. Enter opens the selected folder, Delete removes it from recent folders, and Esc restores the previous folder.\r\n\r\n"
|
||||
L"In Change drive, press 1 for FTP, 2 for SFTP, 3 for SMB, or 4 for Recent folders. Use the digit shown beside a LAN drive or Wake action.\r\n\r\n"
|
||||
L"Folder shortcuts open frequently used locations. In the default scheme Ctrl+0–9 recalls a digit and Ctrl+Shift+0–9 adds the current folder."},
|
||||
{L"Find files",L"search filter mask results alt f7 paths subfolders",
|
||||
L"Find files searches from the active folder, including subfolders. Supply a filename mask such as *.md. The results show their locations and can be opened or used in file operations.\r\n\r\n"
|
||||
@@ -26,8 +27,8 @@ constexpr struct
|
||||
L"Open a ZIP or 7z archive from a local pane to browse its entries. Copy entries out to extract them. Back out through the parent entry or Esc.\r\n\r\n"
|
||||
L"Use Pack files to create or update a ZIP or 7z archive. Review the destination, compression and conflict choices before saving."},
|
||||
{L"Space Analyzer",L"storage folder size allocation disk tree treemap sunburst",
|
||||
L"Open Space Analyzer from Commands for a local folder. The tree and charts show which folders consume space. Select an item to inspect its contribution and choose the display you need.\r\n\r\n"
|
||||
L"Logical size describes file data. Allocated size describes disk allocation where it can be measured."},
|
||||
L"Open Space Analyzer from the Left or Right menu to scan a local folder in its pane. Use Close or Esc to return to the file list. The Commands menu opens a separate analyzer window.\r\n\r\n"
|
||||
L"Choose Logical size for file data or Size on disk for measured disk allocation. The selected metric is used in Tree, Treemap and Sunburst."},
|
||||
{L"Properties and locking processes",L"context menu windows owner attributes filesystem locks handle",
|
||||
L"Properties shows available file details and Windows attributes. The Windows context menu exposes actions supplied by the file type and the operating system.\r\n\r\n"
|
||||
L"Use Locking processes for selected local items to see processes with open handles. Save any work in the owning program before closing it."},
|
||||
|
||||
@@ -307,7 +307,8 @@ INT_PTR lavenderDialogColors(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
return reinterpret_cast<INT_PTR>(GetStockObject(DC_BRUSH));
|
||||
}
|
||||
|
||||
RECT paintLavenderDialogFrame(HWND dialog,HDC dc,RECT client,const wchar_t *title,const wchar_t *hints=nullptr)
|
||||
RECT paintLavenderDialogFrame(HWND dialog,HDC dc,RECT client,const wchar_t *title,
|
||||
const wchar_t *hints=nullptr,bool popup=false)
|
||||
{
|
||||
using namespace lavender;
|
||||
const LavenderMetrics metrics(dialog);
|
||||
@@ -315,30 +316,35 @@ RECT paintLavenderDialogFrame(HWND dialog,HDC dc,RECT client,const wchar_t *titl
|
||||
const bool operation=isLavenderFileOperation(dialog);
|
||||
const auto edge=dialogEdge(dialog);
|
||||
LONG headerBottom=client.top+metrics.px(operationHeaderHeight);
|
||||
if(operation)
|
||||
if(operation || popup)
|
||||
{
|
||||
for(auto control=GetWindow(dialog,GW_CHILD);control;control=GetWindow(control,GW_HWNDNEXT))
|
||||
{
|
||||
if(!IsWindowVisible(control)) continue;
|
||||
RECT bounds{};
|
||||
GetWindowRect(control,&bounds);
|
||||
MapWindowPoints(nullptr,dialog,reinterpret_cast<POINT*>(&bounds),2);
|
||||
headerBottom=std::min(headerBottom,bounds.top);
|
||||
}
|
||||
rounded(dc,client,metrics.px(9),edge,edge);
|
||||
const int stroke=metrics.px(2);
|
||||
auto inner=client;
|
||||
InflateRect(&inner,-stroke,-stroke);
|
||||
const int diameter=metrics.px(14);
|
||||
const auto clip=CreateRoundRectRgn(inner.left,inner.top,inner.right+1,inner.bottom+1,diameter,diameter);
|
||||
const auto saved=SaveDC(dc);
|
||||
if(clip && saved)
|
||||
if(popup)
|
||||
rounded(dc,inner,metrics.px(7),operationSurface,operationSurface);
|
||||
else
|
||||
{
|
||||
ExtSelectClipRgn(dc,clip,RGN_AND);
|
||||
fill(dc,{inner.left,std::max(inner.top,headerBottom),inner.right,inner.bottom},operationSurface);
|
||||
for(auto control=GetWindow(dialog,GW_CHILD);control;control=GetWindow(control,GW_HWNDNEXT))
|
||||
{
|
||||
if(!IsWindowVisible(control)) continue;
|
||||
RECT bounds{};
|
||||
GetWindowRect(control,&bounds);
|
||||
MapWindowPoints(nullptr,dialog,reinterpret_cast<POINT*>(&bounds),2);
|
||||
headerBottom=std::min(headerBottom,bounds.top);
|
||||
}
|
||||
const int diameter=metrics.px(14);
|
||||
const auto clip=CreateRoundRectRgn(inner.left,inner.top,inner.right+1,inner.bottom+1,diameter,diameter);
|
||||
const auto saved=SaveDC(dc);
|
||||
if(clip && saved)
|
||||
{
|
||||
ExtSelectClipRgn(dc,clip,RGN_AND);
|
||||
fill(dc,{inner.left,std::max(inner.top,headerBottom),inner.right,inner.bottom},operationSurface);
|
||||
}
|
||||
if(saved) RestoreDC(dc,saved);
|
||||
if(clip) DeleteObject(clip);
|
||||
}
|
||||
if(saved) RestoreDC(dc,saved);
|
||||
if(clip) DeleteObject(clip);
|
||||
}
|
||||
else rounded(dc,client,metrics.px(9),surface,line);
|
||||
auto content=client;
|
||||
@@ -357,3 +363,8 @@ RECT paintLavenderDialogFrame(HWND dialog,HDC dc,RECT client,const wchar_t *titl
|
||||
if(hints) text(dc,{content.left,client.bottom-metrics.px(21),content.right,client.bottom},hints,muted,DT_CENTER);
|
||||
return content;
|
||||
}
|
||||
|
||||
void paintLavenderPopupFrame(HWND popup,HDC dc,RECT bounds,const wchar_t *title)
|
||||
{
|
||||
paintLavenderDialogFrame(popup,dc,bounds,title,nullptr,true);
|
||||
}
|
||||
+67
-38
@@ -40,6 +40,7 @@
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
#include "files_terminal.h"
|
||||
#include "files_folder_size.h"
|
||||
#include "files_archive.h"
|
||||
#include "files_git_changes.h"
|
||||
#include "files_compare_text.h"
|
||||
@@ -309,17 +310,7 @@ DWORD readElevatedFolder(const ElevatedHelper &session,const fs::path &directory
|
||||
}
|
||||
return stop.stop_requested()?ERROR_CANCELLED:ERROR_TIMEOUT;
|
||||
}
|
||||
struct FolderSize
|
||||
{
|
||||
uint64_t bytes{};
|
||||
bool partial{}, failed{}, previous{};
|
||||
|
||||
void add(uint64_t amount)
|
||||
{
|
||||
if(amount>UINT64_MAX-bytes) partial=true;
|
||||
else bytes+=amount;
|
||||
}
|
||||
};
|
||||
using ks::files::FolderSize;
|
||||
using FolderSizes=std::map<fs::path,FolderSize>;
|
||||
|
||||
constexpr ULONGLONG folderSpinnerDelay=2000;
|
||||
@@ -808,6 +799,11 @@ std::wstring panelCaption(const Panel &panel)
|
||||
|
||||
Panel panels[2];
|
||||
HWND quickViewWindow{};
|
||||
HWND spacePaneWindow{};
|
||||
int spacePaneSide=-1;
|
||||
void closeSpacePane(HWND owner,bool restorePane=true);
|
||||
void toggleSpacePane(HWND owner,int side);
|
||||
void focusSpacePane();
|
||||
HWND quickImageWindow{};
|
||||
bool quickViewDisplaysImage{};
|
||||
int quickViewSource{};
|
||||
@@ -929,7 +925,6 @@ ks::files::InlineListAction driveWakeAction(driveWakeLabel);
|
||||
std::vector<DriveQuery> driveQueries;
|
||||
std::map<LRESULT,DriveChoice> remoteDriveRows;
|
||||
std::map<std::pair<std::string,std::optional<fs::path>>,wchar_t> driveDigits;
|
||||
constexpr wchar_t ftpDriveDigit=L'1';
|
||||
constexpr UINT_PTR driveQueryTimer=3;
|
||||
ULONGLONG nextDriveRefresh{},driveRefreshDeadline{};
|
||||
int drivePickerWidth{};
|
||||
@@ -1714,6 +1709,7 @@ void swapPanels(HWND window)
|
||||
std::swap(panels[0],panels[1]);
|
||||
active=1-active;
|
||||
if(quickViewWindow) quickViewSource=1-quickViewSource;
|
||||
if(spacePaneWindow) spacePaneSide=1-spacePaneSide;
|
||||
if(sshPrompt) sshPrompt->panel=1-sshPrompt->panel;
|
||||
for(auto &command:terminalCommands)
|
||||
if(command.panel>=0) command.panel=1-command.panel;
|
||||
@@ -1829,7 +1825,7 @@ void layout(HWND window,bool activeOnly)
|
||||
place(panels[i].path,x+inset,panelTop,std::max(0,end-x-2*inset),pathHeight);
|
||||
const int headingHeight=detailedPanel(panels[i])?rowHeight:0;
|
||||
const int listWidth=std::max(0,end-x-(lavender?2*inset:panelMargin+3)-scrollBarWidth(panels[i].list));
|
||||
const bool panelVisible=!gitMode && !terminalVisible && (!quickViewWindow || i==quickViewSource);
|
||||
const bool panelVisible=!gitMode && !terminalVisible && i!=spacePaneSide && (!quickViewWindow || i==quickViewSource);
|
||||
ShowWindow(panels[i].path,panelVisible?SW_SHOWNA:SW_HIDE);
|
||||
ShowWindow(panels[i].list,panelVisible?SW_SHOWNA:SW_HIDE);
|
||||
SendMessageW(panels[i].selectionSummary,WM_SETFONT,panelFont,FALSE);
|
||||
@@ -1921,6 +1917,15 @@ void layout(HWND window,bool activeOnly)
|
||||
ShowWindow(preview,!gitMode && !terminalVisible && current?SW_SHOWNA:SW_HIDE);
|
||||
}
|
||||
}
|
||||
if(spacePaneWindow)
|
||||
{
|
||||
const int left=spacePaneSide?middle+2:0;
|
||||
const int right=spacePaneSide?width:middle-2;
|
||||
const int bottom=panelBottom+summaryHeight+textHeight+detailsInset;
|
||||
SetWindowPos(spacePaneWindow,nullptr,left+panelMargin,pathTop,std::max(0,right-left-2*panelMargin),
|
||||
std::max(0,bottom-pathTop),SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
ShowWindow(spacePaneWindow,!gitMode && !terminalVisible?SW_SHOWNA:SW_HIDE);
|
||||
}
|
||||
if(IsWindowVisible(panelSearchPopup)) placePanelSearch(window);
|
||||
layoutGitChanges(window);
|
||||
RedrawWindow(window,nullptr,nullptr,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
|
||||
@@ -2012,6 +2017,11 @@ void invalidatePanelCursorChange(HWND list,LRESULT previous)
|
||||
|
||||
void activatePanel(int index)
|
||||
{
|
||||
if(index==spacePaneSide)
|
||||
{
|
||||
focusSpacePane();
|
||||
return;
|
||||
}
|
||||
if(quickViewWindow && index!=quickViewSource) return;
|
||||
const auto previous=active;
|
||||
active=index;
|
||||
@@ -3862,7 +3872,7 @@ bool queueFolderMeasurements(Panel &panel,const std::vector<fs::path> &folders,b
|
||||
const auto stop=job->stop.get_token();
|
||||
try
|
||||
{
|
||||
const auto measure=[&](const auto &listDirectory)
|
||||
const auto measure=[&](const auto &listDirectory,bool local=false)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
@@ -3882,7 +3892,8 @@ bool queueFolderMeasurements(Panel &panel,const std::vector<fs::path> &folders,b
|
||||
job->started=GetTickCount64();
|
||||
}
|
||||
}
|
||||
const auto size=measureFolder(folder,stop,listDirectory);
|
||||
auto native=local?ks::files::measureNtfsFolder(folder,stop):std::nullopt;
|
||||
const auto size=native?*native:measureFolder(folder,stop,listDirectory);
|
||||
if(stop.stop_requested()) continue;
|
||||
std::lock_guard lock(job->mutex);
|
||||
job->completed.emplace(folder,size);
|
||||
@@ -3903,7 +3914,7 @@ bool queueFolderMeasurements(Panel &panel,const std::vector<fs::path> &folders,b
|
||||
measure([&](const fs::path &directory,const FileVisitor &visit)
|
||||
{
|
||||
return listMeasuredDirectory(host,directory,visit,stop);
|
||||
});
|
||||
},!peer);
|
||||
}
|
||||
}
|
||||
catch(const std::exception &)
|
||||
@@ -4085,16 +4096,23 @@ void runActivePeerAction(HWND owner,bool update)
|
||||
(update?L"Requesting a KSwitcher update on ":L"Requesting hibernation for ")+peer.name+L"...");
|
||||
}
|
||||
|
||||
constexpr std::array driveSourceLabels{L"FTP",L"SFTP",L"SMB",L"Recent folders"};
|
||||
constexpr std::wstring_view driveShortcutDigits=L"1234567890";
|
||||
|
||||
LRESULT ftpDriveRow() {return lanDrivePicker?-1:static_cast<LRESULT>(drivePaths.size())+1;}
|
||||
LRESULT sftpDriveRow() {return lanDrivePicker?-1:ftpDriveRow()+1;}
|
||||
LRESULT smbDriveRow() {return lanDrivePicker?-1:sftpDriveRow()+1;}
|
||||
LRESULT recentDriveRow() {return lanDrivePicker?-1:smbDriveRow()+1;}
|
||||
LRESULT lanHeaderRow() {return recentDriveRow()+1;}
|
||||
|
||||
bool builtInDriveSource(LRESULT row)
|
||||
{
|
||||
return !lanDrivePicker && row>=ftpDriveRow() && row<lanHeaderRow();
|
||||
}
|
||||
|
||||
bool driveSourceRow(LRESULT row)
|
||||
{
|
||||
return row>=0 && (row<static_cast<LRESULT>(drivePaths.size()) || row==ftpDriveRow() ||
|
||||
row==sftpDriveRow() || row==smbDriveRow() || row==recentDriveRow());
|
||||
return (row>=0 && row<static_cast<LRESULT>(drivePaths.size())) || builtInDriveSource(row);
|
||||
}
|
||||
|
||||
bool panelItemPropertiesAvailable(const Panel &panel);
|
||||
@@ -4143,7 +4161,8 @@ void selectDrive()
|
||||
if(menuIndex==0 || menuIndex==4)
|
||||
{
|
||||
const int index=menuIndex==4;
|
||||
if(row>4) panelViewAction(owner,panels[index],static_cast<int>(row)-5);
|
||||
if(row>5) panelViewAction(owner,panels[index],static_cast<int>(row)-6);
|
||||
else if(row==5) toggleSpacePane(owner,index);
|
||||
else if(row==4) chooseDrive(index);
|
||||
else setMode(index,static_cast<PanelMode>(row));
|
||||
}
|
||||
@@ -4279,12 +4298,17 @@ LRESULT CALLBACK pickerKeys(HWND window, UINT msg, WPARAM wp, LPARAM lp, UINT_PT
|
||||
{ return path.native().front()==key; });
|
||||
if(disk!=drivePaths.end()) row=disk-drivePaths.begin();
|
||||
}
|
||||
else if(key==ftpDriveDigit) row=ftpDriveRow();
|
||||
else if(key>=L'0' && key<=L'9')
|
||||
{
|
||||
const auto choice=std::find_if(remoteDriveRows.begin(),remoteDriveRows.end(),
|
||||
[key](const auto &entry){return entry.second.digit==key;});
|
||||
if(choice!=remoteDriveRows.end()) row=choice->first;
|
||||
const auto digit=driveShortcutDigits.find(key);
|
||||
if(!lanDrivePicker && digit<driveSourceLabels.size())
|
||||
row=ftpDriveRow()+static_cast<LRESULT>(digit);
|
||||
else
|
||||
{
|
||||
const auto choice=std::find_if(remoteDriveRows.begin(),remoteDriveRows.end(),
|
||||
[key](const auto &entry){return entry.second.digit==key;});
|
||||
if(choice!=remoteDriveRows.end()) row=choice->first;
|
||||
}
|
||||
}
|
||||
if(row!=LB_ERR)
|
||||
{
|
||||
@@ -4409,8 +4433,9 @@ void layoutDrivePicker(int selected,bool focus)
|
||||
const int panelWidth=panel.right-panel.left;
|
||||
const auto frame=dialogFrameMetrics(GetDpiForWindow(owner));
|
||||
const int inset=frame.content(),vertical=dialogListInset(frame,textHeight);
|
||||
const int limit=lanDrivePicker?panelWidth:panelWidth*4/5;
|
||||
const int width=std::clamp(drivePickerWidth,90,std::max(90,limit-2*inset));
|
||||
const int scrollWidth=scrollBarWidth(picker);
|
||||
const int width=std::clamp(drivePickerWidth+scrollWidth,90,std::max(90,panelWidth-2*inset));
|
||||
const int listWidth=std::max(1,width-scrollWidth);
|
||||
const int height=std::min(std::max(1,(static_cast<int>(panel.bottom-panel.top)-2*vertical)/textHeight),
|
||||
static_cast<int>(SendMessageW(picker,LB_GETCOUNT,0,0)))*textHeight;
|
||||
const int x=panel.left+(panel.right-panel.left-width)/2;
|
||||
@@ -4420,11 +4445,11 @@ void layoutDrivePicker(int selected,bool focus)
|
||||
if(layout) layout=DeferWindowPos(layout,pickerFrame,HWND_TOP,
|
||||
x-inset,y-vertical,width+2*inset,height+2*vertical,flags);
|
||||
if(layout) layout=DeferWindowPos(layout,picker,HWND_TOP,x,y,
|
||||
std::max(1,width-scrollBarWidth(picker)),height,flags);
|
||||
listWidth,height,flags);
|
||||
if(!layout || !EndDeferWindowPos(layout))
|
||||
{
|
||||
SetWindowPos(pickerFrame,HWND_TOP,x-inset,y-vertical,width+2*inset,height+2*vertical,flags);
|
||||
SetWindowPos(picker,HWND_TOP,x,y,std::max(1,width-scrollBarWidth(picker)),height,flags);
|
||||
SetWindowPos(picker,HWND_TOP,x,y,listWidth,height,flags);
|
||||
}
|
||||
RedrawWindow(pickerFrame,nullptr,nullptr,RDW_INVALIDATE|RDW_UPDATENOW);
|
||||
SendMessageW(picker,LB_SETCURSEL,selected,0);
|
||||
@@ -4442,18 +4467,15 @@ void showRemoteDrives(bool focus=false,int initialRow=0)
|
||||
for(auto count=SendMessageW(picker,LB_GETCOUNT,0,0);count>static_cast<LRESULT>(drivePaths.size());--count)
|
||||
SendMessageW(picker,LB_DELETESTRING,count-1,0);
|
||||
remoteDriveRows.clear();
|
||||
const auto add=[](const std::wstring &label)
|
||||
const auto add=[](const std::wstring &label,int shortcutColumns=0)
|
||||
{
|
||||
drivePickerWidth=std::max(drivePickerWidth,static_cast<int>(label.size()+2)*cellWidth);
|
||||
drivePickerWidth=std::max(drivePickerWidth,(static_cast<int>(label.size())+2+shortcutColumns)*cellWidth);
|
||||
return SendMessageW(picker,LB_ADDSTRING,0,reinterpret_cast<LPARAM>(label.c_str()));
|
||||
};
|
||||
if(!lanDrivePicker)
|
||||
{
|
||||
add(L"");
|
||||
add(L"FTP");
|
||||
add(L"SFTP");
|
||||
add(L"SMB");
|
||||
add(L"Recent folders");
|
||||
for(const auto label:driveSourceLabels) add(label,2);
|
||||
}
|
||||
add(L"KSwitcher LAN");
|
||||
if(!drivePeerLookupError.empty()) add(L" "+drivePeerLookupError);
|
||||
@@ -4472,7 +4494,7 @@ void showRemoteDrives(bool focus=false,int initialRow=0)
|
||||
if(current.peer && current.peer->id==query.peer.id && path==current.directory.root_path())
|
||||
matchingDrive=row;
|
||||
const auto id=std::pair{query.peer.id,path};
|
||||
constexpr std::wstring_view available=L"234567890";
|
||||
const auto available=driveShortcutDigits.substr(lanDrivePicker?1:driveSourceLabels.size());
|
||||
auto digit=driveDigits.find(id);
|
||||
if(digit==driveDigits.end() && driveDigits.size()<available.size())
|
||||
digit=driveDigits.emplace(id,available[driveDigits.size()]).first;
|
||||
@@ -4571,6 +4593,7 @@ void pollDriveQueries(HWND owner)
|
||||
|
||||
void chooseDrive(int index,bool fromMenu,bool lanOnly)
|
||||
{
|
||||
if(index==spacePaneSide) closeSpacePane(GetParent(picker));
|
||||
lanDrivePicker=lanOnly;
|
||||
if(quickViewWindow && index!=quickViewSource) toggleQuickView(GetParent(picker));
|
||||
folderPicker.reset();
|
||||
@@ -4783,6 +4806,7 @@ void toggleQuickView(HWND owner)
|
||||
setStatus(L"Could not open Quick View.");
|
||||
return;
|
||||
}
|
||||
if(spacePaneWindow) closeSpacePane(owner,false);
|
||||
quickViewSource=active;
|
||||
refreshQuickView(panel);
|
||||
layout(owner);
|
||||
@@ -8559,6 +8583,7 @@ void openMenu(HWND window, int index)
|
||||
rows.push_back(std::move(label));
|
||||
}
|
||||
rows.push_back(index==0?L" Change drive\tAlt+F1":L" Change drive\tAlt+F2");
|
||||
rows.push_back(index/4==spacePaneSide?L" Close Space Analyzer":L" Space Analyzer");
|
||||
if(panelViewAvailable(panel))
|
||||
{
|
||||
constexpr const wchar_t *sortLabels[]{L"Sort by name\tCtrl+F3",L"Sort by extension\tCtrl+F4",
|
||||
@@ -8834,7 +8859,9 @@ void restoreCommandFocus()
|
||||
if(focus==GetParent(terminalInput)) SetFocus(gitChangesView->list);
|
||||
return;
|
||||
}
|
||||
if(GetFocus()!=terminalInput && !GetCapture() && commandLineAvailable(GetParent(terminalInput)))
|
||||
const auto focus=GetFocus();
|
||||
if(spacePaneWindow && (focus==spacePaneWindow || IsChild(spacePaneWindow,focus))) return;
|
||||
if(focus!=terminalInput && !GetCapture() && commandLineAvailable(GetParent(terminalInput)))
|
||||
SetFocus(terminalInput);
|
||||
}
|
||||
|
||||
@@ -9243,7 +9270,7 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
|
||||
const auto start=panelSearchPrefix.size()>cells?panelSearchPrefix.size()-cells:0;
|
||||
if(lavenderFiles())
|
||||
{
|
||||
paintLavenderDialogFrame(window,item.hDC,item.rcItem,L"Search");
|
||||
paintLavenderPopupFrame(item.hwndItem,item.hDC,item.rcItem,L"Search");
|
||||
lavender::rounded(item.hDC,field,LavenderMetrics(window).px(5),lavender::path,lavender::line);
|
||||
field.left+=LavenderMetrics(window).px(6);
|
||||
lavender::text(item.hDC,field,panelSearchPrefix.c_str()+start,lavender::ink);
|
||||
@@ -9355,7 +9382,7 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
|
||||
if(lavenderFiles())
|
||||
{
|
||||
const auto title=driveFrame?L"Change drive":folderPicker?folderPicker->caption:L"";
|
||||
paintLavenderDialogFrame(window,item.hDC,item.rcItem,title);
|
||||
paintLavenderPopupFrame(item.hwndItem,item.hDC,item.rcItem,title);
|
||||
paintScrollPosition(item.hwndItem,item.hDC,item.hwndItem==pickerFrame?picker:completionList,lavender::path);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -9600,7 +9627,7 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
|
||||
RECT button{};
|
||||
const auto choice=remoteDriveRows.find(item.itemID);
|
||||
const bool wake=choice!=remoteDriveRows.end() && !choice->second.path;
|
||||
const auto digit=item.itemID==ftpDriveRow()?ftpDriveDigit:
|
||||
const auto digit=builtInDriveSource(item.itemID)?driveShortcutDigits[item.itemID-ftpDriveRow()]:
|
||||
choice==remoteDriveRows.end()?L'\0':choice->second.digit;
|
||||
SelectObject(item.hDC,mono);
|
||||
SetTextColor(item.hDC,foreground);
|
||||
@@ -9847,6 +9874,7 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
|
||||
return 0;
|
||||
case WM_DESTROY:
|
||||
filesMcp.stop();
|
||||
closeSpacePane(window,false);
|
||||
pendingPanelDrop.reset();
|
||||
closeGitChanges(window,false);
|
||||
for(auto &panel:panels)
|
||||
@@ -9950,6 +9978,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR, int show)
|
||||
if(GetForegroundWindow()==window || IsChild(window,GetFocus())) restoreCommandFocus();
|
||||
if(GetMessageW(&message,nullptr,0,0)<=0) break;
|
||||
if(handleFilesHelpMessage(message) || handleComparisonMessage(message)) continue;
|
||||
if(handleSpacePaneMessage(window,message)) continue;
|
||||
if(message.message==WM_KEYDOWN && message.wParam==VK_TAB &&
|
||||
(GetKeyState(VK_CONTROL)&0x8000) && !(GetKeyState(VK_MENU)&0x8000) &&
|
||||
ks::files::cycleTextWindows(GetAncestor(message.hwnd,GA_ROOT),(GetKeyState(VK_SHIFT)&0x8000)!=0))
|
||||
|
||||
+201
-42
@@ -2,6 +2,7 @@ constexpr int spacePath=488,spaceTree=489,spaceStatus=490,spaceFooter=491;
|
||||
constexpr int spaceStop=492,spaceRescan=493,spaceView=494;
|
||||
constexpr int spaceCapacity=495,spaceScope=496,spaceMapButton=497,spaceMap=498;
|
||||
constexpr int spaceSunburstButton=499,spaceSunburstList=500,spaceSunburstLabel=501;
|
||||
constexpr int spaceTreeButton=502,spaceMetric=503;
|
||||
constexpr UINT_PTR spaceUpdateTimer=1;
|
||||
constexpr UINT_PTR spaceVolumeTimer=2;
|
||||
constexpr size_t spaceBatchSize=256;
|
||||
@@ -151,7 +152,7 @@ struct SpaceAnalyzer
|
||||
fs::path folder, root, selected;
|
||||
SpaceVolume volume;
|
||||
std::future<SpaceVolume> pendingVolume;
|
||||
bool selectedFolder{}, volumeScope{};
|
||||
bool selectedFolder{}, volumeScope{}, embedded{}, onDisk{};
|
||||
SpaceDisplay display{SpaceDisplay::tree};
|
||||
std::shared_ptr<SpaceRun> run;
|
||||
std::vector<SpaceNode> nodes;
|
||||
@@ -163,6 +164,13 @@ struct SpaceAnalyzer
|
||||
bool scanning{}, hasResults{};
|
||||
};
|
||||
|
||||
void showSpaceSelection(HWND owner,const SpaceAnalyzer &state,int origin,int answer);
|
||||
|
||||
uint64_t spaceBytes(const SpaceAnalyzer &state,const SpaceNode &node)
|
||||
{
|
||||
return state.onDisk?node.allocated.known.bytes:node.size.bytes;
|
||||
}
|
||||
|
||||
void layoutSpaceAnalyzer(HWND dialog)
|
||||
{
|
||||
RECT bounds{};
|
||||
@@ -173,39 +181,61 @@ void layoutSpaceAnalyzer(HWND dialog)
|
||||
const auto place=[&](int id,int top,int height) {
|
||||
SetWindowPos(GetDlgItem(dialog,id),nullptr,inset,top,width,height,SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
};
|
||||
const auto state=reinterpret_cast<const SpaceAnalyzer *>(GetWindowLongPtrW(dialog,DWLP_USER));
|
||||
const bool embedded=state && state->embedded;
|
||||
const auto gap=dialogColumnGap();
|
||||
const auto buttonHeight=textHeight;
|
||||
const auto buttonRows=[&](std::initializer_list<int> ids,int y,bool position)
|
||||
{
|
||||
const auto start=y;
|
||||
int x=inset;
|
||||
for(const auto id:ids)
|
||||
{
|
||||
const auto button=GetDlgItem(dialog,id);
|
||||
const auto buttonWidth=std::min(width,farDialogButtonWidth(button));
|
||||
if(x>inset && x+buttonWidth>inset+width)
|
||||
{
|
||||
y+=buttonHeight+dialogRowGap();
|
||||
x=inset;
|
||||
}
|
||||
if(position) SetWindowPos(button,nullptr,x,y,buttonWidth,buttonHeight,SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
x+=buttonWidth+gap;
|
||||
}
|
||||
return y-start+buttonHeight;
|
||||
};
|
||||
auto top=dialogListInset(frame,textHeight);
|
||||
place(spacePath,top,textHeight);
|
||||
top+=textHeight;
|
||||
place(spaceCapacity,top,textHeight);
|
||||
top+=textHeight+dialogRowGap();
|
||||
const auto buttonHeight=textHeight;
|
||||
auto x=inset;
|
||||
for(const auto id:{spaceScope,spaceMapButton,spaceSunburstButton})
|
||||
{
|
||||
const auto button=GetDlgItem(dialog,id);
|
||||
const auto width=std::max(12L*cellWidth,farDialogButtonWidth(button));
|
||||
SetWindowPos(button,nullptr,x,top,width,buttonHeight,SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
x+=width+dialogColumnGap();
|
||||
}
|
||||
top+=buttonHeight+dialogRowGap();
|
||||
place(spaceTree,top,9*textHeight);
|
||||
const auto state=reinterpret_cast<const SpaceAnalyzer *>(GetWindowLongPtrW(dialog,DWLP_USER));
|
||||
top+=buttonRows({spaceScope,spaceTreeButton,spaceMapButton,spaceSunburstButton},top,true)+dialogRowGap();
|
||||
const auto metric=GetDlgItem(dialog,spaceMetric);
|
||||
SetWindowPos(metric,nullptr,inset,top,std::min(width,20L*cellWidth),5*textHeight,
|
||||
SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
RECT metricBounds{};
|
||||
GetWindowRect(metric,&metricBounds);
|
||||
top+=std::max<LONG>(textHeight,metricBounds.bottom-metricBounds.top)+dialogRowGap();
|
||||
|
||||
const auto footerHeight=embedded?buttonRows(spaceFooterButtons,0,false):0;
|
||||
const auto treeHeight=embedded?std::max(1L,bounds.bottom-top-inset-footerHeight-textHeight-3*dialogRowGap()):
|
||||
9*static_cast<LONG>(textHeight);
|
||||
place(spaceTree,top,treeHeight);
|
||||
if(state && state->display==SpaceDisplay::sunburst)
|
||||
{
|
||||
const auto graphWidth=width*3/5;
|
||||
const auto gap=dialogColumnGap();
|
||||
SetWindowPos(GetDlgItem(dialog,spaceSunburstLabel),nullptr,inset+graphWidth,top-textHeight-dialogRowGap(),
|
||||
SetWindowPos(GetDlgItem(dialog,spaceSunburstLabel),nullptr,inset+graphWidth,top,
|
||||
width-graphWidth,textHeight,SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
SetWindowPos(GetDlgItem(dialog,spaceMap),nullptr,inset,top,graphWidth-gap,9*textHeight,
|
||||
SetWindowPos(GetDlgItem(dialog,spaceMap),nullptr,inset,top,std::max(1L,graphWidth-gap),treeHeight,
|
||||
SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
SetWindowPos(GetDlgItem(dialog,spaceSunburstList),nullptr,inset+graphWidth,top,width-graphWidth,
|
||||
9*textHeight,SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
SetWindowPos(GetDlgItem(dialog,spaceSunburstList),nullptr,inset+graphWidth,top+textHeight,width-graphWidth,
|
||||
std::max(1L,treeHeight-textHeight),SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
}
|
||||
else place(spaceMap,top,9*textHeight);
|
||||
top+=9*textHeight+dialogRowGap();
|
||||
else place(spaceMap,top,treeHeight);
|
||||
top+=treeHeight+dialogRowGap();
|
||||
place(spaceStatus,top,textHeight);
|
||||
place(spaceFooter,top+textHeight+dialogRowGap(),1);
|
||||
layoutDialogButtons(dialog,spaceFooter,spaceFooterButtons);
|
||||
if(embedded) buttonRows(spaceFooterButtons,top+textHeight+2*dialogRowGap(),true);
|
||||
else layoutDialogButtons(dialog,spaceFooter,spaceFooterButtons);
|
||||
}
|
||||
|
||||
HTREEITEM insertSpaceNode(HWND tree,SpaceAnalyzer &state,size_t index)
|
||||
@@ -230,6 +260,22 @@ void expandSpaceNode(HWND tree,SpaceAnalyzer &state,size_t index)
|
||||
for(auto child:node.children) insertSpaceNode(tree,state,child);
|
||||
}
|
||||
|
||||
int CALLBACK compareSpaceNodes(LPARAM left,LPARAM right,LPARAM payload)
|
||||
{
|
||||
const auto &state=*reinterpret_cast<const SpaceAnalyzer *>(payload);
|
||||
const auto &a=state.nodes[left],&b=state.nodes[right];
|
||||
const auto aSize=spaceBytes(state,a),bSize=spaceBytes(state,b);
|
||||
if(aSize!=bSize) return aSize>bSize?-1:1;
|
||||
return a.path.compare(b.path);
|
||||
}
|
||||
|
||||
void sortSpaceChildren(HWND tree,const SpaceAnalyzer &state,const SpaceNode &node)
|
||||
{
|
||||
if(!node.item || !node.expanded || node.children.size()<2) return;
|
||||
TVSORTCB sort{node.item,compareSpaceNodes,reinterpret_cast<LPARAM>(&state)};
|
||||
TreeView_SortChildrenCB(tree,&sort,FALSE);
|
||||
}
|
||||
|
||||
void addSpaceEvent(HWND tree,SpaceAnalyzer &state,SpaceEvent event)
|
||||
{
|
||||
if(!event.item)
|
||||
@@ -283,6 +329,11 @@ std::wstring spaceAllocatedSize(const SpaceNode &node)
|
||||
return result+L" on disk";
|
||||
}
|
||||
|
||||
std::wstring spaceMetricSize(const SpaceAnalyzer &state,const SpaceNode &node)
|
||||
{
|
||||
return state.onDisk?spaceAllocatedSize(node):spaceLogicalSize(node);
|
||||
}
|
||||
|
||||
std::wstring spaceNodeText(const SpaceAnalyzer &state,size_t index)
|
||||
{
|
||||
const auto &node=state.nodes[index];
|
||||
@@ -297,11 +348,12 @@ std::wstring spaceNodeText(const SpaceAnalyzer &state,size_t index)
|
||||
}
|
||||
if(!state.hasResults) return name;
|
||||
if(node.link) return name+L" [link]";
|
||||
auto result=name+L" — "+spaceLogicalSize(node)+L" · "+spaceAllocatedSize(node);
|
||||
if(parent.size.bytes)
|
||||
auto result=name+L" — "+spaceMetricSize(state,node);
|
||||
const auto parentBytes=spaceBytes(state,parent);
|
||||
if(parentBytes && (!state.onDisk || node.allocated.measured || !node.allocated.unavailable))
|
||||
{
|
||||
wchar_t share[48]{};
|
||||
swprintf_s(share,L" (%.1f%%)",100.0*static_cast<double>(node.size.bytes)/static_cast<double>(parent.size.bytes));
|
||||
swprintf_s(share,L" (%.1f%%)",100.0*static_cast<double>(spaceBytes(state,node))/static_cast<double>(parentBytes));
|
||||
result+=share;
|
||||
}
|
||||
return result;
|
||||
@@ -359,12 +411,12 @@ void updateSpaceTree(HWND dialog,SpaceAnalyzer &state)
|
||||
const auto &allocation=state.nodes[0].allocated;
|
||||
auto label=std::wstring(status)+L" · "+std::to_wstring(state.files)+L" files";
|
||||
if(indexed) label+=L" · NTFS index";
|
||||
if(allocation.unavailable || allocation.known.partial) label+=L" · on-disk sizes partial";
|
||||
else label+=state.display==SpaceDisplay::treemap?L" · logical size by area":
|
||||
state.display==SpaceDisplay::sunburst?L" · logical size by angle":L" · logical shares of parent";
|
||||
label+=state.onDisk?L" · Size on disk":L" · Logical size";
|
||||
if(state.onDisk && (allocation.unavailable || allocation.known.partial)) label+=L" (partial)";
|
||||
SetDlgItemTextW(dialog,spaceStatus,label.c_str());
|
||||
if(finished)
|
||||
{
|
||||
for(const auto &node:state.nodes) sortSpaceChildren(tree,state,node);
|
||||
EnableWindow(GetDlgItem(dialog,spaceStop),FALSE);
|
||||
EnableWindow(GetDlgItem(dialog,spaceRescan),TRUE);
|
||||
EnableWindow(GetDlgItem(dialog,spaceScope),!state.volume.root.empty() &&
|
||||
@@ -409,6 +461,8 @@ void prepareSpaceScope(HWND dialog,SpaceAnalyzer &state)
|
||||
layoutSpaceAnalyzer(dialog);
|
||||
}
|
||||
|
||||
void rescanSpace(HWND dialog,SpaceAnalyzer &state);
|
||||
|
||||
void updateSpaceVolume(HWND dialog,SpaceAnalyzer &state)
|
||||
{
|
||||
if(!state.pendingVolume.valid() ||
|
||||
@@ -426,6 +480,7 @@ void updateSpaceVolume(HWND dialog,SpaceAnalyzer &state)
|
||||
EnableWindow(GetDlgItem(dialog,spaceScope),
|
||||
!state.volume.root.empty() && !sameVolumeRoot(state.folder,state.volume.root));
|
||||
prepareSpaceScope(dialog,state);
|
||||
if(state.embedded) rescanSpace(dialog,state);
|
||||
}
|
||||
|
||||
void rescanSpace(HWND dialog,SpaceAnalyzer &state)
|
||||
@@ -467,6 +522,10 @@ INT_PTR CALLBACK spaceAnalyzerDialog(HWND dialog,UINT message,WPARAM wp,LPARAM l
|
||||
SetWindowSubclass(GetDlgItem(dialog,spaceSunburstList),spaceSunburstListKeys,1,reinterpret_cast<DWORD_PTR>(&state));
|
||||
TreeView_SetBkColor(tree,RGB(255,255,255));
|
||||
TreeView_SetTextColor(tree,RGB(0,0,0));
|
||||
for(const auto label:{L"Logical size",L"Size on disk"})
|
||||
SendDlgItemMessageW(dialog,spaceMetric,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(label));
|
||||
SendDlgItemMessageW(dialog,spaceMetric,CB_SETCURSEL,0,0);
|
||||
EnableWindow(GetDlgItem(dialog,spaceTreeButton),FALSE);
|
||||
layoutSpaceAnalyzer(dialog);
|
||||
const auto inset=dialogFrameMetrics(GetDpiForWindow(dialog)).content();
|
||||
// Rescan is one character wider than the initial Start label.
|
||||
@@ -487,6 +546,7 @@ INT_PTR CALLBACK spaceAnalyzerDialog(HWND dialog,UINT message,WPARAM wp,LPARAM l
|
||||
{
|
||||
SetDlgItemTextW(dialog,spaceCapacity,L"Volume capacity unavailable");
|
||||
prepareSpaceScope(dialog,state);
|
||||
if(state.embedded) rescanSpace(dialog,state);
|
||||
}
|
||||
SetFocus(tree);
|
||||
return FALSE;
|
||||
@@ -494,6 +554,11 @@ INT_PTR CALLBACK spaceAnalyzerDialog(HWND dialog,UINT message,WPARAM wp,LPARAM l
|
||||
const auto state=reinterpret_cast<SpaceAnalyzer *>(GetWindowLongPtrW(dialog,DWLP_USER));
|
||||
if(!state) return FALSE;
|
||||
const auto tree=GetDlgItem(dialog,spaceTree);
|
||||
if(message==WM_SIZE && state->embedded)
|
||||
{
|
||||
layoutSpaceAnalyzer(dialog);
|
||||
return TRUE;
|
||||
}
|
||||
if(message==WM_DRAWITEM && wp==spaceMap)
|
||||
{
|
||||
const auto &paint=*reinterpret_cast<const DRAWITEMSTRUCT *>(lp);
|
||||
@@ -535,7 +600,11 @@ INT_PTR CALLBACK spaceAnalyzerDialog(HWND dialog,UINT message,WPARAM wp,LPARAM l
|
||||
{
|
||||
const auto &item=*reinterpret_cast<const NMTREEVIEWW *>(lp);
|
||||
const auto index=static_cast<size_t>(item.itemNew.lParam);
|
||||
if(item.action==TVE_EXPAND && index<state->nodes.size()) expandSpaceNode(tree,*state,index);
|
||||
if(item.action==TVE_EXPAND && index<state->nodes.size())
|
||||
{
|
||||
expandSpaceNode(tree,*state,index);
|
||||
sortSpaceChildren(tree,*state,state->nodes[index]);
|
||||
}
|
||||
}
|
||||
if(notification->code==TVN_SELCHANGEDW)
|
||||
{
|
||||
@@ -562,12 +631,23 @@ INT_PTR CALLBACK spaceAnalyzerDialog(HWND dialog,UINT message,WPARAM wp,LPARAM l
|
||||
{
|
||||
state->volumeScope=!state->volumeScope;
|
||||
prepareSpaceScope(dialog,*state);
|
||||
if(state->embedded) rescanSpace(dialog,*state);
|
||||
return TRUE;
|
||||
}
|
||||
if(command==spaceMapButton || command==spaceSunburstButton)
|
||||
if(command==spaceMetric && HIWORD(wp)==CBN_SELCHANGE)
|
||||
{
|
||||
const auto chart=command==spaceMapButton?SpaceDisplay::treemap:SpaceDisplay::sunburst;
|
||||
setSpaceDisplay(dialog,*state,state->display==chart?SpaceDisplay::tree:chart);
|
||||
state->onDisk=SendDlgItemMessageW(dialog,spaceMetric,CB_GETCURSEL,0,0)==1;
|
||||
for(const auto &node:state->nodes) sortSpaceChildren(tree,*state,node);
|
||||
InvalidateRect(tree,nullptr,FALSE);
|
||||
if(state->display!=SpaceDisplay::tree) refreshSpaceChart(GetDlgItem(dialog,spaceMap),*state);
|
||||
if(state->run) updateSpaceTree(dialog,*state);
|
||||
return TRUE;
|
||||
}
|
||||
if(command==spaceTreeButton || command==spaceMapButton || command==spaceSunburstButton)
|
||||
{
|
||||
const auto display=command==spaceTreeButton?SpaceDisplay::tree:
|
||||
command==spaceMapButton?SpaceDisplay::treemap:SpaceDisplay::sunburst;
|
||||
setSpaceDisplay(dialog,*state,display);
|
||||
if(state->run) updateSpaceTree(dialog,*state);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -594,7 +674,8 @@ INT_PTR CALLBACK spaceAnalyzerDialog(HWND dialog,UINT message,WPARAM wp,LPARAM l
|
||||
}
|
||||
if(message==WM_CLOSE || (message==WM_COMMAND && LOWORD(wp)==IDCANCEL))
|
||||
{
|
||||
FilesModalDialog::finish(dialog,IDCANCEL);
|
||||
if(state->embedded) closeSpacePane(GetParent(dialog));
|
||||
else FilesModalDialog::finish(dialog,IDCANCEL);
|
||||
return TRUE;
|
||||
}
|
||||
if(message==WM_DESTROY)
|
||||
@@ -606,17 +687,8 @@ INT_PTR CALLBACK spaceAnalyzerDialog(HWND dialog,UINT message,WPARAM wp,LPARAM l
|
||||
return paintCopyDialog(dialog,message,wp,lp,L" Space Analyzer ",false,{spaceFooter});
|
||||
}
|
||||
|
||||
void openSpaceAnalyzer(HWND owner,Panel &panel)
|
||||
void showSpaceSelection(HWND owner,const SpaceAnalyzer &state,int origin,int answer)
|
||||
{
|
||||
if(panel.peer || panel.ftp || panel.archive || panel.directory.empty())
|
||||
{
|
||||
setStatus(L"Space Analyzer requires an open local folder.");
|
||||
return;
|
||||
}
|
||||
const auto origin=static_cast<int>(&panel-panels);
|
||||
SpaceAnalyzer state{.folder=folderPathWithoutSeparator(panel.directory),.root=folderPathWithoutSeparator(panel.directory)};
|
||||
const auto answer=FilesModalDialog::run(GetModuleHandleW(nullptr),MAKEINTRESOURCEW(118),owner,
|
||||
spaceAnalyzerDialog,reinterpret_cast<LPARAM>(&state));
|
||||
if(answer==spaceView)
|
||||
{
|
||||
ks::files::openTextWindow(owner,state.selected,false,textWindowDialogs(),nullptr);
|
||||
@@ -633,3 +705,90 @@ void openSpaceAnalyzer(HWND owner,Panel &panel)
|
||||
if(state.selectedFolder) openOn(other,state.selected,true,{});
|
||||
else revealLocalFile(other,state.selected);
|
||||
}
|
||||
|
||||
bool spaceAnalyzerAvailable(const Panel &panel)
|
||||
{
|
||||
return !panel.peer && !panel.ftp && !panel.archive && !panelListsLocations(panel) && !panel.directory.empty();
|
||||
}
|
||||
|
||||
void openSpaceAnalyzer(HWND owner,Panel &panel)
|
||||
{
|
||||
if(!spaceAnalyzerAvailable(panel))
|
||||
{
|
||||
setStatus(L"Space Analyzer requires an open local folder.");
|
||||
return;
|
||||
}
|
||||
const auto folder=folderPathWithoutSeparator(panel.directory);
|
||||
SpaceAnalyzer state{.folder=folder,.root=folder};
|
||||
const auto answer=FilesModalDialog::run(GetModuleHandleW(nullptr),MAKEINTRESOURCEW(118),owner,
|
||||
spaceAnalyzerDialog,reinterpret_cast<LPARAM>(&state));
|
||||
showSpaceSelection(owner,state,static_cast<int>(&panel-panels),static_cast<int>(answer));
|
||||
}
|
||||
|
||||
std::unique_ptr<SpaceAnalyzer> spacePane;
|
||||
|
||||
void focusSpacePane()
|
||||
{
|
||||
if(spacePaneWindow && IsWindowVisible(spacePaneWindow)) SetFocus(GetDlgItem(spacePaneWindow,spaceTree));
|
||||
}
|
||||
|
||||
void closeSpacePane(HWND owner,bool restorePane)
|
||||
{
|
||||
if(!spacePaneWindow) return;
|
||||
const auto side=std::exchange(spacePaneSide,-1);
|
||||
DestroyWindow(std::exchange(spacePaneWindow,nullptr));
|
||||
spacePane.reset();
|
||||
if(restorePane)
|
||||
{
|
||||
activatePanel(side);
|
||||
layout(owner);
|
||||
restoreCommandFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void toggleSpacePane(HWND owner,int side)
|
||||
{
|
||||
if(spacePaneSide==side)
|
||||
{
|
||||
closeSpacePane(owner);
|
||||
return;
|
||||
}
|
||||
const auto &panel=panels[side];
|
||||
if(!spaceAnalyzerAvailable(panel) || terminalVisible)
|
||||
{
|
||||
setStatus(L"Space Analyzer requires a visible local file pane.");
|
||||
return;
|
||||
}
|
||||
const auto folder=folderPathWithoutSeparator(panel.directory);
|
||||
auto state=std::make_unique<SpaceAnalyzer>();
|
||||
state->folder=state->root=folder;
|
||||
state->embedded=true;
|
||||
const auto window=CreateDialogParamW(GetModuleHandleW(nullptr),MAKEINTRESOURCEW(621),owner,
|
||||
spaceAnalyzerDialog,reinterpret_cast<LPARAM>(state.get()));
|
||||
if(!window)
|
||||
{
|
||||
setStatus(L"Could not open Space Analyzer in this pane.");
|
||||
return;
|
||||
}
|
||||
closeQuickViews();
|
||||
closeSpacePane(owner,false);
|
||||
spacePane=std::move(state);
|
||||
spacePaneWindow=window;
|
||||
spacePaneSide=side;
|
||||
activatePanel(1-side);
|
||||
layout(owner);
|
||||
focusSpacePane();
|
||||
}
|
||||
|
||||
bool handleSpacePaneMessage(HWND owner,MSG &message)
|
||||
{
|
||||
if(!spacePaneWindow || (message.hwnd!=spacePaneWindow && !IsChild(spacePaneWindow,message.hwnd))) return false;
|
||||
if(message.message==WM_KEYDOWN && message.wParam==VK_ESCAPE)
|
||||
{
|
||||
if(SendDlgItemMessageW(spacePaneWindow,spaceMetric,CB_GETDROPPEDSTATE,0,0))
|
||||
SendDlgItemMessageW(spacePaneWindow,spaceMetric,CB_SHOWDROPDOWN,FALSE,0);
|
||||
else closeSpacePane(owner);
|
||||
return true;
|
||||
}
|
||||
return IsDialogMessageW(spacePaneWindow,&message)!=FALSE;
|
||||
}
|
||||
+10
-14
@@ -5,7 +5,8 @@ void finishSpaceSelection(HWND dialog,SpaceAnalyzer &state,size_t selected,int a
|
||||
if(action==spaceView && node.folder) return;
|
||||
state.selected=node.path;
|
||||
state.selectedFolder=node.folder;
|
||||
FilesModalDialog::finish(dialog,action);
|
||||
if(state.embedded) showSpaceSelection(GetParent(dialog),state,spacePaneSide,action);
|
||||
else FilesModalDialog::finish(dialog,action);
|
||||
}
|
||||
|
||||
void divideSpaceTiles(std::span<const size_t> nodes,std::span<const long double> prefix,RECT bounds,
|
||||
@@ -51,14 +52,14 @@ void layoutSpaceMap(HWND map,SpaceAnalyzer &state)
|
||||
if(state.mapFolder>=state.nodes.size()) return;
|
||||
std::vector<size_t> items;
|
||||
for(auto index:state.nodes[state.mapFolder].children)
|
||||
if(state.nodes[index].size.bytes) items.push_back(index);
|
||||
if(spaceBytes(state,state.nodes[index])) items.push_back(index);
|
||||
std::sort(items.begin(),items.end(),[&](size_t left,size_t right) {
|
||||
const auto a=state.nodes[left].size.bytes, b=state.nodes[right].size.bytes;
|
||||
const auto a=spaceBytes(state,state.nodes[left]), b=spaceBytes(state,state.nodes[right]);
|
||||
return a!=b?a>b:left<right;
|
||||
});
|
||||
std::vector<long double> prefix{0};
|
||||
prefix.reserve(items.size()+1);
|
||||
for(auto index:items) prefix.push_back(prefix.back()+state.nodes[index].size.bytes);
|
||||
for(auto index:items) prefix.push_back(prefix.back()+spaceBytes(state,state.nodes[index]));
|
||||
RECT bounds{};
|
||||
GetClientRect(map,&bounds);
|
||||
const auto minimum=std::max(4,MulDiv(8,GetDpiForWindow(map),96));
|
||||
@@ -120,14 +121,8 @@ void paintSpaceMap(const DRAWITEMSTRUCT &paint,const SpaceAnalyzer &state)
|
||||
bounds.top+=textHeight;
|
||||
if(bounds.bottom-bounds.top>=textHeight)
|
||||
{
|
||||
const auto logical=spaceLogicalSize(node);
|
||||
DrawTextW(paint.hDC,logical.c_str(),-1,&bounds,DT_SINGLELINE|DT_NOPREFIX|DT_END_ELLIPSIS);
|
||||
bounds.top+=textHeight;
|
||||
if(bounds.bottom-bounds.top>=textHeight)
|
||||
{
|
||||
const auto allocated=spaceAllocatedSize(node);
|
||||
DrawTextW(paint.hDC,allocated.c_str(),-1,&bounds,DT_SINGLELINE|DT_NOPREFIX|DT_END_ELLIPSIS);
|
||||
}
|
||||
const auto value=spaceMetricSize(state,node);
|
||||
DrawTextW(paint.hDC,value.c_str(),-1,&bounds,DT_SINGLELINE|DT_NOPREFIX|DT_END_ELLIPSIS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,8 +214,9 @@ void setSpaceDisplay(HWND dialog,SpaceAnalyzer &state,SpaceDisplay display)
|
||||
state.mapFolder=node.folder && !node.link?index:node.parent;
|
||||
}
|
||||
state.display=display;
|
||||
SetDlgItemTextW(dialog,spaceMapButton,display==SpaceDisplay::treemap?L"Tr&ee":L"Tree&map");
|
||||
SetDlgItemTextW(dialog,spaceSunburstButton,showSunburst?L"Tr&ee":L"S&unburst");
|
||||
EnableWindow(GetDlgItem(dialog,spaceTreeButton),!showTree);
|
||||
EnableWindow(GetDlgItem(dialog,spaceMapButton),display!=SpaceDisplay::treemap);
|
||||
EnableWindow(GetDlgItem(dialog,spaceSunburstButton),!showSunburst);
|
||||
layoutSpaceAnalyzer(dialog);
|
||||
ShowWindow(tree,showTree?SW_SHOW:SW_HIDE);
|
||||
ShowWindow(map,showTree?SW_HIDE:SW_SHOW);
|
||||
|
||||
@@ -12,15 +12,16 @@ void addSunburstRing(SpaceAnalyzer &state,size_t folder,unsigned ring,double sta
|
||||
if(ring>=sunburstRings || end-start<0.02) return;
|
||||
const auto &parent=state.nodes[folder];
|
||||
double total=0;
|
||||
for(auto index:parent.children) total+=static_cast<double>(state.nodes[index].size.bytes);
|
||||
for(auto index:parent.children) total+=static_cast<double>(spaceBytes(state,state.nodes[index]));
|
||||
if(total<=0) return;
|
||||
const auto span=end-start;
|
||||
auto cursor=start;
|
||||
for(auto index:parent.children)
|
||||
{
|
||||
const auto &item=state.nodes[index];
|
||||
if(!item.size.bytes) continue;
|
||||
const auto next=std::min(end,cursor+span*static_cast<double>(item.size.bytes)/total);
|
||||
const auto size=spaceBytes(state,item);
|
||||
if(!size) continue;
|
||||
const auto next=std::min(end,cursor+span*static_cast<double>(size)/total);
|
||||
if(next-cursor>=0.02)
|
||||
{
|
||||
state.sectors.push_back({index,ring,cursor,next});
|
||||
@@ -75,7 +76,7 @@ void layoutSunburst(HWND map,SpaceAnalyzer &state)
|
||||
const auto &node=state.nodes[sector.node];
|
||||
const auto &root=state.nodes[state.mapFolder];
|
||||
const auto name=node.path.lexically_relative(root.path).native();
|
||||
const auto line=name+L" — "+spaceLogicalSize(node);
|
||||
const auto line=name+L" — "+spaceMetricSize(state,node);
|
||||
const auto row=SendMessageW(list,LB_ADDSTRING,0,reinterpret_cast<LPARAM>(line.c_str()));
|
||||
if(row>=0)
|
||||
{
|
||||
|
||||
+52
-11
@@ -1,15 +1,53 @@
|
||||
#pragma once
|
||||
#include "platform.h"
|
||||
#include <uiautomation.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
namespace ks
|
||||
{
|
||||
inline bool focusedTextBelongsToWindow(IUIAutomation *automation, IUIAutomationElement *focused, HWND target)
|
||||
{
|
||||
using Microsoft::WRL::ComPtr;
|
||||
DWORD process{};
|
||||
GetWindowThreadProcessId(target, &process);
|
||||
int focusedProcess{};
|
||||
if (!process || FAILED(focused->get_CurrentProcessId(&focusedProcess))) return false;
|
||||
if (process == static_cast<DWORD>(focusedProcess)) return true;
|
||||
BOOL hasFocus{}, readOnly = TRUE;
|
||||
ComPtr<IUIAutomationValuePattern> value;
|
||||
if (FAILED(focused->get_CurrentHasKeyboardFocus(&hasFocus)) || !hasFocus ||
|
||||
FAILED(focused->GetCurrentPatternAs(UIA_ValuePatternId, IID_PPV_ARGS(&value))) || !value ||
|
||||
FAILED(value->get_CurrentIsReadOnly(&readOnly)) || readOnly)
|
||||
return false;
|
||||
|
||||
// WebView2 exposes text through a different process. Its accessibility
|
||||
// ancestors lead back to a native child window of the foreground app.
|
||||
ComPtr<IUIAutomationTreeWalker> walker;
|
||||
if (FAILED(automation->get_RawViewWalker(&walker)) || !walker)
|
||||
return false;
|
||||
ComPtr<IUIAutomationElement> element = focused;
|
||||
for (int depth = 0; element && depth < 32; ++depth)
|
||||
{
|
||||
UIA_HWND native{};
|
||||
if (SUCCEEDED(element->get_CurrentNativeWindowHandle(&native)) && native)
|
||||
{
|
||||
const auto hwnd = reinterpret_cast<HWND>(native);
|
||||
return hwnd == target || IsChild(target, hwnd);
|
||||
}
|
||||
ComPtr<IUIAutomationElement> parent;
|
||||
if (FAILED(walker->GetParentElement(element.Get(), &parent))) return false;
|
||||
element = std::move(parent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read-only UI Automation: never select, move the caret, or touch the clipboard.
|
||||
class PasteProbe
|
||||
{
|
||||
IUIAutomation2 *automation{};
|
||||
IUIAutomationElement *element{};
|
||||
IUIAutomationTextPattern *pattern{};
|
||||
HWND targetWindow{};
|
||||
|
||||
static std::optional<std::wstring> rangeText(IUIAutomationTextRange *range)
|
||||
{
|
||||
@@ -24,7 +62,7 @@ class PasteProbe
|
||||
public:
|
||||
std::wstring status = L"not-requested";
|
||||
std::optional<std::wstring> precedingCharacter;
|
||||
PasteProbe(bool enabled, HWND target)
|
||||
PasteProbe(bool enabled, HWND target) : targetWindow(target)
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
@@ -36,17 +74,15 @@ class PasteProbe
|
||||
automation->put_TransactionTimeout(200);
|
||||
if (FAILED(automation->GetFocusedElement(&element)) || !element)
|
||||
return;
|
||||
if (target)
|
||||
if (target && GetForegroundWindow() != target)
|
||||
{
|
||||
DWORD process{};
|
||||
GetWindowThreadProcessId(target, &process);
|
||||
int focusedProcess{};
|
||||
if (!process || FAILED(element->get_CurrentProcessId(&focusedProcess)) ||
|
||||
process != static_cast<DWORD>(focusedProcess) || GetForegroundWindow() != target)
|
||||
{
|
||||
status = L"focused-control-changed";
|
||||
return;
|
||||
}
|
||||
status = L"focused-window-changed";
|
||||
return;
|
||||
}
|
||||
if (target && !focusedTextBelongsToWindow(automation, element, target))
|
||||
{
|
||||
status = L"focused-control-outside-target";
|
||||
return;
|
||||
}
|
||||
BOOL password = TRUE;
|
||||
if (FAILED(element->get_CurrentIsPassword(&password)) || password)
|
||||
@@ -95,6 +131,11 @@ class PasteProbe
|
||||
{
|
||||
if (!pattern)
|
||||
return {};
|
||||
if (targetWindow && GetForegroundWindow() != targetWindow)
|
||||
{
|
||||
status = L"focused-window-changed";
|
||||
return {};
|
||||
}
|
||||
if (characters <= 0 || characters > 4096)
|
||||
{
|
||||
status = L"readback-size-limit";
|
||||
|
||||
+6
-4
@@ -676,9 +676,10 @@ bool needsSelectionDelay(HWND target)
|
||||
{
|
||||
const auto name = lower(processName(target));
|
||||
return name == L"ms-teams" || name == L"msedgewebview2" ||
|
||||
name == L"chrome" || name == L"msedge" || name == L"chatgpt" || name == L"codex";
|
||||
name == L"chrome" || name == L"msedge" || name == L"chatgpt" ||
|
||||
name == L"codex" || name == L"claude";
|
||||
}
|
||||
bool selectPrevious(size_t count, const std::function<bool()> &valid)
|
||||
bool selectPrevious(size_t count, const std::function<bool()> &valid, bool forcePacing)
|
||||
{
|
||||
if (count > 100000)
|
||||
return false;
|
||||
@@ -686,9 +687,10 @@ bool selectPrevious(size_t count, const std::function<bool()> &valid)
|
||||
// Shift+Left events can all use the same caret position and select only one
|
||||
// character. Give each change time to settle before sending the next one.
|
||||
const auto target = GetForegroundWindow();
|
||||
const bool paced = forcePacing || needsSelectionDelay(target);
|
||||
diagnosticEvent(L"SelectPrevious requested=" + std::to_wstring(count) +
|
||||
L" mode=" + (needsSelectionDelay(target) ? std::wstring(L"paced-25ms") : std::wstring(L"batch")));
|
||||
if (needsSelectionDelay(target))
|
||||
(paced ? L" mode=paced-25ms" : L" mode=batch"));
|
||||
if (paced)
|
||||
{
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ ULONG_PTR inputMarker();
|
||||
bool ownKeyboardInput(const KBDLLHOOKSTRUCT &);
|
||||
INPUT keyboardInput(WORD key, DWORD flags = 0);
|
||||
bool needsSelectionDelay(HWND);
|
||||
bool selectPrevious(size_t count, const std::function<bool()> &valid);
|
||||
bool selectPrevious(size_t count, const std::function<bool()> &valid, bool forcePacing = false);
|
||||
bool modifiersReleased();
|
||||
void releaseModifiers();
|
||||
std::filesystem::path dataDirectory();
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include "platform.h"
|
||||
namespace ks
|
||||
{
|
||||
inline constexpr wchar_t AppVersion[] = L"0.8.3";
|
||||
inline constexpr wchar_t AppVersion[] = L"0.8.8";
|
||||
inline constexpr UINT UpdateMessage = WM_APP + 7;
|
||||
inline constexpr UINT UpdateCheckIntervalMs = 6 * 60 * 60 * 1000;
|
||||
inline constexpr UINT UpdateNotificationRetryMs = 5 * 60 * 1000;
|
||||
|
||||
@@ -81,8 +81,8 @@ function Open-FilesSource([IntPtr]$Window, [int]$Side, [string]$Source) {
|
||||
[void][FilesCommandsUi]::Post($Window, 0x111, [IntPtr](0x20000 + 121), $picker)
|
||||
}
|
||||
|
||||
function Invoke-FilesCommand([IntPtr]$Window, [string]$LabelPattern) {
|
||||
[void][FilesCommandsUi]::Post($Window, 273, [IntPtr]132, [IntPtr]::Zero)
|
||||
function Invoke-FilesCommand([IntPtr]$Window, [string]$LabelPattern, [int]$Menu = 132) {
|
||||
[void][FilesCommandsUi]::Post($Window, 273, [IntPtr]$Menu, [IntPtr]::Zero)
|
||||
$picker = [FilesCommandsUi]::GetDlgItem($Window, 121)
|
||||
[void](Wait-For 'the Commands menu' { [FilesCommandsUi]::IsWindowVisible($picker) })
|
||||
$count = [FilesCommandsUi]::Send($picker, 395, [IntPtr]::Zero, [IntPtr]::Zero).ToInt64()
|
||||
|
||||
@@ -2,10 +2,12 @@ param(
|
||||
[string]$Executable = "$PSScriptRoot/../build/files-dev/KSwitcher.Files.exe",
|
||||
[switch]$OfflineWake,
|
||||
[switch]$FtpProfiles,
|
||||
[switch]$Far,
|
||||
[string]$Screenshot
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
. "$PSScriptRoot/files_commands_ui.ps1"
|
||||
Add-Type @'
|
||||
using System;
|
||||
@@ -45,8 +47,9 @@ $previousDpi = [FilesDriveShortcutTest]::SetThreadDpiAwarenessContext([IntPtr](-
|
||||
try {
|
||||
if ($FtpProfiles) {
|
||||
$preferences = [Microsoft.Win32.Registry]::CurrentUser.CreateSubKey('Software\KSwitcher\Files')
|
||||
$preferenceNames = 'FtpProfiles', 'LeftWide', 'RightWide', 'LeftPath', 'RightPath', 'LeftCursor', 'RightCursor',
|
||||
'LeftFtpLocation', 'RightFtpLocation', 'FontPoints', 'WindowPlacement'
|
||||
$preferenceNames = 'FtpProfiles', 'SftpProfiles', 'RecentFolders', 'LeftWide', 'RightWide',
|
||||
'LeftPath', 'RightPath', 'LeftCursor', 'RightCursor', 'LeftFtpLocation', 'RightFtpLocation',
|
||||
'FontPoints', 'WindowPlacement', 'AppearanceMode', 'PanelScale', 'DisplayFont', 'RestoreLocalDocuments'
|
||||
foreach ($name in $preferenceNames) {
|
||||
if ($name -in $preferences.GetValueNames()) {
|
||||
$savedPreferences[$name] = @($preferences.GetValue($name), $preferences.GetValueKind($name))
|
||||
@@ -54,8 +57,17 @@ try {
|
||||
}
|
||||
$profile = '[{"name":"Test FTP profile","host":"localhost","user":"","port":21,"secret":[]}]'
|
||||
$preferences.SetValue('FtpProfiles', [Text.Encoding]::UTF8.GetBytes($profile), 'Binary')
|
||||
$profile = '[{"name":"Test SFTP profile","host":"localhost","user":"","port":22,"secret":[]}]'
|
||||
$preferences.SetValue('SftpProfiles', [Text.Encoding]::UTF8.GetBytes($profile), 'Binary')
|
||||
$recentFolder = [IO.Path]::GetFullPath($env:TEMP)
|
||||
$recentJson = ConvertTo-Json -InputObject @($recentFolder) -Compress
|
||||
$preferences.SetValue('RecentFolders', [Text.Encoding]::UTF8.GetBytes($recentJson), 'Binary')
|
||||
foreach ($name in 'LeftWide', 'RightWide') { $preferences.SetValue($name, 1, 'DWord') }
|
||||
$preferences.SetValue('FontPoints', 80, 'DWord')
|
||||
$preferences.SetValue('PanelScale', 100, 'DWord')
|
||||
$preferences.SetValue('AppearanceMode', [int]!$Far, 'DWord')
|
||||
$preferences.SetValue('RestoreLocalDocuments', 0, 'DWord')
|
||||
$preferences.DeleteValue('DisplayFont', $false)
|
||||
foreach ($name in 'LeftFtpLocation', 'RightFtpLocation', 'WindowPlacement') {
|
||||
$preferences.DeleteValue($name, $false)
|
||||
}
|
||||
@@ -74,17 +86,18 @@ try {
|
||||
$picker = [FilesDriveShortcutTest]::GetDlgItem($window, 121)
|
||||
$path = [FilesDriveShortcutTest]::GetDlgItem($window, 142)
|
||||
function Open-Picker([int]$Side = 0) {
|
||||
[void][FilesDriveShortcutTest]::PostMessage($window, 260, [IntPtr](112 + $Side), [IntPtr]::Zero)
|
||||
Wait-Until { [FilesDriveShortcutTest]::IsWindowVisible($picker) }
|
||||
Invoke-FilesCommand $window '*Change drive*' (130 + 4 * $Side)
|
||||
Wait-Until { (Read-Picker) -contains 'KSwitcher LAN' }
|
||||
}
|
||||
function Read-Picker {
|
||||
$count = [FilesDriveShortcutTest]::SendMessage($picker, 395, [IntPtr]::Zero, $null).ToInt32()
|
||||
for ($i = 0; $i -lt $count; $i++) { Read-Text $picker 393 $i }
|
||||
}
|
||||
function Render-Picker {
|
||||
function Render-Picker([int]$Height = 0) {
|
||||
$client = [FilesDriveShortcutTest+Rect]::new()
|
||||
[void][FilesDriveShortcutTest]::GetClientRect($picker, [ref]$client)
|
||||
$bitmap = [Drawing.Bitmap]::new($client.Right, $client.Bottom)
|
||||
$captureHeight = if ($Height -gt 0) { [Math]::Min($Height, $client.Bottom) } else { $client.Bottom }
|
||||
$bitmap = [Drawing.Bitmap]::new($client.Right, $captureHeight)
|
||||
$graphics = [Drawing.Graphics]::FromImage($bitmap)
|
||||
try {
|
||||
$dc = $graphics.GetHdc()
|
||||
@@ -137,17 +150,43 @@ try {
|
||||
$line -ne $bitmap.GetPixel($bitmap.Width - 5, $y).ToArgb()) {
|
||||
throw "The local disks and FTP divider did not render in panel $side."
|
||||
}
|
||||
$ftpBounds = [FilesDriveShortcutTest+Rect]::new()
|
||||
[void][FilesDriveShortcutTest]::SendRect($picker, 408, [IntPtr]$row, [ref]$ftpBounds)
|
||||
$yellow = [Drawing.Color]::Yellow.ToArgb()
|
||||
$hasDigit = $false
|
||||
for ($lineY = $ftpBounds.Top; $lineY -lt $ftpBounds.Bottom -and $lineY -lt $bitmap.Height -and !$hasDigit; $lineY++) {
|
||||
for ($x = 0; $x -lt [Math]::Min(128,$bitmap.Width); $x++) {
|
||||
if ($bitmap.GetPixel($x,$lineY).ToArgb() -eq $yellow) { $hasDigit = $true; break }
|
||||
$accent = if ($Far) { [Drawing.Color]::Yellow.ToArgb() } else { [Drawing.Color]::FromArgb(70, 72, 187).ToArgb() }
|
||||
$dpi = [FilesCommandsUi]::GetDpiForWindow($picker)
|
||||
$pixels = [Math]::Round(8 * $dpi / 72)
|
||||
$font = [Drawing.Font]::new('Consolas', $pixels, [Drawing.FontStyle]::Regular, [Drawing.GraphicsUnit]::Pixel)
|
||||
try {
|
||||
$columns = @(0, 0, 0)
|
||||
$flags = [Windows.Forms.TextFormatFlags]::NoPadding -bor [Windows.Forms.TextFormatFlags]::SingleLine
|
||||
$layout = [Drawing.Size]::new(10000, 1000)
|
||||
for ($disk = 0; $disk -lt $row - 1; ++$disk) {
|
||||
$parts = $rows[$disk] -split [char]9
|
||||
for ($column = 0; $column -lt 3; ++$column) {
|
||||
$width = [Windows.Forms.TextRenderer]::MeasureText($parts[$column], $font, $layout, $flags).Width
|
||||
$columns[$column] = [Math]::Max($columns[$column], $width)
|
||||
}
|
||||
}
|
||||
$space = [Windows.Forms.TextRenderer]::MeasureText(' ', $font, $layout, $flags).Width
|
||||
$lastColumnEnd = $columns[0] + $columns[1] + $columns[2] + 5 * $space + 2
|
||||
if ($bitmap.Width -lt $lastColumnEnd) {
|
||||
throw "Free-space values are clipped in panel $side (end $lastColumnEnd, width $($bitmap.Width))."
|
||||
}
|
||||
} finally { $font.Dispose() }
|
||||
for ($offset = 0; $offset -lt 4; $offset++) {
|
||||
$bounds = [FilesDriveShortcutTest+Rect]::new()
|
||||
[void][FilesDriveShortcutTest]::SendRect($picker, 408, [IntPtr]($row + $offset), [ref]$bounds)
|
||||
$hasDigit = $false
|
||||
for ($lineY = $bounds.Top; $lineY -lt $bounds.Bottom -and $lineY -lt $bitmap.Height -and !$hasDigit; $lineY++) {
|
||||
for ($x = 0; $x -lt [Math]::Min(128,$bitmap.Width); $x++) {
|
||||
if ($bitmap.GetPixel($x,$lineY).ToArgb() -eq $accent) { $hasDigit = $true; break }
|
||||
}
|
||||
}
|
||||
if (!$hasDigit) { throw "The $($rows[$row + $offset]) shortcut digit did not render in panel $side." }
|
||||
}
|
||||
if ($Screenshot -and $side -eq 0) {
|
||||
$sources = Render-Picker $bounds.Bottom
|
||||
try { $sources.Save($Screenshot, [Drawing.Imaging.ImageFormat]::Png) }
|
||||
finally { $sources.Dispose() }
|
||||
}
|
||||
if (!$hasDigit) { throw "The FTP shortcut digit did not render in panel $side." }
|
||||
if ($Screenshot -and $side -eq 0) { $bitmap.Save($Screenshot, [Drawing.Imaging.ImageFormat]::Png) }
|
||||
} finally { $bitmap.Dispose() }
|
||||
[void][FilesDriveShortcutTest]::SendMessage($picker, 390, [IntPtr]($row - 2), $null)
|
||||
Press-Shortcut '1'
|
||||
@@ -163,8 +202,19 @@ try {
|
||||
} finally { $graphics.ReleaseHdc($dc) }
|
||||
} finally { $graphics.Dispose() }
|
||||
if ($process.HasExited) { throw "Files exited while rendering the FTP profile in panel $side." }
|
||||
Open-Picker $side
|
||||
Press-Shortcut '2'
|
||||
Wait-Until { (Read-Text $panelPath) -ceq 'SFTP' }
|
||||
if ((Read-Text $list 393 0) -cne 'Test SFTP profile') { throw "Saved SFTP profile missing from panel $side." }
|
||||
Open-Picker $side
|
||||
Press-Shortcut '3'
|
||||
Wait-Until { (Read-Text $panelPath) -ceq 'SMB' }
|
||||
Open-Picker $side
|
||||
Press-Shortcut '4'
|
||||
Wait-Until { (Read-Text $panelPath) -ceq 'Recent folders' }
|
||||
Wait-Until { (Read-FilesList $list) -contains $recentFolder }
|
||||
}
|
||||
Write-Output 'Both source menus rendered the FTP shortcut, skipped group dividers, and opened FTP with 1.'
|
||||
Write-Output 'Both source menus rendered shortcuts 1–4 and opened FTP, SFTP, SMB, and Recent folders.'
|
||||
return
|
||||
}
|
||||
if ($OfflineWake) {
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
#include "files_folder_size.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace fs=std::filesystem;
|
||||
using ks::files::measureNtfsFolder;
|
||||
|
||||
namespace
|
||||
{
|
||||
struct Fixture
|
||||
{
|
||||
fs::path path=fs::temp_directory_path()/
|
||||
(L"ks-files-size-"+std::to_wstring(GetCurrentProcessId())+L"-"+std::to_wstring(GetTickCount64()));
|
||||
Fixture() {fs::create_directory(path);}
|
||||
~Fixture() {std::error_code error;fs::remove_all(path,error);}
|
||||
};
|
||||
|
||||
void write(const fs::path &path,const char *data)
|
||||
{
|
||||
std::ofstream file(path,std::ios::binary);
|
||||
if(!(file<<data)) throw std::runtime_error("Could not create scan fixture.");
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
Fixture fixture;
|
||||
wchar_t filesystem[32]{};
|
||||
if(!GetVolumeInformationW(fixture.path.root_path().c_str(),nullptr,0,nullptr,nullptr,nullptr,
|
||||
filesystem,static_cast<DWORD>(std::size(filesystem))) || std::wstring_view(filesystem)!=L"NTFS")
|
||||
{
|
||||
std::cout<<"Native NTFS scan unavailable on the temporary volume.\n";
|
||||
return 77;
|
||||
}
|
||||
const auto root=fixture.path/L"selected";
|
||||
const auto empty=root/L"empty";
|
||||
fs::create_directories(empty);
|
||||
const auto emptySize=measureNtfsFolder(empty,{});
|
||||
if(!emptySize || emptySize->bytes || emptySize->partial) throw std::runtime_error("Empty NTFS folder.");
|
||||
const auto source=root/L"source.bin";
|
||||
write(source,"abc");
|
||||
const auto branch=root/L"nested";
|
||||
fs::create_directory(branch);
|
||||
fs::create_hard_link(source,branch/L"alias.bin");
|
||||
// Force more than one NTFS page and several concurrent directory jobs.
|
||||
for(int i=0;i<600;++i)
|
||||
{
|
||||
const auto suffix=std::to_wstring(i);
|
||||
write(branch/(L"long-filename-0123456789-"+suffix+L".txt"),"x");
|
||||
if(i<8)
|
||||
{
|
||||
const auto sibling=root/(L"sibling-"+suffix);
|
||||
fs::create_directory(sibling);
|
||||
write(sibling/L"payload","12");
|
||||
}
|
||||
}
|
||||
const auto total=measureNtfsFolder(root,{});
|
||||
if(!total || total->partial || total->bytes!=622)
|
||||
throw std::runtime_error("NTFS scan must sum all pages, branches and hard-link names.");
|
||||
std::stop_source canceled;
|
||||
canceled.request_stop();
|
||||
const auto stopped=measureNtfsFolder(root,canceled.get_token());
|
||||
if(!stopped || stopped->bytes) throw std::runtime_error("Canceled scan counted files.");
|
||||
std::cout<<"NTFS folder sizes passed.\n";
|
||||
return 0;
|
||||
}
|
||||
catch(const std::exception &error)
|
||||
{
|
||||
std::cerr<<error.what()<<'\n';
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
+49
-12
@@ -1,6 +1,7 @@
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$Executable,
|
||||
[string]$Screenshot,
|
||||
[switch]$DrivePickerOnly,
|
||||
[string]$DialogScreenshotDirectory
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
@@ -118,6 +119,45 @@ function Set-Style($Window, [int]$Style) {
|
||||
Wait-Until { [LavenderWindow]::Activate($Window) }
|
||||
}
|
||||
|
||||
function Save-DialogScreenshot($Window, $Bounds, [string]$Name) {
|
||||
$owner = Get-Bounds $Window
|
||||
$horizontal = [int](105 * $scale)
|
||||
$vertical = [int](88 * $scale)
|
||||
$context = [LavenderWindow+Rect]::new()
|
||||
$context.Left = [Math]::Max($owner.Left, $Bounds.Left - $horizontal)
|
||||
$context.Right = [Math]::Min($owner.Right, $Bounds.Right + $horizontal)
|
||||
$context.Top = [Math]::Max($owner.Top, $Bounds.Top - $vertical)
|
||||
$context.Bottom = [Math]::Min($owner.Bottom, $Bounds.Bottom + $vertical)
|
||||
$scene = Read-Window $context
|
||||
try { $scene.Save((Join-Path $DialogScreenshotDirectory $Name), [Drawing.Imaging.ImageFormat]::Png) }
|
||||
finally { $scene.Dispose() }
|
||||
}
|
||||
|
||||
function Test-LavenderDrivePicker($Window) {
|
||||
Invoke-FilesCommand $Window '*Change drive*' 134
|
||||
$frame = [LavenderWindow]::GetDlgItem($Window, 122)
|
||||
Wait-Until { [LavenderWindow]::IsWindowVisible($frame) }
|
||||
Start-Sleep -Milliseconds 160
|
||||
$bounds = Get-Bounds $frame
|
||||
$image = Read-Window $bounds
|
||||
try {
|
||||
$x = $bounds.Left + [int](($bounds.Right - $bounds.Left) / 2)
|
||||
$y = $bounds.Top + [int](($bounds.Bottom - $bounds.Top) / 2)
|
||||
$stroke = [Math]::Round(2 * $scale, [MidpointRounding]::AwayFromZero)
|
||||
Test-Pixel $image $bounds $x ($bounds.Top + $stroke - 1) '#4648BB' 'Drive picker top outline'
|
||||
Test-Pixel $image $bounds $x ($bounds.Bottom - $stroke) '#4648BB' 'Drive picker bottom outline'
|
||||
Test-Pixel $image $bounds ($bounds.Left + $stroke - 1) $y '#4648BB' 'Drive picker left outline'
|
||||
Test-Pixel $image $bounds ($bounds.Right - $stroke) $y '#4648BB' 'Drive picker right outline'
|
||||
Test-Pixel $image $bounds $x ($bounds.Bottom - $stroke - 1) '#F2EFFB' 'Drive picker surface'
|
||||
if ($DialogScreenshotDirectory) {
|
||||
Save-DialogScreenshot $Window $bounds 'files-lavender-drive.png'
|
||||
}
|
||||
} finally { $image.Dispose() }
|
||||
$picker = [LavenderWindow]::GetDlgItem($Window, 121)
|
||||
[void][LavenderWindow]::Post($picker, 0x100, [IntPtr]27, [IntPtr]::Zero)
|
||||
Wait-Until { ![LavenderWindow]::IsWindowVisible($frame) }
|
||||
}
|
||||
|
||||
function Test-LavenderDialog($Window, [string]$Keys, [int]$ControlId, [string]$Name) {
|
||||
$keyboard.SendKeys($Keys)
|
||||
try {
|
||||
@@ -137,23 +177,14 @@ function Test-LavenderDialog($Window, [string]$Keys, [int]$ControlId, [string]$N
|
||||
([int](($field.Top + $field.Bottom) / 2)) '#FFFFFF' 'Copy destination field'
|
||||
}
|
||||
if ($DialogScreenshotDirectory -and $Name -eq 'Copy') {
|
||||
$owner = Get-Bounds $Window
|
||||
$horizontal = [int](105 * $scale)
|
||||
$vertical = [int](88 * $scale)
|
||||
$context = [LavenderWindow+Rect]::new()
|
||||
$context.Left = [Math]::Max($owner.Left, $bounds.Left - $horizontal)
|
||||
$context.Right = [Math]::Min($owner.Right, $bounds.Right + $horizontal)
|
||||
$context.Top = [Math]::Max($owner.Top, $bounds.Top - $vertical)
|
||||
$context.Bottom = [Math]::Min($owner.Bottom, $bounds.Bottom + $vertical)
|
||||
$scene = Read-Window $context
|
||||
try { $scene.Save((Join-Path $DialogScreenshotDirectory 'files-lavender-copy.png'), [Drawing.Imaging.ImageFormat]::Png) }
|
||||
finally { $scene.Dispose() }
|
||||
Save-DialogScreenshot $Window $bounds 'files-lavender-copy.png'
|
||||
}
|
||||
} finally { $image.Dispose() }
|
||||
$keyboard.SendKeys('{ESC}')
|
||||
Wait-Until { ![LavenderWindow]::IsWindow($dialog) -and [LavenderWindow]::Activate($Window) }
|
||||
}
|
||||
|
||||
. "$PSScriptRoot/files_commands_ui.ps1"
|
||||
$exe = (Resolve-Path $Executable).Path
|
||||
$key = [Microsoft.Win32.Registry]::CurrentUser.CreateSubKey('Software\KSwitcher\Files')
|
||||
$names = 'AppearanceMode', 'LeftPanelMode', 'RightPanelMode', 'LeftViewOrder', 'RightViewOrder', 'LeftPath', 'RightPath', 'LeftCursor', 'RightCursor', 'WindowPlacement', 'OptionsLocation'
|
||||
@@ -179,7 +210,7 @@ try {
|
||||
foreach ($name in '.gitignore', 'CMakeLists.txt', 'FILES-UI.md', 'LICENSE', 'README.md') {
|
||||
[IO.File]::WriteAllText((Join-Path $right.FullName $name), ('Example content' * (40 + 54 * $name.Length)))
|
||||
}
|
||||
$key.SetValue('AppearanceMode', 0, 'DWord')
|
||||
$key.SetValue('AppearanceMode', [int]$DrivePickerOnly.IsPresent, 'DWord')
|
||||
$key.SetValue('LeftPanelMode', 1, 'DWord')
|
||||
$key.SetValue('RightPanelMode', 1, 'DWord')
|
||||
$key.SetValue('LeftViewOrder', 0, 'DWord')
|
||||
@@ -203,6 +234,12 @@ try {
|
||||
$rightList = [LavenderWindow]::GetDlgItem($window, 103)
|
||||
Wait-Until { [LavenderWindow]::Send($leftList, 0x18B, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32() -eq 6 -and
|
||||
[LavenderWindow]::Send($rightList, 0x18B, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32() -eq 12 }
|
||||
if ($DrivePickerOnly) {
|
||||
if ($DialogScreenshotDirectory) { [void][IO.Directory]::CreateDirectory($DialogScreenshotDirectory) }
|
||||
Test-LavenderDrivePicker $window
|
||||
'Verified the lavender drive picker surface and the outline on all four edges.'
|
||||
return
|
||||
}
|
||||
$farRow = [LavenderWindow]::Send($leftList, 0x1A1, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32()
|
||||
Set-Style $window 1
|
||||
$rowHeight = [LavenderWindow]::Send($leftList, 0x1A1, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32()
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
param([Parameter(Mandatory)][string]$Executable,[string]$Screenshot)
|
||||
$ErrorActionPreference='Stop'
|
||||
. "$PSScriptRoot/files_commands_ui.ps1"
|
||||
|
||||
function Read-Label([IntPtr]$control,[uint32]$message=13) {
|
||||
$text=[Text.StringBuilder]::new(1024)
|
||||
[void][FilesCommandsUi]::Read($control,$message,[IntPtr]$(if($message -eq 13){$text.Capacity}else{0}),$text)
|
||||
$text.ToString()
|
||||
}
|
||||
function Click([IntPtr]$panel,[int]$id) {
|
||||
[void][FilesCommandsUi]::Send($panel,273,$id,[FilesCommandsUi]::GetDlgItem($panel,$id))
|
||||
}
|
||||
function Set-Metric([IntPtr]$panel,[int]$row) {
|
||||
$select=[FilesCommandsUi]::GetDlgItem($panel,503)
|
||||
if(!$select) {throw 'The analyzer metric selector is missing.'}
|
||||
[void][FilesCommandsUi]::Send($select,334,$row,0)
|
||||
[void][FilesCommandsUi]::Send($panel,273,(65536+503),$select)
|
||||
}
|
||||
|
||||
$exe=(Resolve-Path -LiteralPath $Executable).Path
|
||||
$fixture=[IO.Directory]::CreateTempSubdirectory('ks-space-pane-').FullName
|
||||
$preferences=[Microsoft.Win32.Registry]::CurrentUser.CreateSubKey('Software\KSwitcher\Files')
|
||||
$keys='LeftPath','RightPath','LeftFtpLocation','RightFtpLocation','WindowPlacement',
|
||||
'LeftCursor','RightCursor','RestoreLocalDocuments'
|
||||
$saved=@{}
|
||||
foreach($key in $keys) {
|
||||
if($key -in $preferences.GetValueNames()) {$saved[$key]=@($preferences.GetValue($key),$preferences.GetValueKind($key))}
|
||||
}
|
||||
$app=$null
|
||||
$dpi=[FilesCommandsUi]::SetThreadDpiAwarenessContext([IntPtr](-4))
|
||||
try {
|
||||
$left=[IO.Directory]::CreateDirectory((Join-Path $fixture 'left')).FullName
|
||||
$right=[IO.Directory]::CreateDirectory((Join-Path $fixture 'right')).FullName
|
||||
[IO.File]::WriteAllBytes((Join-Path $left 'allocated.bin'),[byte[]]::new(5307))
|
||||
$preferences.SetValue('LeftPath',$left,'String')
|
||||
$preferences.SetValue('RightPath',$right,'String')
|
||||
$preferences.SetValue('RestoreLocalDocuments',0,'DWord')
|
||||
foreach($key in 'LeftFtpLocation','RightFtpLocation','WindowPlacement') {$preferences.DeleteValue($key,$false)}
|
||||
$app=Start-Process -FilePath $exe -WindowStyle Hidden -PassThru
|
||||
$main=Wait-For 'Files main window' {
|
||||
$candidate=[IntPtr]::Zero
|
||||
while(($candidate=[FilesCommandsUi]::FindWindowEx(0,$candidate,'KSwitcher.Files',[NullString]::Value)) -ne 0) {
|
||||
[uint32]$owner=0
|
||||
[void][FilesCommandsUi]::GetWindowThreadProcessId($candidate,[ref]$owner)
|
||||
if($owner -eq $app.Id) {return $candidate}
|
||||
}
|
||||
}
|
||||
[void][FilesCommandsUi]::ShowWindow($main,4)
|
||||
[void][FilesCommandsUi]::SetWindowPos($main,0,24,24,1240,710,20)
|
||||
$leftList=[FilesCommandsUi]::GetDlgItem($main,102)
|
||||
$rightList=[FilesCommandsUi]::GetDlgItem($main,103)
|
||||
[void](Wait-For 'fixture folder' {(Read-Label ([FilesCommandsUi]::GetDlgItem($main,142))) -eq $left})
|
||||
Invoke-FilesCommand $main '*Space Analyzer' 130
|
||||
$analyzer=Wait-For 'Space Analyzer child pane' {
|
||||
$candidate=[FilesCommandsUi]::FindWindowEx($main,0,'#32770',[NullString]::Value)
|
||||
if($candidate -and [FilesCommandsUi]::IsWindowVisible($candidate) -and
|
||||
[FilesCommandsUi]::GetDlgItem($candidate,489)) {return $candidate}
|
||||
}
|
||||
if([FilesCommandsUi]::IsWindowVisible($leftList) -or ![FilesCommandsUi]::IsWindowVisible($rightList)) {
|
||||
throw 'The analyzer should replace only the selected pane.'
|
||||
}
|
||||
$state=[FilesCommandsUi]::GetDlgItem($analyzer,490)
|
||||
[void](Wait-For 'automatic fixture scan' {(Read-Label $state) -like 'Complete*Logical size'})
|
||||
Set-Metric $analyzer 1
|
||||
[void](Wait-For 'allocated tree metric' {(Read-Label $state) -like '*Size on disk'})
|
||||
Click $analyzer 499
|
||||
$sunburst=[FilesCommandsUi]::GetDlgItem($analyzer,500)
|
||||
[void](Wait-For 'allocated chart item' {(Read-Label $sunburst 393) -like 'allocated.bin*on disk'})
|
||||
Set-Metric $analyzer 0
|
||||
[void](Wait-For 'logical chart metric' {(Read-Label $sunburst 393) -like 'allocated.bin*logical'})
|
||||
Click $analyzer 497
|
||||
if(![FilesCommandsUi]::IsWindowVisible([FilesCommandsUi]::GetDlgItem($analyzer,498))) {
|
||||
throw 'Treemap did not show in the analyzer pane.'
|
||||
}
|
||||
Click $analyzer 502
|
||||
Set-Metric $analyzer 1
|
||||
if($Screenshot) {
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
$bounds=[FilesCommandsUi+Rect]::new()
|
||||
[void][FilesCommandsUi]::GetClientRect($main,[ref]$bounds)
|
||||
$image=[Drawing.Bitmap]::new($bounds.Right,$bounds.Bottom)
|
||||
try {
|
||||
$graphics=[Drawing.Graphics]::FromImage($image)
|
||||
try {
|
||||
$dc=$graphics.GetHdc()
|
||||
try {if(![FilesCommandsUi]::PrintWindow($main,$dc,3)) {throw 'Cannot render Space Analyzer.'}}
|
||||
finally {$graphics.ReleaseHdc($dc)}
|
||||
} finally {$graphics.Dispose()}
|
||||
$image.Save($Screenshot,[Drawing.Imaging.ImageFormat]::Png)
|
||||
} finally {$image.Dispose()}
|
||||
}
|
||||
Click $analyzer 1
|
||||
[void](Wait-For 'selection opened in the other pane' {
|
||||
[FilesCommandsUi]::IsWindowVisible($analyzer) -and
|
||||
(Read-Label ([FilesCommandsUi]::GetDlgItem($main,143))) -eq $left
|
||||
})
|
||||
Click $analyzer 2
|
||||
[void](Wait-For 'restored file pane' {
|
||||
[FilesCommandsUi]::IsWindowVisible($leftList) -and (Read-Label ([FilesCommandsUi]::GetDlgItem($main,142))) -eq $left
|
||||
})
|
||||
Invoke-FilesCommand $main '*Space Analyzer' 134
|
||||
$analyzer=Wait-For 'analyzer in the right pane' {
|
||||
$candidate=[FilesCommandsUi]::FindWindowEx($main,0,'#32770',[NullString]::Value)
|
||||
if($candidate -and [FilesCommandsUi]::IsWindowVisible($candidate) -and
|
||||
[FilesCommandsUi]::GetDlgItem($candidate,489) -and ![FilesCommandsUi]::IsWindowVisible($rightList)) {
|
||||
return $candidate
|
||||
}
|
||||
}
|
||||
[void][FilesCommandsUi]::Post([FilesCommandsUi]::GetDlgItem($analyzer,489),256,27,0)
|
||||
[void](Wait-For 'right file pane restored with Esc' {[FilesCommandsUi]::IsWindowVisible($rightList)})
|
||||
'Verified in-pane analysis on both sides, size selection in tree and charts, and return to files.'
|
||||
} finally {
|
||||
if($app -and !$app.HasExited) {$app.Kill();$app.WaitForExit()}
|
||||
foreach($key in $keys) {
|
||||
if($saved.ContainsKey($key)) {$preferences.SetValue($key,$saved[$key][0],$saved[$key][1])}
|
||||
else {$preferences.DeleteValue($key,$false)}
|
||||
}
|
||||
$preferences.Dispose()
|
||||
if($dpi) {[void][FilesCommandsUi]::SetThreadDpiAwarenessContext($dpi)}
|
||||
$resolved=(Resolve-Path -LiteralPath $fixture).Path
|
||||
if($resolved -ne [IO.Path]::GetFullPath($fixture)) {throw 'Unexpected fixture path.'}
|
||||
[IO.Directory]::Delete($resolved,$true)
|
||||
}
|
||||
+1
-1
@@ -1138,7 +1138,7 @@ int main(int argc, char **argv) {
|
||||
auto events = GetDlgItem(pane, 733);
|
||||
auto visible = [&](int id) { return (GetWindowLongPtrW(GetDlgItem(pane, id), GWL_STYLE) & WS_VISIBLE) != 0; };
|
||||
auto selectPage = [&](int index) { selectSettingsPage(settings, index); };
|
||||
require(TreeView_GetCount(navigation) == 20, "all Settings sections are listed");
|
||||
require(TreeView_GetCount(navigation) == 21, "all Settings sections are listed");
|
||||
selectPage(3);
|
||||
require(visible(243) && !visible(501), "Clipboard lists excluded apps separately from OCR");
|
||||
require(TreeView_GetParent(navigation, settingsSection(navigation, 19)) == settingsSection(navigation, 3),
|
||||
|
||||
@@ -67,9 +67,10 @@ void chooseInputAction(HWND resident, DWORD pid, const wchar_t *expected)
|
||||
}
|
||||
}
|
||||
require(donationSeparated && donation.hbmpItem, "tray donation item has an icon and both separators");
|
||||
require(help && GetMenuItemCount(help) == 2 && menuTitle(help, 0) == L"&User guide" &&
|
||||
menuTitle(help, 1) == L"&About KSwitcher",
|
||||
"tray Help submenu contains User guide and About KSwitcher");
|
||||
require(help && GetMenuItemCount(help) == 3 && menuTitle(help, 0) == L"&User guide" &&
|
||||
menuTitle(help, 1) == ks::whatsNewTitle(GetThreadUILanguage()) &&
|
||||
menuTitle(help, 2) == L"&About KSwitcher",
|
||||
"tray Help submenu contains User guide, release notes and About KSwitcher");
|
||||
require(PostMessageW(popup, WM_CHAR, L'i', 0), "cannot select input menu item");
|
||||
until([&] { return !IsWindow(popup); }, "tray action did not close menu");
|
||||
query(resident, WM_NULL);
|
||||
|
||||
+158
-2
@@ -1,5 +1,6 @@
|
||||
#include "app.h"
|
||||
#include "diagnostics.h"
|
||||
#include "paste_probe.h"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@@ -61,6 +62,11 @@ namespace
|
||||
{
|
||||
ks::App *app{};
|
||||
HWND host{}, field{};
|
||||
HWND externalEditor{};
|
||||
ULONGLONG externalPopupUntil{};
|
||||
bool insertExternalSnippet{};
|
||||
bool insertTerminalSnippet{};
|
||||
constexpr wchar_t externalSnippetText[] = L"snippet test";
|
||||
ks::Clip saved;
|
||||
bool snippetRecoveryOnly = false;
|
||||
LONG unfilteredSnippetWidth{};
|
||||
@@ -79,6 +85,7 @@ bool typeDuringMacros = false;
|
||||
ULONGLONG macroStart{}, macroEnd{};
|
||||
int copyFailuresRemaining = 0, copyRequests = 0;
|
||||
int droppedSelectionKeys = 0;
|
||||
int delayedSelectionKeys = 0;
|
||||
bool trimCopiedSpaces = false;
|
||||
int trimmedCopies = 0;
|
||||
bool temporaryClipboardExcluded = true;
|
||||
@@ -152,6 +159,16 @@ LRESULT CALLBACK observeEnter(HWND w, UINT message, WPARAM wp, LPARAM lp, UINT_P
|
||||
--copyFailuresRemaining;
|
||||
return 0;
|
||||
}
|
||||
if (delayedSelectionKeys)
|
||||
{
|
||||
DWORD start{}, end{};
|
||||
SendMessageW(w, EM_GETSEL, reinterpret_cast<WPARAM>(&start), reinterpret_cast<LPARAM>(&end));
|
||||
auto result = DefSubclassProc(w, message, wp, lp);
|
||||
// Apply the remaining Shift+Left moves after publishing the partial selection.
|
||||
SendMessageW(w, EM_SETSEL, end, start - std::min<DWORD>(start, delayedSelectionKeys));
|
||||
delayedSelectionKeys = 0;
|
||||
return result;
|
||||
}
|
||||
if (trimCopiedSpaces)
|
||||
{
|
||||
auto result = DefSubclassProc(w, message, wp, lp);
|
||||
@@ -278,6 +295,53 @@ void expandMacroSnippet(const wchar_t *replacement)
|
||||
record(L";zmtest");
|
||||
app->transform(0, 0, 0, field);
|
||||
}
|
||||
|
||||
bool terminalShowsTestDraft()
|
||||
{
|
||||
using Microsoft::WRL::ComPtr;
|
||||
ComPtr<IUIAutomation2> automation;
|
||||
if (FAILED(CoCreateInstance(CLSID_CUIAutomation8, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&automation))))
|
||||
return false;
|
||||
automation->put_TransactionTimeout(150);
|
||||
ComPtr<IUIAutomationElement> element;
|
||||
ComPtr<IUIAutomationTreeWalker> walker;
|
||||
if (FAILED(automation->GetFocusedElement(&element)) || !element ||
|
||||
!ks::focusedTextBelongsToWindow(automation.Get(), element.Get(), externalEditor) ||
|
||||
FAILED(automation->get_RawViewWalker(&walker)) || !walker)
|
||||
return false;
|
||||
// The xterm accessibility tree is beside the input's screen element.
|
||||
for (int depth = 0; element && depth < 3; ++depth)
|
||||
{
|
||||
ComPtr<IUIAutomationElement> parent;
|
||||
walker->GetParentElement(element.Get(), &parent);
|
||||
element = std::move(parent);
|
||||
}
|
||||
if (!element) return false;
|
||||
VARIANT className{};
|
||||
className.vt = VT_BSTR;
|
||||
className.bstrVal = SysAllocString(L"xterm-accessibility-tree");
|
||||
ComPtr<IUIAutomationCondition> condition;
|
||||
const auto hr = automation->CreatePropertyCondition(UIA_ClassNamePropertyId, className, &condition);
|
||||
VariantClear(&className);
|
||||
ComPtr<IUIAutomationElement> tree, row;
|
||||
if (FAILED(hr) || !condition || FAILED(element->FindFirst(TreeScope_Descendants, condition.Get(), &tree)) ||
|
||||
!tree || FAILED(walker->GetLastChildElement(tree.Get(), &row))) return false;
|
||||
while (row)
|
||||
{
|
||||
BSTR name{};
|
||||
row->get_CurrentName(&name);
|
||||
std::wstring_view line(name ? name : L"", SysStringLen(name));
|
||||
const auto end = line.find_last_not_of(L" \t\r\n\u00a0");
|
||||
const bool matches = end != line.npos && line.substr(0, end + 1).ends_with(externalSnippetText);
|
||||
SysFreeString(name);
|
||||
if (end != line.npos) return matches;
|
||||
ComPtr<IUIAutomationElement> previous;
|
||||
walker->GetPreviousSiblingElement(row.Get(), &previous);
|
||||
row = std::move(previous);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void finish()
|
||||
{
|
||||
KillTimer(host, 1);
|
||||
@@ -337,7 +401,65 @@ LRESULT CALLBACK procedure(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
}
|
||||
switch (stage++)
|
||||
{
|
||||
case 101:
|
||||
require(GetForegroundWindow() == externalEditor, "external editor retains foreground before typing");
|
||||
app->settings.snippets = {{L";ksw-regression", externalSnippetText}};
|
||||
app->resetInput();
|
||||
externalPopupUntil = GetTickCount64() + 2000;
|
||||
typeKeys({VK_OEM_1});
|
||||
break;
|
||||
case 102:
|
||||
{
|
||||
if (GetForegroundWindow() != externalEditor)
|
||||
throw std::runtime_error("External editor lost foreground while typing");
|
||||
const bool visible = ks::InputRegressionAccess::suggestionsVisible(*app);
|
||||
if (!visible && GetTickCount64() < externalPopupUntil)
|
||||
{
|
||||
stage = 102;
|
||||
break;
|
||||
}
|
||||
if (!visible) typeKeys({VK_BACK});
|
||||
else if (insertExternalSnippet || insertTerminalSnippet)
|
||||
{
|
||||
externalPopupUntil = GetTickCount64() + 3000;
|
||||
typeKeys({VK_TAB});
|
||||
}
|
||||
else typeKeys({VK_ESCAPE, VK_BACK});
|
||||
require(visible, "semicolon shows suggestions in the external editor");
|
||||
break;
|
||||
}
|
||||
case 103:
|
||||
if (insertExternalSnippet)
|
||||
{
|
||||
require(GetForegroundWindow() == externalEditor, "insertion leaves the external editor focused");
|
||||
ks::PasteProbe probe(true, externalEditor);
|
||||
const auto text = probe.read(static_cast<int>(std::size(externalSnippetText) - 1));
|
||||
const bool inserted = text && *text == externalSnippetText;
|
||||
if (inserted)
|
||||
{
|
||||
ks::chord('A', MOD_CONTROL);
|
||||
typeKeys({VK_BACK});
|
||||
}
|
||||
require(inserted, "Tab inserts the selected snippet in the external editor");
|
||||
}
|
||||
else if (insertTerminalSnippet)
|
||||
{
|
||||
const bool inserted = GetForegroundWindow() == externalEditor &&
|
||||
!ks::InputRegressionAccess::suggestionsVisible(*app) && terminalShowsTestDraft();
|
||||
if (!inserted && GetTickCount64() < externalPopupUntil)
|
||||
{
|
||||
stage = 103;
|
||||
break;
|
||||
}
|
||||
require(inserted, "Tab replaces the prefix in the live shell prompt");
|
||||
}
|
||||
else
|
||||
require(!ks::InputRegressionAccess::suggestionsVisible(*app), "Escape dismisses external suggestions");
|
||||
finish();
|
||||
break;
|
||||
case 0:
|
||||
app->settings.writeLog = true;
|
||||
ks::setLoggingEnabled(true);
|
||||
saved = ks::readClipboard(app->window, 64 * 1024 * 1024);
|
||||
captured = true;
|
||||
app->ownSequence = ks::writeClipboard(app->window, ks::textClip(sentinel));
|
||||
@@ -685,6 +807,26 @@ LRESULT CALLBACK procedure(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
case 59:
|
||||
require(text() == L"OLDghbdtn NEXT", "hotkey without selection reconverts only the previous middle range");
|
||||
require(ks::readClipboard(app->window).text() == sentinel, "selected and repeated conversions restore clipboard");
|
||||
[[fallthrough]];
|
||||
case 95:
|
||||
if (!captured)
|
||||
{
|
||||
saved = ks::readClipboard(app->window, 64 * 1024 * 1024);
|
||||
captured = true;
|
||||
app->ownSequence = ks::writeClipboard(app->window, ks::textClip(sentinel));
|
||||
}
|
||||
prepare(L" nen NEXT", false);
|
||||
SendMessageW(field, EM_SETSEL, 6, 6);
|
||||
record(L"nen ");
|
||||
droppedSelectionKeys = delayedSelectionKeys = 2;
|
||||
app->transform(ks::Direct + ru);
|
||||
stage = 96;
|
||||
break;
|
||||
case 96:
|
||||
require(text() == L" " + ks::convertTo(L"nen ", app->layouts, ru, en) + L"NEXT",
|
||||
"delayed selection preserves the older prefix and text after the caret");
|
||||
require(!droppedSelectionKeys && !delayedSelectionKeys, "fixture applied the delayed selection moves");
|
||||
require(ks::readClipboard(app->window).text() == sentinel, "delayed selection restores clipboard");
|
||||
finish();
|
||||
break;
|
||||
case 66:
|
||||
@@ -1196,6 +1338,15 @@ LRESULT CALLBACK procedure(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
} // namespace
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const bool externalEditorTest = argc > 1 && std::string_view(argv[1]) == "--snippet-external-editor";
|
||||
if (externalEditorTest)
|
||||
{
|
||||
insertExternalSnippet = argc > 2 && std::string_view(argv[2]) == "--insert";
|
||||
insertTerminalSnippet = argc > 2 && std::string_view(argv[2]) == "--terminal-insert";
|
||||
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
externalEditor = GetForegroundWindow();
|
||||
if (!externalEditor) return 1;
|
||||
}
|
||||
conversionOnly = argc > 1 && std::string(argv[1]) == "--conversion-only";
|
||||
typosOnly = argc > 1 && std::string(argv[1]) == "--typos-only";
|
||||
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||
@@ -1362,7 +1513,7 @@ int main(int argc, char **argv)
|
||||
if (language == 0x419)
|
||||
ru = i;
|
||||
}
|
||||
if (en < 0 || ru < 0)
|
||||
if (!externalEditorTest && (en < 0 || ru < 0))
|
||||
throw std::runtime_error(
|
||||
"Integration test requires installed English US and Russian layouts");
|
||||
WNDCLASSW cls{};
|
||||
@@ -1372,7 +1523,8 @@ int main(int argc, char **argv)
|
||||
cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
RegisterClassW(&cls);
|
||||
host = CreateWindowW(cls.lpszClassName, L"KSwitcher — automated test editor",
|
||||
WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 650, 320, nullptr, nullptr,
|
||||
WS_OVERLAPPEDWINDOW | (externalEditorTest ? 0 : WS_VISIBLE),
|
||||
100, 100, 650, 320, nullptr, nullptr,
|
||||
cls.hInstance, nullptr);
|
||||
field =
|
||||
CreateWindowW(L"EDIT", L"", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_MULTILINE | ES_WANTRETURN,
|
||||
@@ -1392,6 +1544,10 @@ int main(int argc, char **argv)
|
||||
stage = 93;
|
||||
if (argc > 1 && std::string(argv[1]) == "--snippet-word-boundaries")
|
||||
stage = 84;
|
||||
if (externalEditorTest)
|
||||
stage = 101;
|
||||
if (argc > 1 && std::string(argv[1]) == "--delayed-selection-only")
|
||||
stage = 95;
|
||||
SetTimer(host, 1, 100, nullptr);
|
||||
auto forwarding = SetWindowsHookExW(WH_KEYBOARD_LL,forwardingHook,GetModuleHandleW(nullptr),0);
|
||||
require(forwarding!=nullptr,"downstream forwarding fixture installed before application hook");
|
||||
|
||||
@@ -449,6 +449,18 @@ int main(int argc, char **argv)
|
||||
"cycle does not use disabled English when all candidates are unchanged");
|
||||
require(ks::nextConversionLayout(L"123 ", layouts, {0, 1, 2}, 0) == 1,
|
||||
"unchanged digits finish after a bounded cycle");
|
||||
auto digitLayouts = layouts;
|
||||
digitLayouts[2].handle = reinterpret_cast<HKL>(static_cast<ULONG_PTR>(0xf0a80422));
|
||||
ks::Run digitRun;
|
||||
digitRun.layout = digitLayouts[2].handle;
|
||||
digitRun.keys = L"4732";
|
||||
const int digitSource = digitRun.match(L"4732", digitLayouts, en);
|
||||
require(digitSource == 2 && ks::nextConversionLayout(L"4732", digitLayouts, {1, 0, 2}, digitSource) == 1 &&
|
||||
ks::convertTo(L"4732", digitLayouts, 1, digitSource) == L"4732",
|
||||
"shared digits advance from the tracked Ukrainian layout to Russian without changing text");
|
||||
digitRun.keys = L"ghbdtn";
|
||||
require(digitRun.match(L"ghbdtn", digitLayouts, en) == 0,
|
||||
"recent input falls back when the tracked layout does not reproduce the selection");
|
||||
require(ks::nextConversionLayout(L"рф", layouts, {2, 0}, 1) == 0,
|
||||
"source outside cycle still skips unchanged candidates");
|
||||
require(ks::cycleCase(L"hello world") == L"Hello World", "title case");
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ try {
|
||||
Assert ([IO.File]::ReadAllText((Join-Path $target 'KSwitcher.exe')) -eq 'old binary fixture') 'partial install rollback'
|
||||
if ($Network) {
|
||||
$metadata=Join-Path $root 'live-releases.json'
|
||||
Receive-File 'https://gitea.hrynco.com/api/v1/repos/hrynco/hrynco-kswitcher/releases?limit=100' $metadata 2MB
|
||||
Receive-ReleaseMetadata $metadata
|
||||
$live=Select-Release (Get-Content -LiteralPath $metadata -Raw | ConvertFrom-Json) ([version]'0.0.0')
|
||||
Assert ($null -ne $live) 'live repository exposes a complete stable release'
|
||||
$liveZip=Join-Path $root 'live.zip'; $liveSum=Join-Path $root 'live-sums.txt'
|
||||
|
||||
@@ -9,7 +9,7 @@ try {
|
||||
if ($script:progressWindow.Percent -ne 42) { throw 'Determinate download progress missing' }
|
||||
$script:progressWindow.SavePreview((Join-Path $PreviewDirectory 'download.png'))
|
||||
if ($Network) {
|
||||
Receive-File 'https://gitea.hrynco.com/api/v1/repos/hrynco/hrynco-kswitcher/releases?limit=100' (Join-Path $PreviewDirectory 'releases.json') 2MB 'Downloading update'
|
||||
Receive-ReleaseMetadata (Join-Path $PreviewDirectory 'releases.json') 'Downloading update'
|
||||
if ($script:progressWindow.Percent -ne 100) { throw 'Real download did not finish at 100 percent' }
|
||||
}
|
||||
foreach ($stage in @('Verifying download','Preparing installation','Closing KSwitcher','Installing update','Restarting KSwitcher','Restoring previous version')) {
|
||||
|
||||
Reference in new issue
Block a user