Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2b9a65237 | ||
|
|
e7ef2e600b | ||
|
|
211a5e0b59 | ||
|
|
0ad8d7f6aa |
No files matched your search
+7
-2
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(KSwitcher VERSION 0.8.1 LANGUAGES C CXX RC)
|
||||
project(KSwitcher VERSION 0.8.3 LANGUAGES C CXX RC)
|
||||
if(NOT WIN32)
|
||||
message(FATAL_ERROR "KSwitcher uses native Windows APIs")
|
||||
endif()
|
||||
@@ -36,7 +36,7 @@ add_custom_target(check-files-quick-view
|
||||
DEPENDS KSwitcherFiles
|
||||
VERBATIM)
|
||||
target_include_directories(KSwitcherFiles PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/build/terminal-deps/sdk/build/native/include")
|
||||
target_link_libraries(KSwitcherFiles PRIVATE user32 gdi32 comctl32 shell32 comdlg32 advapi32 ole32 uuid wininet netapi32 mpr userenv KSwitcherFilesImage libssh2::libssh2)
|
||||
target_link_libraries(KSwitcherFiles PRIVATE user32 gdi32 comctl32 shell32 comdlg32 advapi32 ole32 uuid wininet netapi32 mpr userenv dwmapi KSwitcherFilesImage libssh2::libssh2)
|
||||
if(MSVC)
|
||||
target_compile_options(KSwitcherFiles PRIVATE /utf-8)
|
||||
else()
|
||||
@@ -245,6 +245,11 @@ 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-lavender
|
||||
COMMAND "${KSWITCHER_POWERSHELL}" -NoProfile -ExecutionPolicy Bypass
|
||||
-File "${CMAKE_CURRENT_SOURCE_DIR}/tests/files_lavender.ps1"
|
||||
-Executable "$<TARGET_FILE:KSwitcherFiles>")
|
||||
set_tests_properties(files-lavender PROPERTIES RUN_SERIAL TRUE TIMEOUT 55)
|
||||
add_test(NAME files-space-analyzer-layout
|
||||
COMMAND "${KSWITCHER_POWERSHELL}" -NoProfile -ExecutionPolicy Bypass
|
||||
-File "${CMAKE_CURRENT_SOURCE_DIR}/tests/files_space_analyzer_layout.ps1"
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# Оформлення KSwitcher Files
|
||||
|
||||
**F9 → Options → Appearance → Window style → Lavender** вмикає світлі
|
||||
заокруглені панелі, виділення поточного рядка, смугу команд і оформлення
|
||||
власних діалогів та налаштувань. Діалоги файлових операцій мають темний
|
||||
заголовок, помітну рамку й білі поля на лавандовому тлі. Попередження мають
|
||||
червоний заголовок. За замовчуванням увімкнено Far. Гарячі клавіші діють в обох стилях.
|
||||
|
||||
Far Manager є зразком для оформлення файлового менеджера. Основне вікно використовує системний заголовок Windows. Панелі, меню й діалоги операцій використовують моноширинний шрифт менеджера та оформлення в стилі Far.
|
||||
Іконка головного вікна показує дві сині панелі з бірюзовою рамкою та виділеним рядком.
|
||||
|
||||
@@ -726,6 +732,9 @@ Warning і початковий фокус на No.
|
||||
попередньої гілки. Клік по поточній папці або кнопці редагування та Ctrl+L
|
||||
відкривають поле шляху. Tab доповнює назву папки, Enter відкриває шлях,
|
||||
а Esc повертає до тих самих панелей і курсора.
|
||||
- Над обома панелями працює спільний компонент рядка шляху. У Lavender кнопки
|
||||
навігації стоять ліворуч, а сегменти за шириною підпису розділяються знаком `›`.
|
||||
Назва поточної папки виділена напівжирним шрифтом і заокругленим фоном.
|
||||
|
||||
- У заголовку FTP- чи SFTP-папки клік по назві профілю відкриває збережені
|
||||
підключення. У LAN-папці клік по назві ПК відкриває спарені комп’ютери
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
# Latest Windows release
|
||||
|
||||
## 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.
|
||||
|
||||
**Українською.**
|
||||
|
||||
- **Files.** У Lavender над обома панелями тепер видно компактні сегменти шляху з роздільниками `›`. Поточна папка має заокруглене виділення. Клік на батьківській папці відкриває її, клік на поточній відкриває введення шляху, а трикрапка показує приховані папки.
|
||||
|
||||
## v0.8.2 — 2026-11-26
|
||||
|
||||
- **Files.** Choose **F9 → Options → Appearance → Window style → Lavender** for light panes, clearer selection and a redesigned command bar. File operation dialogs have a dark title band, with a red band for warnings. Far remains the default, and keyboard shortcuts work in both styles.
|
||||
- **What’s new.** KSwitcher shows release notes after an update. Reopen them from **Help → What’s new** in the tray.
|
||||
|
||||
**Українською.**
|
||||
|
||||
- **Files.** Виберіть **F9 → Options → Appearance → Window style → Lavender**, щоб увімкнути світлі панелі, виразніше виділення й оновлену смугу команд. Діалоги файлових операцій мають темний заголовок, а попередження — червоний. Far лишається стандартним режимом, в обох стилях працюють ті самі гарячі клавіші.
|
||||
- **Що нового.** KSwitcher показує нотатки після оновлення. Повторно відкрийте їх через **Help → What’s new** у треї.
|
||||
|
||||
## v0.8.1 — 2026-11-26
|
||||
|
||||
- **SMB.** Saved connections and a server’s shares open in the selected Files panel. Press **Enter** to open a connection or share. **Esc** returns to the previous list or folder. Profile editing and sign-in use their existing dialogs.
|
||||
|
||||
@@ -1 +1 @@
|
||||
4f73fa962a4a84ebb7b564fdb5e8cac6baeeff460d3e7147f09d6ded62553021 KSwitcher-win-x64.zip
|
||||
0726c819b43cd1508c4fa22b717ab13b0da826f5a48bbc3a4b0f10e6418d207a KSwitcher-win-x64.zip
|
||||
+73
-73
@@ -1,181 +1,181 @@
|
||||
{
|
||||
"version": "0.8.3",
|
||||
"schema": 1,
|
||||
"files": [
|
||||
{
|
||||
"size": 3193344,
|
||||
"sha256": "134aff7d86cdba13eecf9e32a0556e0267c0900800bd6dc1e9b005729190eb7a",
|
||||
"path": "KSwitcher.exe",
|
||||
"sha256": "ceaeff987356f31cc4e1773b41825fe8bc621d51abd9884964339457b724198f"
|
||||
"size": 3247616
|
||||
},
|
||||
{
|
||||
"size": 2892800,
|
||||
"sha256": "7f90f6af18c9ac7f9e0f8255bfd339c49c9ea28e2da88d6b6e3443f6a867a1dd",
|
||||
"path": "KSwitcher.Config.exe",
|
||||
"sha256": "d2d8fabbe9758d6744b04014cddc96cd7c87710249e025594861ed7bec508b9b"
|
||||
"size": 2849792
|
||||
},
|
||||
{
|
||||
"size": 3193344,
|
||||
"sha256": "f010f82aba8ace45abf0b90db991804964c1ec18f783a4169add56f478c96344",
|
||||
"path": "KSwitcher.Screenshot.exe",
|
||||
"sha256": "b2503e613fa203773a6ead05efaf4430fb297d642569ac64927a77acd78f53a8"
|
||||
"size": 3193344
|
||||
},
|
||||
{
|
||||
"size": 5977600,
|
||||
"sha256": "caa66e3d8cddd094f1de317fb1a6410d4413f30034cdb61f130d7fcee21004bb",
|
||||
"path": "KSwitcher.Files.exe",
|
||||
"sha256": "047d8ba01a3a316ca53c609283dee2638474731390dee74427ea881cc71d3617"
|
||||
"size": 6000640
|
||||
},
|
||||
{
|
||||
"size": 194912,
|
||||
"sha256": "d3fce90bdeecb08596e377dea6a316354dd8949e32ff09b89d51be00c14e21b6",
|
||||
"path": "WebView2Loader.dll",
|
||||
"sha256": "d3fce90bdeecb08596e377dea6a316354dd8949e32ff09b89d51be00c14e21b6"
|
||||
"size": 194912
|
||||
},
|
||||
{
|
||||
"size": 1103,
|
||||
"sha256": "e256f01188af527e4d06d21d06fbf785ae9c50d4b328bf03cbe0ba7f0aa4228f",
|
||||
"path": "terminal/addon-fit-LICENSE.txt",
|
||||
"sha256": "e256f01188af527e4d06d21d06fbf785ae9c50d4b328bf03cbe0ba7f0aa4228f"
|
||||
"size": 1103
|
||||
},
|
||||
{
|
||||
"size": 1521,
|
||||
"sha256": "ba3ea256ce0620a0992a197d6c9baea64823fc93d8da07a9e366ca9943c18527",
|
||||
"path": "terminal/addon-fit.js",
|
||||
"sha256": "ba3ea256ce0620a0992a197d6c9baea64823fc93d8da07a9e366ca9943c18527"
|
||||
"size": 1521
|
||||
},
|
||||
{
|
||||
"size": 527,
|
||||
"sha256": "084d97a727b778fb10d31adcd557ee7840a38377ed60e0ef0f3ece93b349b1ef",
|
||||
"path": "terminal/index.html",
|
||||
"sha256": "084d97a727b778fb10d31adcd557ee7840a38377ed60e0ef0f3ece93b349b1ef"
|
||||
"size": 527
|
||||
},
|
||||
{
|
||||
"size": 1073,
|
||||
"sha256": "792c48c5a849a15fdf9e37e8bcf9e6d1dd13b32b46c642a748a0a46a9919d473",
|
||||
"path": "terminal/markdown-it-LICENSE.txt",
|
||||
"sha256": "792c48c5a849a15fdf9e37e8bcf9e6d1dd13b32b46c642a748a0a46a9919d473"
|
||||
"size": 1073
|
||||
},
|
||||
{
|
||||
"size": 100786,
|
||||
"sha256": "391f2aa638e75e6c7859d0a5c5650ef0956722a45998f17e05b83bc655778e1e",
|
||||
"path": "terminal/markdown-it.js",
|
||||
"sha256": "391f2aa638e75e6c7859d0a5c5650ef0956722a45998f17e05b83bc655778e1e"
|
||||
"size": 100786
|
||||
},
|
||||
{
|
||||
"size": 3800,
|
||||
"sha256": "98984c8f76bd231dab00ef54034bfc2f29b365ee0b31c05edb16ad5216bd5bc2",
|
||||
"path": "terminal/markdown.html",
|
||||
"sha256": "98984c8f76bd231dab00ef54034bfc2f29b365ee0b31c05edb16ad5216bd5bc2"
|
||||
"size": 3800
|
||||
},
|
||||
{
|
||||
"size": 18721,
|
||||
"sha256": "8b5429a035ce8ce11f77a222b5ee946844fd1e2999e1bb5c8f7c030ddbb1ff96",
|
||||
"path": "terminal/markdown.js",
|
||||
"sha256": "8b5429a035ce8ce11f77a222b5ee946844fd1e2999e1bb5c8f7c030ddbb1ff96"
|
||||
"size": 18721
|
||||
},
|
||||
{
|
||||
"size": 1089,
|
||||
"sha256": "ec9fb67dcb25eccc416ed56e1aab819222c805a2a4bfe4cb19e7556bf2ffde80",
|
||||
"path": "terminal/mermaid-LICENSE.txt",
|
||||
"sha256": "ec9fb67dcb25eccc416ed56e1aab819222c805a2a4bfe4cb19e7556bf2ffde80"
|
||||
"size": 1089
|
||||
},
|
||||
{
|
||||
"size": 5537838,
|
||||
"sha256": "336df803d87a38b70a01e736e666c8f7601d2ce42f5e47c8fafe5d721074b9a3",
|
||||
"path": "terminal/mermaid.js",
|
||||
"sha256": "336df803d87a38b70a01e736e666c8f7601d2ce42f5e47c8fafe5d721074b9a3"
|
||||
"size": 5537838
|
||||
},
|
||||
{
|
||||
"size": 6627,
|
||||
"sha256": "838707e2813f7d007f7f60670a78ae4a4a6c97ca9a235d623cb85e16dc50e0c7",
|
||||
"path": "terminal/terminal.js",
|
||||
"sha256": "838707e2813f7d007f7f60670a78ae4a4a6c97ca9a235d623cb85e16dc50e0c7"
|
||||
"size": 6627
|
||||
},
|
||||
{
|
||||
"size": 1261,
|
||||
"sha256": "b569f629d00f2626a8100df2a1798210535621e42164dfd426a6fe5aac7b0ccd",
|
||||
"path": "terminal/xterm-LICENSE.txt",
|
||||
"sha256": "b569f629d00f2626a8100df2a1798210535621e42164dfd426a6fe5aac7b0ccd"
|
||||
"size": 1261
|
||||
},
|
||||
{
|
||||
"size": 7112,
|
||||
"sha256": "854a7c0fb70e8b1a083c16797ab827299fb18744f5ad34f227b48337e33293c6",
|
||||
"path": "terminal/xterm.css",
|
||||
"sha256": "854a7c0fb70e8b1a083c16797ab827299fb18744f5ad34f227b48337e33293c6"
|
||||
"size": 7112
|
||||
},
|
||||
{
|
||||
"size": 488663,
|
||||
"sha256": "14903579ff54664cd72f8e8699e6961a6272c21863ec1c3b118cdc8af5d4a972",
|
||||
"path": "terminal/xterm.js",
|
||||
"sha256": "14903579ff54664cd72f8e8699e6961a6272c21863ec1c3b118cdc8af5d4a972"
|
||||
"size": 488663
|
||||
},
|
||||
{
|
||||
"size": 4401,
|
||||
"sha256": "d3c81140cce01c26bf6cbf52aa40e0825e1fa35b9a91d1387170a65d2597082c",
|
||||
"path": "LICENSE",
|
||||
"sha256": "d3c81140cce01c26bf6cbf52aa40e0825e1fa35b9a91d1387170a65d2597082c"
|
||||
"size": 4401
|
||||
},
|
||||
{
|
||||
"size": 1096,
|
||||
"sha256": "61e08da79c44061654015ce6b0c4061c23ee1dd18237fbf09e9bfda3c0ea2831",
|
||||
"path": "json-LICENSE.txt",
|
||||
"sha256": "61e08da79c44061654015ce6b0c4061c23ee1dd18237fbf09e9bfda3c0ea2831"
|
||||
"size": 1096
|
||||
},
|
||||
{
|
||||
"size": 883,
|
||||
"sha256": "185c5a37521316e940ead89cbf0b1ba5862d810c7c966e6c6a14a4a515b23625",
|
||||
"path": "files-text-license.txt",
|
||||
"sha256": "185c5a37521316e940ead89cbf0b1ba5862d810c7c966e6c6a14a4a515b23625"
|
||||
"size": 883
|
||||
},
|
||||
{
|
||||
"size": 4990,
|
||||
"sha256": "57d6d9b1f85ac93b3bc73f6f7bdf4346e896c4644d6fa461c380ae29070c029d",
|
||||
"path": "files-archive-license.txt",
|
||||
"sha256": "57d6d9b1f85ac93b3bc73f6f7bdf4346e896c4644d6fa461c380ae29070c029d"
|
||||
"size": 4990
|
||||
},
|
||||
{
|
||||
"size": 3044,
|
||||
"sha256": "7997c62a2f766674ceb99976485a6cf5c772309e79101a400c421d526b82f6e4",
|
||||
"path": "files-image-license.txt",
|
||||
"sha256": "7997c62a2f766674ceb99976485a6cf5c772309e79101a400c421d526b82f6e4"
|
||||
"size": 3044
|
||||
},
|
||||
{
|
||||
"size": 2064,
|
||||
"sha256": "19c254c71ee49aefbd8854ac55b05d719c5f1e4f8ef9a982324b898501b39594",
|
||||
"path": "files-sftp-license.txt",
|
||||
"sha256": "19c254c71ee49aefbd8854ac55b05d719c5f1e4f8ef9a982324b898501b39594"
|
||||
"size": 2064
|
||||
},
|
||||
{
|
||||
"size": 105515,
|
||||
"sha256": "be1b3fca2a291284ab550e9e77042fb27ecf927861d2d8fb8ec4907258477f01",
|
||||
"path": "README.md",
|
||||
"sha256": "be1b3fca2a291284ab550e9e77042fb27ecf927861d2d8fb8ec4907258477f01"
|
||||
"size": 105515
|
||||
},
|
||||
{
|
||||
"size": 16722,
|
||||
"sha256": "917c2f41b3943647fdfafa911d93f72b8c6fb0d08592016ce1a698d256e038bb",
|
||||
"path": "LAN-PREVIEW.md",
|
||||
"sha256": "917c2f41b3943647fdfafa911d93f72b8c6fb0d08592016ce1a698d256e038bb"
|
||||
"size": 16722
|
||||
},
|
||||
{
|
||||
"size": 732485,
|
||||
"sha256": "d0c022b27b9fbc2ff7b6b8bec723cc1adc4eef517202f9ff77eed5d8bea3acb9",
|
||||
"path": "dictionaries/en.txt",
|
||||
"sha256": "d0c022b27b9fbc2ff7b6b8bec723cc1adc4eef517202f9ff77eed5d8bea3acb9"
|
||||
"size": 732485
|
||||
},
|
||||
{
|
||||
"size": 20566,
|
||||
"sha256": "0bdfb0201d1803634f268cdff0993b8349d2c70e956a06dbb667c8dd65254ec5",
|
||||
"path": "dictionaries/LICENSE-CC-BY-SA-4.0.txt",
|
||||
"sha256": "0bdfb0201d1803634f268cdff0993b8349d2c70e956a06dbb667c8dd65254ec5"
|
||||
"size": 20566
|
||||
},
|
||||
{
|
||||
"size": 2265,
|
||||
"sha256": "3017bf44d3be9d9dfab21bd6778aa52b7947e61acf9ce2bc86b41d6e949ac311",
|
||||
"path": "dictionaries/README.md",
|
||||
"sha256": "3017bf44d3be9d9dfab21bd6778aa52b7947e61acf9ce2bc86b41d6e949ac311"
|
||||
"size": 2265
|
||||
},
|
||||
{
|
||||
"size": 1109134,
|
||||
"sha256": "80e6b6a27815973535f7facb636c597eb845dfee45cfabfc4e9b3341b9332849",
|
||||
"path": "dictionaries/ru.txt",
|
||||
"sha256": "80e6b6a27815973535f7facb636c597eb845dfee45cfabfc4e9b3341b9332849"
|
||||
"size": 1109134
|
||||
},
|
||||
{
|
||||
"size": 1280,
|
||||
"sha256": "98e5b3fe7304e37705c9e5ff48b0b399ccb16e806736d21f09921b99e5f2a408",
|
||||
"path": "dictionaries/sources.json",
|
||||
"sha256": "98e5b3fe7304e37705c9e5ff48b0b399ccb16e806736d21f09921b99e5f2a408"
|
||||
"size": 1280
|
||||
},
|
||||
{
|
||||
"size": 940799,
|
||||
"sha256": "d30e990d6ec2983c04f3644a3c61c6c668e8c542323f5931916fdd55b916eebf",
|
||||
"path": "dictionaries/uk.txt",
|
||||
"sha256": "d30e990d6ec2983c04f3644a3c61c6c668e8c542323f5931916fdd55b916eebf"
|
||||
"size": 940799
|
||||
},
|
||||
{
|
||||
"size": 993,
|
||||
"sha256": "a34b5161a8315af037e1ec71d816bfc688f7c364141d4ee2347cf0515ef0c82a",
|
||||
"path": "tools/README.txt",
|
||||
"sha256": "a34b5161a8315af037e1ec71d816bfc688f7c364141d4ee2347cf0515ef0c82a"
|
||||
"size": 993
|
||||
},
|
||||
{
|
||||
"size": 133120,
|
||||
"sha256": "b6a36bcdc26fc6bb55083e023e2fafb60236e541e9b1b7e598c66816a3089175",
|
||||
"path": "tools/StayHere.exe",
|
||||
"sha256": "98f657cdd3d5dec5db8b45760edc656e23c362edc9002b6828d2fe4c8b86073b"
|
||||
"size": 133120
|
||||
},
|
||||
{
|
||||
"size": 2796,
|
||||
"sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413",
|
||||
"path": "tools/StayHere-README.md",
|
||||
"sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413"
|
||||
"size": 2796
|
||||
}
|
||||
],
|
||||
"schema": 1,
|
||||
"version": "0.8.1"
|
||||
]
|
||||
}
|
||||
+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,1,0
|
||||
PRODUCTVERSION 0,8,1,0
|
||||
FILEVERSION 0,8,3,0
|
||||
PRODUCTVERSION 0,8,3,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.1"
|
||||
VALUE "FileVersion", "0.8.3"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
+3
-1
@@ -250,7 +250,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMEN
|
||||
CAPTION "KSwitcher Files Options"
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
LTEXT "&Search settings", -1, 8, 8, 113, 10
|
||||
LTEXT "&Search settings", 418, 8, 8, 113, 10
|
||||
EDITTEXT 270, 8, 21, 113, 14, ES_AUTOHSCROLL
|
||||
CONTROL "", 271, "SysTreeView32", WS_TABSTOP | WS_BORDER | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS, 8, 40, 113, 240
|
||||
LTEXT "", 272, 131, 8, 253, 12
|
||||
@@ -276,6 +276,8 @@ BEGIN
|
||||
PUSHBUTTON "Change &color…", 279, 131, 48, 82, 15
|
||||
LTEXT "", 280, 222, 50, 155, 12
|
||||
LTEXT "", 281, 131, 30, 254, 14
|
||||
LTEXT "Interface style", 416, 131, 30, 105, 14
|
||||
COMBOBOX 417, 245, 28, 132, 65, CBS_DROPDOWNLIST | WS_TABSTOP
|
||||
PUSHBUTTON "Change &font…", 282, 131, 52, 82, 15
|
||||
LTEXT "&Outer padding (px at 96 DPI)", 302, 131, 31, 173, 12
|
||||
COMBOBOX 303, 311, 28, 56, 125, CBS_DROPDOWNLIST | WS_TABSTOP | WS_VSCROLL
|
||||
|
||||
+11
-8
@@ -660,18 +660,21 @@ class Transaction
|
||||
}
|
||||
auto text = select(count) ? copy() : std::wstring{};
|
||||
diagnosticEvent(L"Selection initial match=" + std::to_wstring(matches(text)) + L" copied=" + diagnosticText(text));
|
||||
// The editor may finish applying queued Shift+Left events after copying
|
||||
// the suffix. Collapse to its right edge before trying the full range again.
|
||||
// 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.
|
||||
if (valid() && !matches(text) && !text.empty() &&
|
||||
(suffixMatches ? suffixMatches(text) : newlines(wordCandidate).ends_with(newlines(text))) &&
|
||||
caretSteps(text) < count)
|
||||
{
|
||||
diagnosticEvent(L"Selection: reselecting full range after verified suffix");
|
||||
if (!finishSelection(false))
|
||||
return {};
|
||||
Sleep(25);
|
||||
if (!selectPrevious(count, [&] { return valid(); }, true))
|
||||
return {};
|
||||
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);
|
||||
}
|
||||
text = copy();
|
||||
diagnosticEvent(L"Selection: suffix recovery match=" + std::to_wstring(matches(text)) + L" copied=" + diagnosticText(text));
|
||||
}
|
||||
|
||||
@@ -259,14 +259,15 @@ INT_PTR CALLBACK commandHistoryDialog(HWND dialog,UINT message,WPARAM wp,LPARAM
|
||||
SendMessageW(item.hwndItem,LB_GETTEXT,item.itemID,reinterpret_cast<LPARAM>(label.data()));
|
||||
label.resize(count);
|
||||
const bool selected=(item.itemState&ODS_SELECTED)!=0 && item.itemData<terminalHistory.size();
|
||||
const auto background=colors[selected?Selection:Dialog];
|
||||
const auto ink=colors[Text];
|
||||
const auto palette=farDropDownPalette();
|
||||
const auto background=selected?palette.selection:palette.surface;
|
||||
const auto ink=palette.text;
|
||||
if(item.itemData==static_cast<ULONG_PTR>(-1))
|
||||
{
|
||||
auto bounds=item.rcItem;
|
||||
InflateRect(&bounds,-historyRowInset(GetDpiForWindow(dialog)),0);
|
||||
const auto saved=SaveDC(item.hDC);
|
||||
SelectObject(item.hDC,mono);
|
||||
SelectObject(item.hDC,dialogUiFont());
|
||||
SetBkColor(item.hDC,background);
|
||||
SetTextColor(item.hDC,ink);
|
||||
ExtTextOutW(item.hDC,0,0,ETO_OPAQUE,&bounds,nullptr,0,nullptr);
|
||||
|
||||
@@ -1051,6 +1051,7 @@ INT_PTR CALLBACK comparisonDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
SendMessageW(dialog,WM_SETICON,ICON_SMALL,reinterpret_cast<LPARAM>(small));
|
||||
SendMessageW(dialog,WM_SETICON,ICON_BIG,reinterpret_cast<LPARAM>(large));
|
||||
ks::files::setFileWindowTaskbar(dialog,IDI_FILES_COMPARE,L"HrynCo.KSwitcher.Files.Compare");
|
||||
if(lavenderFiles()) styleLavenderDialogControls(dialog);
|
||||
initializeComparisonToolbar(toolbar);
|
||||
const auto actions=GetDlgItem(dialog,408);
|
||||
initializeComparisonActions(actions);
|
||||
@@ -1070,6 +1071,7 @@ INT_PTR CALLBACK comparisonDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
{
|
||||
applyComparisonAppearance(dialog,*comparison);
|
||||
layoutComparisonHeaders(dialog,*comparison);
|
||||
RedrawWindow(dialog,nullptr,nullptr,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
|
||||
return TRUE;
|
||||
}
|
||||
if(message==WM_CLOSE && comparison)
|
||||
@@ -1195,7 +1197,7 @@ INT_PTR CALLBACK comparisonDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
return lavenderDialogColors(dialog,message,wp,lp);
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK comparisonProgressDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
|
||||
@@ -54,6 +54,8 @@ LRESULT CALLBACK filesDialogMouse(int code,WPARAM message,LPARAM data)
|
||||
class FilesModalDialog
|
||||
{
|
||||
public:
|
||||
inline static void (*styleControls)(HWND){};
|
||||
inline static INT_PTR (*styleBackground)(HWND,UINT,WPARAM,LPARAM){};
|
||||
FilesModalDialog(HINSTANCE instance,LPCWSTR resource,HWND owner,DLGPROC procedure,LPARAM argument,
|
||||
bool watchOutsideClicks=true,bool fitToOwner=true)
|
||||
: owner_(owner),focus_(GetFocus()),procedure_(procedure),argument_(argument),
|
||||
@@ -347,7 +349,10 @@ private:
|
||||
lp=state->argument_;
|
||||
}
|
||||
if(!state) return FALSE;
|
||||
if(styleBackground)
|
||||
if(const auto styled=styleBackground(dialog,message,wp,lp)) return styled;
|
||||
const auto handled=state->procedure_(dialog,message,wp,lp);
|
||||
if(message==WM_INITDIALOG && styleControls) styleControls(dialog);
|
||||
if(message==WM_NCDESTROY) RemovePropW(dialog,stateProperty_);
|
||||
if(!handled && message==WM_CLOSE)
|
||||
{
|
||||
|
||||
@@ -309,12 +309,16 @@ INT_PTR CALLBACK quickFolderDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
const auto dc=BeginPaint(dialog,&ps);
|
||||
RECT client{};
|
||||
GetClientRect(dialog,&client);
|
||||
const auto frame=CreateSolidBrush(colors[Text]);
|
||||
const auto bounds=paintDialogFrame(dc,client,dialogFrameMetrics(GetDpiForWindow(dialog)),teal,frame);
|
||||
DeleteObject(frame);
|
||||
paintDialogFrameCaptions(dc,client,bounds,L"Folder shortcuts",teal,colors[Text],mono,
|
||||
view->digit<0?L"Enter Esc":quickFolderHints);
|
||||
paintScrollPosition(dialog,dc,GetDlgItem(dialog,shortcutList),colors[Dialog]);
|
||||
const auto hints=view->digit<0?L"Enter Esc":quickFolderHints;
|
||||
if(lavenderFiles()) paintLavenderDialogFrame(dialog,dc,client,L"Folder shortcuts",hints);
|
||||
else
|
||||
{
|
||||
const auto frame=CreateSolidBrush(colors[Text]);
|
||||
const auto bounds=paintDialogFrame(dc,client,dialogFrameMetrics(GetDpiForWindow(dialog)),teal,frame);
|
||||
DeleteObject(frame);
|
||||
paintDialogFrameCaptions(dc,client,bounds,L"Folder shortcuts",teal,colors[Text],mono,hints);
|
||||
}
|
||||
paintScrollPosition(dialog,dc,GetDlgItem(dialog,shortcutList),lavenderFiles()?lavender::surface:colors[Dialog]);
|
||||
EndPaint(dialog,&ps);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
namespace lavender
|
||||
{
|
||||
constexpr COLORREF canvas=RGB(238,240,250), surface=RGB(255,255,255), line=RGB(218,221,241);
|
||||
constexpr COLORREF ink=RGB(29,33,64), muted=RGB(91,97,133), accent=RGB(70,72,187);
|
||||
constexpr COLORREF activeEdge=RGB(151,151,244), selection=RGB(231,227,253), idleSelection=RGB(240,241,249);
|
||||
constexpr COLORREF folder=RGB(124,133,227), key=RGB(231,230,252), path=RGB(247,247,253);
|
||||
constexpr COLORREF marked=RGB(105,52,170), markedSelection=RGB(219,209,250);
|
||||
|
||||
HFONT font{}, emphasis{};
|
||||
|
||||
void setFont(UINT dpi)
|
||||
{
|
||||
if(font) DeleteObject(font);
|
||||
if(emphasis) DeleteObject(emphasis);
|
||||
const auto create=[&](int weight)
|
||||
{
|
||||
return CreateFontW(-MulDiv(14,dpi,96),0,0,0,weight,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
|
||||
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,CLEARTYPE_QUALITY,DEFAULT_PITCH,L"Segoe UI");
|
||||
};
|
||||
font=create(FW_NORMAL);
|
||||
emphasis=create(FW_SEMIBOLD);
|
||||
}
|
||||
|
||||
void fill(HDC dc,const RECT &rect,COLORREF color)
|
||||
{
|
||||
SetDCBrushColor(dc,color);
|
||||
FillRect(dc,&rect,static_cast<HBRUSH>(GetStockObject(DC_BRUSH)));
|
||||
}
|
||||
|
||||
void rounded(HDC dc,RECT rect,int radius,COLORREF color,COLORREF border)
|
||||
{
|
||||
if(rect.right<=rect.left || rect.bottom<=rect.top) return;
|
||||
const auto brush=SelectObject(dc,GetStockObject(DC_BRUSH));
|
||||
const auto pen=SelectObject(dc,GetStockObject(DC_PEN));
|
||||
SetDCBrushColor(dc,color);
|
||||
SetDCPenColor(dc,border);
|
||||
RoundRect(dc,rect.left,rect.top,rect.right,rect.bottom,2*radius,2*radius);
|
||||
SelectObject(dc,pen);
|
||||
SelectObject(dc,brush);
|
||||
}
|
||||
|
||||
void text(HDC dc,RECT rect,const wchar_t *label,COLORREF color,UINT alignment=DT_LEFT,
|
||||
UINT ellipsis=DT_END_ELLIPSIS,HFONT textFont=nullptr)
|
||||
{
|
||||
if(rect.right<=rect.left) return;
|
||||
if(!textFont) textFont=font;
|
||||
const auto previous=SelectObject(dc,textFont?textFont:GetStockObject(DEFAULT_GUI_FONT));
|
||||
const auto background=SetBkMode(dc,TRANSPARENT);
|
||||
const auto inkColor=SetTextColor(dc,color);
|
||||
DrawTextW(dc,label,-1,&rect,DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX|alignment|ellipsis);
|
||||
SetTextColor(dc,inkColor);
|
||||
SetBkMode(dc,background);
|
||||
SelectObject(dc,previous);
|
||||
}
|
||||
}
|
||||
|
||||
struct LavenderMetrics
|
||||
{
|
||||
UINT dpi;
|
||||
int px(int value) const { return MulDiv(value,dpi,96); }
|
||||
int row;
|
||||
explicit LavenderMetrics(HWND window): dpi(GetDpiForWindow(window)),row(px(25)) {}
|
||||
};
|
||||
|
||||
void styleLavenderCaption(HWND window,bool enabled)
|
||||
{
|
||||
const COLORREF surface=enabled?lavender::path:DWMWA_COLOR_DEFAULT;
|
||||
const COLORREF text=enabled?lavender::ink:DWMWA_COLOR_DEFAULT;
|
||||
DwmSetWindowAttribute(window,DWMWA_CAPTION_COLOR,&surface,sizeof(surface));
|
||||
DwmSetWindowAttribute(window,DWMWA_TEXT_COLOR,&text,sizeof(text));
|
||||
}
|
||||
|
||||
void paintLavenderFileIcon(HDC dc,RECT row,const LavenderMetrics &metrics,bool folder)
|
||||
{
|
||||
using namespace lavender;
|
||||
const int x=row.left+metrics.px(9), y=(row.top+row.bottom-metrics.px(12))/2;
|
||||
const int stroke=metrics.px(1);
|
||||
if(folder)
|
||||
{
|
||||
const auto edge=RGB(104,114,205);
|
||||
rounded(dc,{x,y,x+metrics.px(8),y+metrics.px(8)},stroke,lavender::folder,edge);
|
||||
rounded(dc,{x,y+metrics.px(3),x+metrics.px(14),y+metrics.px(12)},2*stroke,lavender::folder,edge);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int left=x+metrics.px(2), right=x+metrics.px(12), bottom=y+metrics.px(13);
|
||||
rounded(dc,{left,y,right,bottom},stroke,path,RGB(157,164,198));
|
||||
for(int offset:{5,8}) fill(dc,{left+2*stroke,y+metrics.px(offset),right-2*stroke,
|
||||
y+metrics.px(offset)+stroke},RGB(185,190,215));
|
||||
}
|
||||
}
|
||||
|
||||
void paintLavenderCommand(const DRAWITEMSTRUCT &item,const std::wstring &label,const LavenderMetrics &metrics,bool compact)
|
||||
{
|
||||
using namespace lavender;
|
||||
const auto &box=item.rcItem;
|
||||
fill(item.hDC,box,canvas);
|
||||
const bool pressed=item.itemState&ODS_SELECTED;
|
||||
rounded(item.hDC,box,metrics.px(8),pressed?selection:path,pressed?activeEdge:line);
|
||||
const auto separator=label.find(L' ');
|
||||
const auto shortcut=label.substr(0,separator);
|
||||
const int width=metrics.px(shortcut.size()>3?48:27);
|
||||
const int padding=metrics.px(5);
|
||||
if(compact)
|
||||
{
|
||||
const LONG left=std::max(box.left,(box.left+box.right-width)/2);
|
||||
const LONG top=box.top+metrics.px(2);
|
||||
const RECT badge{left,top,std::min(box.right,left+width),top+metrics.px(17)};
|
||||
rounded(item.hDC,badge,metrics.px(4),key,key);
|
||||
text(item.hDC,badge,shortcut.c_str(),accent,DT_CENTER);
|
||||
if(separator!=label.npos)
|
||||
text(item.hDC,{box.left+1,badge.bottom,box.right-1,box.bottom-1},
|
||||
label.c_str()+separator+1,ink,DT_CENTER);
|
||||
return;
|
||||
}
|
||||
const LONG top=(box.top+box.bottom-metrics.px(18))/2;
|
||||
const RECT badge{box.left+padding,top,std::min(box.left+padding+width,box.right-padding),top+metrics.px(18)};
|
||||
rounded(item.hDC,badge,metrics.px(4),key,key);
|
||||
text(item.hDC,badge,shortcut.c_str(),accent,DT_CENTER);
|
||||
if(separator!=label.npos)
|
||||
text(item.hDC,{badge.right+padding,box.top,box.right-padding,box.bottom},label.c_str()+separator+1,ink);
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
constexpr auto lavenderDialogWarning=L"KSwitcher.Files.Lavender.Warning";
|
||||
constexpr auto lavenderFileOperation=L"KSwitcher.Files.Lavender.FileOperation";
|
||||
constexpr int lavenderSidebarLabel=418;
|
||||
constexpr int operationHeaderHeight=27;
|
||||
constexpr COLORREF operationSurface=RGB(242,239,251), operationBorder=RGB(111,96,166);
|
||||
|
||||
bool isLavenderFileOperation(HWND dialog) { return GetPropW(dialog,lavenderFileOperation)!=nullptr; }
|
||||
void markLavenderFileOperation(HWND dialog)
|
||||
{
|
||||
if(lavenderFiles()) SetPropW(dialog,lavenderFileOperation,reinterpret_cast<HANDLE>(1));
|
||||
}
|
||||
|
||||
COLORREF lavenderDialogSurface(HWND dialog)
|
||||
{
|
||||
return isLavenderFileOperation(dialog)?operationSurface:lavender::surface;
|
||||
}
|
||||
|
||||
HFONT dialogUiFont() { return lavenderFiles() && lavender::font?lavender::font:mono; }
|
||||
|
||||
bool dialogClass(HWND control,const wchar_t *name)
|
||||
{
|
||||
wchar_t type[64]{};
|
||||
GetClassNameW(control,type,static_cast<int>(std::size(type)));
|
||||
return _wcsicmp(type,name)==0;
|
||||
}
|
||||
|
||||
COLORREF dialogEdge(HWND dialog)
|
||||
{
|
||||
return GetPropW(dialog,lavenderDialogWarning)?RGB(161,43,72):lavender::accent;
|
||||
}
|
||||
|
||||
void paintLavenderDialogButton(HWND control,HDC dc,RECT bounds,bool pressed,bool focused,bool primary)
|
||||
{
|
||||
using namespace lavender;
|
||||
const LavenderMetrics metrics(control);
|
||||
const bool enabled=IsWindowEnabled(control)!=FALSE;
|
||||
const auto id=GetDlgCtrlID(control);
|
||||
const auto dialog=GetParent(control);
|
||||
const bool operation=isLavenderFileOperation(dialog);
|
||||
const auto accentColor=id==IDCANCEL || id==IDNO?accent:dialogEdge(dialog);
|
||||
const auto bg=!enabled?canvas:primary?accentColor:pressed?selection:operation?surface:path;
|
||||
fill(dc,bounds,lavenderDialogSurface(dialog));
|
||||
InflateRect(&bounds,-metrics.px(1),-metrics.px(1));
|
||||
rounded(dc,bounds,metrics.px(6),bg,focused?accentColor:primary?bg:enabled && operation?operationBorder:line);
|
||||
wchar_t label[128]{};
|
||||
GetWindowTextW(control,label,static_cast<int>(std::size(label)));
|
||||
const auto previous=SelectObject(dc,reinterpret_cast<HFONT>(SendMessageW(control,WM_GETFONT,0,0)));
|
||||
const auto mode=SetBkMode(dc,TRANSPARENT);
|
||||
const auto color=SetTextColor(dc,!enabled?muted:primary?surface:ink);
|
||||
InflateRect(&bounds,-metrics.px(3),0);
|
||||
DrawTextW(dc,label,-1,&bounds,DT_CENTER|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS);
|
||||
if(focused && primary)
|
||||
{
|
||||
InflateRect(&bounds,0,-metrics.px(3));
|
||||
DrawFocusRect(dc,&bounds);
|
||||
}
|
||||
SetTextColor(dc,color);
|
||||
SetBkMode(dc,mode);
|
||||
SelectObject(dc,previous);
|
||||
}
|
||||
|
||||
void paintLavenderToggle(HWND control,HDC dc,RECT bounds,bool radio)
|
||||
{
|
||||
using namespace lavender;
|
||||
const LavenderMetrics metrics(control);
|
||||
const int side=std::min(metrics.px(14),static_cast<int>(bounds.bottom-bounds.top));
|
||||
const LONG x=bounds.left+metrics.px(1), y=(bounds.top+bounds.bottom-side)/2;
|
||||
const bool checked=SendMessageW(control,BM_GETCHECK,0,0)==BST_CHECKED;
|
||||
const bool enabled=IsWindowEnabled(control)!=FALSE;
|
||||
const RECT indicator{x,y,x+side,y+side};
|
||||
fill(dc,bounds,lavenderDialogSurface(GetParent(control)));
|
||||
rounded(dc,indicator,radio?side/2:metrics.px(3),checked?accent:path,enabled?accent:line);
|
||||
if(checked && radio)
|
||||
{
|
||||
auto dot=indicator;
|
||||
InflateRect(&dot,-side/3,-side/3);
|
||||
rounded(dc,dot,side/4,surface,surface);
|
||||
}
|
||||
else if(checked)
|
||||
{
|
||||
const auto old=SelectObject(dc,GetStockObject(DC_PEN));
|
||||
SetDCPenColor(dc,surface);
|
||||
const POINT check[]{{x+side/4,y+side/2},{x+side*2/5,y+side*2/3},{x+side*3/4,y+side/3}};
|
||||
Polyline(dc,check,static_cast<int>(std::size(check)));
|
||||
SelectObject(dc,old);
|
||||
}
|
||||
bounds.left=x+side+metrics.px(6);
|
||||
wchar_t label[128]{};
|
||||
GetWindowTextW(control,label,static_cast<int>(std::size(label)));
|
||||
const auto previous=SelectObject(dc,reinterpret_cast<HFONT>(SendMessageW(control,WM_GETFONT,0,0)));
|
||||
SetBkMode(dc,TRANSPARENT);
|
||||
SetTextColor(dc,enabled?ink:muted);
|
||||
DrawTextW(dc,label,-1,&bounds,DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS);
|
||||
if(GetFocus()==control)
|
||||
{
|
||||
RECT extent{};
|
||||
DrawTextW(dc,label,-1,&extent,DT_SINGLELINE|DT_CALCRECT);
|
||||
bounds.right=std::min(bounds.right,bounds.left+extent.right+metrics.px(3));
|
||||
DrawFocusRect(dc,&bounds);
|
||||
}
|
||||
SelectObject(dc,previous);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK lavenderNativeButton(HWND control,UINT message,WPARAM wp,LPARAM lp,UINT_PTR,DWORD_PTR)
|
||||
{
|
||||
if(!lavenderFiles()) return DefSubclassProc(control,message,wp,lp);
|
||||
const auto style=GetWindowLongPtrW(control,GWL_STYLE)&BS_TYPEMASK;
|
||||
if(message==WM_PAINT || message==WM_PRINTCLIENT)
|
||||
{
|
||||
PAINTSTRUCT paint{};
|
||||
const auto dc=message==WM_PAINT?BeginPaint(control,&paint):reinterpret_cast<HDC>(wp);
|
||||
RECT bounds{};
|
||||
GetClientRect(control,&bounds);
|
||||
if(style==BS_GROUPBOX)
|
||||
{
|
||||
const LavenderMetrics metrics(control);
|
||||
auto frame=bounds;
|
||||
frame.top+=metrics.px(7);
|
||||
lavender::fill(dc,bounds,lavender::surface);
|
||||
lavender::rounded(dc,frame,metrics.px(7),lavender::surface,lavender::line);
|
||||
wchar_t label[96]{};
|
||||
GetWindowTextW(control,label,static_cast<int>(std::size(label)));
|
||||
paintDialogCaption(dc,{bounds.left,bounds.top,bounds.right,bounds.top+metrics.px(15)},label,
|
||||
static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)),lavender::muted,
|
||||
reinterpret_cast<HFONT>(SendMessageW(control,WM_GETFONT,0,0)));
|
||||
}
|
||||
else if(style==BS_AUTOCHECKBOX || style==BS_AUTORADIOBUTTON)
|
||||
paintLavenderToggle(control,dc,bounds,style==BS_AUTORADIOBUTTON);
|
||||
else paintLavenderDialogButton(control,dc,bounds,(SendMessageW(control,BM_GETSTATE,0,0)&BST_PUSHED)!=0,
|
||||
GetFocus()==control,style==BS_DEFPUSHBUTTON);
|
||||
if(message==WM_PAINT) EndPaint(control,&paint);
|
||||
return 0;
|
||||
}
|
||||
const auto result=DefSubclassProc(control,message,wp,lp);
|
||||
if(message==WM_SETFOCUS || message==WM_KILLFOCUS || message==WM_ENABLE || message==BM_SETSTATE ||
|
||||
message==BM_SETCHECK || message==BM_SETSTYLE || message==WM_SETTEXT ||
|
||||
message==WM_LBUTTONUP || message==WM_KEYUP)
|
||||
InvalidateRect(control,nullptr,FALSE);
|
||||
return result;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK lavenderEditEdge(HWND control,UINT message,WPARAM wp,LPARAM lp,UINT_PTR,DWORD_PTR)
|
||||
{
|
||||
if(message==WM_NCCALCSIZE && lavenderFiles())
|
||||
{
|
||||
const auto result=DefSubclassProc(control,message,wp,lp);
|
||||
auto &client=*reinterpret_cast<RECT*>(lp);
|
||||
const auto inset=LavenderMetrics(control).px(2);
|
||||
InflateRect(&client,-inset,-inset);
|
||||
return result;
|
||||
}
|
||||
if(message==WM_NCPAINT && lavenderFiles())
|
||||
{
|
||||
const auto dc=GetWindowDC(control);
|
||||
if(!dc) return DefSubclassProc(control,message,wp,lp);
|
||||
RECT bounds{}, client{};
|
||||
GetWindowRect(control,&bounds);
|
||||
GetClientRect(control,&client);
|
||||
MapWindowPoints(control,nullptr,reinterpret_cast<POINT*>(&client),2);
|
||||
OffsetRect(&client,-bounds.left,-bounds.top);
|
||||
OffsetRect(&bounds,-bounds.left,-bounds.top);
|
||||
ExcludeClipRect(dc,client.left,client.top,client.right,client.bottom);
|
||||
const auto dialog=GetParent(control);
|
||||
const bool operation=isLavenderFileOperation(dialog);
|
||||
lavender::fill(dc,bounds,lavenderDialogSurface(dialog));
|
||||
lavender::rounded(dc,bounds,LavenderMetrics(control).px(4),operation?lavender::surface:lavender::path,
|
||||
GetFocus()==control?(operation?dialogEdge(dialog):lavender::activeEdge):operation?operationBorder:lavender::line);
|
||||
ReleaseDC(control,dc);
|
||||
return 0;
|
||||
}
|
||||
const auto result=DefSubclassProc(control,message,wp,lp);
|
||||
if((message==WM_SETFOCUS || message==WM_KILLFOCUS) && lavenderFiles())
|
||||
RedrawWindow(control,nullptr,nullptr,RDW_INVALIDATE|RDW_FRAME);
|
||||
return result;
|
||||
}
|
||||
|
||||
void paintLavenderComboFace(HWND control,HDC dc,RECT bounds,const wchar_t *label)
|
||||
{
|
||||
using namespace lavender;
|
||||
const LavenderMetrics metrics(control);
|
||||
const bool focused=GetFocus()==control;
|
||||
const auto dialog=GetParent(control);
|
||||
const bool operation=isLavenderFileOperation(dialog);
|
||||
fill(dc,bounds,lavenderDialogSurface(dialog));
|
||||
rounded(dc,bounds,metrics.px(5),operation?surface:path,
|
||||
focused?(operation?dialogEdge(dialog):activeEdge):operation?operationBorder:line);
|
||||
const LONG center=label[0]?bounds.right-metrics.px(10):(bounds.left+bounds.right)/2;
|
||||
const LONG middle=(bounds.top+bounds.bottom)/2;
|
||||
const int arm=metrics.px(3);
|
||||
const auto previous=SelectObject(dc,GetStockObject(DC_PEN));
|
||||
SetDCPenColor(dc,IsWindowEnabled(control)?accent:muted);
|
||||
const POINT arrow[]{{center-arm,middle-arm/2},{center,middle+arm/2},{center+arm,middle-arm/2}};
|
||||
Polyline(dc,arrow,static_cast<int>(std::size(arrow)));
|
||||
SelectObject(dc,previous);
|
||||
bounds.left+=metrics.px(7);
|
||||
bounds.right-=metrics.px(20);
|
||||
const auto oldFont=SelectObject(dc,reinterpret_cast<HFONT>(SendMessageW(control,WM_GETFONT,0,0)));
|
||||
SetTextColor(dc,IsWindowEnabled(control)?ink:muted);
|
||||
SetBkMode(dc,TRANSPARENT);
|
||||
DrawTextW(dc,label,-1,&bounds,DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS|DT_NOPREFIX);
|
||||
SelectObject(dc,oldFont);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK lavenderNativeCombo(HWND control,UINT message,WPARAM wp,LPARAM lp,UINT_PTR,DWORD_PTR)
|
||||
{
|
||||
if(lavenderFiles() && (message==WM_PAINT || message==WM_PRINTCLIENT))
|
||||
{
|
||||
PAINTSTRUCT paint{};
|
||||
const auto dc=message==WM_PAINT?BeginPaint(control,&paint):reinterpret_cast<HDC>(wp);
|
||||
RECT bounds{};
|
||||
GetClientRect(control,&bounds);
|
||||
const auto length=GetWindowTextLengthW(control);
|
||||
std::wstring label(length+1,L'\0');
|
||||
GetWindowTextW(control,label.data(),static_cast<int>(label.size()));
|
||||
paintLavenderComboFace(control,dc,bounds,label.c_str());
|
||||
if(message==WM_PAINT) EndPaint(control,&paint);
|
||||
return 0;
|
||||
}
|
||||
const auto result=DefSubclassProc(control,message,wp,lp);
|
||||
if(message==WM_SETFOCUS || message==WM_KILLFOCUS || message==CB_SETCURSEL || message==WM_ENABLE)
|
||||
InvalidateRect(control,nullptr,FALSE);
|
||||
return result;
|
||||
}
|
||||
|
||||
void styleLavenderDialogControls(HWND dialog)
|
||||
{
|
||||
const bool modern=lavenderFiles();
|
||||
const bool custom=(GetWindowLongPtrW(dialog,GWL_STYLE)&WS_CAPTION)==0;
|
||||
if(!custom) styleLavenderCaption(dialog,modern);
|
||||
for(auto control=GetWindow(dialog,GW_CHILD);control;control=GetWindow(control,GW_HWNDNEXT))
|
||||
{
|
||||
DWORD_PTR oldEdge{};
|
||||
if(!modern)
|
||||
{
|
||||
if(GetWindowSubclass(control,lavenderEditEdge,1,&oldEdge))
|
||||
{
|
||||
RemoveWindowSubclass(control,lavenderEditEdge,1);
|
||||
SetWindowLongPtrW(control,GWL_EXSTYLE,GetWindowLongPtrW(control,GWL_EXSTYLE)|oldEdge);
|
||||
SendMessageW(control,EM_SETMARGINS,EC_LEFTMARGIN|EC_RIGHTMARGIN,
|
||||
MAKELPARAM(EC_USEFONTINFO,EC_USEFONTINFO));
|
||||
SetWindowPos(control,nullptr,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
}
|
||||
if(dialogClass(control,WC_TREEVIEWW))
|
||||
{
|
||||
const auto style=GetWindowLongPtrW(control,GWL_STYLE);
|
||||
SetWindowLongPtrW(control,GWL_STYLE,(style&~TVS_FULLROWSELECT)|WS_BORDER|TVS_HASLINES);
|
||||
TreeView_SetBkColor(control,CLR_NONE);
|
||||
TreeView_SetTextColor(control,CLR_NONE);
|
||||
TreeView_SetLineColor(control,CLR_DEFAULT);
|
||||
SetWindowPos(control,nullptr,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(custom) SendMessageW(control,WM_SETFONT,reinterpret_cast<WPARAM>(dialogUiFont()),FALSE);
|
||||
if(dialogClass(control,L"Button"))
|
||||
{
|
||||
const auto type=GetWindowLongPtrW(control,GWL_STYLE)&BS_TYPEMASK;
|
||||
DWORD_PTR existing{};
|
||||
if(type!=BS_OWNERDRAW && !GetWindowSubclass(control,lavenderNativeButton,2,&existing))
|
||||
SetWindowSubclass(control,lavenderNativeButton,2,0);
|
||||
}
|
||||
else if(dialogClass(control,WC_TREEVIEWW))
|
||||
{
|
||||
const auto style=GetWindowLongPtrW(control,GWL_STYLE);
|
||||
SetWindowLongPtrW(control,GWL_STYLE,(style&~(WS_BORDER|TVS_HASLINES))|TVS_FULLROWSELECT);
|
||||
TreeView_SetBkColor(control,lavender::path);
|
||||
TreeView_SetTextColor(control,lavender::ink);
|
||||
TreeView_SetLineColor(control,lavender::activeEdge);
|
||||
SetWindowPos(control,nullptr,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
}
|
||||
else if(dialogClass(control,L"ComboBox"))
|
||||
{
|
||||
const auto style=GetWindowLongPtrW(control,GWL_STYLE);
|
||||
if((style&3)==CBS_DROPDOWNLIST && !(style&(CBS_OWNERDRAWFIXED|CBS_OWNERDRAWVARIABLE)))
|
||||
SetWindowSubclass(control,lavenderNativeCombo,1,0);
|
||||
}
|
||||
else if((dialogClass(control,L"KSwitcher.Files.FarEdit") ||
|
||||
(dialogClass(control,L"Edit") && !(GetWindowLongPtrW(control,GWL_STYLE)&ES_READONLY))) &&
|
||||
!GetWindowSubclass(control,lavenderEditEdge,1,&oldEdge))
|
||||
{
|
||||
const auto style=GetWindowLongPtrW(control,GWL_EXSTYLE);
|
||||
SetWindowLongPtrW(control,GWL_EXSTYLE,style&~WS_EX_CLIENTEDGE);
|
||||
SetWindowSubclass(control,lavenderEditEdge,1,style&WS_EX_CLIENTEDGE);
|
||||
SetWindowPos(control,nullptr,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
const auto padding=LavenderMetrics(control).px(6);
|
||||
SendMessageW(control,EM_SETMARGINS,EC_LEFTMARGIN|EC_RIGHTMARGIN,MAKELPARAM(padding,padding));
|
||||
}
|
||||
}
|
||||
RedrawWindow(dialog,nullptr,nullptr,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
|
||||
}
|
||||
|
||||
INT_PTR lavenderDialogColors(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
{
|
||||
if(message==WM_NCDESTROY) RemovePropW(dialog,lavenderFileOperation);
|
||||
if(!lavenderFiles()) return FALSE;
|
||||
if(message!=WM_CTLCOLORDLG && message!=WM_CTLCOLORSTATIC && message!=WM_CTLCOLOREDIT && message!=WM_CTLCOLORLISTBOX &&
|
||||
message!=WM_CTLCOLORBTN) return FALSE;
|
||||
const auto dc=reinterpret_cast<HDC>(wp);
|
||||
const auto control=reinterpret_cast<HWND>(lp);
|
||||
const bool field=message==WM_CTLCOLOREDIT ||
|
||||
(message==WM_CTLCOLORSTATIC && dialogClass(control,L"KSwitcher.Files.FarEdit"));
|
||||
const auto background=field?(isLavenderFileOperation(dialog)?lavender::surface:lavender::path):
|
||||
GetDlgCtrlID(control)==lavenderSidebarLabel && message==WM_CTLCOLORSTATIC?lavender::path:lavenderDialogSurface(dialog);
|
||||
SetTextColor(dc,IsWindowEnabled(control)?lavender::ink:lavender::muted);
|
||||
SetBkColor(dc,background);
|
||||
SetDCBrushColor(dc,background);
|
||||
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)
|
||||
{
|
||||
using namespace lavender;
|
||||
const LavenderMetrics metrics(dialog);
|
||||
fill(dc,client,canvas);
|
||||
const bool operation=isLavenderFileOperation(dialog);
|
||||
const auto edge=dialogEdge(dialog);
|
||||
LONG headerBottom=client.top+metrics.px(operationHeaderHeight);
|
||||
if(operation)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
else rounded(dc,client,metrics.px(9),surface,line);
|
||||
auto content=client;
|
||||
const int inset=metrics.px(10);
|
||||
InflateRect(&content,-inset,0);
|
||||
std::wstring_view caption(title);
|
||||
const auto first=caption.find_first_not_of(L' ');
|
||||
if(first!=caption.npos)
|
||||
{
|
||||
caption=caption.substr(first,caption.find_last_not_of(L' ')-first+1);
|
||||
const auto titleInset=dialogFrameMetrics(metrics.dpi).content();
|
||||
auto label=RECT{client.left+titleInset,client.top+metrics.px(4),content.right,client.top+metrics.px(23)};
|
||||
if(operation) label.bottom=headerBottom;
|
||||
text(dc,label,std::wstring(caption).c_str(),operation?surface:edge);
|
||||
}
|
||||
if(hints) text(dc,{content.left,client.bottom-metrics.px(21),content.right,client.bottom},hints,muted,DT_CENTER);
|
||||
return content;
|
||||
}
|
||||
+376
-99
File diff suppressed because it is too large.
Load diff
+77
-6
@@ -18,7 +18,9 @@ constexpr int wideColumnControls[]{275,276,201,202,204};
|
||||
constexpr int statusColumnControls[]{277,203,205,206,207,208};
|
||||
constexpr int colorOptionControls[]{279,280};
|
||||
constexpr int appearanceControls[]{281,282};
|
||||
enum AppearanceSection { Font, DialogFrame, SystemThemes };
|
||||
enum AppearanceSection { Font, DialogFrame, SystemThemes, WindowStyle };
|
||||
constexpr int windowStyleChoice=417;
|
||||
constexpr int windowStyleControls[]{416,windowStyleChoice};
|
||||
constexpr int terminalScaleSection=1,areaScaleLabel=528,areaScaleControl=529;
|
||||
constexpr int systemLightChoice=531,systemDarkChoice=533;
|
||||
constexpr int systemThemeControls[]{530,systemLightChoice,532,systemDarkChoice,535};
|
||||
@@ -105,6 +107,7 @@ void showPanelModeOptions(HWND dialog)
|
||||
|
||||
struct OptionsBaseline
|
||||
{
|
||||
FilesAppearance appearance=filesAppearance;
|
||||
LOGFONTW font=displayFont;
|
||||
int points=fontPoints;
|
||||
DialogFramePadding padding=dialogFramePadding;
|
||||
@@ -127,6 +130,7 @@ struct OptionsBaseline
|
||||
struct OptionsDraft
|
||||
{
|
||||
OptionsBaseline baseline;
|
||||
FilesAppearance appearance=baseline.appearance;
|
||||
ks::files::TextSettings text=baseline.text;
|
||||
ComparisonAppearance comparison=baseline.comparison;
|
||||
FilesKeySettings keySettings=baseline.keySettings;
|
||||
@@ -144,7 +148,7 @@ struct OptionsDraft
|
||||
DWORD location{};
|
||||
int markdownError{};
|
||||
HTREEITEM wideColumnsNode{},markdownNode{};
|
||||
RECT initialClient{};
|
||||
RECT initialClient{}, resetBounds{};
|
||||
UINT initialDpi=96;
|
||||
OptionsControl controls[10]{
|
||||
{optionsTree,OptionsAnchor::StretchHeight},
|
||||
@@ -185,7 +189,7 @@ void updateOptionsApply(HWND dialog,const OptionsDraft &draft)
|
||||
checked(rightClickMarksControl)!=base.mouseMarks || checked(driveButtonsControl)!=base.drives ||
|
||||
checked(compactLayoutControl)!=base.compact || checked(restoreDocumentsControl)!=base.restoreLocal ||
|
||||
fields!=base.fields || draft.palette!=base.palette || draft.styles!=base.styles ||
|
||||
draft.framePadding!=base.padding || optionsFontChanged(draft) ||
|
||||
draft.framePadding!=base.padding || optionsFontChanged(draft) || draft.appearance!=base.appearance ||
|
||||
checked(optionsRemoteTerminal)!=base.remoteTerminal ||
|
||||
checked(optionsRemoteHibernate)!=base.remoteHibernate ||
|
||||
checked(optionsRemoteUpdate)!=base.remoteUpdate ||
|
||||
@@ -202,7 +206,8 @@ LRESULT CALLBACK optionsGroupBackground(HWND group,UINT message,WPARAM wp,LPARAM
|
||||
const auto dc=reinterpret_cast<HDC>(wp);
|
||||
RECT client{};
|
||||
GetClientRect(group,&client);
|
||||
FillRect(dc,&client,GetSysColorBrush(COLOR_3DFACE));
|
||||
if(lavenderFiles()) lavender::fill(dc,client,lavender::surface);
|
||||
else FillRect(dc,&client,GetSysColorBrush(COLOR_3DFACE));
|
||||
return TRUE;
|
||||
}
|
||||
return DefSubclassProc(group,message,wp,lp);
|
||||
@@ -221,6 +226,7 @@ void layoutOptionsPreview(HWND dialog)
|
||||
{
|
||||
const auto id=GetDlgCtrlID(child);
|
||||
if(child==preview || id==IDOK || id==IDCANCEL || id==optionsApply ||
|
||||
(lavenderFiles() && id==optionsReset) ||
|
||||
!(GetWindowLongPtrW(child,GWL_STYLE)&WS_VISIBLE)) continue;
|
||||
const auto bounds=dialogControlBounds(dialog,id);
|
||||
if(id!=-1 && bounds.left>=title.left-4) top=std::max(top,bounds.bottom);
|
||||
@@ -254,6 +260,13 @@ void layoutOptions(HWND dialog,const OptionsDraft &draft)
|
||||
SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOREDRAW);
|
||||
}
|
||||
groupDialogButtons(dialog,{IDOK,IDCANCEL,optionsApply},true);
|
||||
const auto reset=draft.resetBounds;
|
||||
const auto ok=dialogControlBounds(dialog,IDOK);
|
||||
const auto resetLeft=lavenderFiles()?dialogControlBounds(dialog,optionsTree).left:scale(reset.left);
|
||||
const auto resetTop=lavenderFiles()?ok.top:scale(reset.top);
|
||||
const auto resetHeight=lavenderFiles()?ok.bottom-ok.top:scale(reset.bottom-reset.top);
|
||||
SetWindowPos(GetDlgItem(dialog,optionsReset),nullptr,resetLeft,resetTop,
|
||||
scale(reset.right-reset.left),resetHeight,SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW);
|
||||
if(draft.page==PanelColors && draft.section==fileStyleSection) layoutFileStyleFields(dialog,false);
|
||||
layoutOptionsPreview(dialog);
|
||||
// Paint the final layout together, including the areas vacated by moved controls.
|
||||
@@ -583,7 +596,8 @@ void showOptionsPage(HWND dialog,OptionsDraft &draft,int page,int section)
|
||||
title=page==PanelModes?panelSectionNames[section]:page==PanelColors?
|
||||
(section==fileStyleSection?L"File type styles":colorNames[section]):
|
||||
page==CommandLine?(section==terminalScaleSection?L"Terminal appearance":L"Command history"):
|
||||
section==SystemThemes?L"System themes":section==DialogFrame?L"Dialog frame":L"Font";
|
||||
section==WindowStyle?L"Window style":section==SystemThemes?L"System themes":
|
||||
section==DialogFrame?L"Dialog frame":L"Font";
|
||||
}
|
||||
SetDlgItemTextW(dialog,optionsTitle,title);
|
||||
const auto show=[&](auto &controls,bool visible)
|
||||
@@ -612,6 +626,8 @@ void showOptionsPage(HWND dialog,OptionsDraft &draft,int page,int section)
|
||||
show(statusColumnControls,page==PanelModes && section==StatusColumns);
|
||||
show(appearanceControls,page==Appearance && section==Font);
|
||||
show(systemThemeControls,page==Appearance && section==SystemThemes);
|
||||
show(windowStyleControls,page==Appearance && section==WindowStyle);
|
||||
SendDlgItemMessageW(dialog,windowStyleChoice,CB_SETCURSEL,static_cast<WPARAM>(draft.appearance),0);
|
||||
if(page==Appearance && section==SystemThemes) showSystemThemeRoles(dialog,draft.text);
|
||||
showAreaScale(dialog,draft,optionsScaleArea(page,section));
|
||||
show(comparisonControls,page==CompareFiles);
|
||||
@@ -633,7 +649,8 @@ void showOptionsPage(HWND dialog,OptionsDraft &draft,int page,int section)
|
||||
constexpr int fileStyleControls[]{287,288,289,290,291,292,293,294,295,296,297,298,300,fileStyleState};
|
||||
show(fileStyleControls,fileTypes);
|
||||
const auto preview=GetDlgItem(dialog,fileStylePreview);
|
||||
const bool panelPreview=page>=0 && page<CommandLine && section>=0 && !(page==Appearance && section==SystemThemes);
|
||||
const bool panelPreview=page>=0 && page<CommandLine && section>=0 &&
|
||||
!(page==Appearance && (section==SystemThemes || section==WindowStyle));
|
||||
ShowWindow(preview,panelPreview?SW_SHOW:SW_HIDE);
|
||||
layoutOptionsPreview(dialog);
|
||||
RedrawWindow(dialog,nullptr,nullptr,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
|
||||
@@ -756,6 +773,7 @@ void filterOptions(HWND dialog,OptionsDraft &draft)
|
||||
{
|
||||
addSection(L"Font",Font,matches(L"Display font") || matches(L"Panel scale"));
|
||||
addSection(L"System themes",SystemThemes,matches(L"Light mode palette") || matches(L"Dark mode palette"));
|
||||
addSection(L"Window style",WindowStyle,matches(L"Interface style") || matches(L"Lavender") || matches(L"Far"));
|
||||
addSection(L"Dialog frame",DialogFrame,
|
||||
matches(L"Outer padding") || matches(L"Inner padding") || matches(L"Row text padding"));
|
||||
}
|
||||
@@ -776,6 +794,7 @@ INT_PTR CALLBACK optionsDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
SetWindowLongPtrW(dialog,DWLP_USER,lp);
|
||||
draft.initialDpi=GetDpiForWindow(dialog);
|
||||
GetClientRect(dialog,&draft.initialClient);
|
||||
draft.resetBounds=dialogControlBounds(dialog,optionsReset);
|
||||
for(auto &control:draft.controls) control.bounds=dialogControlBounds(dialog,control.id);
|
||||
// Group boxes are behind their sibling controls. Erase their full client
|
||||
// area on resize while clipping out the controls inside the frame.
|
||||
@@ -799,6 +818,8 @@ INT_PTR CALLBACK optionsDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
SendDlgItemMessageW(dialog,comparisonColorCombo,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(label));
|
||||
SendDlgItemMessageW(dialog,comparisonColorCombo,CB_SETCURSEL,0,0);
|
||||
SendDlgItemMessageW(dialog,optionsSearch,EM_SETLIMITTEXT,255,0);
|
||||
for(const auto label:{L"Far",L"Lavender"})
|
||||
SendDlgItemMessageW(dialog,windowStyleChoice,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(label));
|
||||
for(const auto &option:frameOptions)
|
||||
for(DWORD value=0;value<=option.maximum;++value)
|
||||
SendDlgItemMessageW(dialog,option.id,CB_ADDSTRING,0,
|
||||
@@ -824,11 +845,30 @@ INT_PTR CALLBACK optionsDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
CheckDlgButton(dialog,optionsRemoteHibernate,ks::lan::remoteHibernateAllowed());
|
||||
CheckDlgButton(dialog,optionsRemoteUpdate,ks::lan::remoteUpdateAllowed());
|
||||
filterOptions(dialog,draft);
|
||||
if(lavenderFiles()) layoutOptions(dialog,draft);
|
||||
updateOptionsApply(dialog,draft);
|
||||
return TRUE;
|
||||
}
|
||||
auto *draft=reinterpret_cast<OptionsDraft*>(GetWindowLongPtrW(dialog,DWLP_USER));
|
||||
if(!draft) return FALSE;
|
||||
if(message==WM_PAINT && lavenderFiles())
|
||||
{
|
||||
PAINTSTRUCT paint{};
|
||||
const auto dc=BeginPaint(dialog,&paint);
|
||||
RECT client{};
|
||||
GetClientRect(dialog,&client);
|
||||
const LavenderMetrics metrics(dialog);
|
||||
const auto title=dialogControlBounds(dialog,optionsTitle);
|
||||
const auto tree=dialogControlBounds(dialog,optionsTree);
|
||||
const auto apply=dialogControlBounds(dialog,optionsApply);
|
||||
lavender::fill(dc,client,lavender::surface);
|
||||
lavender::rounded(dc,{tree.left-metrics.px(4),metrics.px(4),tree.right+metrics.px(4),
|
||||
tree.bottom+metrics.px(4)},metrics.px(7),lavender::path,lavender::line);
|
||||
lavender::fill(dc,{title.left,title.bottom+metrics.px(3),title.right,title.bottom+metrics.px(3)+1},lavender::line);
|
||||
lavender::fill(dc,{client.left,apply.top-metrics.px(5),client.right,apply.top-metrics.px(5)+1},lavender::line);
|
||||
EndPaint(dialog,&paint);
|
||||
return TRUE;
|
||||
}
|
||||
if(message==WM_DRAWITEM && wp==fileStylePreview)
|
||||
{
|
||||
const auto &item=*reinterpret_cast<const DRAWITEMSTRUCT*>(lp);
|
||||
@@ -855,6 +895,22 @@ INT_PTR CALLBACK optionsDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
}
|
||||
if(message==WM_NOTIFY && wp==optionsTree)
|
||||
{
|
||||
if(lavenderFiles() && reinterpret_cast<const NMHDR*>(lp)->code==NM_CUSTOMDRAW)
|
||||
{
|
||||
auto &draw=*reinterpret_cast<NMTVCUSTOMDRAW*>(lp);
|
||||
if(draw.nmcd.dwDrawStage==CDDS_PREPAINT)
|
||||
{
|
||||
SetWindowLongPtrW(dialog,DWLP_MSGRESULT,CDRF_NOTIFYITEMDRAW);
|
||||
return TRUE;
|
||||
}
|
||||
if(draw.nmcd.dwDrawStage==CDDS_ITEMPREPAINT)
|
||||
{
|
||||
draw.clrText=lavender::ink;
|
||||
draw.clrTextBk=(draw.nmcd.uItemState&CDIS_SELECTED)?lavender::selection:lavender::path;
|
||||
SetWindowLongPtrW(dialog,DWLP_MSGRESULT,CDRF_NEWFONT);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
const auto &change=*reinterpret_cast<const NMTREEVIEWW*>(lp);
|
||||
if(change.hdr.code==TVN_SELCHANGEDW && change.itemNew.hItem)
|
||||
{
|
||||
@@ -874,6 +930,14 @@ INT_PTR CALLBACK optionsDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
if(changeTextOption(dialog,*draft,wp)) return TRUE;
|
||||
switch(LOWORD(wp))
|
||||
{
|
||||
case windowStyleChoice:
|
||||
if(HIWORD(wp)==CBN_SELCHANGE)
|
||||
{
|
||||
draft->appearance=SendDlgItemMessageW(dialog,windowStyleChoice,CB_GETCURSEL,0,0)==1?
|
||||
FilesAppearance::Lavender:FilesAppearance::Far;
|
||||
updateOptionsApply(dialog,*draft);
|
||||
}
|
||||
return TRUE;
|
||||
case optionsSearch:
|
||||
if(HIWORD(wp)==EN_CHANGE) filterOptions(dialog,*draft);
|
||||
return TRUE;
|
||||
@@ -1007,6 +1071,8 @@ INT_PTR CALLBACK optionsDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
}
|
||||
return TRUE;
|
||||
case optionsReset:
|
||||
if(draft->page==allOptions || (draft->page==Appearance && (draft->section<0 || draft->section==WindowStyle)))
|
||||
draft->appearance=FilesAppearance::Far;
|
||||
if(draft->page==allOptions) draft->scales=ks::files::defaultAppearanceScales;
|
||||
else if(const auto area=optionsScaleArea(draft->page,draft->section))
|
||||
draft->scales[ks::files::appearanceIndex(*area)]=100;
|
||||
@@ -1244,6 +1310,7 @@ INT_PTR CALLBACK optionsDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
saveChanged(dialogFrameOuterKey,draft->framePadding.outer,base.padding.outer);
|
||||
saveChanged(dialogFrameInnerKey,draft->framePadding.inner,base.padding.inner);
|
||||
saveChanged(dialogRowTextKey,draft->framePadding.rowText,base.padding.rowText);
|
||||
saveChanged(filesAppearanceKey,static_cast<DWORD>(draft->appearance),static_cast<DWORD>(base.appearance));
|
||||
for(size_t i=0;i<draft->scales.size();++i) saveChanged(areaScaleKeys[i],draft->scales[i],base.scales[i]);
|
||||
if(fontChanged)
|
||||
{
|
||||
@@ -1255,13 +1322,16 @@ INT_PTR CALLBACK optionsDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
const auto mode=panelModeOption(dialog,index);
|
||||
if(mode!=base.modes[index]) savePanelMode(index,mode);
|
||||
}
|
||||
const bool appearanceChanged=draft->appearance!=base.appearance;
|
||||
loadFilesPreferences(owner);
|
||||
if(appearanceChanged) styleLavenderDialogControls(dialog);
|
||||
refreshFilesKeyBar();
|
||||
notifyFilesPreferences(owner);
|
||||
const auto dialogOwner=GetWindow(dialog,GW_OWNER);
|
||||
if(dialogOwner!=owner)
|
||||
SendMessageW(dialogOwner,filesPreferencesChanged,reinterpret_cast<WPARAM>(owner),0);
|
||||
draft->baseline=OptionsBaseline{};
|
||||
draft->appearance=draft->baseline.appearance;
|
||||
draft->text=draft->baseline.text;
|
||||
draft->comparison=draft->baseline.comparison;
|
||||
draft->keySettings=draft->baseline.keySettings;
|
||||
@@ -1289,6 +1359,7 @@ INT_PTR CALLBACK optionsDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
|
||||
if(draft->page==PanelColors && draft->section==fileStyleSection)
|
||||
updateFileStyleEditor(dialog,*draft,true);
|
||||
showOptionsPage(dialog,*draft,draft->page,draft->section);
|
||||
if(appearanceChanged) layoutOptions(dialog,*draft);
|
||||
layout(owner);
|
||||
showFileDetails(panels[active]);
|
||||
RedrawWindow(owner,nullptr,nullptr,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN|RDW_UPDATENOW);
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
enum class PathAction { back, forward, up, edit, source, ancestors, previous, folder };
|
||||
|
||||
struct PathPart
|
||||
{
|
||||
PathAction action{};
|
||||
std::wstring label;
|
||||
fs::path target;
|
||||
std::vector<fs::path> hidden;
|
||||
RECT rect{};
|
||||
RECT separator{};
|
||||
bool current{}, dim{}, enabled=true;
|
||||
};
|
||||
|
||||
std::wstring pathSegmentLabel(const fs::path &path,FolderProvider provider,bool compact)
|
||||
{
|
||||
if(isTransferFolder(provider) && path==ftpRoot) return L"/";
|
||||
if(compact && provider==FolderProvider::local && !path.has_relative_path())
|
||||
{
|
||||
auto drive=path.root_name().native();
|
||||
if(drive.size()==2 && drive.back()==L':') return drive;
|
||||
}
|
||||
return panelParentPath(path,provider==FolderProvider::local).empty()?path.native():path.filename().native();
|
||||
}
|
||||
|
||||
struct PathBarMetrics
|
||||
{
|
||||
bool compact;
|
||||
LavenderMetrics dpi;
|
||||
LONG button, padding, separator;
|
||||
|
||||
PathBarMetrics(HWND window,RECT bounds): compact(lavenderFiles()),dpi(window),
|
||||
button(std::max(1L,std::min(compact?static_cast<LONG>(dpi.px(21)):2L*cellWidth,
|
||||
(bounds.right-bounds.left)/7))),
|
||||
padding(compact?dpi.px(7):0),separator(compact?dpi.px(9):0) {}
|
||||
|
||||
RECT breadcrumbBounds(RECT bounds) const
|
||||
{
|
||||
bounds.left=std::min(bounds.right,bounds.left+4*button+dpi.px(2));
|
||||
return bounds;
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<PathPart> panelPathParts(HDC dc,const Panel &panel,RECT bounds,const PathBarMetrics &metrics)
|
||||
{
|
||||
if(bounds.right<=bounds.left) return {};
|
||||
const LONG width=metrics.button;
|
||||
const auto breadcrumb=metrics.breadcrumbBounds(bounds);
|
||||
const auto font=metrics.compact && dc?SelectObject(dc,lavender::font?lavender::font:GetStockObject(DEFAULT_GUI_FONT)):nullptr;
|
||||
const auto measure=[&](const std::wstring &label,bool current=false)
|
||||
{
|
||||
SIZE size{};
|
||||
if(font)
|
||||
{
|
||||
const auto regular=current && lavender::emphasis?SelectObject(dc,lavender::emphasis):nullptr;
|
||||
const auto measured=GetTextExtentPoint32W(dc,label.c_str(),static_cast<int>(label.size()),&size);
|
||||
if(regular) SelectObject(dc,regular);
|
||||
if(measured) return size.cx+2*metrics.padding;
|
||||
}
|
||||
return static_cast<LONG>(label.size()+2)*cellWidth;
|
||||
};
|
||||
std::vector<PathPart> parts;
|
||||
bool hasCrumb=false;
|
||||
const auto add=[&](PathPart part,LONG length,bool crumb=false)
|
||||
{
|
||||
if(length<=0 || bounds.left>=bounds.right) return;
|
||||
if(crumb && hasCrumb && metrics.separator)
|
||||
{
|
||||
const auto end=std::min(bounds.right-1,bounds.left+metrics.separator);
|
||||
part.separator={bounds.left,bounds.top,end,bounds.bottom};
|
||||
bounds.left=end;
|
||||
}
|
||||
part.rect={bounds.left,bounds.top,std::min(bounds.right,bounds.left+length),bounds.bottom};
|
||||
bounds.left=part.rect.right;
|
||||
parts.push_back(std::move(part));
|
||||
hasCrumb|=crumb;
|
||||
};
|
||||
const auto location=folderLocation(panel,panel.directory);
|
||||
const auto provider=location.provider;
|
||||
const auto local=provider==FolderProvider::local;
|
||||
const auto parent=panelParentPath(panel.directory,local);
|
||||
add({.action=PathAction::back,.label=L"←",.enabled=panel.navigation.neighbor(-1).has_value()},width);
|
||||
add({.action=PathAction::forward,.label=L"→",.enabled=panel.navigation.neighbor(1).has_value()},width);
|
||||
add({.action=PathAction::up,.label=L"↑",.target=parent,.enabled=!parent.empty()},width);
|
||||
add({.action=PathAction::edit,.label=L"✎"},width);
|
||||
|
||||
if(metrics.compact)
|
||||
{
|
||||
bounds.left=std::min(bounds.right,breadcrumb.left+metrics.dpi.px(1));
|
||||
bounds.right=std::max(bounds.left,bounds.right-metrics.dpi.px(1));
|
||||
}
|
||||
if(!local && (!metrics.compact || !location.label.empty()))
|
||||
{
|
||||
const auto available=std::max(1L,(bounds.right-bounds.left)/2);
|
||||
add({.action=PathAction::source,.label=location.label},std::min(available,measure(location.label)),true);
|
||||
}
|
||||
|
||||
std::vector<fs::path> ancestors, previous;
|
||||
for(auto path=parent;!path.empty();path=panelParentPath(path,local)) ancestors.push_back(path);
|
||||
std::reverse(ancestors.begin(),ancestors.end());
|
||||
if(inFolderBranch(panel.directory,panel.navigation.previousBranch,provider))
|
||||
{
|
||||
for(auto path=panel.navigation.previousBranch;!sameFolderPath(path,panel.directory,provider);
|
||||
path=panelParentPath(path,local))
|
||||
previous.push_back(path);
|
||||
std::reverse(previous.begin(),previous.end());
|
||||
}
|
||||
|
||||
const LONG room=bounds.right-bounds.left;
|
||||
const auto label=[&](const fs::path &path) { return pathSegmentLabel(path,provider,metrics.compact); };
|
||||
const auto segmentWidth=[&](const fs::path &path) { return measure(label(path))+metrics.separator; };
|
||||
const LONG overflowWidth=width+metrics.separator;
|
||||
LONG currentWidth=measure(label(panel.directory),true);
|
||||
LONG required=currentWidth+metrics.separator;
|
||||
for(const auto &path:ancestors) required+=segmentWidth(path);
|
||||
for(const auto &path:previous) required+=segmentWidth(path);
|
||||
if(!hasCrumb) required-=metrics.separator;
|
||||
size_t firstAncestor=0,visiblePrevious=previous.size();
|
||||
if(required>room)
|
||||
{
|
||||
const LONG reserved=(!ancestors.empty()?overflowWidth:0)+(!previous.empty()?overflowWidth:0)+
|
||||
(hasCrumb?metrics.separator:0);
|
||||
currentWidth=std::min(currentWidth,std::max(1L,room-reserved));
|
||||
LONG remaining=room-currentWidth-reserved;
|
||||
firstAncestor=ancestors.size();
|
||||
while(firstAncestor && remaining>=segmentWidth(ancestors[firstAncestor-1]))
|
||||
remaining-=segmentWidth(ancestors[--firstAncestor]);
|
||||
visiblePrevious=0;
|
||||
while(visiblePrevious<previous.size() && remaining>=segmentWidth(previous[visiblePrevious]))
|
||||
remaining-=segmentWidth(previous[visiblePrevious++]);
|
||||
}
|
||||
|
||||
if(firstAncestor)
|
||||
add({.action=PathAction::ancestors,.label=L"…",
|
||||
.hidden={ancestors.begin(),ancestors.begin()+firstAncestor}},width,true);
|
||||
for(size_t i=firstAncestor;i<ancestors.size();++i)
|
||||
add({.action=PathAction::folder,.label=label(ancestors[i]),.target=ancestors[i]},
|
||||
segmentWidth(ancestors[i])-metrics.separator,true);
|
||||
add({.action=PathAction::edit,.label=label(panel.directory),.current=true},currentWidth,true);
|
||||
for(size_t i=0;i<visiblePrevious;++i)
|
||||
add({.action=PathAction::folder,.label=label(previous[i]),.target=previous[i],.dim=true},
|
||||
segmentWidth(previous[i])-metrics.separator,true);
|
||||
if(visiblePrevious<previous.size())
|
||||
add({.action=PathAction::previous,.label=L"…",
|
||||
.hidden={previous.begin()+visiblePrevious,previous.end()},.dim=true},width,true);
|
||||
if(font) SelectObject(dc,font);
|
||||
return parts;
|
||||
}
|
||||
|
||||
void paintPanelPath(HDC dc,HWND window,RECT bounds,const Panel &panel,bool activePanel)
|
||||
{
|
||||
const PathBarMetrics metrics(window,bounds);
|
||||
const int saved=SaveDC(dc);
|
||||
SelectObject(dc,mono);
|
||||
SetBkMode(dc,TRANSPARENT);
|
||||
HPEN separatorPen{};
|
||||
if(metrics.compact)
|
||||
{
|
||||
lavender::rounded(dc,metrics.breadcrumbBounds(bounds),metrics.dpi.px(7),lavender::path,lavender::line);
|
||||
separatorPen=CreatePen(PS_SOLID,metrics.dpi.px(1),lavender::muted);
|
||||
}
|
||||
for(const auto &part:panelPathParts(dc,panel,bounds,metrics))
|
||||
{
|
||||
const bool current=activePanel && part.current;
|
||||
if(metrics.compact)
|
||||
{
|
||||
auto label=part.rect;
|
||||
const auto &gap=part.separator;
|
||||
const LONG radius=metrics.dpi.px(2);
|
||||
if(gap.right-gap.left>2*radius)
|
||||
{
|
||||
const LONG x=(gap.left+gap.right)/2, y=(gap.top+gap.bottom)/2;
|
||||
const auto pen=SelectObject(dc,separatorPen?separatorPen:GetStockObject(DC_PEN));
|
||||
if(!separatorPen) SetDCPenColor(dc,lavender::muted);
|
||||
MoveToEx(dc,x-1,y-radius,nullptr);
|
||||
LineTo(dc,x+radius-1,y);
|
||||
LineTo(dc,x-1,y+radius+1);
|
||||
SelectObject(dc,pen);
|
||||
}
|
||||
if(part.current)
|
||||
{
|
||||
auto chip=part.rect;
|
||||
InflateRect(&chip,0,-metrics.dpi.px(3));
|
||||
lavender::rounded(dc,chip,metrics.dpi.px(5),lavender::key,lavender::key);
|
||||
InflateRect(&label,-metrics.dpi.px(4),0);
|
||||
}
|
||||
lavender::text(dc,label,part.label.c_str(),!part.enabled || part.dim?lavender::muted:lavender::ink,
|
||||
DT_CENTER,DT_END_ELLIPSIS,part.current?lavender::emphasis:nullptr);
|
||||
continue;
|
||||
}
|
||||
FillRect(dc,&part.rect,current?teal:blue);
|
||||
SetTextColor(dc,!part.enabled || part.dim?RGB(160,170,190):colors[current?Text:Frame]);
|
||||
auto text=part.rect;
|
||||
DrawTextW(dc,part.label.c_str(),static_cast<int>(part.label.size()),&text,
|
||||
DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS|DT_NOPREFIX);
|
||||
}
|
||||
if(separatorPen) DeleteObject(separatorPen);
|
||||
if(saved) RestoreDC(dc,saved);
|
||||
}
|
||||
|
||||
void paintLavenderPanelPath(const DRAWITEMSTRUCT &item,const Panel &panel,bool navigable,bool activePanel)
|
||||
{
|
||||
auto bounds=item.rcItem;
|
||||
lavender::fill(item.hDC,bounds,lavender::surface);
|
||||
if(navigable)
|
||||
{
|
||||
paintPanelPath(item.hDC,item.hwndItem,bounds,panel,activePanel);
|
||||
return;
|
||||
}
|
||||
const LavenderMetrics metrics(item.hwndItem);
|
||||
lavender::rounded(item.hDC,bounds,metrics.px(7),lavender::path,
|
||||
activePanel?lavender::activeEdge:lavender::line);
|
||||
paintLavenderFileIcon(item.hDC,bounds,metrics,true);
|
||||
bounds.left+=metrics.px(30);
|
||||
bounds.right-=metrics.px(9);
|
||||
const auto caption=panelCaption(panel);
|
||||
lavender::text(item.hDC,bounds,caption.c_str(),lavender::ink,DT_LEFT,DT_PATH_ELLIPSIS);
|
||||
}
|
||||
@@ -4,8 +4,6 @@ bool pathNavigationAvailable(const Panel &panel)
|
||||
return !transferProfileList(panel) && !panel.findOrigin && !panel.archive && !panel.directory.empty();
|
||||
}
|
||||
|
||||
enum class PathAction { back, forward, up, edit, source, ancestors, previous, folder };
|
||||
|
||||
void navigatePanelPath(Panel &panel,const fs::path &path)
|
||||
{
|
||||
if(path.empty()) return;
|
||||
@@ -25,119 +23,6 @@ void navigatePanelHistory(Panel &panel,int direction)
|
||||
}
|
||||
}
|
||||
|
||||
struct PathPart
|
||||
{
|
||||
PathAction action{};
|
||||
std::wstring label;
|
||||
fs::path target;
|
||||
std::vector<fs::path> hidden;
|
||||
RECT rect{};
|
||||
bool current{}, dim{}, enabled=true;
|
||||
};
|
||||
|
||||
std::wstring pathSegmentLabel(const fs::path &path,FolderProvider provider)
|
||||
{
|
||||
if(isTransferFolder(provider) && path==ftpRoot) return L"/";
|
||||
return panelParentPath(path,provider==FolderProvider::local).empty()?path.native():path.filename().native();
|
||||
}
|
||||
|
||||
LONG segmentWidth(const fs::path &path,FolderProvider provider)
|
||||
{
|
||||
return static_cast<LONG>(pathSegmentLabel(path,provider).size()+2)*cellWidth;
|
||||
}
|
||||
|
||||
std::vector<PathPart> panelPathParts(const Panel &panel,RECT bounds)
|
||||
{
|
||||
const LONG total=bounds.right-bounds.left;
|
||||
if(total<=0) return {};
|
||||
const LONG width=std::max(1L,std::min(2L*cellWidth,total/7));
|
||||
std::vector<PathPart> parts;
|
||||
const auto add=[&](PathPart part,LONG length)
|
||||
{
|
||||
if(length<=0 || bounds.left>=bounds.right) return;
|
||||
part.rect={bounds.left,bounds.top,std::min(bounds.right,bounds.left+length),bounds.bottom};
|
||||
bounds.left=part.rect.right;
|
||||
parts.push_back(std::move(part));
|
||||
};
|
||||
const auto location=folderLocation(panel,panel.directory);
|
||||
const auto provider=location.provider;
|
||||
const auto local=provider==FolderProvider::local;
|
||||
const auto parent=panelParentPath(panel.directory,local);
|
||||
add({.action=PathAction::back,.label=L"←",.enabled=panel.navigation.neighbor(-1).has_value()},width);
|
||||
add({.action=PathAction::forward,.label=L"→",.enabled=panel.navigation.neighbor(1).has_value()},width);
|
||||
add({.action=PathAction::up,.label=L"↑",.target=parent,.enabled=!parent.empty()},width);
|
||||
add({.action=PathAction::edit,.label=L"✎"},width);
|
||||
|
||||
if(!local)
|
||||
{
|
||||
const auto available=std::max(1L,(bounds.right-bounds.left)/2);
|
||||
const auto sourceWidth=std::min(available,static_cast<LONG>(location.label.size()+2)*cellWidth);
|
||||
add({.action=PathAction::source,.label=location.label},sourceWidth);
|
||||
}
|
||||
|
||||
std::vector<fs::path> ancestors, previous;
|
||||
for(auto path=parent;!path.empty();path=panelParentPath(path,local)) ancestors.push_back(path);
|
||||
std::reverse(ancestors.begin(),ancestors.end());
|
||||
if(inFolderBranch(panel.directory,panel.navigation.previousBranch,provider))
|
||||
{
|
||||
for(auto path=panel.navigation.previousBranch;!sameFolderPath(path,panel.directory,provider);
|
||||
path=panelParentPath(path,local))
|
||||
previous.push_back(path);
|
||||
std::reverse(previous.begin(),previous.end());
|
||||
}
|
||||
|
||||
const LONG room=bounds.right-bounds.left;
|
||||
LONG required=segmentWidth(panel.directory,provider);
|
||||
for(const auto &path:ancestors) required+=segmentWidth(path,provider);
|
||||
for(const auto &path:previous) required+=segmentWidth(path,provider);
|
||||
size_t firstAncestor=0,visiblePrevious=previous.size();
|
||||
LONG currentWidth=segmentWidth(panel.directory,provider);
|
||||
if(required>room)
|
||||
{
|
||||
const LONG reserved=(!ancestors.empty()?width:0)+(!previous.empty()?width:0);
|
||||
currentWidth=std::min(currentWidth,std::max(1L,room-reserved));
|
||||
LONG remaining=room-currentWidth-reserved;
|
||||
firstAncestor=ancestors.size();
|
||||
while(firstAncestor && remaining>=segmentWidth(ancestors[firstAncestor-1],provider))
|
||||
remaining-=segmentWidth(ancestors[--firstAncestor],provider);
|
||||
visiblePrevious=0;
|
||||
while(visiblePrevious<previous.size() && remaining>=segmentWidth(previous[visiblePrevious],provider))
|
||||
remaining-=segmentWidth(previous[visiblePrevious++],provider);
|
||||
}
|
||||
|
||||
if(firstAncestor)
|
||||
add({.action=PathAction::ancestors,.label=L"…",
|
||||
.hidden={ancestors.begin(),ancestors.begin()+firstAncestor}},width);
|
||||
for(size_t i=firstAncestor;i<ancestors.size();++i)
|
||||
add({.action=PathAction::folder,.label=pathSegmentLabel(ancestors[i],provider),.target=ancestors[i]},
|
||||
segmentWidth(ancestors[i],provider));
|
||||
add({.action=PathAction::edit,.label=pathSegmentLabel(panel.directory,provider),.current=true},currentWidth);
|
||||
for(size_t i=0;i<visiblePrevious;++i)
|
||||
add({.action=PathAction::folder,.label=pathSegmentLabel(previous[i],provider),.target=previous[i],.dim=true},
|
||||
segmentWidth(previous[i],provider));
|
||||
if(visiblePrevious<previous.size())
|
||||
add({.action=PathAction::previous,.label=L"…",
|
||||
.hidden={previous.begin()+visiblePrevious,previous.end()},.dim=true},width);
|
||||
return parts;
|
||||
}
|
||||
|
||||
void paintPanelPath(HDC dc,RECT bounds,const Panel &panel,bool activePanel)
|
||||
{
|
||||
const int saved=SaveDC(dc);
|
||||
SelectObject(dc,mono);
|
||||
SetBkMode(dc,TRANSPARENT);
|
||||
for(const auto &part:panelPathParts(panel,bounds))
|
||||
{
|
||||
const bool current=activePanel && part.current;
|
||||
FillRect(dc,&part.rect,current?teal:blue);
|
||||
SetTextColor(dc,!part.enabled || part.dim?RGB(160,170,190):colors[current?Text:Frame]);
|
||||
auto text=part.rect;
|
||||
DrawTextW(dc,part.label.c_str(),static_cast<int>(part.label.size()),&text,
|
||||
DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS|DT_NOPREFIX);
|
||||
}
|
||||
if(saved) RestoreDC(dc,saved);
|
||||
}
|
||||
|
||||
constexpr int addressField=485,addressLabel=486,addressFooter=487;
|
||||
|
||||
struct PathPrompt
|
||||
@@ -433,7 +318,11 @@ LRESULT CALLBACK pathBarInput(HWND window,UINT message,WPARAM wp,LPARAM lp,UINT_
|
||||
RECT bounds{};
|
||||
GetClientRect(window,&bounds);
|
||||
const POINT mouse{GET_X_LPARAM(lp),GET_Y_LPARAM(lp)};
|
||||
const auto parts=panelPathParts(panel,bounds);
|
||||
const PathBarMetrics metrics(window,bounds);
|
||||
const auto dc=metrics.compact?GetDC(window):nullptr;
|
||||
if(metrics.compact && !dc) return 0;
|
||||
const auto parts=panelPathParts(dc,panel,bounds,metrics);
|
||||
if(dc) ReleaseDC(window,dc);
|
||||
for(const auto &part:parts)
|
||||
{
|
||||
if(!part.enabled || !PtInRect(&part.rect,mouse)) continue;
|
||||
|
||||
+11
-50
@@ -10,42 +10,6 @@ class PasteProbe
|
||||
IUIAutomation2 *automation{};
|
||||
IUIAutomationElement *element{};
|
||||
IUIAutomationTextPattern *pattern{};
|
||||
HWND targetWindow{};
|
||||
|
||||
bool focusBelongsToTarget() const
|
||||
{
|
||||
DWORD process{};
|
||||
GetWindowThreadProcessId(targetWindow, &process);
|
||||
int focusedProcess{};
|
||||
if (process && SUCCEEDED(element->get_CurrentProcessId(&focusedProcess)) &&
|
||||
process == static_cast<DWORD>(focusedProcess))
|
||||
return true;
|
||||
|
||||
// WebView2 can report a renderer process for the focused element.
|
||||
// Require a native window in its UIA ancestry rooted in the target.
|
||||
auto release = [](auto *value) { if (value) value->Release(); };
|
||||
IUIAutomationTreeWalker *rawWalker{};
|
||||
const auto walkerResult = automation->get_RawViewWalker(&rawWalker);
|
||||
std::unique_ptr<IUIAutomationTreeWalker, decltype(release)> walker(rawWalker, release);
|
||||
if (FAILED(walkerResult) || !walker) return false;
|
||||
|
||||
element->AddRef();
|
||||
std::unique_ptr<IUIAutomationElement, decltype(release)> current(element, release);
|
||||
for (int depth = 0; depth < 32 && current; ++depth)
|
||||
{
|
||||
UIA_HWND native{};
|
||||
if (SUCCEEDED(current->get_CurrentNativeWindowHandle(&native)) && native)
|
||||
{
|
||||
const auto window = reinterpret_cast<HWND>(native);
|
||||
return window == targetWindow || IsChild(targetWindow, window);
|
||||
}
|
||||
IUIAutomationElement *parent{};
|
||||
const auto parentResult = walker->GetParentElement(current.get(), &parent);
|
||||
current.reset(parent);
|
||||
if (FAILED(parentResult)) break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::optional<std::wstring> rangeText(IUIAutomationTextRange *range)
|
||||
{
|
||||
@@ -60,7 +24,7 @@ class PasteProbe
|
||||
public:
|
||||
std::wstring status = L"not-requested";
|
||||
std::optional<std::wstring> precedingCharacter;
|
||||
PasteProbe(bool enabled, HWND target) : targetWindow(target)
|
||||
PasteProbe(bool enabled, HWND target)
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
@@ -72,15 +36,17 @@ class PasteProbe
|
||||
automation->put_TransactionTimeout(200);
|
||||
if (FAILED(automation->GetFocusedElement(&element)) || !element)
|
||||
return;
|
||||
if (target && GetForegroundWindow() != target)
|
||||
if (target)
|
||||
{
|
||||
status = L"focused-window-changed";
|
||||
return;
|
||||
}
|
||||
if (target && !focusBelongsToTarget())
|
||||
{
|
||||
status = L"focused-control-outside-target";
|
||||
return;
|
||||
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;
|
||||
}
|
||||
}
|
||||
BOOL password = TRUE;
|
||||
if (FAILED(element->get_CurrentIsPassword(&password)) || password)
|
||||
@@ -129,11 +95,6 @@ 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";
|
||||
|
||||
+4
-6
@@ -676,10 +676,9 @@ 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"claude";
|
||||
name == L"chrome" || name == L"msedge" || name == L"chatgpt" || name == L"codex";
|
||||
}
|
||||
bool selectPrevious(size_t count, const std::function<bool()> &valid, bool forcePacing)
|
||||
bool selectPrevious(size_t count, const std::function<bool()> &valid)
|
||||
{
|
||||
if (count > 100000)
|
||||
return false;
|
||||
@@ -687,10 +686,9 @@ bool selectPrevious(size_t count, const std::function<bool()> &valid, bool force
|
||||
// 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) +
|
||||
(paced ? L" mode=paced-25ms" : L" mode=batch"));
|
||||
if (paced)
|
||||
L" mode=" + (needsSelectionDelay(target) ? std::wstring(L"paced-25ms") : std::wstring(L"batch")));
|
||||
if (needsSelectionDelay(target))
|
||||
{
|
||||
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 forcePacing = false);
|
||||
bool selectPrevious(size_t count, const std::function<bool()> &valid);
|
||||
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.1";
|
||||
inline constexpr wchar_t AppVersion[] = L"0.8.3";
|
||||
inline constexpr UINT UpdateMessage = WM_APP + 7;
|
||||
inline constexpr UINT UpdateCheckIntervalMs = 6 * 60 * 60 * 1000;
|
||||
inline constexpr UINT UpdateNotificationRetryMs = 5 * 60 * 1000;
|
||||
|
||||
@@ -236,6 +236,7 @@ $extension = ".ksfiles$unique"
|
||||
$progId = "KSwitcher.Files.Test.$unique"
|
||||
$saved = @{}
|
||||
$profileValues = 'LeftPath', 'RightPath', 'LeftCursor', 'RightCursor', 'LeftWide', 'RightWide',
|
||||
'LeftPanelMode', 'RightPanelMode', 'LeftViewOrder', 'RightViewOrder', 'AppearanceMode',
|
||||
'ShowDetails', 'StatusFields', 'CommandHistory', 'CommandHistoryKey', 'PreviousCommandKey', 'WindowPlacement', 'FontPoints'
|
||||
$process = $null
|
||||
$trace = $null
|
||||
@@ -275,6 +276,8 @@ try {
|
||||
$profile.SetValue('RightPath', $rightDir)
|
||||
foreach ($name in 'LeftCursor', 'RightCursor') { $profile.DeleteValue($name, $false) }
|
||||
foreach ($name in 'LeftWide', 'RightWide', 'ShowDetails') { $profile.SetValue($name, 1) }
|
||||
foreach ($name in 'LeftPanelMode', 'RightPanelMode') { $profile.SetValue($name, 1, 'DWord') }
|
||||
foreach ($name in 'LeftViewOrder', 'RightViewOrder', 'AppearanceMode') { $profile.SetValue($name, 0, 'DWord') }
|
||||
$profile.SetValue('StatusFields', 3)
|
||||
|
||||
if($TerminalOnly){
|
||||
|
||||
@@ -0,0 +1,345 @@
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$Executable,
|
||||
[string]$Screenshot,
|
||||
[string]$DialogScreenshotDirectory
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
Add-Type @'
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
public static class LavenderWindow {
|
||||
[StructLayout(LayoutKind.Sequential)] public struct Rect { public int Left, Top, Right, Bottom; }
|
||||
[DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr window, out Rect rect);
|
||||
[DllImport("user32.dll")] public static extern IntPtr GetDlgItem(IntPtr window, int id);
|
||||
[DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow();
|
||||
[DllImport("user32.dll")] public static extern bool IsWindow(IntPtr window);
|
||||
[DllImport("user32.dll")] public static extern bool IsWindowVisible(IntPtr window);
|
||||
[DllImport("user32.dll")] public static extern IntPtr GetLastActivePopup(IntPtr window);
|
||||
[DllImport("user32.dll")] public static extern IntPtr GetWindow(IntPtr window, uint command);
|
||||
[DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr window);
|
||||
[DllImport("user32.dll")] static extern void keybd_event(byte key, byte scan, uint flags, UIntPtr extra);
|
||||
public static bool Activate(IntPtr window) {
|
||||
if (GetForegroundWindow() == window) return true;
|
||||
keybd_event(0x12, 0, 0, UIntPtr.Zero);
|
||||
keybd_event(0x12, 0, 2, UIntPtr.Zero);
|
||||
SetForegroundWindow(window);
|
||||
return GetForegroundWindow() == window;
|
||||
}
|
||||
[DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr window, IntPtr after, int x, int y, int width, int height, uint flags);
|
||||
[DllImport("user32.dll")] public static extern IntPtr SetThreadDpiAwarenessContext(IntPtr context);
|
||||
[DllImport("user32.dll")] public static extern uint GetDpiForWindow(IntPtr window);
|
||||
[DllImport("user32.dll", EntryPoint="SendMessageW")] public static extern IntPtr Send(IntPtr window, uint message, IntPtr w, IntPtr l);
|
||||
[DllImport("user32.dll", EntryPoint="PostMessageW")] public static extern bool Post(IntPtr window, uint message, IntPtr w, IntPtr l);
|
||||
[DllImport("user32.dll", EntryPoint="SendMessageW", CharSet=CharSet.Unicode)]
|
||||
public static extern IntPtr SendText(IntPtr window, uint message, IntPtr w, string text);
|
||||
[DllImport("dwmapi.dll")] public static extern int DwmGetWindowAttribute(IntPtr window, int attribute, out Rect rect, int size);
|
||||
}
|
||||
'@
|
||||
|
||||
function Wait-Until([scriptblock]$Condition) {
|
||||
for ($attempt = 0; $attempt -lt 100; $attempt++) {
|
||||
if (& $Condition) { return }
|
||||
Start-Sleep -Milliseconds 50
|
||||
}
|
||||
throw "Timed out waiting for $Condition"
|
||||
}
|
||||
|
||||
function Get-Bounds($Window) {
|
||||
$bounds = [LavenderWindow+Rect]::new()
|
||||
if (![LavenderWindow]::GetWindowRect($Window, [ref]$bounds)) { throw 'Missing window or control.' }
|
||||
$bounds
|
||||
}
|
||||
|
||||
function Read-Window($Bounds) {
|
||||
$image = [Drawing.Bitmap]::new(($Bounds.Right - $Bounds.Left), ($Bounds.Bottom - $Bounds.Top))
|
||||
$graphics = [Drawing.Graphics]::FromImage($image)
|
||||
try { $graphics.CopyFromScreen($Bounds.Left, $Bounds.Top, 0, 0, $image.Size) }
|
||||
finally { $graphics.Dispose() }
|
||||
$image
|
||||
}
|
||||
|
||||
function Test-Pixel($Image, $Bounds, $X, $Y, $Expected, $Description) {
|
||||
$actual = $Image.GetPixel($X - $Bounds.Left, $Y - $Bounds.Top)
|
||||
if ($actual.ToArgb() -ne [Drawing.ColorTranslator]::FromHtml($Expected).ToArgb()) {
|
||||
throw "$Description expected $Expected, got $($actual.Name)."
|
||||
}
|
||||
}
|
||||
|
||||
function Test-PathBar($Image, $Bounds, $Path, [double]$Scale, [string]$Name) {
|
||||
$chip = [Drawing.ColorTranslator]::FromHtml('#E7E6FC').ToArgb()
|
||||
$separator = [Drawing.ColorTranslator]::FromHtml('#5B6185').ToArgb()
|
||||
$chipColumns = [Collections.Generic.List[int]]::new()
|
||||
$chevrons = 0
|
||||
$chipY = $Path.Top - $Bounds.Top + [int](5 * $Scale)
|
||||
$centerY = [int][Math]::Floor(($Path.Top + $Path.Bottom) / 2) - $Bounds.Top
|
||||
for ($x = $Path.Left - $Bounds.Left + [int](85 * $Scale); $x -lt $Path.Right - $Bounds.Left; $x++) {
|
||||
if ($Image.GetPixel($x, $chipY).ToArgb() -eq $chip) { $chipColumns.Add($x) }
|
||||
if ($Image.GetPixel($x, $centerY).ToArgb() -eq $separator) { $chevrons++ }
|
||||
}
|
||||
if ($chevrons -eq 0) { throw "$Name does not render a breadcrumb chevron." }
|
||||
if ($chipColumns.Count -lt [int](35 * $Scale) -or $chipColumns.Count -gt [int](93 * $Scale)) {
|
||||
throw "$Name does not fit the current-folder chip to its label ($($chipColumns.Count) pixels)."
|
||||
}
|
||||
$edgeY = $Path.Top - $Bounds.Top + [int][Math]::Floor($Scale)
|
||||
$chipCenter = $chipColumns[[int][Math]::Floor($chipColumns.Count / 2)]
|
||||
if ($Image.GetPixel($chipCenter, $edgeY).ToArgb() -eq $chip) {
|
||||
throw "$Name current-folder chip touches the top edge of the bar."
|
||||
}
|
||||
$chipCenter + $Bounds.Left - $Path.Left
|
||||
}
|
||||
|
||||
function Open-LavenderOptions($Window) {
|
||||
$keyboard.SendKeys('{F9}')
|
||||
Wait-Until { [LavenderWindow]::IsWindowVisible([LavenderWindow]::GetDlgItem($Window, 133)) }
|
||||
[void][LavenderWindow]::Post($Window, 0x111, [IntPtr]133, [IntPtr]::Zero)
|
||||
Wait-Until {
|
||||
$popup = [LavenderWindow]::GetLastActivePopup($Window)
|
||||
[LavenderWindow]::IsWindowVisible($popup) -and
|
||||
[LavenderWindow]::GetDlgItem($popup, 270) -ne [IntPtr]::Zero
|
||||
}
|
||||
[LavenderWindow]::GetLastActivePopup($Window)
|
||||
}
|
||||
|
||||
function Set-Style($Window, [int]$Style) {
|
||||
$dialog = Open-LavenderOptions $Window
|
||||
$search = [LavenderWindow]::GetDlgItem($dialog, 270)
|
||||
[void][LavenderWindow]::SendText($search, 0xC, [IntPtr]::Zero, 'Interface style')
|
||||
$combo = [LavenderWindow]::GetDlgItem($dialog, 417)
|
||||
Wait-Until { [LavenderWindow]::IsWindowVisible($combo) }
|
||||
[void][LavenderWindow]::Send($combo, 0x14E, [IntPtr]$Style, [IntPtr]::Zero)
|
||||
if ([LavenderWindow]::Send($combo, 0x147, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32() -ne $Style) {
|
||||
throw "Could not select Files style $Style."
|
||||
}
|
||||
[void][LavenderWindow]::Send($dialog, 0x111, [IntPtr](417 + (1 -shl 16)), $combo)
|
||||
[void][LavenderWindow]::Post($dialog, 0x111, [IntPtr]1, [IntPtr]::Zero)
|
||||
Wait-Until { ![LavenderWindow]::IsWindow($dialog) }
|
||||
Wait-Until { [LavenderWindow]::Activate($Window) }
|
||||
}
|
||||
|
||||
function Test-LavenderDialog($Window, [string]$Keys, [int]$ControlId, [string]$Name) {
|
||||
$keyboard.SendKeys($Keys)
|
||||
try {
|
||||
Wait-Until { [LavenderWindow]::GetDlgItem([LavenderWindow]::GetLastActivePopup($Window), $ControlId) -ne [IntPtr]::Zero }
|
||||
} catch { throw "$Name dialog did not open after $Keys. $_" }
|
||||
$dialog = [LavenderWindow]::GetLastActivePopup($Window)
|
||||
Start-Sleep -Milliseconds 160
|
||||
$bounds = Get-Bounds $dialog
|
||||
$image = Read-Window $bounds
|
||||
try {
|
||||
$sampleX = $bounds.Right - [int](8 * $scale)
|
||||
Test-Pixel $image $bounds $sampleX ($bounds.Top + [int](12 * $scale)) '#4648BB' "$Name title band"
|
||||
Test-Pixel $image $bounds $sampleX ($bounds.Bottom - [int](12 * $scale)) '#F2EFFB' "$Name surface"
|
||||
if ($Name -eq 'Copy') {
|
||||
$field = Get-Bounds ([LavenderWindow]::GetDlgItem($dialog, $ControlId))
|
||||
Test-Pixel $image $bounds ($field.Right - [int](12 * $scale)) `
|
||||
([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() }
|
||||
}
|
||||
} finally { $image.Dispose() }
|
||||
$keyboard.SendKeys('{ESC}')
|
||||
Wait-Until { ![LavenderWindow]::IsWindow($dialog) -and [LavenderWindow]::Activate($Window) }
|
||||
}
|
||||
|
||||
$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'
|
||||
$saved = @{}
|
||||
foreach ($name in $names) {
|
||||
if ($name -in $key.GetValueNames()) { $saved[$name] = @($key.GetValue($name), $key.GetValueKind($name)) }
|
||||
}
|
||||
$fixture = if ($Screenshot) {
|
||||
$target = [IO.Path]::GetFullPath($Screenshot)
|
||||
$demoName = 'Demo-' + [Guid]::NewGuid().ToString('N').Substring(0, 6)
|
||||
[IO.Directory]::CreateDirectory((Join-Path (Split-Path $target) $demoName))
|
||||
} else { [IO.Directory]::CreateTempSubdirectory('ks-files-lavender-') }
|
||||
$previousDpi = [LavenderWindow]::SetThreadDpiAwarenessContext([IntPtr](-4))
|
||||
try {
|
||||
$left = $fixture.CreateSubdirectory('Projects')
|
||||
$right = $fixture.CreateSubdirectory('KSwitcher')
|
||||
foreach ($name in 'Archives', 'Design assets', 'KSwitcher', 'Release notes', 'Screenshots') {
|
||||
[void]$left.CreateSubdirectory($name)
|
||||
}
|
||||
foreach ($name in 'cmake', 'dictionaries', 'resources', 'src', 'tests', 'tools') {
|
||||
[void]$right.CreateSubdirectory($name)
|
||||
}
|
||||
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('LeftPanelMode', 1, 'DWord')
|
||||
$key.SetValue('RightPanelMode', 1, 'DWord')
|
||||
$key.SetValue('LeftViewOrder', 0, 'DWord')
|
||||
$key.SetValue('RightViewOrder', 0, 'DWord')
|
||||
$key.SetValue('LeftPath', $left.FullName, 'String')
|
||||
$key.SetValue('RightPath', $right.FullName, 'String')
|
||||
$key.SetValue('LeftCursor', (Join-Path $left.FullName 'KSwitcher'), 'String')
|
||||
$key.SetValue('RightCursor', (Join-Path $right.FullName 'src'), 'String')
|
||||
$key.DeleteValue('WindowPlacement', $false)
|
||||
$keyboard = New-Object -ComObject WScript.Shell
|
||||
$process = Start-Process -FilePath $exe -PassThru
|
||||
Wait-Until { $process.Refresh(); $process.MainWindowHandle -ne [IntPtr]::Zero -and [LavenderWindow]::Activate($process.MainWindowHandle) }
|
||||
$window = $process.MainWindowHandle
|
||||
$work = [Windows.Forms.Screen]::FromHandle($window).WorkingArea
|
||||
$scale = [LavenderWindow]::GetDpiForWindow($window) / 96
|
||||
$width = [Math]::Min($work.Width - 30, [int](1220 * $scale))
|
||||
$height = [Math]::Min($work.Height - 30, [int](665 * $scale))
|
||||
[void][LavenderWindow]::SetWindowPos($window, [IntPtr]::Zero, $work.Left + 15, $work.Top + 15, $width, $height, 0x14)
|
||||
[void][LavenderWindow]::SetForegroundWindow($window)
|
||||
$leftList = [LavenderWindow]::GetDlgItem($window, 102)
|
||||
$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 }
|
||||
$farRow = [LavenderWindow]::Send($leftList, 0x1A1, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32()
|
||||
Set-Style $window 1
|
||||
$rowHeight = [LavenderWindow]::Send($leftList, 0x1A1, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32()
|
||||
$expectedHeight = [Math]::Max($farRow, [Math]::Round(25 * $scale, [MidpointRounding]::AwayFromZero))
|
||||
if ($rowHeight -ne $expectedHeight -or $key.GetValue('AppearanceMode') -ne 1) {
|
||||
throw "Applying Lavender returned row height $rowHeight at scale $scale and saved mode $($key.GetValue('AppearanceMode'))."
|
||||
}
|
||||
$keyboard.SendKeys('{TAB}')
|
||||
Start-Sleep -Milliseconds 250
|
||||
$bounds = Get-Bounds $window
|
||||
$leftBounds = Get-Bounds $leftList
|
||||
$rightBounds = Get-Bounds $rightList
|
||||
$leftIndex = [LavenderWindow]::Send($leftList, 0x188, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32()
|
||||
$rightIndex = [LavenderWindow]::Send($rightList, 0x188, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32()
|
||||
if ($leftIndex -lt 0 -or $rightIndex -lt 0) { throw 'Missing current row for the appearance check.' }
|
||||
$command = Get-Bounds ([LavenderWindow]::GetDlgItem($window, 113))
|
||||
$leftPath = Get-Bounds ([LavenderWindow]::GetDlgItem($window, 142))
|
||||
$rightPathWindow = [LavenderWindow]::GetDlgItem($window, 143)
|
||||
$rightPath = Get-Bounds $rightPathWindow
|
||||
$pad = [int](8 * $scale)
|
||||
$image = Read-Window $bounds
|
||||
try {
|
||||
Test-Pixel $image $bounds ($leftPath.Left - $pad) ($leftPath.Top - $pad) '#EEF0FA' 'Rounded panel corner'
|
||||
Test-Pixel $image $bounds ($rightPath.Left + 30) ($rightPath.Top - $pad) '#9797F4' 'Active panel outline'
|
||||
[void](Test-PathBar $image $bounds $leftPath $scale 'Inactive panel path')
|
||||
$currentFolderX = Test-PathBar $image $bounds $rightPath $scale 'Active panel path'
|
||||
Test-Pixel $image $bounds ([int](($leftBounds.Left + $leftBounds.Right) / 2)) ($leftBounds.Top + $leftIndex * $rowHeight + 5) '#F0F1F9' 'Inactive row'
|
||||
Test-Pixel $image $bounds ([int](($rightBounds.Left + $rightBounds.Right) / 2)) ($rightBounds.Top + $rightIndex * $rowHeight + 5) '#E7E3FD' 'Active row after Tab'
|
||||
Test-Pixel $image $bounds ($command.Right - 9) ($command.Top + 5) '#F7F7FD' 'Command button surface'
|
||||
if ($Screenshot) {
|
||||
$crop = [LavenderWindow+Rect]::new()
|
||||
if ([LavenderWindow]::DwmGetWindowAttribute($window, 9, [ref]$crop, 16) -ne 0) { $crop = $bounds }
|
||||
$area = [Drawing.Rectangle]::new(($crop.Left - $bounds.Left), ($crop.Top - $bounds.Top),
|
||||
($crop.Right - $crop.Left), ($crop.Bottom - $crop.Top))
|
||||
$visible = $image.Clone($area, [Drawing.Imaging.PixelFormat]::Format24bppRgb)
|
||||
try { $visible.Save($Screenshot, [Drawing.Imaging.ImageFormat]::Png) }
|
||||
finally { $visible.Dispose() }
|
||||
}
|
||||
} finally { $image.Dispose() }
|
||||
|
||||
$middleY = [int](($rightPath.Bottom - $rightPath.Top) / 2)
|
||||
$click = [IntPtr](($middleY -shl 16) + $currentFolderX)
|
||||
[void][LavenderWindow]::Post($rightPathWindow, 0x201, [IntPtr]1, $click)
|
||||
[void][LavenderWindow]::Post($rightPathWindow, 0x202, [IntPtr]::Zero, $click)
|
||||
Wait-Until { [LavenderWindow]::GetDlgItem([LavenderWindow]::GetLastActivePopup($window), 485) -ne [IntPtr]::Zero }
|
||||
$address = [LavenderWindow]::GetLastActivePopup($window)
|
||||
[void][LavenderWindow]::Post($address, 0x111, [IntPtr]2, [IntPtr]::Zero)
|
||||
Wait-Until { ![LavenderWindow]::IsWindow($address) -and [LavenderWindow]::Activate($window) }
|
||||
|
||||
if ($DialogScreenshotDirectory) { [void][IO.Directory]::CreateDirectory($DialogScreenshotDirectory) }
|
||||
Test-LavenderDialog $window '{F5}' 211 'Copy'
|
||||
Test-LavenderDialog $window '{F6}' 211 'Rename/Move'
|
||||
Test-LavenderDialog $window '{F7}' 361 'Make folder'
|
||||
Test-LavenderDialog $window '{F8}' 241 'Delete'
|
||||
|
||||
$keyboard.SendKeys('{F5}')
|
||||
Wait-Until { [LavenderWindow]::GetDlgItem([LavenderWindow]::GetLastActivePopup($window), 211) -ne [IntPtr]::Zero }
|
||||
$copy = [LavenderWindow]::GetLastActivePopup($window)
|
||||
[void][LavenderWindow]::SendText([LavenderWindow]::GetDlgItem($copy, 211), 0xC, [IntPtr]::Zero, 'invalid*name')
|
||||
[void][LavenderWindow]::Post($copy, 0x111, [IntPtr]1, [IntPtr]::Zero)
|
||||
Wait-Until {
|
||||
$popup = [LavenderWindow]::GetForegroundWindow()
|
||||
[LavenderWindow]::GetWindow($popup, 4) -eq $copy -and
|
||||
[LavenderWindow]::GetDlgItem($popup, 100) -ne [IntPtr]::Zero
|
||||
}
|
||||
$warning = [LavenderWindow]::GetForegroundWindow()
|
||||
Start-Sleep -Milliseconds 160
|
||||
$warningBounds = Get-Bounds $warning
|
||||
$warningButton = Get-Bounds ([LavenderWindow]::GetDlgItem($warning, 1))
|
||||
$warningImage = Read-Window $warningBounds
|
||||
try {
|
||||
Test-Pixel $warningImage $warningBounds ($warningBounds.Right - [int](8 * $scale)) `
|
||||
($warningBounds.Top + [int](8 * $scale)) '#A12B48' 'Nested warning title band'
|
||||
Test-Pixel $warningImage $warningBounds ($warningButton.Left + [int](9 * $scale)) `
|
||||
([int](($warningButton.Top + $warningButton.Bottom) / 2)) '#A12B48' 'Nested warning action'
|
||||
} finally { $warningImage.Dispose() }
|
||||
$keyboard.SendKeys('{ESC}')
|
||||
Wait-Until { ![LavenderWindow]::IsWindow($warning) }
|
||||
$keyboard.SendKeys('{ESC}')
|
||||
Wait-Until { ![LavenderWindow]::IsWindow($copy) -and [LavenderWindow]::Activate($window) }
|
||||
|
||||
$options = Open-LavenderOptions $window
|
||||
Start-Sleep -Milliseconds 160
|
||||
$optionsBounds = Get-Bounds $options
|
||||
$visibleOptions = [LavenderWindow+Rect]::new()
|
||||
if ([LavenderWindow]::DwmGetWindowAttribute($options, 9, [ref]$visibleOptions, 16) -eq 0) {
|
||||
$optionsBounds = $visibleOptions
|
||||
}
|
||||
$searchBounds = Get-Bounds ([LavenderWindow]::GetDlgItem($options, 270))
|
||||
$optionsImage = Read-Window $optionsBounds
|
||||
try {
|
||||
Test-Pixel $optionsImage $optionsBounds ($searchBounds.Right - [int](12 * $scale)) `
|
||||
([int](($searchBounds.Top + $searchBounds.Bottom) / 2)) '#F7F7FD' 'Options search field'
|
||||
if ($DialogScreenshotDirectory) {
|
||||
$optionsImage.Save((Join-Path $DialogScreenshotDirectory 'files-lavender-options.png'), [Drawing.Imaging.ImageFormat]::Png)
|
||||
}
|
||||
} finally { $optionsImage.Dispose() }
|
||||
[void][LavenderWindow]::Post($options, 0x111, [IntPtr]2, [IntPtr]::Zero)
|
||||
Wait-Until { ![LavenderWindow]::IsWindow($options) -and [LavenderWindow]::Activate($window) }
|
||||
|
||||
$keyboard.SendKeys('{DOWN}')
|
||||
Wait-Until { [LavenderWindow]::Send($rightList, 0x188, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32() -eq ($rightIndex + 1) }
|
||||
$keyboard.SendKeys('^{F1}')
|
||||
Wait-Until { $key.GetValue('RightPanelMode') -eq 0 }
|
||||
$keyboard.SendKeys('^{F2}')
|
||||
Wait-Until { $key.GetValue('RightPanelMode') -eq 1 }
|
||||
[void][LavenderWindow]::SetWindowPos($window, [IntPtr]::Zero, $work.Left + 15, $work.Top + 15,
|
||||
[int](580 * $scale), [int](420 * $scale), 0x14)
|
||||
$compact = Get-Bounds ([LavenderWindow]::GetDlgItem($window, 113))
|
||||
if (($compact.Bottom - $compact.Top) -le ($command.Bottom - $command.Top)) {
|
||||
throw 'The command bar did not switch to its compact layout.'
|
||||
}
|
||||
[void]$process.CloseMainWindow()
|
||||
if (!$process.WaitForExit(4000)) { throw 'Files did not close.' }
|
||||
$process = Start-Process -FilePath $exe -PassThru
|
||||
Wait-Until { $process.Refresh(); $process.MainWindowHandle -ne [IntPtr]::Zero -and [LavenderWindow]::Activate($process.MainWindowHandle) }
|
||||
$window = $process.MainWindowHandle
|
||||
$leftList = [LavenderWindow]::GetDlgItem($window, 102)
|
||||
if ([LavenderWindow]::Send($leftList, 0x1A1, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32() -ne $rowHeight) {
|
||||
throw 'Lavender did not survive restart.'
|
||||
}
|
||||
Set-Style $window 0
|
||||
if ([LavenderWindow]::Send($leftList, 0x1A1, [IntPtr]::Zero, [IntPtr]::Zero).ToInt32() -ne $farRow) {
|
||||
throw 'Far did not restore its row geometry.'
|
||||
}
|
||||
'Lavender and Far switching, restart, keyboard navigation, Brief/Wide shortcuts, and rendered panels and dialogs verified.'
|
||||
} finally {
|
||||
if ($process -and !$process.HasExited) {
|
||||
[void]$process.CloseMainWindow()
|
||||
if (!$process.WaitForExit(3000)) { $process.Kill(); $process.WaitForExit() }
|
||||
}
|
||||
foreach ($name in $names) {
|
||||
if ($saved.ContainsKey($name)) { $key.SetValue($name, $saved[$name][0], $saved[$name][1]) }
|
||||
else { $key.DeleteValue($name, $false) }
|
||||
}
|
||||
$key.Dispose()
|
||||
$resolvedFixture = (Resolve-Path -LiteralPath $fixture.FullName).Path
|
||||
if ($resolvedFixture -eq $fixture.FullName) { $fixture.Delete($true) }
|
||||
if ($previousDpi) { [void][LavenderWindow]::SetThreadDpiAwarenessContext($previousDpi) }
|
||||
}
|
||||
@@ -79,7 +79,6 @@ 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;
|
||||
@@ -153,16 +152,6 @@ 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);
|
||||
@@ -349,8 +338,6 @@ LRESULT CALLBACK procedure(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
switch (stage++)
|
||||
{
|
||||
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));
|
||||
@@ -698,26 +685,6 @@ 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:
|
||||
@@ -1425,8 +1392,6 @@ int main(int argc, char **argv)
|
||||
stage = 93;
|
||||
if (argc > 1 && std::string(argv[1]) == "--snippet-word-boundaries")
|
||||
stage = 84;
|
||||
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");
|
||||
|
||||
Reference in new issue
Block a user