Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53842935a7 |
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(KSwitcher VERSION 0.6.123 LANGUAGES CXX RC)
|
||||
project(KSwitcher VERSION 0.6.124 LANGUAGES CXX RC)
|
||||
if(NOT WIN32)
|
||||
message(FATAL_ERROR "KSwitcher uses native Windows APIs")
|
||||
endif()
|
||||
|
||||
@@ -493,6 +493,22 @@ ChatGPT and Codex desktop editors use paced selection for snippet triggers. If o
|
||||
|
||||
**Українською.** У настільних ChatGPT і Codex тригер виділяється з паузами між натисканнями. Якщо виділилася лише перевірена кінцева частина, KSwitcher доповнює виділення й перевіряє весь тригер перед заміною. Інший текст або зміна фокусу скасовують операцію. Тригери розпізнаються в різних розкладках. Один сніпет можна прив’язати до кількох програм через **Add app** або назви процесів через кому; ці прив’язки вже підтримують синхронізацію.
|
||||
|
||||
### Snippet macros
|
||||
|
||||
In **Settings → Snippets**, type macros into a snippet's replacement text. **Macro help…** sits beside the marker buttons below the editor, with **Save snippets** at the right. KSwitcher inserts and verifies the text, places `{cursor}`, then runs macros in the order written. A snippet needs some replacement text.
|
||||
|
||||
- `{{shift}}`, `{{alt}}` and `{{tab}}` tap individual keys. Key names are case-insensitive. Letters, digits, `F1`–`F24`, navigation and editing keys also work.
|
||||
- `{{altr}}+{{ctrl}}` holds both keys together. Join key markers with `+` without spaces and put modifiers before the final key, as in `{{ctrl}}+{{shift}}+{{A}}`. Use `l` or `r` after `ctrl`, `alt`, `shift` or `win` to select a side. The unsuffixed names use the left keys.
|
||||
- `rider .{pause:50}{enter}` inserts `rider .`, waits 50 milliseconds, then presses Enter. One pause can be 0–10,000 milliseconds. Use `{{return}}` for Enter inside a chord, as in `{{ctrl}}+{{return}}`.
|
||||
- Write `{{cursor}}`, `{{enter}}`, `{{pause:50}}` or `{{{shift}}}` to insert the corresponding marker literally.
|
||||
|
||||
**Українською.** Додавай макроси в текст заміни в **Settings → Snippets**. **Macro help…** розташована поруч із кнопками маркерів під редактором, а **Save snippets** — праворуч. KSwitcher вставляє й перевіряє текст, встановлює курсор за `{cursor}`, а далі виконує макроси в порядку запису. Сніпет має містити текст заміни.
|
||||
|
||||
- `{{shift}}`, `{{alt}}` і `{{tab}}` натискають окремі клавіші. Регістр назви клавіші не має значення. Також підтримуються літери, цифри, `F1`–`F24`, клавіші навігації та редагування.
|
||||
- `{{altr}}+{{ctrl}}` затискає обидві клавіші разом. З’єднуй маркери знаком `+` без пробілів і став модифікатори перед основною клавішею, як у `{{ctrl}}+{{shift}}+{{A}}`. Суфікси `l` і `r` у назвах `ctrl`, `alt`, `shift` і `win` вибирають ліву й праву клавіші. Без суфікса використовується ліва.
|
||||
- `rider .{pause:50}{enter}` вставляє `rider .`, чекає 50 мілісекунд і натискає Enter. Допустимий діапазон однієї паузи — від 0 до 10 000 мілісекунд. Для Enter у комбінації використовуй `{{return}}`, наприклад `{{ctrl}}+{{return}}`.
|
||||
- Записуй `{{cursor}}`, `{{enter}}`, `{{pause:50}}` або `{{{shift}}}`, щоб вставити відповідний маркер як звичайний текст.
|
||||
|
||||
### Application-specific snippets — v0.6.51
|
||||
|
||||
In **Settings → Snippets**, select a snippet and enable **Only in these applications**. Enter executable names separated by commas, or select a currently open application's process and choose **Add app**. For example: `ms-teams.exe, outlook.exe`. Uncheck the option for a global snippet. A checked but empty restriction cannot be saved. Use **Save snippets** to apply the changes.
|
||||
@@ -518,12 +534,12 @@ Scopes are saved with snippets and included in manual import/export and synchron
|
||||
editor selection metadata remain identical. Unobserved or altered foreign copies are rejected.
|
||||
Snippets normally require accessibility verification of their selected trigger and pasted text,
|
||||
even with logging disabled. If verification is unavailable or the paste differs, expansion
|
||||
stops without running cursor or Enter actions. Clipboard changes during paste also cancel actions.
|
||||
stops before placing the cursor or running key actions. Clipboard changes during paste also cancel actions.
|
||||
Far Manager uses its native Alt+Shift+Arrow selection, Ctrl+Insert copy and Shift+Insert
|
||||
paste commands instead: both the trigger and inserted text must match verified clipboard
|
||||
copies from Far. Cancellation restores the full temporary selection, not one cursor step.
|
||||
Far supports nonempty single-line replacements up to 4096 caret steps, including
|
||||
`{cursor}` and verified `{enter}` actions. Empty or multiline replacements are rejected
|
||||
`{cursor}` and key macros after verification. Empty or multiline replacements are rejected
|
||||
before selection; pasting a newline could execute a command before it can be verified.
|
||||
- Teams recent-word conversion uses a single word-selection command and validates the copied range.
|
||||
If the editor's word boundary differs from the recorded typing, it falls back to paced character
|
||||
@@ -540,12 +556,10 @@ Scopes are saved with snippets and included in manual import/export and synchron
|
||||
repeat-conversion state and does not switch the Windows layout.
|
||||
- Case cycling, Russian/Ukrainian transliteration, verified undo and repeated conversion.
|
||||
- Text snippets across layouts, multiline insertion and a verified `{cursor}` position;
|
||||
`{enter}` presses Enter after insertion and cursor placement (once per marker), before buffered typing resumes.
|
||||
For example, `rider .{enter}` inserts `rider .` and presses Enter.
|
||||
after insertion and cursor placement, macros run in the order written, before buffered typing resumes.
|
||||
Automatic correction is suppressed during snippet expansion and for typing buffered by that expansion; the global setting is preserved.
|
||||
If the trigger cannot be verified after the copy attempts, it is preserved, queued typing resumes,
|
||||
and no Enter action is sent.
|
||||
`{{cursor}}` and `{{enter}}` insert literal markers. Snippets are stored as plaintext settings, as in [Typlo](https://github.com/bitcodepro/Typlo).
|
||||
and no key actions are sent. Snippets are stored as plaintext settings, as in [Typlo](https://github.com/bitcodepro/Typlo).
|
||||
- Clipboard history for text, HTML/RTF, file lists, DIB and PNG images; plain-text paste;
|
||||
full-text search, pinning, deletion, full text viewing and image previews.
|
||||
- Image thumbnails and text/file icons appear directly in the history list. Only visible rows
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# Latest Windows release
|
||||
|
||||
## v0.6.124 — 2026-11-21
|
||||
|
||||
Snippets can tap keys such as `{{shift}}`, hold combinations such as `{{altr}}+{{ctrl}}`, and wait with `{pause:50}`. After verifying the inserted text and placing `{cursor}`, KSwitcher runs the macros in order. The Snippets tab groups marker buttons and **Macro help…** below the editor, with **Save snippets** at the right.
|
||||
|
||||
**Українською.**
|
||||
|
||||
Сніпети підтримують окремі клавіші, як-от `{{shift}}`, комбінації на кшталт `{{altr}}+{{ctrl}}` і паузи, як-от `{pause:50}` на 50 мс. KSwitcher виконує макроси за порядком запису після перевірки вставленого тексту й встановлення `{cursor}`. На вкладці **Snippets** кнопки маркерів і **Macro help…** згруповані під редактором, а **Save snippets** розташована праворуч.
|
||||
|
||||
## v0.6.123 — 2026-11-20
|
||||
|
||||
- The tray shows a steady gray dot when all paired PCs are offline. The amber dot pulses while a discovered PC is connecting. Green means every online paired PC is connected.
|
||||
|
||||
@@ -1 +1 @@
|
||||
868941978ca231f3df01917277d8ec5b8de970c81f6b83b5fa9e64b18b71ab9a KSwitcher-win-x64.zip
|
||||
17a584b5de09496bdfe7b1cd74e991b7a0e44f46198b4db72c241600df8643c9 KSwitcher-win-x64.zip
|
||||
+71
-71
@@ -1,166 +1,166 @@
|
||||
{
|
||||
"version": "0.6.124",
|
||||
"schema": 1,
|
||||
"version": "0.6.123",
|
||||
"files": [
|
||||
{
|
||||
"size": 5892884,
|
||||
"sha256": "043c10eb6752656fc2aa6c1f8d329d4fe243347a5275088e5dc4385638acd870",
|
||||
"path": "KSwitcher.exe"
|
||||
"size": 2489344,
|
||||
"path": "KSwitcher.exe",
|
||||
"sha256": "3a5537b81043a0bdbd6dc1b9c4c4b12ca538daf3a36c22c58a3d84b53c9929b7"
|
||||
},
|
||||
{
|
||||
"size": 5948997,
|
||||
"sha256": "ac6368858b86d4e9a4a2c1cf4cd90c39b58d699909c417f73d9f882c54dd96a0",
|
||||
"path": "KSwitcher.Config.exe"
|
||||
"size": 2463232,
|
||||
"path": "KSwitcher.Config.exe",
|
||||
"sha256": "220e722f5c09198c7392f10137c2bcc001b2f6f67776ebaf3291baf4d15144cc"
|
||||
},
|
||||
{
|
||||
"size": 5763947,
|
||||
"sha256": "d2f435c645419a155e6feac7761d9894f7bd2099cd695a93650847c869c50ffb",
|
||||
"path": "KSwitcher.Screenshot.exe"
|
||||
"size": 3064320,
|
||||
"path": "KSwitcher.Screenshot.exe",
|
||||
"sha256": "b706ff989e918053a62b49fc2c438293ea17b33c6e3f695be6deb1ac4e13bc44"
|
||||
},
|
||||
{
|
||||
"size": 9395313,
|
||||
"sha256": "43512aa25c8b9854cb3134b9480e24049eab77a0008af55cede06369dc6a0964",
|
||||
"path": "KSwitcher.Files.exe"
|
||||
"size": 4377088,
|
||||
"path": "KSwitcher.Files.exe",
|
||||
"sha256": "384c88517a5ab3c7db09cc737dc31d009a4fdf01a929d05e93869ddb22c5abd2"
|
||||
},
|
||||
{
|
||||
"size": 194912,
|
||||
"sha256": "d3fce90bdeecb08596e377dea6a316354dd8949e32ff09b89d51be00c14e21b6",
|
||||
"path": "WebView2Loader.dll"
|
||||
"path": "WebView2Loader.dll",
|
||||
"sha256": "d3fce90bdeecb08596e377dea6a316354dd8949e32ff09b89d51be00c14e21b6"
|
||||
},
|
||||
{
|
||||
"size": 1103,
|
||||
"sha256": "e256f01188af527e4d06d21d06fbf785ae9c50d4b328bf03cbe0ba7f0aa4228f",
|
||||
"path": "terminal/addon-fit-LICENSE.txt"
|
||||
"path": "terminal/addon-fit-LICENSE.txt",
|
||||
"sha256": "e256f01188af527e4d06d21d06fbf785ae9c50d4b328bf03cbe0ba7f0aa4228f"
|
||||
},
|
||||
{
|
||||
"size": 1521,
|
||||
"sha256": "ba3ea256ce0620a0992a197d6c9baea64823fc93d8da07a9e366ca9943c18527",
|
||||
"path": "terminal/addon-fit.js"
|
||||
"path": "terminal/addon-fit.js",
|
||||
"sha256": "ba3ea256ce0620a0992a197d6c9baea64823fc93d8da07a9e366ca9943c18527"
|
||||
},
|
||||
{
|
||||
"size": 527,
|
||||
"sha256": "084d97a727b778fb10d31adcd557ee7840a38377ed60e0ef0f3ece93b349b1ef",
|
||||
"path": "terminal/index.html"
|
||||
"path": "terminal/index.html",
|
||||
"sha256": "084d97a727b778fb10d31adcd557ee7840a38377ed60e0ef0f3ece93b349b1ef"
|
||||
},
|
||||
{
|
||||
"size": 1073,
|
||||
"sha256": "792c48c5a849a15fdf9e37e8bcf9e6d1dd13b32b46c642a748a0a46a9919d473",
|
||||
"path": "terminal/markdown-it-LICENSE.txt"
|
||||
"path": "terminal/markdown-it-LICENSE.txt",
|
||||
"sha256": "792c48c5a849a15fdf9e37e8bcf9e6d1dd13b32b46c642a748a0a46a9919d473"
|
||||
},
|
||||
{
|
||||
"size": 100786,
|
||||
"sha256": "391f2aa638e75e6c7859d0a5c5650ef0956722a45998f17e05b83bc655778e1e",
|
||||
"path": "terminal/markdown-it.js"
|
||||
"path": "terminal/markdown-it.js",
|
||||
"sha256": "391f2aa638e75e6c7859d0a5c5650ef0956722a45998f17e05b83bc655778e1e"
|
||||
},
|
||||
{
|
||||
"size": 3599,
|
||||
"sha256": "b83ae50c2ada2aa6efcb02016ab54461fc9de5653111f976a51945ee0afd2094",
|
||||
"path": "terminal/markdown.html"
|
||||
"path": "terminal/markdown.html",
|
||||
"sha256": "b83ae50c2ada2aa6efcb02016ab54461fc9de5653111f976a51945ee0afd2094"
|
||||
},
|
||||
{
|
||||
"size": 17575,
|
||||
"sha256": "9a48dc026dbd3970a88c34775836534d795b90765a381fce3f2a7be9640d44c8",
|
||||
"path": "terminal/markdown.js"
|
||||
"path": "terminal/markdown.js",
|
||||
"sha256": "9a48dc026dbd3970a88c34775836534d795b90765a381fce3f2a7be9640d44c8"
|
||||
},
|
||||
{
|
||||
"size": 1089,
|
||||
"sha256": "ec9fb67dcb25eccc416ed56e1aab819222c805a2a4bfe4cb19e7556bf2ffde80",
|
||||
"path": "terminal/mermaid-LICENSE.txt"
|
||||
"path": "terminal/mermaid-LICENSE.txt",
|
||||
"sha256": "ec9fb67dcb25eccc416ed56e1aab819222c805a2a4bfe4cb19e7556bf2ffde80"
|
||||
},
|
||||
{
|
||||
"size": 5537838,
|
||||
"sha256": "336df803d87a38b70a01e736e666c8f7601d2ce42f5e47c8fafe5d721074b9a3",
|
||||
"path": "terminal/mermaid.js"
|
||||
"path": "terminal/mermaid.js",
|
||||
"sha256": "336df803d87a38b70a01e736e666c8f7601d2ce42f5e47c8fafe5d721074b9a3"
|
||||
},
|
||||
{
|
||||
"size": 5065,
|
||||
"sha256": "8268049507da54079422db2b4d90b41cd0a1e99b5946b675173ea3543de27f0b",
|
||||
"path": "terminal/terminal.js"
|
||||
"path": "terminal/terminal.js",
|
||||
"sha256": "8268049507da54079422db2b4d90b41cd0a1e99b5946b675173ea3543de27f0b"
|
||||
},
|
||||
{
|
||||
"size": 1261,
|
||||
"sha256": "b569f629d00f2626a8100df2a1798210535621e42164dfd426a6fe5aac7b0ccd",
|
||||
"path": "terminal/xterm-LICENSE.txt"
|
||||
"path": "terminal/xterm-LICENSE.txt",
|
||||
"sha256": "b569f629d00f2626a8100df2a1798210535621e42164dfd426a6fe5aac7b0ccd"
|
||||
},
|
||||
{
|
||||
"size": 7112,
|
||||
"sha256": "854a7c0fb70e8b1a083c16797ab827299fb18744f5ad34f227b48337e33293c6",
|
||||
"path": "terminal/xterm.css"
|
||||
"path": "terminal/xterm.css",
|
||||
"sha256": "854a7c0fb70e8b1a083c16797ab827299fb18744f5ad34f227b48337e33293c6"
|
||||
},
|
||||
{
|
||||
"size": 488663,
|
||||
"sha256": "14903579ff54664cd72f8e8699e6961a6272c21863ec1c3b118cdc8af5d4a972",
|
||||
"path": "terminal/xterm.js"
|
||||
"path": "terminal/xterm.js",
|
||||
"sha256": "14903579ff54664cd72f8e8699e6961a6272c21863ec1c3b118cdc8af5d4a972"
|
||||
},
|
||||
{
|
||||
"size": 4401,
|
||||
"sha256": "d3c81140cce01c26bf6cbf52aa40e0825e1fa35b9a91d1387170a65d2597082c",
|
||||
"path": "LICENSE"
|
||||
"path": "LICENSE",
|
||||
"sha256": "d3c81140cce01c26bf6cbf52aa40e0825e1fa35b9a91d1387170a65d2597082c"
|
||||
},
|
||||
{
|
||||
"size": 1096,
|
||||
"sha256": "61e08da79c44061654015ce6b0c4061c23ee1dd18237fbf09e9bfda3c0ea2831",
|
||||
"path": "json-LICENSE.txt"
|
||||
"path": "json-LICENSE.txt",
|
||||
"sha256": "61e08da79c44061654015ce6b0c4061c23ee1dd18237fbf09e9bfda3c0ea2831"
|
||||
},
|
||||
{
|
||||
"size": 883,
|
||||
"sha256": "185c5a37521316e940ead89cbf0b1ba5862d810c7c966e6c6a14a4a515b23625",
|
||||
"path": "files-text-license.txt"
|
||||
"path": "files-text-license.txt",
|
||||
"sha256": "185c5a37521316e940ead89cbf0b1ba5862d810c7c966e6c6a14a4a515b23625"
|
||||
},
|
||||
{
|
||||
"size": 95524,
|
||||
"sha256": "23d203a1fe73d1adc5e51d088420848cfabf03929401b78c4dbb249d0b5bdbf6",
|
||||
"path": "README.md"
|
||||
"size": 98328,
|
||||
"path": "README.md",
|
||||
"sha256": "c9a6911afe36f3183077d179d3e560b989f182548a7aa7f62108da0a63097f12"
|
||||
},
|
||||
{
|
||||
"size": 12353,
|
||||
"sha256": "3ab51025826e8aa2f7c07b70b920b556409b002029b4bb92cb34c5b32dac6e54",
|
||||
"path": "LAN-PREVIEW.md"
|
||||
"path": "LAN-PREVIEW.md",
|
||||
"sha256": "3ab51025826e8aa2f7c07b70b920b556409b002029b4bb92cb34c5b32dac6e54"
|
||||
},
|
||||
{
|
||||
"size": 732485,
|
||||
"sha256": "d0c022b27b9fbc2ff7b6b8bec723cc1adc4eef517202f9ff77eed5d8bea3acb9",
|
||||
"path": "dictionaries/en.txt"
|
||||
"path": "dictionaries/en.txt",
|
||||
"sha256": "d0c022b27b9fbc2ff7b6b8bec723cc1adc4eef517202f9ff77eed5d8bea3acb9"
|
||||
},
|
||||
{
|
||||
"size": 20566,
|
||||
"sha256": "0bdfb0201d1803634f268cdff0993b8349d2c70e956a06dbb667c8dd65254ec5",
|
||||
"path": "dictionaries/LICENSE-CC-BY-SA-4.0.txt"
|
||||
"path": "dictionaries/LICENSE-CC-BY-SA-4.0.txt",
|
||||
"sha256": "0bdfb0201d1803634f268cdff0993b8349d2c70e956a06dbb667c8dd65254ec5"
|
||||
},
|
||||
{
|
||||
"size": 2265,
|
||||
"sha256": "3017bf44d3be9d9dfab21bd6778aa52b7947e61acf9ce2bc86b41d6e949ac311",
|
||||
"path": "dictionaries/README.md"
|
||||
"path": "dictionaries/README.md",
|
||||
"sha256": "3017bf44d3be9d9dfab21bd6778aa52b7947e61acf9ce2bc86b41d6e949ac311"
|
||||
},
|
||||
{
|
||||
"size": 1109134,
|
||||
"sha256": "80e6b6a27815973535f7facb636c597eb845dfee45cfabfc4e9b3341b9332849",
|
||||
"path": "dictionaries/ru.txt"
|
||||
"path": "dictionaries/ru.txt",
|
||||
"sha256": "80e6b6a27815973535f7facb636c597eb845dfee45cfabfc4e9b3341b9332849"
|
||||
},
|
||||
{
|
||||
"size": 1280,
|
||||
"sha256": "98e5b3fe7304e37705c9e5ff48b0b399ccb16e806736d21f09921b99e5f2a408",
|
||||
"path": "dictionaries/sources.json"
|
||||
"path": "dictionaries/sources.json",
|
||||
"sha256": "98e5b3fe7304e37705c9e5ff48b0b399ccb16e806736d21f09921b99e5f2a408"
|
||||
},
|
||||
{
|
||||
"size": 940799,
|
||||
"sha256": "d30e990d6ec2983c04f3644a3c61c6c668e8c542323f5931916fdd55b916eebf",
|
||||
"path": "dictionaries/uk.txt"
|
||||
"path": "dictionaries/uk.txt",
|
||||
"sha256": "d30e990d6ec2983c04f3644a3c61c6c668e8c542323f5931916fdd55b916eebf"
|
||||
},
|
||||
{
|
||||
"size": 993,
|
||||
"sha256": "a34b5161a8315af037e1ec71d816bfc688f7c364141d4ee2347cf0515ef0c82a",
|
||||
"path": "tools/README.txt"
|
||||
"path": "tools/README.txt",
|
||||
"sha256": "a34b5161a8315af037e1ec71d816bfc688f7c364141d4ee2347cf0515ef0c82a"
|
||||
},
|
||||
{
|
||||
"size": 540583,
|
||||
"sha256": "bb595202cc4749f3c0fe47adc92d4b02a174abeb5765e493673de9f5e070251c",
|
||||
"path": "tools/StayHere.exe"
|
||||
"size": 133120,
|
||||
"path": "tools/StayHere.exe",
|
||||
"sha256": "79a80ed066e8c1301ec0b22d63bd5590c5477feea4d59e65cf29deac86195149"
|
||||
},
|
||||
{
|
||||
"size": 2796,
|
||||
"sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413",
|
||||
"path": "tools/StayHere-README.md"
|
||||
"path": "tools/StayHere-README.md",
|
||||
"sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413"
|
||||
}
|
||||
]
|
||||
}
|
||||
+3
-3
@@ -9,8 +9,8 @@ IDC_SCREENSHOT_PENCIL CURSOR "icons/lucide/pencil.cur"
|
||||
1 RT_MANIFEST "app.manifest"
|
||||
201 RCDATA "update.ps1"
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 0,6,123,0
|
||||
PRODUCTVERSION 0,6,123,0
|
||||
FILEVERSION 0,6,124,0
|
||||
PRODUCTVERSION 0,6,124,0
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_APP
|
||||
BEGIN
|
||||
@@ -20,7 +20,7 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "FileDescription", "KSwitcher — native keyboard and clipboard utility"
|
||||
VALUE "ProductName", "KSwitcher"
|
||||
VALUE "FileVersion", "0.6.123"
|
||||
VALUE "FileVersion", "0.6.124"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
+39
-14
@@ -300,9 +300,7 @@ class Transaction
|
||||
if (captured && clipboardModified && GetClipboardSequenceNumber() == expected)
|
||||
try
|
||||
{
|
||||
auto started = GetTickCount64();
|
||||
app.ownSequence = snapshot.restore(app.window, expected);
|
||||
diagnosticEvent(L"Clipboard snapshot restored: elapsedMs=" + std::to_wstring(GetTickCount64() - started));
|
||||
restoreClipboard();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -347,6 +345,13 @@ class Transaction
|
||||
expected = now;
|
||||
}
|
||||
}
|
||||
void restoreClipboard()
|
||||
{
|
||||
const auto started = GetTickCount64();
|
||||
clipboardModified = false;
|
||||
app.ownSequence = snapshot.restore(app.window, expected);
|
||||
diagnosticEvent(L"Clipboard snapshot restored: elapsedMs=" + std::to_wstring(GetTickCount64() - started));
|
||||
}
|
||||
void write(const Clip &c)
|
||||
{
|
||||
check();
|
||||
@@ -1400,7 +1405,7 @@ bool App::queueSnippet(HWND target, size_t index, size_t length, HWND editor)
|
||||
typingTarget = target;
|
||||
snippetPending = static_cast<int>(index);
|
||||
snippetPendingLength = length;
|
||||
snippetPendingEditor = editor;
|
||||
snippetPendingEditor = editor ? editor : snippetGuiInfo(target).hwndFocus;
|
||||
snippetTyping = true;
|
||||
busy = true;
|
||||
if (PostMessageW(window, SnippetMessage, index, static_cast<LPARAM>(inputVersion.load())))
|
||||
@@ -2439,6 +2444,7 @@ void App::transform(int command, int snippet, size_t snippetLength, HWND snippet
|
||||
std::to_wstring(recent.at ? start - recent.at : 0) +
|
||||
L" id=" + std::to_wstring(attempt));
|
||||
bool automatic = false;
|
||||
Template snippetTemplate;
|
||||
if (command == AutoCorrect)
|
||||
{
|
||||
// The editor must select the complete previous word. Unlike manual
|
||||
@@ -2511,9 +2517,10 @@ void App::transform(int command, int snippet, size_t snippetLength, HWND snippet
|
||||
const auto length = snippetLength ? snippetLength : sn.trigger.size();
|
||||
if (recent.keys.size() < length)
|
||||
return;
|
||||
result = parseTemplate(sn.text).text;
|
||||
snippetTemplate = parseTemplate(sn.text);
|
||||
result = std::move(snippetTemplate.text);
|
||||
// A multiline clipboard paste can execute a console command
|
||||
// before readback. Only explicit, verified {enter} may do so.
|
||||
// before readback. Explicit key actions run after verification.
|
||||
if (farSnippet && (result.empty() || result.find_first_of(L"\r\n") != result.npos ||
|
||||
caretSteps(result) > 4096))
|
||||
{
|
||||
@@ -2746,25 +2753,43 @@ void App::transform(int command, int snippet, size_t snippetLength, HWND snippet
|
||||
if (snippet >= 0 && sent && tx.valid())
|
||||
{
|
||||
tx.check();
|
||||
auto t = parseTemplate(config.snippets[snippet].text);
|
||||
if (!t.suffix.empty())
|
||||
if (!snippetTemplate.suffix.empty())
|
||||
{
|
||||
if (!tx.select(caretSteps(t.suffix))) return;
|
||||
if (!tx.select(caretSteps(snippetTemplate.suffix))) return;
|
||||
auto suffix = tx.copy();
|
||||
if (!tx.valid()) return;
|
||||
if (newlines(suffix) != newlines(t.suffix))
|
||||
if (newlines(suffix) != newlines(snippetTemplate.suffix))
|
||||
{
|
||||
tx.finishSelection(false);
|
||||
return;
|
||||
}
|
||||
if (!tx.finishSelection(true)) return;
|
||||
}
|
||||
// Action markers run after insertion and cursor placement,
|
||||
// before any physical typing buffered during expansion.
|
||||
for (int i = 0; i < t.enters && tx.valid(); ++i)
|
||||
if (!snippetTemplate.actions.empty() && tx.valid())
|
||||
{
|
||||
tx.check();
|
||||
if (!chord(VK_RETURN)) break;
|
||||
// Clipboard shortcuts must see the user's clipboard, and
|
||||
// any copies they make must survive the transaction.
|
||||
tx.restoreClipboard();
|
||||
suspended = false;
|
||||
}
|
||||
for (const auto &action : snippetTemplate.actions)
|
||||
{
|
||||
if (!tx.valid()) return;
|
||||
if (const auto *keys = std::get_if<std::vector<WORD>>(&action))
|
||||
{
|
||||
if (!chord(*keys))
|
||||
throw std::runtime_error("Windows could not send all snippet keys");
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto deadline = GetTickCount64() + std::get<DWORD>(action);
|
||||
for (auto now = GetTickCount64(); now < deadline; now = GetTickCount64())
|
||||
{
|
||||
if (!tx.valid()) return;
|
||||
Sleep(static_cast<DWORD>(std::min<ULONGLONG>(deadline - now, 15)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (to >= 0 && config.switchLayout && tx.valid() && (sent || result == text))
|
||||
|
||||
+115
-60
@@ -319,40 +319,6 @@ std::wstring transliterate(const std::wstring &text)
|
||||
}
|
||||
return out;
|
||||
}
|
||||
Template parseTemplate(const std::wstring &text)
|
||||
{
|
||||
Template t;
|
||||
size_t cursor = std::wstring::npos;
|
||||
for (size_t i = 0; i < text.size();)
|
||||
{
|
||||
if (text.compare(i, 9, L"{{enter}}") == 0)
|
||||
{
|
||||
t.text += L"{enter}";
|
||||
i += 9;
|
||||
}
|
||||
else if (text.compare(i, 7, L"{enter}") == 0)
|
||||
{
|
||||
++t.enters;
|
||||
i += 7;
|
||||
}
|
||||
else if (text.compare(i, 10, L"{{cursor}}\0", 10) == 0)
|
||||
{
|
||||
t.text += L"{cursor}";
|
||||
i += 10;
|
||||
}
|
||||
else if (text.compare(i, 8, L"{cursor}") == 0)
|
||||
{
|
||||
cursor = t.text.size();
|
||||
++t.cursors;
|
||||
i += 8;
|
||||
}
|
||||
else
|
||||
t.text += text[i++];
|
||||
}
|
||||
if (cursor != text.npos)
|
||||
t.suffix = t.text.substr(cursor);
|
||||
return t;
|
||||
}
|
||||
namespace
|
||||
{
|
||||
const std::vector<std::pair<UINT, std::wstring>> &namedKeys()
|
||||
@@ -377,7 +343,121 @@ const std::vector<std::pair<UINT, std::wstring>> &namedKeys()
|
||||
{VK_DIVIDE, L"Divide"}, {VK_DECIMAL, L"Decimal"}};
|
||||
return names;
|
||||
}
|
||||
WORD namedKey(const std::wstring &token)
|
||||
{
|
||||
if (token.size() == 1 && ((token[0] >= L'a' && token[0] <= L'z') || iswdigit(token[0])))
|
||||
return upper(token)[0];
|
||||
if (token.size() == 4 && token.starts_with(L"num") && token[3] >= L'0' && token[3] <= L'9')
|
||||
return VK_NUMPAD0 + token[3] - L'0';
|
||||
if (token.size() >= 2 && token[0] == L'f')
|
||||
{
|
||||
wchar_t *tail{};
|
||||
long n = wcstol(token.c_str() + 1, &tail, 10);
|
||||
if (!*tail && n >= 1 && n <= 24) return static_cast<WORD>(VK_F1 + n - 1);
|
||||
return 0;
|
||||
}
|
||||
for (const auto &[key, name] : namedKeys())
|
||||
if (lower(name) == token) return static_cast<WORD>(key);
|
||||
return 0;
|
||||
}
|
||||
WORD snippetKey(std::wstring_view name)
|
||||
{
|
||||
const auto token = lower(std::wstring(name));
|
||||
static constexpr std::pair<std::wstring_view, WORD> modifiers[] = {
|
||||
{L"shift", VK_LSHIFT}, {L"shiftl", VK_LSHIFT}, {L"shiftr", VK_RSHIFT},
|
||||
{L"ctrl", VK_LCONTROL}, {L"ctrll", VK_LCONTROL}, {L"ctrlr", VK_RCONTROL},
|
||||
{L"alt", VK_LMENU}, {L"altl", VK_LMENU}, {L"altr", VK_RMENU},
|
||||
{L"win", VK_LWIN}, {L"winl", VK_LWIN}, {L"winr", VK_RWIN}};
|
||||
for (const auto &[label, key] : modifiers)
|
||||
if (label == token) return key;
|
||||
if (token == L"return") return VK_RETURN;
|
||||
// The old double-braced Enter marker is still an escape.
|
||||
return token == L"enter" ? 0 : namedKey(token);
|
||||
}
|
||||
struct SnippetMarker
|
||||
{
|
||||
std::wstring_view name;
|
||||
size_t length, depth;
|
||||
};
|
||||
std::optional<SnippetMarker> snippetMarker(std::wstring_view input)
|
||||
{
|
||||
if (!input.starts_with(L'{')) return {};
|
||||
size_t depth = 1;
|
||||
while (depth < 3 && depth < input.size() && input[depth] == L'{') ++depth;
|
||||
const auto end = input.find_first_of(L"{}", depth);
|
||||
if (end == input.npos || !input.substr(end).starts_with(std::wstring_view(L"}}}", depth)))
|
||||
return {};
|
||||
return SnippetMarker{input.substr(depth, end - depth), end + depth, depth};
|
||||
}
|
||||
std::optional<DWORD> snippetPause(std::wstring_view token)
|
||||
{
|
||||
constexpr std::wstring_view prefix = L"pause:";
|
||||
constexpr DWORD maxPause = 10000;
|
||||
if (!token.starts_with(prefix) || token.size() == prefix.size()) return {};
|
||||
DWORD duration = 0;
|
||||
for (wchar_t digit : token.substr(prefix.size()))
|
||||
{
|
||||
if (digit < L'0' || digit > L'9') return {};
|
||||
duration = duration * 10 + (digit - L'0');
|
||||
if (duration > maxPause) return {};
|
||||
}
|
||||
return duration;
|
||||
}
|
||||
} // namespace
|
||||
Template parseTemplate(const std::wstring &text)
|
||||
{
|
||||
Template t;
|
||||
std::wstring_view remaining(text);
|
||||
size_t cursor = text.npos;
|
||||
while (!remaining.empty())
|
||||
{
|
||||
const auto marker = snippetMarker(remaining);
|
||||
if (!marker)
|
||||
{
|
||||
t.text += remaining.front();
|
||||
remaining.remove_prefix(1);
|
||||
continue;
|
||||
}
|
||||
const auto [name, length, depth] = *marker;
|
||||
const auto pause = depth <= 2 ? snippetPause(name) : std::nullopt;
|
||||
const WORD key = depth >= 2 ? snippetKey(name) : 0;
|
||||
const bool legacyEscape = name == L"cursor" || name == L"enter";
|
||||
if (depth == 1 && name == L"cursor")
|
||||
{
|
||||
cursor = t.text.size();
|
||||
++t.cursors;
|
||||
}
|
||||
else if (depth == 1 && name == L"enter")
|
||||
t.actions.emplace_back(std::vector<WORD>{VK_RETURN});
|
||||
else if (depth == 1 && pause)
|
||||
t.actions.emplace_back(*pause);
|
||||
else if (depth == 2 && key)
|
||||
{
|
||||
std::vector<WORD> keys{key};
|
||||
remaining.remove_prefix(length);
|
||||
while (remaining.starts_with(L'+'))
|
||||
{
|
||||
const auto next = snippetMarker(remaining.substr(1));
|
||||
if (!next || next->depth != 2) break;
|
||||
const WORD nextKey = snippetKey(next->name);
|
||||
if (!nextKey) break;
|
||||
if (std::find(keys.begin(), keys.end(), nextKey) == keys.end())
|
||||
keys.push_back(nextKey);
|
||||
remaining.remove_prefix(1 + next->length);
|
||||
}
|
||||
t.actions.emplace_back(std::move(keys));
|
||||
continue;
|
||||
}
|
||||
else if ((depth >= 2 && legacyEscape) || (depth == 2 && pause) || (depth == 3 && key))
|
||||
t.text += remaining.substr(1, length - 2);
|
||||
else
|
||||
t.text += remaining.substr(0, length);
|
||||
remaining.remove_prefix(length);
|
||||
}
|
||||
if (cursor != text.npos)
|
||||
t.suffix = t.text.substr(cursor);
|
||||
return t;
|
||||
}
|
||||
std::wstring Hotkey::format() const
|
||||
{
|
||||
if (!key)
|
||||
@@ -423,32 +503,7 @@ std::optional<Hotkey> Hotkey::parse(std::wstring s)
|
||||
h.modifiers |= MOD_WIN;
|
||||
else
|
||||
{
|
||||
if (h.key)
|
||||
return {};
|
||||
if (token.size() == 1 && ((token[0] >= L'a' && token[0] <= L'z') || iswdigit(token[0])))
|
||||
h.key = upper(token)[0];
|
||||
else if (token.size() == 4 && token.substr(0, 3) == L"num" && token[3] >= L'0' &&
|
||||
token[3] <= L'9')
|
||||
h.key = VK_NUMPAD0 + token[3] - L'0';
|
||||
else if (token.size() >= 2 && token[0] == L'f')
|
||||
{
|
||||
wchar_t *tail{};
|
||||
long n = wcstol(token.c_str() + 1, &tail, 10);
|
||||
if (*tail || n < 1 || n > 24)
|
||||
return {};
|
||||
h.key = VK_F1 + (UINT)n - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto &[key, name] : namedKeys())
|
||||
if (lower(name) == token)
|
||||
{
|
||||
h.key = key;
|
||||
break;
|
||||
}
|
||||
if (!h.key)
|
||||
return {};
|
||||
}
|
||||
if (h.key || !(h.key = namedKey(token))) return {};
|
||||
}
|
||||
if (end == s.npos)
|
||||
break;
|
||||
|
||||
+3
-1
@@ -5,6 +5,7 @@
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
#include <windows.h>
|
||||
|
||||
@@ -42,11 +43,12 @@ std::wstring snippetAppName(std::wstring);
|
||||
int snippetAppPriority(const Snippet &, const std::wstring &process);
|
||||
std::wstring snippetId(const Snippet &);
|
||||
std::wstring newSnippetId();
|
||||
using SnippetAction = std::variant<std::vector<WORD>, DWORD>;
|
||||
struct Template
|
||||
{
|
||||
std::wstring text, suffix;
|
||||
std::vector<SnippetAction> actions;
|
||||
int cursors = 0;
|
||||
int enters = 0;
|
||||
};
|
||||
Template parseTemplate(const std::wstring &);
|
||||
struct Hotkey
|
||||
|
||||
+28
-16
@@ -490,32 +490,44 @@ INPUT keyboardInput(WORD key, DWORD flags)
|
||||
return input;
|
||||
}
|
||||
bool chord(WORD key, UINT mods)
|
||||
{
|
||||
WORD keys[5];
|
||||
size_t count = 0;
|
||||
for (auto [modifier, vk] : {std::pair<UINT, WORD>{MOD_CONTROL, VK_CONTROL},
|
||||
{MOD_ALT, VK_MENU}, {MOD_SHIFT, VK_SHIFT}, {MOD_WIN, VK_LWIN}})
|
||||
if (mods & modifier)
|
||||
keys[count++] = vk;
|
||||
keys[count++] = key;
|
||||
return chord(std::span<const WORD>(keys, count));
|
||||
}
|
||||
bool chord(std::span<const WORD> keys)
|
||||
{
|
||||
std::vector<INPUT> inputs;
|
||||
inputs.reserve(2 * keys.size());
|
||||
auto add = [&](WORD k, bool up)
|
||||
{
|
||||
INPUT i = keyboardInput(k, up ? KEYEVENTF_KEYUP : 0);
|
||||
if (k >= VK_LSHIFT && k <= VK_RMENU)
|
||||
{
|
||||
i.ki.wScan = static_cast<WORD>(MapVirtualKeyW(k, MAPVK_VK_TO_VSC));
|
||||
i.ki.dwFlags |= KEYEVENTF_SCANCODE;
|
||||
}
|
||||
if ((k >= VK_PRIOR && k <= VK_DOWN) || k == VK_INSERT || k == VK_DELETE ||
|
||||
k == VK_DIVIDE || k == VK_LWIN || k == VK_SNAPSHOT ||
|
||||
k == VK_DIVIDE || k == VK_LWIN || k == VK_RWIN || k == VK_RMENU ||
|
||||
k == VK_RCONTROL || k == VK_SNAPSHOT ||
|
||||
(k >= VK_VOLUME_MUTE && k <= VK_VOLUME_UP))
|
||||
i.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
|
||||
inputs.push_back(i);
|
||||
};
|
||||
for (auto [m, k] : {std::pair<UINT, WORD>{MOD_CONTROL, VK_CONTROL},
|
||||
{MOD_ALT, VK_MENU},
|
||||
{MOD_SHIFT, VK_SHIFT},
|
||||
{MOD_WIN, VK_LWIN}})
|
||||
if (mods & m)
|
||||
add(k, false);
|
||||
add(key, false);
|
||||
add(key, true);
|
||||
for (auto [m, k] : {std::pair<UINT, WORD>{MOD_WIN, VK_LWIN},
|
||||
{MOD_SHIFT, VK_SHIFT},
|
||||
{MOD_ALT, VK_MENU},
|
||||
{MOD_CONTROL, VK_CONTROL}})
|
||||
if (mods & m)
|
||||
add(k, true);
|
||||
return SendInput((UINT)inputs.size(), inputs.data(), sizeof(INPUT)) == inputs.size();
|
||||
for (WORD key : keys) add(key, false);
|
||||
for (auto it = keys.rbegin(); it != keys.rend(); ++it) add(*it, true);
|
||||
const auto sent = SendInput(static_cast<UINT>(inputs.size()), inputs.data(), sizeof(INPUT));
|
||||
if (sent == inputs.size()) return true;
|
||||
// Release any keys already pressed if Windows accepted only part of the chord.
|
||||
const auto pending = std::min<size_t>(sent, inputs.size() - sent);
|
||||
if (pending)
|
||||
SendInput(static_cast<UINT>(pending), inputs.data() + inputs.size() - pending, sizeof(INPUT));
|
||||
return false;
|
||||
}
|
||||
std::optional<SystemVolume> changeSystemVolume(MouseActionType action, int step)
|
||||
{
|
||||
|
||||
@@ -56,6 +56,7 @@ DWORD writeClipboard(HWND, const Clip &);
|
||||
DWORD writeClipboardGuarded(HWND, const Clip &, std::optional<DWORD> expected);
|
||||
Clip textClip(const std::wstring &);
|
||||
bool chord(WORD key, UINT modifiers = 0);
|
||||
bool chord(std::span<const WORD> keys);
|
||||
struct SystemVolume
|
||||
{
|
||||
int percent{};
|
||||
|
||||
+24
-11
@@ -1137,7 +1137,7 @@ LRESULT CALLBACK historyProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
|
||||
#endif
|
||||
#ifndef KS_RESIDENT_APP
|
||||
constexpr int SnippetsPage = 4, SaveSnippets = 318;
|
||||
constexpr int SnippetsPage = 4, SaveSnippets = 318, SnippetMacros = 320;
|
||||
struct SnippetView
|
||||
{
|
||||
App *app{};
|
||||
@@ -1994,7 +1994,8 @@ LRESULT CALLBACK settingsProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
value(w, 283, L"Copied to clipboard.");
|
||||
return 0;
|
||||
}
|
||||
if (id >= 301 && id <= SaveSnippets && snippetCommand(w, &v->snippets, wp, true))
|
||||
if (((id >= 301 && id <= SaveSnippets) || id == SnippetMacros) &&
|
||||
snippetCommand(w, &v->snippets, wp, true))
|
||||
return 0;
|
||||
if (id == 220 && HIWORD(wp) == LBN_SELCHANGE && !v->filling)
|
||||
{
|
||||
@@ -2260,6 +2261,18 @@ bool snippetCommand(HWND w, SnippetView *v, WPARAM wp, bool embedded)
|
||||
SendDlgItemMessageW(w, 303, EM_REPLACESEL, TRUE, (LPARAM)(id == 312 ? L"{cursor}" : L"{enter}"));
|
||||
return true;
|
||||
}
|
||||
if (id == SnippetMacros)
|
||||
{
|
||||
MessageBoxW(w,
|
||||
L"After the text is inserted and {cursor} is placed, macros run in order.\n\n"
|
||||
L"Tap a key: {{shift}}, {{altr}}, {{tab}}, {{F5}}\n"
|
||||
L"Hold keys together: {{ctrl}}+{{shift}}+{{A}}\n"
|
||||
L"Press Enter: {enter} or {{return}} in a combination\n"
|
||||
L"Wait: {pause:50} for 50 milliseconds (0–10000)\n\n"
|
||||
L"Use an extra pair of braces for literal markers, for example {{enter}} or {{{shift}}}.",
|
||||
L"Snippet macros", MB_OK | MB_ICONINFORMATION);
|
||||
return true;
|
||||
}
|
||||
if (id == (embedded ? SaveSnippets : IDOK))
|
||||
{
|
||||
saveSnippetDraft(w, v);
|
||||
@@ -2286,8 +2299,8 @@ void createSnippetEditor(HWND w, SnippetView *view, bool embedded)
|
||||
label(w, L"Triggers", 24, top, 186);
|
||||
control(w, L"LISTBOX", L"", WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | WS_BORDER,
|
||||
301, 24, top + 24, 186, 170 + textHeight);
|
||||
button(w, L"&Add", 310, 24, actions, 86);
|
||||
button(w, L"&Delete", 311, 120, actions, 90);
|
||||
button(w, L"&Add", 310, 24, actions, 88);
|
||||
button(w, L"&Delete", 311, 122, actions, 88);
|
||||
label(w, L"&Trigger (for example ;addr)", 232, top, 452);
|
||||
edit(w, 302, 232, top + 24, 452);
|
||||
checkbox(w, L"Only in these &applications (unchecked: everywhere)", 314, 232, top + 55, 452);
|
||||
@@ -2297,18 +2310,18 @@ void createSnippetEditor(HWND w, SnippetView *view, bool embedded)
|
||||
label(w, L"Process names, comma-separated (for example chrome.exe)", 232, top + 144, 452);
|
||||
label(w, L"&Replacement text", 232, top + 170, 452);
|
||||
edit(w, 303, 232, top + 194, 452, textHeight, ES_MULTILINE | ES_WANTRETURN | ES_AUTOVSCROLL | WS_VSCROLL);
|
||||
button(w, L"Insert cursor &marker", 312, 232, actions, 190);
|
||||
button(w, L"Insert &Enter marker", 313, 432, actions, 190);
|
||||
button(w, L"Cursor &marker", 312, 232, actions, 108);
|
||||
button(w, L"&Enter marker", 313, 348, actions, 100);
|
||||
button(w, L"Macro &help…", SnippetMacros, 456, actions, 96);
|
||||
if (embedded)
|
||||
{
|
||||
control(w, L"STATIC", L"", 0, 319, 232, actions + 35, 286, 24);
|
||||
button(w, L"Sa&ve snippets", SaveSnippets, 530, actions + 30, 154);
|
||||
button(w, L"Sa&ve snippets", SaveSnippets, 572, actions, 112);
|
||||
control(w, L"STATIC", L"", 0, 319, 232, actions + 33, 452, 24);
|
||||
}
|
||||
else
|
||||
{
|
||||
control(w, L"STATIC", L"Use {{cursor}} / {{enter}} for literal markers.", 0, 0, 232, actions + 35, 452, 22);
|
||||
button(w, L"&Save", IDOK, 474, actions + 65, 100);
|
||||
button(w, L"&Cancel", IDCANCEL, 584, actions + 65, 100);
|
||||
button(w, L"&Save", IDOK, 474, actions + 44, 100);
|
||||
button(w, L"&Cancel", IDCANCEL, 584, actions + 44, 100);
|
||||
}
|
||||
std::set<std::wstring> apps;
|
||||
EnumWindows([](HWND candidate, LPARAM context)->BOOL {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include "platform.h"
|
||||
namespace ks
|
||||
{
|
||||
inline constexpr wchar_t AppVersion[] = L"0.6.123";
|
||||
inline constexpr wchar_t AppVersion[] = L"0.6.124";
|
||||
inline constexpr UINT UpdateMessage = WM_APP + 7;
|
||||
inline constexpr UINT UpdateCheckIntervalMs = 6 * 60 * 60 * 1000;
|
||||
inline constexpr UINT UpdateNotificationRetryMs = 5 * 60 * 1000;
|
||||
|
||||
@@ -830,6 +830,25 @@ int main(int argc, char **argv) {
|
||||
require(visible(208) && visible(256), "logging controls are in Diagnostics");
|
||||
selectPage(4);
|
||||
require(visible(301) && visible(303) && visible(318), "Snippets has an inline editor and its own Save button");
|
||||
auto snippetBounds = [&](int id) {
|
||||
RECT bounds{};
|
||||
GetWindowRect(GetDlgItem(settings, id), &bounds);
|
||||
return bounds;
|
||||
};
|
||||
const RECT list = snippetBounds(301), replacement = snippetBounds(303);
|
||||
const RECT add = snippetBounds(310), remove = snippetBounds(311);
|
||||
const RECT cursor = snippetBounds(312), enter = snippetBounds(313);
|
||||
const RECT help = snippetBounds(320), save = snippetBounds(318), status = snippetBounds(319);
|
||||
require(visible(320) && add.left == list.left && remove.right == list.right &&
|
||||
add.top == cursor.top && remove.top == cursor.top && cursor.top > replacement.bottom &&
|
||||
enter.top == cursor.top && help.top == cursor.top && save.top == cursor.top &&
|
||||
cursor.left == replacement.left && save.right == replacement.right &&
|
||||
add.right < remove.left && remove.right < cursor.left &&
|
||||
cursor.right < enter.left && enter.right < help.left && help.right < save.left &&
|
||||
status.top >= save.bottom && status.bottom <= snippetBounds(261).top,
|
||||
"snippet buttons share a clear aligned row above separate save feedback");
|
||||
require(IsWindowEnabled(GetDlgItem(settings, 320)) && !IsWindowEnabled(GetDlgItem(settings, 312)),
|
||||
"macro help is available before a snippet is selected");
|
||||
const bool awake = app.settings.awake;
|
||||
SendDlgItemMessageW(settings, 205, BM_SETCHECK, awake ? BST_UNCHECKED : BST_CHECKED, 0);
|
||||
SendMessageW(settings, WM_COMMAND, 310, 0);
|
||||
|
||||
+62
-1
@@ -69,6 +69,10 @@ bool conversionOnly = false;
|
||||
bool typosOnly = false;
|
||||
int pasteBehavior = 0;
|
||||
int enterPresses = 0;
|
||||
bool observeMacros = false, moveFocusOnMacro = false;
|
||||
bool rightAltAndCtrl = false, rightShift = false;
|
||||
bool typeDuringMacros = false;
|
||||
ULONGLONG macroStart{}, macroEnd{};
|
||||
int copyFailuresRemaining = 0, copyRequests = 0;
|
||||
int droppedSelectionKeys = 0;
|
||||
bool trimCopiedSpaces = false;
|
||||
@@ -88,6 +92,18 @@ LRESULT CALLBACK forwardingHook(int code, WPARAM wp, LPARAM lp)
|
||||
}
|
||||
LRESULT CALLBACK observeEnter(HWND w, UINT message, WPARAM wp, LPARAM lp, UINT_PTR, DWORD_PTR)
|
||||
{
|
||||
if (observeMacros && (message == WM_KEYDOWN || message == WM_SYSKEYDOWN) && wp == VK_F8)
|
||||
{
|
||||
macroStart = GetTickCount64();
|
||||
rightAltAndCtrl = (GetKeyState(VK_RMENU) & 0x8000) && (GetKeyState(VK_RCONTROL) & 0x8000);
|
||||
if (moveFocusOnMacro) SetFocus(host);
|
||||
return 0;
|
||||
}
|
||||
if (observeMacros && macroStart && message == WM_KEYDOWN && wp == VK_LEFT)
|
||||
{
|
||||
macroEnd = GetTickCount64();
|
||||
rightShift = (GetKeyState(VK_RSHIFT) & 0x8000) != 0;
|
||||
}
|
||||
if (message == WM_KEYDOWN && wp == VK_LEFT && droppedSelectionKeys > 0 &&
|
||||
(GetKeyState(VK_SHIFT) & 0x8000))
|
||||
{
|
||||
@@ -237,7 +253,14 @@ void typeKeys(std::initializer_list<WORD> keys)
|
||||
inputs.push_back(input);
|
||||
}
|
||||
require(SendInput(static_cast<UINT>(inputs.size()), inputs.data(), sizeof(INPUT)) == inputs.size(),
|
||||
"snippet autocomplete keyboard input submitted");
|
||||
"snippet keyboard input submitted");
|
||||
}
|
||||
void expandMacroSnippet(const wchar_t *replacement)
|
||||
{
|
||||
app->settings.snippets = {{L";zmtest", replacement}};
|
||||
prepare(L"prefix ;zmtest", false);
|
||||
record(L";zmtest");
|
||||
app->transform(0, 0, 0, field);
|
||||
}
|
||||
void finish()
|
||||
{
|
||||
@@ -272,6 +295,11 @@ LRESULT CALLBACK procedure(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
throw std::runtime_error("Native integration timed out");
|
||||
if (app->busy)
|
||||
{
|
||||
if (typeDuringMacros && ks::InputRegressionAccess::deferring(*app))
|
||||
{
|
||||
typeDuringMacros = false;
|
||||
typeKeys({VK_SPACE, 'X'});
|
||||
}
|
||||
if (typeDuringCorrection && ks::InputRegressionAccess::deferring(*app))
|
||||
{
|
||||
typeDuringCorrection = false;
|
||||
@@ -869,6 +897,37 @@ LRESULT CALLBACK procedure(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
require(enterPresses == 0, "unverified snippet never submits Enter even without logging");
|
||||
require(ks::readClipboard(app->window).text() == sentinel, "rejected snippet restores clipboard");
|
||||
pasteBehavior = 0;
|
||||
stage = 80;
|
||||
break;
|
||||
case 80:
|
||||
if (!captured) saved = ks::readClipboard(app->window, 64 * 1024 * 1024);
|
||||
captured = true;
|
||||
app->ownSequence = ks::writeClipboard(app->window, ks::textClip(sentinel));
|
||||
app->settings.autoCorrect = false;
|
||||
ActivateKeyboardLayout(app->layouts[en].handle, 0);
|
||||
observeMacros = true;
|
||||
typeDuringMacros = true;
|
||||
expandMacroSnippet(L"left{cursor}right{{ctrlr}}+{{altr}}+{{F8}}{pause:150}{{shiftr}}+{{left}}{enter}");
|
||||
break;
|
||||
case 81:
|
||||
require(rightAltAndCtrl && rightShift && ks::modifiersReleased(),
|
||||
"snippet chords press the specified right modifiers and release them");
|
||||
require(macroStart && macroEnd >= macroStart + 140, "snippet pause separates actual keyboard events");
|
||||
require(text() == L"prefix lef\r\n xright",
|
||||
"snippet macros start at the cursor marker and finish before buffered typing");
|
||||
require(ks::readClipboard(app->window).text() == sentinel, "snippet macros restore the clipboard");
|
||||
expandMacroSnippet(L"left{cursor}right{{ctrl}}+{{V}}");
|
||||
break;
|
||||
case 82:
|
||||
require(text() == L"prefix left" + sentinel + L"right", "a snippet paste chord uses the user's clipboard");
|
||||
enterPresses = 0;
|
||||
macroStart = 0;
|
||||
moveFocusOnMacro = true;
|
||||
expandMacroSnippet(L"done{{F8}}{pause:250}{enter}");
|
||||
break;
|
||||
case 83:
|
||||
require(macroStart && GetFocus() == host && text() == L"prefix done" && enterPresses == 0,
|
||||
"snippet macros stop when focus moves to a different control");
|
||||
finish();
|
||||
break;
|
||||
case 84:
|
||||
@@ -1234,6 +1293,8 @@ int main(int argc, char **argv)
|
||||
stage = 64;
|
||||
if (argc > 1 && std::string(argv[1]) == "--snippet-autocomplete")
|
||||
stage = 66;
|
||||
if (argc > 1 && std::string(argv[1]) == "--snippet-macros")
|
||||
stage = 80;
|
||||
if (argc > 1 && std::string(argv[1]) == "--snippet-word-boundaries")
|
||||
stage = 84;
|
||||
SetTimer(host, 1, 100, nullptr);
|
||||
|
||||
+22
-6
@@ -459,12 +459,28 @@ int main(int argc, char **argv)
|
||||
require(ks::transliterate(L"Shchuka") == L"Щука", "reverse transliteration");
|
||||
require(ks::parseTemplate(L"a{cursor}b").suffix == L"b", "snippet suffix");
|
||||
require(ks::parseTemplate(L"{{cursor}}").text == L"{cursor}", "escaped cursor");
|
||||
require(ks::parseTemplate(L"rider .{enter}").text == L"rider ." &&
|
||||
ks::parseTemplate(L"rider .{enter}").enters == 1, "Enter is an action, not inserted text");
|
||||
require(ks::parseTemplate(L"a{cursor}b{enter}{enter}").suffix == L"b" &&
|
||||
ks::parseTemplate(L"a{cursor}b{enter}{enter}").enters == 2, "Enter actions preserve cursor suffix");
|
||||
require(ks::parseTemplate(L"{{enter}}").text == L"{enter}" &&
|
||||
ks::parseTemplate(L"{{enter}}").enters == 0, "escaped Enter is literal");
|
||||
const auto enters = ks::parseTemplate(L"a{cursor}b{enter}{enter}");
|
||||
require(enters.text == L"ab" && enters.suffix == L"b" &&
|
||||
enters.actions == std::vector<ks::SnippetAction>{std::vector<WORD>{VK_RETURN},
|
||||
std::vector<WORD>{VK_RETURN}},
|
||||
"Enter actions preserve the inserted text and cursor suffix");
|
||||
const auto escaped = ks::parseTemplate(L"before {{cursor}} {{enter}} {{{shift}}} {{pause:50}} after");
|
||||
require(escaped.text == L"before {cursor} {enter} {{shift}} {pause:50} after" && escaped.actions.empty(),
|
||||
"escaped snippet markers are literal even inside text");
|
||||
const auto macros = ks::parseTemplate(L"a{{SHIFT}}{cursor}b{pause:50}{{altr}}+{{ctrl}}+{{F5}}{{tab}}{{ctrl}}+{{return}}");
|
||||
require(macros.text == L"ab" && macros.suffix == L"b" &&
|
||||
macros.actions == std::vector<ks::SnippetAction>{std::vector<WORD>{VK_LSHIFT}, DWORD{50},
|
||||
std::vector<WORD>{VK_RMENU, VK_LCONTROL, VK_F5}, std::vector<WORD>{VK_TAB},
|
||||
std::vector<WORD>{VK_LCONTROL, VK_RETURN}},
|
||||
"snippet macros preserve key chords, tap order, pauses and cursor placement");
|
||||
const std::wstring literal = L"{{unknown}} + {pause:-1} {pause:10001} {pause:99999999999999} {pause:}";
|
||||
const auto unrecognized = ks::parseTemplate(literal);
|
||||
require(unrecognized.text == literal && unrecognized.actions.empty(),
|
||||
"unknown keys and invalid pause durations remain literal");
|
||||
const auto plus = ks::parseTemplate(L"2+{{left}}+1{pause:0}{pause:10000}");
|
||||
require(plus.text == L"2++1" && plus.actions == std::vector<ks::SnippetAction>{
|
||||
std::vector<WORD>{VK_LEFT}, DWORD{0}, DWORD{10000}},
|
||||
"only a plus between key markers forms a chord and pause bounds are inclusive");
|
||||
require(ks::parseTemplate(L"{cursor}{cursor}").cursors == 2, "duplicate cursor detection");
|
||||
require(ks::Hotkey::parse(L"Ctrl+Alt+Shift+Space")->key == VK_SPACE, "hotkey parse");
|
||||
require(!ks::Hotkey::parse(L"Ctrl+F25"), "invalid function key");
|
||||
|
||||
Reference in new issue
Block a user