using batch text entry

This commit is contained in:
antelle 2021-01-31 12:27:20 +01:00
parent ef354fb8af
commit 4e58285cc2
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
3 changed files with 25 additions and 20 deletions

View File

@ -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();
}
}

4
package-lock.json generated
View File

@ -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",

View File

@ -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",