Compare commits

...
Author SHA1 Message Date
agrynco ae7939eca5 Merge pull request 'Promote prerelease to main for KSwitcher v0.8.4' (#208) from prerelease into main 2026-11-27 10:56:56 +02:00
agrynco f7620d164f Merge pull request 'Prepare KSwitcher v0.8.4 for stable delivery' (#207) from codex/deliver-v0.8.4 into prerelease 2026-11-27 10:55:14 +02:00
agrynco 47e10477e1 Prepare KSwitcher v0.8.4 for stable delivery
Refs #204

Refs #122

Refs #196
2026-11-27 10:53:35 +02:00
agrynco f2e403dd39 Merge pull request 'Allow trusted LAN clients to resolve transfer conflicts' (#206) from codex/dirlume-transfer-conflicts into prerelease 2026-11-27 10:00:16 +02:00
agrynco 85cdce1b01 Allow trusted LAN clients to resolve transfer conflicts
Refs #122
2026-11-27 09:57:45 +02:00
agrynco 4acff70e49 Merge pull request 'Move chat language profiles into Settings' (#205) from codex/issue-204-chat-languages into prerelease 2026-11-27 03:27:33 +02:00
agrynco 20bd93b76b Move chat language profiles into Settings
Refs #204
2026-11-27 03:26:54 +02:00
agrynco a63e3534c1 Release KSwitcher v0.8.3 with compact Files breadcrumbs (#203)
Refs #201
2026-11-26 22:02:06 +02:00
agrynco e2b9a65237 Prepare KSwitcher v0.8.3 for delivery
Refs #201
2026-11-26 22:00:30 +02:00
agrynco e7ef2e600b Use compact breadcrumbs above Files panels in Lavender
Refs #201
2026-11-26 21:18:21 +02:00
agrynco 211a5e0b59 Merge pull request 'Release KSwitcher v0.8.2' (#200) from codex/release-v0.8.2 into prerelease 2026-11-26 12:32:47 +02:00
20 changed files with 611 additions and 422 deletions

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.24)
project(KSwitcher VERSION 0.8.2 LANGUAGES C CXX RC)
project(KSwitcher VERSION 0.8.4 LANGUAGES C CXX RC)
if(NOT WIN32)
message(FATAL_ERROR "KSwitcher uses native Windows APIs")
endif()
+3
View File
@@ -732,6 +732,9 @@ Warning і початковий фокус на No.
попередньої гілки. Клік по поточній папці або кнопці редагування та Ctrl+L
відкривають поле шляху. Tab доповнює назву папки, Enter відкриває шлях,
а Esc повертає до тих самих панелей і курсора.
- Над обома панелями працює спільний компонент рядка шляху. У Lavender кнопки
навігації стоять ліворуч, а сегменти за шириною підпису розділяються знаком `›`.
Назва поточної папки виділена напівжирним шрифтом і заокругленим фоном.
- У заголовку FTP- чи SFTP-папки клік по назві профілю відкриває збережені
підключення. У LAN-папці клік по назві ПК відкриває спарені комп’ютери
+10 -2
View File
@@ -35,7 +35,8 @@ retain their original reply formats.
- `capabilities` optionally takes a `peer`. It returns the broker `protocol`
(2), `hostRevision`, and boolean `write`, `delete`, `move`,
`revisionRead`, `onHostTransfer`, and `localEndpoint` fields. With no peer,
`revisionRead`, `onHostTransfer`, `localEndpoint`, and optional
`conflictPrompt` fields. With no peer,
the fields describe the local broker and its grants. With a peer, the flags
also account for its supported protocol. A peer with revision 0 still
supports legacy browsing and downloading.
@@ -57,7 +58,8 @@ retain their original reply formats.
The recycle bin is subject to Windows availability on the paired host.
- `transfer` takes `source` and `target` objects with a `peer` and `path`
each, optional `move` (default false), and a `conflict` policy of `fail`
(default), `skip`, or `replace`. Replace merges directories and replaces
(default), `skip`, `replace`, or `ask` when `conflictPrompt` is available.
Replace merges directories and replaces
regular files after validating the destination revision. The broker
allows at most one local endpoint, represented by `"peer": null`. For a
local endpoint the client must open the pipe with Windows impersonation
@@ -69,6 +71,12 @@ retain their original reply formats.
final frame has `type: "complete"` and counts, or an error. Transfers
on one paired computer use its own file service even across drives. The
local pipe exchanges only control and status for transfers.
- Ask merges directories and reports individual collisions in a JSON frame
with `type: "conflict"`, target `path`, `incoming` and `existing` metadata
(as in `stat`), and boolean `replaceable`. Respond with a JSON frame
containing `decision: "replace"`, `"skip"`, or `"cancel"`. Send
`decision: "wait"` at least once every five seconds while a prompt is open.
Access is checked again after each reply and before publishing the file.
- For a move, the copy phase finishes before source deletion begins.
Skipped items remain at the source. Cancellation or failure can leave
previously completed destination items. Failure during source cleanup
+10 -8
View File
@@ -440,9 +440,10 @@ Drag the divider to resize navigation. The window remembers its size, position,
Switching sections preserves your edits. Save, Cancel, Import and Export stay below every page.
Open the desired chat in Telegram Desktop or Microsoft Teams, then open Settings → Languages →
**Languages for a chat…**. Select the chat and click the languages to include. Choose
**Use languages**, then **Save** in Settings. The subset order is saved from the main
layout list when editing the profile; one-language profiles are supported. **Remove profile** restores default behavior.
**Languages for a chat** in the navigation tree. Find the contact, select the chat and
choose the layouts to include. Click **Apply** to keep Settings open or **Save** to close it.
A profile can contain a single layout and cycles through its layouts in the order shown.
Use **Remove profile** and apply or save the change to restore default behavior.
For a matching chat, **Alt+Shift**, **Win+Space** (and reverse **Win+Shift+Space**) cycle
through that subset. KSwitcher's **Next layout** conversion uses the same subset.
@@ -461,10 +462,11 @@ From v0.6.53, chat profiles (application, visible chat name and ordered language
**Українською.** Вибирайте розділ у дереві Settings або шукайте окремий параметр через **Search settings**.
Перетягніть розділювач, щоб змінити ширину дерева. Settings запам’ятовує розмір і положення вікна
та активний розділ. Перехід між розділами зберігає чернетку. Save, Cancel, Import і Export доступні знизу. Відкрий потрібний чат у Telegram або Teams, потім **Settings → Languages → Languages
for a chat…**. Вибери чат і потрібні мови, натисни **Use languages**, а потім **Save**.
for a chat** у дереві налаштувань. Знайдіть контакт, виберіть чат і потрібні розкладки.
Натисніть **Apply**, щоб залишити Settings відкритим, або **Save**, щоб закрити його.
Набір діє для **Alt+Shift**, **Win+Space**, **Win+Shift+Space** та **Next layout** KSwitcher.
Можна вибрати й одну мову; порядок зберігається із загального списку під час редагування профілю. **Remove profile**
повертає звичайну поведінку. Без профілю системні комбінації працюють як раніше,
Можна вибрати одну розкладку. Розкладки перемикаються в порядку, показаному в списку.
Натисніть **Remove profile** і застосуйте або збережіть зміни, щоб повернути звичайну поведінку. Без профілю системні комбінації працюють як раніше,
а Next layout використовує загальний набір. Видалені з Windows розкладки пропускаються;
якщо доступних мов профілю не залишилося, використовується загальний набір.
Прямі комбінації мов не змінюються; явно задані комбінації KSwitcher мають пріоритет.
@@ -478,11 +480,11 @@ Telegram ігнорується. Teams підтримує зазначений
### Telegram Web in Chrome — v0.6.51
Open a chat in Telegram Web K (`https://web.telegram.org/k/`) in Chrome, then use **Settings → Languages → Languages for a chat...** and select **Telegram Web: name**. Choose languages, then **Use languages → Save**. The same subset applies to Alt+Shift, Win+Space, Win+Shift+Space and Next layout. Web profiles are separate from desktop Telegram profiles. Same-name chats across browser profiles/accounts share a web profile.
Open a chat in Telegram Web K (`https://web.telegram.org/k/`) in Chrome, then use **Settings → Languages → Languages for a chat** and select the contact with **Telegram Web** in the App column. Choose layouts and click **Apply** or **Save**. The same subset applies to Alt+Shift, Win+Space, Win+Shift+Space and Next layout. Web profiles are separate from desktop Telegram profiles. Same-name chats across browser profiles/accounts share a web profile.
Recognition uses Chrome accessibility: the address bar and active document must both identify a Telegram chat, then the visible header supplies the name. The app watches foreground/focus and address/header-change events; it does not use OCR, a polling timer, an extension, or message-history extraction. The address bar, home page and unsupported URLs do not match. Web A and other browsers have not been validated and are not advertised as supported. Page or accessibility changes can make a chat unavailable instead of guessing.
**Українською.** З v0.6.51 підтримано Telegram Web K у Chrome. Відкрий чат, потім **Settings → Languages → Languages for a chat...**, вибери **Telegram Web: ім’я**, мови та **Use languages → Save**. Набір діє для Alt+Shift, Win+Space, Win+Shift+Space і Next layout. Вебпрофілі окремі від Telegram Desktop; однакові назви в різних акаунтах/профілях браузера мають спільний вебпрофіль. Адреса й назва беруться через accessibility, без OCR, таймера, розширення та читання історії повідомлень. В адресному рядку, на головній сторінці й для непідтримуваних адрес профіль не діє. Web A та інші браузери не перевірені й не заявлені як підтримувані.
**Українською.** З v0.6.51 підтримано Telegram Web K у Chrome. Відкрий чат, потім **Settings → Languages → Languages for a chat**, вибери контакт із **Telegram Web** у колонці App та потрібні розкладки, а потім натисни **Apply** або **Save**. Набір діє для Alt+Shift, Win+Space, Win+Shift+Space і Next layout. Вебпрофілі окремі від Telegram Desktop; однакові назви в різних акаунтах/профілях браузера мають спільний вебпрофіль. Адреса й назва беруться через accessibility, без OCR, таймера, розширення та читання історії повідомлень. В адресному рядку, на головній сторінці й для непідтримуваних адрес профіль не діє. Web A та інші браузери не перевірені й не заявлені як підтримувані.
### Snippet autocomplete — v0.6.69
+18
View File
@@ -1,5 +1,23 @@
# Latest Windows release
## v0.8.4 — 2026-11-27
- **Settings.** Open **Languages → Languages for a chat** in the Settings tree to search for a chat and choose its keyboard layouts. Save changes with **Apply** or **Save**.
- **Trusted LAN clients.** Clients such as Dirlume can ask how to handle individual file conflicts during copy or move. When supported, choose to replace, skip or cancel.
**Українською.**
- **Налаштування.** Відкрийте **Languages → Languages for a chat** у дереві Settings, щоб знайти чат і вибрати його розкладки. Застосуйте зміни кнопкою **Apply** або **Save**.
- **Довірені клієнти LAN.** Клієнти на кшталт Dirlume можуть запитувати, як обробити окремі конфлікти файлів під час копіювання або переміщення. Якщо клієнт підтримує цю можливість, виберіть заміну, пропуск або скасування.
## v0.8.3 — 2026-11-26
- **Files.** Lavender now shows compact path segments with chevrons above both panes. The current folder has a rounded highlight. Click an ancestor to open it, the current folder to edit the path, or an ellipsis to reveal hidden folders.
**Українською.**
- **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.
+1 -1
View File
@@ -1 +1 @@
01cc0f4cf1555c6e038ab6ff4d00439c28f4a79ca8452fd5e3f4158947e5ceab KSwitcher-win-x64.zip
9035578c4aa96533a78dd1830966cf0b2f8d9de623f51ec2d111e62249d1c65d KSwitcher-win-x64.zip
+14 -14
View File
@@ -1,26 +1,25 @@
{
"schema": 1,
"version": "0.8.2",
"files": [
{
"path": "KSwitcher.exe",
"sha256": "37cdbed818cb6351e606c8ef4a052a8d1218c515863787b2d407c97cb88858c7",
"size": 3244544
"sha256": "a7ad4db3cb46825c65b851c7e4cbd214f779eb5325a91ca7cdb96a3fe944d8a4",
"size": 3251712
},
{
"path": "KSwitcher.Config.exe",
"sha256": "6ab516b657c95c9fe5461b71e020831337831bd7807b1991a71a4bb40f26889e",
"size": 2849792
"sha256": "c9d2dddc6e2a5e14be02680c1177e4813515e207bada399f255fcbf4aef5e884",
"size": 2850304
},
{
"path": "KSwitcher.Screenshot.exe",
"sha256": "dbc7f702c25ea63e5c8b64bb0a76b8a058cf75938262fb0a20113e80b00d88b7",
"sha256": "1112fd25921d49ef20b3f71b0b8234eea3e9df47b1c1d207bfa22a9f7da34028",
"size": 3193344
},
{
"path": "KSwitcher.Files.exe",
"sha256": "98326211b088d838720068863edfc38988f54b27326e62ed1b4ab79c3f455ab8",
"size": 5998592
"sha256": "b2843967c9b70839e45ec3b8b48bffde41ff8994ea345317beb1bda28e6d6dff",
"size": 6002688
},
{
"path": "WebView2Loader.dll",
@@ -124,13 +123,13 @@
},
{
"path": "README.md",
"sha256": "be1b3fca2a291284ab550e9e77042fb27ecf927861d2d8fb8ec4907258477f01",
"size": 105515
"sha256": "7f179b561fab6125f167203a6ae180a7050d876b056c39f62f3be36cf4bad733",
"size": 105904
},
{
"path": "LAN-PREVIEW.md",
"sha256": "917c2f41b3943647fdfafa911d93f72b8c6fb0d08592016ce1a698d256e038bb",
"size": 16722
"sha256": "4eac1f410e6b544aa45756e24f4fdfe9193c6f732410656160be54ab27a0d7e4",
"size": 17245
},
{
"path": "dictionaries/en.txt",
@@ -169,7 +168,7 @@
},
{
"path": "tools/StayHere.exe",
"sha256": "87f842e25d07bf95dee8116733a10fd2e24fa9a10d645c5ea1f374908aaf0e0b",
"sha256": "1530796fac99f1542b992e4254fc30c16c24ee7e6c6dc7b6ba41d241e3ea6417",
"size": 133120
},
{
@@ -177,5 +176,6 @@
"sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413",
"size": 2796
}
]
],
"version": "0.8.4"
}
+3 -3
View File
@@ -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,2,0
PRODUCTVERSION 0,8,2,0
FILEVERSION 0,8,4,0
PRODUCTVERSION 0,8,4,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.2"
VALUE "FileVersion", "0.8.4"
END
END
BLOCK "VarFileInfo"
+12 -5
View File
@@ -6,13 +6,19 @@ constexpr COLORREF activeEdge=RGB(151,151,244), selection=RGB(231,227,253), idle
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{};
HFONT font{}, emphasis{};
void setFont(UINT dpi)
{
if(font) DeleteObject(font);
font=CreateFontW(-MulDiv(14,dpi,96),0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,CLEARTYPE_QUALITY,DEFAULT_PITCH,L"Segoe UI");
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)
@@ -34,10 +40,11 @@ void rounded(HDC dc,RECT rect,int radius,COLORREF color,COLORREF border)
}
void text(HDC dc,RECT rect,const wchar_t *label,COLORREF color,UINT alignment=DT_LEFT,
UINT ellipsis=DT_END_ELLIPSIS)
UINT ellipsis=DT_END_ELLIPSIS,HFONT textFont=nullptr)
{
if(rect.right<=rect.left) return;
const auto previous=SelectObject(dc,font?font:GetStockObject(DEFAULT_GUI_FONT));
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);
+8 -17
View File
@@ -8847,6 +8847,7 @@ void handleFilesReturn(bool shift)
}
#include "files_smb.inl"
#include "files_path_bar.inl"
#include "files_path_navigation.inl"
LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
@@ -9260,22 +9261,11 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
{
auto bounds=item.rcItem;
const auto &panel=panels[item.CtlID-142];
const auto path=panelCaption(panel);
const bool highlighted=static_cast<int>(item.CtlID)-142==active;
const bool navigable=pathNavigationAvailable(panel);
if(lavenderFiles())
{
const LavenderMetrics metrics(window);
const bool highlighted=static_cast<int>(item.CtlID)-142==active;
lavender::fill(item.hDC,bounds,lavender::surface);
lavender::rounded(item.hDC,bounds,metrics.px(7),lavender::path,
highlighted?lavender::activeEdge:lavender::line);
if(pathNavigationAvailable(panel)) paintPanelPath(item.hDC,bounds,panel,highlighted);
else
{
paintLavenderFileIcon(item.hDC,bounds,metrics,true);
bounds.left+=metrics.px(30);
bounds.right-=metrics.px(9);
lavender::text(item.hDC,bounds,path.c_str(),lavender::ink,DT_LEFT,DT_PATH_ELLIPSIS);
}
paintLavenderPanelPath(item,panel,navigable,highlighted);
return TRUE;
}
FillRect(item.hDC,&bounds,blue);
@@ -9298,12 +9288,12 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
FillRect(item.hDC,&column,lineBrush);
}
}
const bool highlighted=static_cast<int>(item.CtlID)-142==active;
if(pathNavigationAvailable(panel))
if(navigable)
{
paintPanelPath(item.hDC,bounds,panel,highlighted);
paintPanelPath(item.hDC,item.hwndItem,bounds,panel,highlighted);
return TRUE;
}
const auto path=panelCaption(panel);
if(path.empty()) return TRUE;
const int saved=SaveDC(item.hDC);
SelectObject(item.hDC,mono);
@@ -10251,6 +10241,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR, int show)
}
for(auto font:fileStyleFonts) if(font) DeleteObject(font);
if(lavender::font) DeleteObject(lavender::font);
if(lavender::emphasis) DeleteObject(lavender::emphasis);
DeleteObject(mono);
DeleteObject(terminalFont);
DeleteObject(blue);
+217
View File
@@ -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);
}
+5 -122
View File
@@ -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,125 +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;
if(lavenderFiles())
{
if(current) lavender::rounded(dc,part.rect,MulDiv(5,GetDeviceCaps(dc,LOGPIXELSX),96),lavender::key,lavender::key);
lavender::text(dc,part.rect,part.label.c_str(),!part.enabled || part.dim?lavender::muted:lavender::ink,DT_CENTER);
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(saved) RestoreDC(dc,saved);
}
constexpr int addressField=485,addressLabel=486,addressFooter=487;
struct PathPrompt
@@ -439,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;
+25 -5
View File
@@ -48,7 +48,8 @@ Json capabilities(bool write, bool erase, unsigned host)
{
return {{"protocol", 2}, {"hostRevision", host}, {"write", write && host},
{"delete", erase && host}, {"move", write && erase && host},
{"revisionRead", host != 0}, {"onHostTransfer", host != 0}, {"localEndpoint", host != 0}};
{"revisionRead", host != 0}, {"onHostTransfer", host != 0}, {"localEndpoint", host != 0},
{"conflictPrompt", host != 0}};
}
fs::path itemPath(const Json &value)
{
@@ -128,6 +129,27 @@ class ClientTransfer
if (!result.at("continue").get<bool>()) throw std::system_error(ERROR_CANCELLED, std::system_category());
guard();
}
bool resolveConflict(const fs::path &path, const Json &incoming, const Json &existing)
{
if (conflict == "skip") return false;
const bool replaceable = directory(incoming) == directory(existing) && !reparse(existing);
if (conflict == "replace" && replaceable) return true;
if (conflict != "ask") throw std::system_error(ERROR_ALREADY_EXISTS, std::system_category());
if (replaceable && directory(existing)) return true;
sendJson(send, {{"type", "conflict"}, {"path", utf8(path.native())},
{"incoming", incoming}, {"existing", existing}, {"replaceable", replaceable}});
for (;;)
{
const auto answer = Json::parse(receive(256)).at("decision").get<std::string>();
guard();
if (answer == "wait") continue;
if (answer == "skip") return false;
if (answer == "replace" && replaceable) return true;
if (answer == "cancel") throw std::system_error(ERROR_CANCELLED, std::system_category());
throw std::runtime_error("Invalid transfer conflict decision.");
}
}
bool copy(const fs::path &from, const fs::path &to, unsigned depth)
{
if (depth > 256) throw std::runtime_error("The file tree is too deep.");
@@ -139,9 +161,7 @@ class ClientTransfer
if (found)
{
checkFileReply(existing);
if (conflict == "skip") { ++skipped; return false; }
if (conflict != "replace" || directory(original) != directory(existing))
throw std::system_error(ERROR_ALREADY_EXISTS, std::system_category());
if (!resolveConflict(to, original, existing)) { ++skipped; return false; }
requireRegular(existing);
}
@@ -199,7 +219,7 @@ public:
void run(const fs::path &from, const fs::path &to)
{
if (conflict != "fail" && conflict != "skip" && conflict != "replace")
if (conflict != "fail" && conflict != "skip" && conflict != "replace" && conflict != "ask")
throw std::runtime_error("Unknown conflict policy.");
if (sameHost)
{
+144 -193
View File
@@ -1210,7 +1210,8 @@ LRESULT CALLBACK historyProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
#ifndef KS_RESIDENT_APP
constexpr int LanguagesPage = 1, ShortcutsPage = 2, ClipboardPage = 3, SnippetsPage = 4, MousePage = 5;
constexpr int ExceptionsPage = 13, PersonalDictionariesPage = 14, WordBoundariesPage = 15, SnippetMacros = 320;
constexpr int CustomReplacementsPage = 16;
constexpr int CustomReplacementsPage = 16, ChatLanguagesPage = 20;
constexpr int ChatContacts = 710, ChatLayouts = 711, ChatProfileStatus = 712, ChatRemoveProfile = 713, ChatSearch = 714;
constexpr int ClipboardExcludedApps = 243, ClipboardAppName = 244, ClipboardAddApp = 245,
ClipboardRemoveApp = 246, ClipboardAppPicker = 247;
constexpr UINT AppWindowPicked = WM_APP + 78;
@@ -1254,6 +1255,7 @@ constexpr struct SettingsSection
{"openbao", L"OpenBao", L"Connect to OpenBao and synchronize your saved settings.", SyncPage},
{"google-drive", L"Google Drive", L"Synchronize settings across PCs or manage manual backups.", SyncPage},
{"ocr", L"Image text recognition", L"Choose Windows OCR or Tesseract. Recognition runs on this computer.", ClipboardPage},
{"chat-languages", L"Languages for a chat", L"Choose which keyboard layouts to cycle through in a chat.", LanguagesPage},
};
constexpr wchar_t SettingsWindowFile[] = L"configurator-window.json";
struct SettingsWindowState
@@ -1353,6 +1355,9 @@ struct SettingsView
SIZE mouseProfileCheckSize{};
unsigned mouseEvents{}, rawMouseEvents{};
bool rawMouseRegistered{};
std::vector<std::wstring> chatKeys;
int chatSelection = -1;
bool updatingChatContacts{};
SnippetView snippets;
HWND clipboardPickerOutline{};
};
@@ -1863,6 +1868,8 @@ void reflowSettingsPage(HWND pane, WindowLayout &layout, int width, int height)
}
layout.height = fitSettingsColumns(layout, page.first, page.end, available, grid);
const int extra = height * 96 / static_cast<int>(dpi) - layout.height;
if (v.selectedPage == ChatLanguagesPage)
stretchSettingsEditors(layout, page.first, page.end, std::min(extra, 160), {ChatContacts, ChatLayouts}, true);
if (v.selectedPage == SnippetsPage)
stretchSettingsEditors(layout, page.first, page.end, extra, {301, 303}, available < grid.wrapAt);
if (v.selectedPage == MousePage)
@@ -1954,6 +1961,7 @@ void reflowClipboard(HWND pane, WindowLayout &layout, int width, int height)
if (scale(pane, layout.height) > height)
fit(width - GetSystemMetricsForDpi(SM_CXVSCROLL, dpi));
}
void refreshChatLanguages(SettingsView &v);
void selectSettingsPage(SettingsView &v, int selected)
{
if (selected < 0 || selected >= (int)v.pages.size() || selected == v.selectedPage) return;
@@ -1968,6 +1976,7 @@ void selectSettingsPage(SettingsView &v, int selected)
ShowWindow(layout.controls[i].first, SW_HIDE);
}
v.selectedPage = selected;
if (selected == ChatLanguagesPage) refreshChatLanguages(v);
SetWindowTextW(v.heading, settingsSections[selected].name);
SetWindowTextW(v.description, settingsSections[selected].description);
const auto &page = v.pages[selected];
@@ -2274,81 +2283,42 @@ void indexSettingsControl(SettingsView &v, int page, HWND child)
}
v.searchEntries.push_back({page, child, target, std::move(text), aliases});
}
struct ChatLanguagesView
void fillChatLanguages(SettingsView &v)
{
HWND parent{};
SettingsView *settings{};
std::vector<std::wstring> keys;
Settings draft;
int selection = -1;
bool dirty{};
bool updatingList{};
std::wstring search;
};
void collectChatLanguages(HWND w, ChatLanguagesView *v)
{
if (!v->dirty || v->selection < 0) return;
std::vector<std::wstring> cycle;
for (size_t i = 0; i < v->settings->order.size(); ++i)
if (SendDlgItemMessageW(w, 711, LB_GETSEL, i, 0) > 0)
cycle.push_back(v->settings->app->layouts[v->settings->order[i]].id);
if (cycle.empty()) throw std::runtime_error("Select at least one language.");
v->draft.chatCycles[v->keys[v->selection]] = std::move(cycle);
v->dirty = false;
}
void fillChatLanguages(HWND w, ChatLanguagesView *v)
{
int index = v->selection;
EnableWindow(GetDlgItem(w, 711), index >= 0);
EnableWindow(GetDlgItem(w, IDOK), index >= 0);
if (index < 0)
HWND pane = v.viewport;
const bool selected = v.chatSelection >= 0;
EnableWindow(GetDlgItem(pane, ChatLayouts), selected && !v.order.empty());
if (!selected)
{
SendDlgItemMessageW(w, 711, LB_SETSEL, FALSE, -1);
EnableWindow(GetDlgItem(w, 713), FALSE);
value(w, 712, v->keys.empty() ? L"Open a chat, then reopen this dialog to add it." :
L"No contacts match your search.");
SendDlgItemMessageW(pane, ChatLayouts, LB_SETSEL, FALSE, -1);
EnableWindow(GetDlgItem(pane, ChatRemoveProfile), FALSE);
value(pane, ChatProfileStatus, v.chatKeys.empty() ?
L"Open a chat, then return to this page." : L"No matching chat selected.");
return;
}
const auto &draft = v->draft;
auto saved = draft.chatCycles.find(v->keys[index]);
const auto &cycle = saved == draft.chatCycles.end() ? draft.cycle : saved->second;
for (size_t i = 0; i < v->settings->order.size(); ++i)
const auto saved = v.draft.chatCycles.find(v.chatKeys[v.chatSelection]);
const bool hasProfile = saved != v.draft.chatCycles.end();
const auto &cycle = hasProfile ? saved->second : v.draft.cycle;
for (size_t i = 0; i < v.order.size(); ++i)
{
auto &layout = v->settings->app->layouts[v->settings->order[i]];
SendDlgItemMessageW(w, 711, LB_SETSEL,
std::find(cycle.begin(), cycle.end(), layout.id) != cycle.end(), i);
const auto &layout = v.app->layouts[v.order[i]];
SendDlgItemMessageW(pane, ChatLayouts, LB_SETSEL, std::ranges::find(cycle, layout.id) != cycle.end(), i);
}
value(w, 712, saved == draft.chatCycles.end() ? L"No profile yet. Select the languages for this chat." :
L"Chat profile. Select languages, or remove it to use the defaults.");
EnableWindow(GetDlgItem(w, 713), saved != draft.chatCycles.end());
value(pane, ChatProfileStatus, hasProfile ? L"Chat profile" : L"Using the default language cycle");
EnableWindow(GetDlgItem(pane, ChatRemoveProfile), hasProfile);
}
void selectChatRow(HWND list, int index)
void filterChatRows(SettingsView &v, const std::wstring &previous)
{
int row = -1;
if (index >= 0)
{
LVFINDINFOW find{LVFI_PARAM};
find.lParam = index;
row = ListView_FindItem(list, -1, &find);
}
ListView_SetItemState(list, -1, 0, LVIS_SELECTED | LVIS_FOCUSED);
if (row >= 0)
{
ListView_SetItemState(list, row, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
ListView_EnsureVisible(list, row, FALSE);
}
}
void filterChatRows(HWND w, ChatLanguagesView *v)
{
auto list = GetDlgItem(w, 710);
auto search = lower(v->search);
int selection = -1;
v->updatingList = true;
auto list = GetDlgItem(v.viewport, ChatContacts);
const auto search = lower(value(v.viewport, ChatSearch));
int selectedRow = -1;
v.chatSelection = -1;
v.updatingChatContacts = true;
SendMessageW(list, WM_SETREDRAW, FALSE, 0);
ListView_DeleteAllItems(list);
for (size_t i = 0; i < v->keys.size(); ++i)
for (size_t i = 0; i < v.chatKeys.size(); ++i)
{
const auto &key = v->keys[i];
const auto &key = v.chatKeys[i];
auto contact = key.substr(key.find(L'\n') + 1);
if (lower(contact).find(search) == std::wstring::npos) continue;
auto app = key.starts_with(L"telegram\n") ? L"Telegram" :
@@ -2358,153 +2328,99 @@ void filterChatRows(HWND w, ChatLanguagesView *v)
item.iItem = ListView_GetItemCount(list);
item.pszText = contact.data();
item.lParam = static_cast<LPARAM>(i);
int row = ListView_InsertItem(list, &item);
const int row = ListView_InsertItem(list, &item);
if (row < 0) continue;
ListView_SetItemText(list, row, 1, const_cast<wchar_t *>(app));
if (selection < 0 || static_cast<int>(i) == v->selection) selection = static_cast<int>(i);
if (selectedRow < 0 || key == previous)
{
selectedRow = row;
v.chatSelection = static_cast<int>(i);
}
}
if (selectedRow >= 0)
{
ListView_SetItemState(list, selectedRow, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
ListView_EnsureVisible(list, selectedRow, FALSE);
}
selectChatRow(list, selection);
SendMessageW(list, WM_SETREDRAW, TRUE, 0);
InvalidateRect(list, nullptr, TRUE);
v->updatingList = false;
v->selection = selection;
fillChatLanguages(w, v);
v.updatingChatContacts = false;
fillChatLanguages(v);
}
LRESULT CALLBACK chatLanguagesProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
std::wstring selectedChatKey(const SettingsView &v)
{
auto *v = (ChatLanguagesView *)GetWindowLongPtrW(w, GWLP_USERDATA);
if (!v) return DefWindowProcW(w, msg, wp, lp);
try
{
if (msg == WM_NOTIFY && !v->updatingList)
{
auto *change = reinterpret_cast<const NMLISTVIEW *>(lp);
if (change->hdr.idFrom == 710 && change->hdr.code == LVN_ITEMCHANGED &&
(change->uNewState & LVIS_SELECTED) && !(change->uOldState & LVIS_SELECTED))
{
int selected = static_cast<int>(change->lParam);
if (selected == v->selection) return 0;
try { collectChatLanguages(w, v); }
catch (...)
{
v->updatingList = true;
selectChatRow(change->hdr.hwndFrom, v->selection);
v->updatingList = false;
throw;
}
v->selection = selected;
fillChatLanguages(w, v);
return 0;
}
}
if (msg == WM_COMMAND)
{
int id = LOWORD(wp);
if (id == 711 && HIWORD(wp) == LBN_SELCHANGE) { v->dirty = true; return 0; }
if (id == 714 && HIWORD(wp) == EN_CHANGE && !v->updatingList)
{
try { collectChatLanguages(w, v); }
catch (...)
{
v->updatingList = true;
value(w, 714, v->search);
v->updatingList = false;
throw;
}
v->search = value(w, 714);
filterChatRows(w, v);
return 0;
}
if (id == IDOK || id == 713)
{
int selected = v->selection;
if (id == IDOK && selected < 0) return 0;
if (selected < 0 || selected >= (int)v->keys.size())
throw std::runtime_error("Open a Telegram or Teams chat, then reopen this dialog.");
if (id == 713)
{
v->draft.chatCycles.erase(v->keys[selected]);
v->dirty = false;
fillChatLanguages(w, v);
return 0;
}
collectChatLanguages(w, v);
validateSettings(v->draft);
v->settings->draft.chatCycles = std::move(v->draft.chatCycles);
DestroyWindow(w);
return 0;
}
if (id == IDCANCEL) { DestroyWindow(w); return 0; }
}
if (msg == WM_CLOSE) { DestroyWindow(w); return 0; }
if (msg == WM_DPICHANGED)
{
resizeForDpi(w, wp, lp);
auto list = GetDlgItem(w, 710);
ListView_SetColumnWidth(list, 0, scale(w, 442));
ListView_SetColumnWidth(list, 1, scale(w, 140));
return 0;
}
if (msg == WM_NCDESTROY)
{
EnableWindow(v->parent, TRUE);
SetForegroundWindow(v->parent);
disposeFont(w);
delete v;
SetWindowLongPtrW(w, GWLP_USERDATA, 0);
}
}
catch (const std::exception &e) { error(w, e); }
return DefWindowProcW(w, msg, wp, lp);
return v.chatSelection < 0 ? std::wstring{} : v.chatKeys[v.chatSelection];
}
void showChatLanguages(HWND parent, SettingsView *settings)
void refreshChatLanguages(SettingsView &v)
{
const auto previous = selectedChatKey(v);
std::set<std::wstring> keys;
for (const auto &[key, cycle] : settings->draft.chatCycles) keys.insert(key);
struct Context { std::set<std::wstring> &keys; const Settings &settings; } context{keys, settings->draft};
for (const auto &[key, cycle] : v.draft.chatCycles) keys.insert(key);
EnumWindows([](HWND candidate, LPARAM context) -> BOOL
{
if (!IsWindowVisible(candidate)) return TRUE;
auto &data = *(Context *)context;
auto &contacts = *reinterpret_cast<std::set<std::wstring> *>(context);
auto key = lower(processName(candidate)) == L"chrome" ? readChromeChat(candidate) : windowChatKey(candidate);
if (!key.empty()) data.keys.insert(std::move(key));
if (!key.empty()) contacts.insert(std::move(key));
return TRUE;
}, (LPARAM)&context);
}, reinterpret_cast<LPARAM>(&keys));
v.chatKeys.assign(keys.begin(), keys.end());
SendDlgItemMessageW(v.viewport, ChatLayouts, LB_RESETCONTENT, 0, 0);
for (int index : v.order)
SendDlgItemMessageW(v.viewport, ChatLayouts, LB_ADDSTRING, 0,
reinterpret_cast<LPARAM>(v.app->layouts[index].name.c_str()));
filterChatRows(v, previous);
}
void editChatLanguages(SettingsView &v)
{
if (v.chatSelection < 0) return;
std::vector<std::wstring> cycle;
for (size_t i = 0; i < v.order.size(); ++i)
if (SendDlgItemMessageW(v.viewport, ChatLayouts, LB_GETSEL, i, 0) > 0)
cycle.push_back(v.app->layouts[v.order[i]].id);
const bool hasLayouts = !cycle.empty();
if (hasLayouts) v.draft.chatCycles[v.chatKeys[v.chatSelection]] = std::move(cycle);
fillChatLanguages(v);
if (!hasLayouts) value(v.viewport, ChatProfileStatus, L"Select at least one layout, or remove the profile.");
}
void sizeChatContactColumns(HWND list)
{
RECT bounds{};
GetClientRect(list, &bounds);
const int appWidth = scale(list, 140);
const int scrollWidth = GetSystemMetricsForDpi(SM_CXVSCROLL, GetDpiForWindow(list));
ListView_SetColumnWidth(list, 0, std::max(0L, bounds.right - appWidth - scrollWidth));
ListView_SetColumnWidth(list, 1, appWidth);
}
LRESULT CALLBACK chatContactsProc(HWND list, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR, DWORD_PTR)
{
const auto result = DefSubclassProc(list, msg, wp, lp);
if (msg == WM_SIZE) sizeChatContactColumns(list);
return result;
}
void createChatLanguages(HWND pane)
{
INITCOMMONCONTROLSEX controls{sizeof(controls), ICC_LISTVIEW_CLASSES};
InitCommonControlsEx(&controls);
HWND w = makeWindow(*settings->app, L"KSwitcher.ChatLanguages", L"Languages for a chat", chatLanguagesProc, 640, 524);
auto *v = new ChatLanguagesView{parent, settings, {keys.begin(), keys.end()}};
v->draft = settings->draft;
v->updatingList = true;
SetWindowLongPtrW(w, GWLP_HWNDPARENT, (LONG_PTR)parent);
SetWindowLongPtrW(w, GWLP_USERDATA, (LONG_PTR)v);
label(w, L"&Find contact", 18, 19, 106);
edit(w, 714, 130, 14, 492);
auto list = control(w, WC_LISTVIEWW, L"", WS_TABSTOP | WS_BORDER | LVS_REPORT | LVS_SINGLESEL |
LVS_SHOWSELALWAYS | LVS_NOSORTHEADER, 710, 18, 48, 604, 136);
label(pane, L"&Find contact", 24, 68, 660);
edit(pane, ChatSearch, 24, 94, 660);
const auto list = control(pane, WC_LISTVIEWW, L"", WS_TABSTOP | WS_BORDER | LVS_REPORT | LVS_SINGLESEL |
LVS_SHOWSELALWAYS | LVS_NOSORTHEADER, ChatContacts, 24, 126, 660, 106);
ListView_SetExtendedListViewStyle(list, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_LABELTIP);
for (const auto &[title, width] : {std::pair{L"Contact", 442}, std::pair{L"App", 140}})
for (const auto *title : {L"Contact", L"App"})
{
LVCOLUMNW column{LVCF_TEXT | LVCF_WIDTH};
LVCOLUMNW column{LVCF_TEXT};
column.pszText = const_cast<wchar_t *>(title);
column.cx = scale(w, width);
ListView_InsertColumn(list, Header_GetItemCount(ListView_GetHeader(list)), &column);
}
control(w, L"STATIC", L"Open a chat, then reopen this dialog to add it.", 0, 712, 18, 194, 604, 26);
label(w, L"Click languages to include (saved in the order shown)", 18, 228, 604);
control(w, L"LISTBOX", L"", WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY | LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | WS_BORDER,
711, 18, 256, 604, 132);
for (int i : settings->order)
SendDlgItemMessageW(w, 711, LB_ADDSTRING, 0, (LPARAM)settings->app->layouts[i].name.c_str());
label(w, L"Applies to Alt+Shift, Win+Space and KSwitcher Next layout.", 18, 402, 604);
label(w, L"Switch chats freely. Use languages, then Save settings.", 18, 430, 604);
button(w, L"&Remove profile", 713, 18, 476, 170);
button(w, L"&Use languages", IDOK, 300, 476, 170);
button(w, L"&Cancel", IDCANCEL, 486, 476, 136);
filterChatRows(w, v);
EnableWindow(parent, FALSE);
showRequestedWindow(w);
SetFocus(GetDlgItem(w, 714));
SetWindowSubclass(list, chatContactsProc, 1, 0);
sizeChatContactColumns(list);
control(pane, L"STATIC", L"", 0, ChatProfileStatus, 24, 242, 660, 24);
label(pane, L"Select layouts to include, in the order shown.", 24, 270, 660);
control(pane, L"LISTBOX", L"", WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY | LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT |
WS_BORDER, ChatLayouts, 24, 296, 660, 80);
button(pane, L"&Remove profile", ChatRemoveProfile, 24, 388, 170);
label(pane, L"Applies to Alt+Shift, Win+Space, Win+Shift+Space and KSwitcher Next layout.", 24, 424, 660);
}
#include "ui_app_languages.inl"
#include "ui_mouse_buttons.inl"
@@ -2647,6 +2563,7 @@ void fillSettings(HWND root, SettingsView *v)
v->order.push_back(i);
v->selection = 0;
fillLayouts(v);
if (v->selectedPage == ChatLanguagesPage) refreshChatLanguages(*v);
fillMouseProfiles(root, *v);
fillCorrectionOptions(w, s);
v->filling = false;
@@ -3057,6 +2974,20 @@ LRESULT CALLBACK settingsProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
if (LOWORD(wp) != WA_INACTIVE) updateSettingsState(w, v);
break;
case WM_NOTIFY:
if (reinterpret_cast<const NMHDR *>(lp)->idFrom == ChatContacts &&
reinterpret_cast<const NMHDR *>(lp)->code == LVN_ITEMCHANGED)
{
const auto &change = *reinterpret_cast<const NMLISTVIEW *>(lp);
if (!v->updatingChatContacts && ((change.uNewState ^ change.uOldState) & LVIS_SELECTED))
{
if (change.uNewState & LVIS_SELECTED)
v->chatSelection = static_cast<int>(change.lParam);
else if (!ListView_GetSelectedCount(change.hdr.hwndFrom))
v->chatSelection = -1;
fillChatLanguages(*v);
}
return 0;
}
if (reinterpret_cast<const NMHDR *>(lp)->idFrom == SettingsNavigation)
{
const auto code = reinterpret_cast<const NMHDR *>(lp)->code;
@@ -3189,7 +3120,25 @@ LRESULT CALLBACK settingsProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
}
if (id == 263) { collectLayout(v); showAppLanguages(w, v); return 0; }
if (handleMouseBindings(w, *v, wp)) return 0;
if (id == 259) { collectLayout(v); showChatLanguages(w, v); return 0; }
if (id == ChatSearch && HIWORD(wp) == EN_CHANGE)
{
if (v->ready) filterChatRows(*v, selectedChatKey(*v));
return 0;
}
if (id == ChatLayouts && HIWORD(wp) == LBN_SELCHANGE)
{
editChatLanguages(*v);
return 0;
}
if (id == ChatRemoveProfile && HIWORD(wp) == BN_CLICKED)
{
if (v->chatSelection >= 0)
{
v->draft.chatCycles.erase(v->chatKeys[v->chatSelection]);
fillChatLanguages(*v);
}
return 0;
}
if (id == 230)
{
collectLayout(v);
@@ -3985,8 +3934,7 @@ void showSettings(App &app, bool visible)
hotkeyEdit(app, pane, 231, 454, 234, 230);
label(pane, L"Backspace / Delete clears it", 454, 270, 230);
button(pane, L"Re&fresh layouts", 253, 454, 322, 230);
button(pane, L"Languages for a &chat...", 259, 24, 378, 230);
button(pane, L"Languages for &applications...", 263, 272, 378, 300);
button(pane, L"Languages for &applications...", 263, 24, 378, 300);
page();
settingsGroupLabel(pane, L"Keyboard shortcuts", 24, 68);
@@ -4111,6 +4059,9 @@ void showSettings(App &app, bool visible)
createOcrSettings(pane);
page();
createChatLanguages(pane);
page();
v->splitter = control(w, L"STATIC", L"Resize navigation pane", SS_NOTIFY | WS_TABSTOP,
SettingsSplitter, 0, 0, 0, 0);
SetWindowSubclass(v->splitter, settingsSplitterProc, 1, reinterpret_cast<DWORD_PTR>(v));
+1 -1
View File
@@ -2,7 +2,7 @@
#include "platform.h"
namespace ks
{
inline constexpr wchar_t AppVersion[] = L"0.8.2";
inline constexpr wchar_t AppVersion[] = L"0.8.4";
inline constexpr UINT UpdateMessage = WM_APP + 7;
inline constexpr UINT UpdateCheckIntervalMs = 6 * 60 * 60 * 1000;
inline constexpr UINT UpdateNotificationRetryMs = 5 * 60 * 1000;
+62 -45
View File
@@ -854,13 +854,16 @@ int main(int argc,char **argv)
SendMessageW(GetDlgItem(correction, 414), BM_CLICK, 0, 0);
require(!saveEnabled(), "reverting an inline correction edit disables Save");
HWND navigation = settingsNavigation(parent);
constexpr int sections = 20;
constexpr int chatLanguagesPage = 20;
constexpr int sections = 21;
require(navigation && TreeView_GetCount(navigation) == sections &&
TreeView_GetParent(navigation, settingsSection(navigation, 10)) == settingsSection(navigation, 7) &&
TreeView_GetParent(navigation, settingsSection(navigation, 11)) == settingsSection(navigation, 0),
"correction and computer settings are nested under their sections");
require(TreeView_GetParent(navigation, settingsSection(navigation, 19)) == settingsSection(navigation, 3),
"image text recognition is nested under Clipboard");
require(TreeView_GetParent(navigation, settingsSection(navigation, chatLanguagesPage)) ==
settingsSection(navigation, 1), "chat profiles appear under Languages");
for (int section = 12; section <= 16; ++section)
require(TreeView_GetParent(navigation, settingsSection(navigation, section)) == settingsSection(navigation, 11),
"each correction subsection belongs to the correction branch");
@@ -1124,44 +1127,51 @@ int main(int argc,char **argv)
"search reveals the embedded OpenBao page");
SetWindowTextW(search, L"");
selectSettingsPage(parent, 1);
require(!saveEnabled(),"changing sections leaves Settings clean");
SendMessageW(parent, WM_COMMAND, 259, 0);
HWND dialog = findTestWindow(L"KSwitcher.ChatLanguages", nullptr);
require(dialog && !IsWindowEnabled(parent), "chat dialog opens with disabled parent");
auto findFixtureChat = [&](HWND chatDialog) {
SetDlgItemTextW(chatDialog, 714, L"! fIXTURE CHAT");
HWND list = GetDlgItem(chatDialog, 710);
require(!saveEnabled() && !GetDlgItem(pane, 259), "Languages uses the tree to open chat profiles");
selectSettingsPage(parent, chatLanguagesPage);
constexpr int contactsId = 710, layoutsId = 711, removeProfileId = 713, searchContactsId = 714;
require(IsWindowVisible(GetDlgItem(pane, contactsId)) && IsWindowEnabled(parent) &&
!findTestWindow(L"KSwitcher.ChatLanguages", nullptr), "chat profiles open within Settings");
auto findFixtureChat = [&] {
const auto chatPage = settingsViewport(parent);
SetDlgItemTextW(chatPage, searchContactsId, L"! fIXTURE CHAT");
const auto list = GetDlgItem(chatPage, contactsId);
require(ListView_GetItemCount(list) == 1, "case-insensitive contact search finds saved chat");
wchar_t appName[32]{};
ListView_GetItemText(list, 0, 1, appName, std::size(appName));
require(std::wstring(appName) == L"Telegram", "chat list shows the source app separately");
};
SetDlgItemTextW(dialog, 714, L"No matching fixture 8031");
require(ListView_GetItemCount(GetDlgItem(dialog, 710)) == 0 &&
!IsWindowEnabled(GetDlgItem(dialog, IDOK)), "empty search results disable profile actions");
findFixtureChat(dialog);
require(SendDlgItemMessageW(dialog, 711, LB_GETSELCOUNT, 0, 0) == 1, "saved single language selected");
RedrawWindow(dialog, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
RECT rect{}; GetClientRect(dialog, &rect);
HDC dc = GetDC(dialog);
auto selectChatLayouts = [&](bool select) {
const auto chatPage = settingsViewport(parent);
SendDlgItemMessageW(chatPage, layoutsId, LB_SETSEL, select, -1);
SendMessageW(chatPage, WM_COMMAND, MAKEWPARAM(layoutsId, LBN_SELCHANGE), 0);
};
SetDlgItemTextW(pane, searchContactsId, L"No matching fixture 8031");
require(ListView_GetItemCount(GetDlgItem(pane, contactsId)) == 0 &&
!IsWindowEnabled(GetDlgItem(pane, layoutsId)) &&
!IsWindowEnabled(GetDlgItem(pane, removeProfileId)), "empty search disables profile editing");
findFixtureChat();
require(SendDlgItemMessageW(pane, layoutsId, LB_GETSELCOUNT, 0, 0) == 1, "saved single language selected");
selectChatLayouts(false);
require(SendDlgItemMessageW(pane, layoutsId, LB_GETSELCOUNT, 0, 0) == 1 && !saveEnabled(),
"deselecting the last layout keeps the profile");
findFixtureChat();
RedrawWindow(parent, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
RECT rect{};
GetClientRect(parent, &rect);
HDC dc = GetDC(parent);
auto clip = ks::screenshotClip(dc, rect.right, rect.bottom, {});
ReleaseDC(dialog, dc);
ReleaseDC(parent, dc);
ks::atomicWrite(std::filesystem::path(ks::executable()).parent_path() / L"chat-languages.png",
ks::encodePng(ks::decodeImage(clip)));
SendDlgItemMessageW(dialog, 711, LB_SETSEL, TRUE, -1);
SendMessageW(dialog, WM_COMMAND, MAKEWPARAM(711, LBN_SELCHANGE), 0);
SendMessageW(dialog, WM_COMMAND, IDCANCEL, 0);
require(!IsWindow(dialog) && IsWindowEnabled(parent), "cancel closes dialog");
require(!saveEnabled(),"cancelled chat edits do not enable Save");
SendMessageW(parent, WM_COMMAND, 259, 0);
dialog = findTestWindow(L"KSwitcher.ChatLanguages", nullptr);
findFixtureChat(dialog);
require(SendDlgItemMessageW(dialog, 711, LB_GETSELCOUNT, 0, 0) == 1, "cancel discards language edits");
SendDlgItemMessageW(dialog, 711, LB_SETSEL, TRUE, -1);
SendMessageW(dialog, WM_COMMAND, MAKEWPARAM(711, LBN_SELCHANGE), 0);
SendMessageW(dialog, WM_COMMAND, IDOK, 0);
require(!IsWindow(dialog) && IsWindowEnabled(parent), "profile applies to settings draft");
require(saveEnabled() == (app.layouts.size()>1),"accepted chat edits refresh Save immediately");
selectChatLayouts(true);
require(saveEnabled() == (app.layouts.size() > 1) && saveEnabled() == applyEnabled(),
"editing a profile immediately refreshes Apply and Save");
require(app.settings.chatCycles.at(key).size() == 1, "inline editing leaves saved settings untouched");
selectSettingsPage(parent, 1);
selectSettingsPage(parent, chatLanguagesPage);
require(SendDlgItemMessageW(pane, layoutsId, LB_GETSELCOUNT, 0, 0) == static_cast<LRESULT>(app.layouts.size()),
"profile edits survive navigating away and returning");
selectSettingsPage(parent, 16);
SetDlgItemTextW(correction, 412, L"Релізик\r\nрелізик, словечко");
SetDlgItemTextW(correction, 416, L" HeLo = Hello\r\n");
@@ -1174,26 +1184,33 @@ int main(int argc,char **argv)
ks::showSettings(app);
parent = app.settingsWindow;
require(!saveEnabled(),"reopened saved Settings is clean");
SendMessageW(parent, WM_COMMAND, 259, 0);
dialog = findTestWindow(L"KSwitcher.ChatLanguages", nullptr);
findFixtureChat(dialog);
SendMessageW(dialog, WM_COMMAND, 713, 0);
require(IsWindow(dialog), "chat reset keeps dialog open");
SendMessageW(dialog, WM_COMMAND, IDOK, 0);
require(saveEnabled() && status().find(L"Unsaved settings")==0,"removing child profile immediately marks parent dirty");
RedrawWindow(parent,nullptr,nullptr,RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);
GetClientRect(parent,&rect); dc=GetDC(parent);
clip=ks::screenshotClip(dc,rect.right,rect.bottom,{}); ReleaseDC(parent,dc);
ks::atomicWrite(std::filesystem::path(ks::executable()).parent_path()/L"settings-unsaved.png",
selectSettingsPage(parent, chatLanguagesPage);
findFixtureChat();
const auto chatPage = settingsViewport(parent);
require(SendDlgItemMessageW(chatPage, layoutsId, LB_GETSELCOUNT, 0, 0) ==
static_cast<LRESULT>(app.layouts.size()), "reopening shows the saved profile");
SendMessageW(GetDlgItem(chatPage, removeProfileId), BM_CLICK, 0, 0);
require(saveEnabled() && applyEnabled() && status().starts_with(L"Unsaved settings"),
"removing a profile immediately marks Settings dirty");
RedrawWindow(parent, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
GetClientRect(parent, &rect);
dc = GetDC(parent);
clip = ks::screenshotClip(dc, rect.right, rect.bottom, {});
ReleaseDC(parent, dc);
ks::atomicWrite(std::filesystem::path(ks::executable()).parent_path() / L"settings-unsaved.png",
ks::encodePng(ks::decodeImage(clip)));
SendMessageW(parent, WM_COMMAND, IDOK, 0);
require(!app.settings.chatCycles.contains(key), "remove profile restores default");
SendMessageW(parent, WM_COMMAND, SettingsApply, 0);
require(IsWindow(parent) && !saveEnabled() && !applyEnabled() &&
!app.settings.chatCycles.contains(key) &&
!ks::loadSettings(root / L"settings.json", app.layouts).chatCycles.contains(key),
"Apply restores the default, saves the removal and keeps Settings open");
SendMessageW(parent, WM_COMMAND, IDCANCEL, 0);
// Existing shared sets become independent application drafts on edit.
app.settings.appLanguageSets[L"Legacy shared"] = {{app.layouts[0].id}, {L"Codex.exe", L"notepad"}};
ks::showSettings(app);
parent = app.settingsWindow;
SendMessageW(parent, WM_COMMAND, 263, 0);
dialog = findTestWindow(L"KSwitcher.AppLanguages", nullptr);
HWND dialog = findTestWindow(L"KSwitcher.AppLanguages", nullptr);
require(dialog && !IsWindowEnabled(parent), "application language editor opens");
auto selectApp = [&](const wchar_t *name) {
int index = (int)SendDlgItemMessageW(dialog, 720, LB_FINDSTRINGEXACT, -1, (LPARAM)name);
+36 -1
View File
@@ -67,6 +67,29 @@ function Test-Pixel($Image, $Bounds, $X, $Y, $Expected, $Description) {
}
}
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)) }
@@ -197,12 +220,15 @@ try {
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))
$rightPath = Get-Bounds ([LavenderWindow]::GetDlgItem($window, 143))
$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'
@@ -217,6 +243,15 @@ try {
}
} 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'
+1 -1
View File
@@ -1138,7 +1138,7 @@ int main(int argc, char **argv) {
auto events = GetDlgItem(pane, 733);
auto visible = [&](int id) { return (GetWindowLongPtrW(GetDlgItem(pane, id), GWL_STYLE) & WS_VISIBLE) != 0; };
auto selectPage = [&](int index) { selectSettingsPage(settings, index); };
require(TreeView_GetCount(navigation) == 20, "all Settings sections are listed");
require(TreeView_GetCount(navigation) == 21, "all Settings sections are listed");
selectPage(3);
require(visible(243) && !visible(501), "Clipboard lists excluded apps separately from OCR");
require(TreeView_GetParent(navigation, settingsSection(navigation, 19)) == settingsSection(navigation, 3),
+4 -3
View File
@@ -67,9 +67,10 @@ void chooseInputAction(HWND resident, DWORD pid, const wchar_t *expected)
}
}
require(donationSeparated && donation.hbmpItem, "tray donation item has an icon and both separators");
require(help && GetMenuItemCount(help) == 2 && menuTitle(help, 0) == L"&User guide" &&
menuTitle(help, 1) == L"&About KSwitcher",
"tray Help submenu contains User guide and About KSwitcher");
require(help && GetMenuItemCount(help) == 3 && menuTitle(help, 0) == L"&User guide" &&
menuTitle(help, 1) == ks::whatsNewTitle(GetThreadUILanguage()) &&
menuTitle(help, 2) == L"&About KSwitcher",
"tray Help submenu contains User guide, release notes and About KSwitcher");
require(PostMessageW(popup, WM_CHAR, L'i', 0), "cannot select input menu item");
until([&] { return !IsWindow(popup); }, "tray action did not close menu");
query(resident, WM_NULL);
+36
View File
@@ -228,6 +228,42 @@ void verifyFiles(LanClients &clients, const Json &trusted, const std::wstring &p
require(runTransfer(pipe, transfer(endpoint(a, src), endpoint(b, to), false, "replace")).at("type") == "complete" &&
read(to / L"content.txt") == content, "replace conflict policy failed");
const auto ask = [&](const char *decision, bool replaceable) {
Pipe client(pipe, transfer(endpoint(a, src), endpoint(b, to), false, "ask"));
unsigned prompts = 0;
for (;;)
{
auto result = client.reply();
const auto type = result.value("type", "");
if (type == "progress") client.sendJson({{"continue", true}});
else if (type == "conflict")
{
++prompts;
require(result.at("path") == utf8((to / L"content.txt").native()) &&
result.at("replaceable") == replaceable &&
result.at("incoming").at("size") == content.size(), "incorrect conflict prompt");
client.sendJson({{"decision", "wait"}});
client.sendJson({{"decision", decision}});
}
else
{
client.ack();
require(prompts == 1, "ask did not report the nested collision exactly once");
return result;
}
}
};
save(to / L"content.txt", "keep me");
require(ask("skip", true).at("skipped") == 1 && read(to / L"content.txt") == "keep me",
"skipping a prompted collision changed its destination");
require(ask("replace", true).at("type") == "complete" && read(to / L"content.txt") == content,
"confirming a prompted collision did not replace its destination");
fs::remove(to / L"content.txt");
fs::create_directory(to / L"content.txt");
require(ask("replace", false).contains("error") && fs::is_directory(to / L"content.txt"),
"a prompted type mismatch allowed replacement");
fs::remove(to / L"content.txt");
const auto localCopy = root / L"local.txt";
const auto fromLocal = transfer(endpoint(nullptr, file), endpoint(b, dst / L"from-local.txt"), false);
require(runTransfer(pipe, fromLocal).contains("error"), "identification-only pipe accessed local files");