From 4e58285cc28cf816dfcdbafa550b4bc1906b7c1c Mon Sep 17 00:00:00 2001 From: antelle Date: Sun, 31 Jan 2021 12:27:20 +0100 Subject: [PATCH] using batch text entry --- desktop/native-module-host.js | 39 ++++++++++++++++++++--------------- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/desktop/native-module-host.js b/desktop/native-module-host.js index f3df63fc..17d589ec 100644 --- a/desktop/native-module-host.js +++ b/desktop/native-module-host.js @@ -210,26 +210,31 @@ function kbdModifier(modifiers) { } function kbdTextAsKeys(str, modifiers) { - const typer = getAutoType(); const modifier = kbdModifier(modifiers); let ix = 0; - for (const kc of typer.osKeyCodesForChars(str)) { - const char = str[ix++]; - let effectiveModifier = modifier; - if (kc?.modifier) { - typer.keyMoveWithModifier(true, kc.modifier); - effectiveModifier |= kc.modifier; - } - if (kc) { - typer.keyMoveWithCharacter(true, null, kc.code, effectiveModifier); - typer.keyMoveWithCharacter(false, null, kc.code, effectiveModifier); - } else { - typer.keyMoveWithCharacter(true, char, null, effectiveModifier); - typer.keyMoveWithCharacter(false, char, null, effectiveModifier); - } - if (kc?.modifier) { - typer.keyMoveWithModifier(false, kc.modifier); + const typer = getAutoType(); + const tx = typer.beginBatchTextEntry(); + try { + for (const kc of typer.osKeyCodesForChars(str)) { + const char = str[ix++]; + let effectiveModifier = modifier; + if (kc?.modifier) { + typer.keyMoveWithModifier(true, kc.modifier); + effectiveModifier |= kc.modifier; + } + if (kc) { + typer.keyMoveWithCharacter(true, null, kc.code, effectiveModifier); + typer.keyMoveWithCharacter(false, null, kc.code, effectiveModifier); + } else { + typer.keyMoveWithCharacter(true, char, null, effectiveModifier); + typer.keyMoveWithCharacter(false, char, null, effectiveModifier); + } + if (kc?.modifier) { + typer.keyMoveWithModifier(false, kc.modifier); + } } + } finally { + tx.done(); } } diff --git a/package-lock.json b/package-lock.json index a0e3f11c..a5a542c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2062,8 +2062,8 @@ } }, "@keeweb/keeweb-native-modules": { - "version": "https://github.com/keeweb/keeweb-native-modules/releases/download/0.7.11/keeweb-native-modules.tgz", - "integrity": "sha512-EPK6HlxCPvkZJlHLknr8HIxvmJ9vXStI2H16lYdJAWX3GytlN6DIEnSLo25mo9uKCYhHjOyNwxkXfi0UppdZmg==" + "version": "https://github.com/keeweb/keeweb-native-modules/releases/download/0.7.12/keeweb-native-modules.tgz", + "integrity": "sha512-56LkWAQUeyTUQyLzy3cdtPPrhqZ5mfcLsyO53245hO1X4KBoHmec1gYNu9lvNQrFs/7okhMFHdjCHOcyBfeCkQ==" }, "@polka/url": { "version": "1.0.0-next.11", diff --git a/package.json b/package.json index 3d870674..121f2f87 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@babel/plugin-proposal-optional-chaining": "^7.12.7", "@babel/preset-env": "^7.12.11", "@fortawesome/fontawesome-free": "^5.15.2", - "@keeweb/keeweb-native-modules": "https://github.com/keeweb/keeweb-native-modules/releases/download/0.7.11/keeweb-native-modules.tgz", + "@keeweb/keeweb-native-modules": "https://github.com/keeweb/keeweb-native-modules/releases/download/0.7.12/keeweb-native-modules.tgz", "adm-zip": "^0.5.2", "argon2-browser": "1.15.3", "autoprefixer": "^10.2.4",