1
0
mirror of https://github.com/keeweb/keeweb.git synced 2024-06-25 07:37:46 +02:00

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) { function kbdTextAsKeys(str, modifiers) {
const typer = getAutoType();
const modifier = kbdModifier(modifiers); const modifier = kbdModifier(modifiers);
let ix = 0; let ix = 0;
for (const kc of typer.osKeyCodesForChars(str)) { const typer = getAutoType();
const char = str[ix++]; const tx = typer.beginBatchTextEntry();
let effectiveModifier = modifier; try {
if (kc?.modifier) { for (const kc of typer.osKeyCodesForChars(str)) {
typer.keyMoveWithModifier(true, kc.modifier); const char = str[ix++];
effectiveModifier |= kc.modifier; let effectiveModifier = modifier;
} if (kc?.modifier) {
if (kc) { typer.keyMoveWithModifier(true, kc.modifier);
typer.keyMoveWithCharacter(true, null, kc.code, effectiveModifier); effectiveModifier |= kc.modifier;
typer.keyMoveWithCharacter(false, null, kc.code, effectiveModifier); }
} else { if (kc) {
typer.keyMoveWithCharacter(true, char, null, effectiveModifier); typer.keyMoveWithCharacter(true, null, kc.code, effectiveModifier);
typer.keyMoveWithCharacter(false, char, null, effectiveModifier); typer.keyMoveWithCharacter(false, null, kc.code, effectiveModifier);
} } else {
if (kc?.modifier) { typer.keyMoveWithCharacter(true, char, null, effectiveModifier);
typer.keyMoveWithModifier(false, kc.modifier); 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": { "@keeweb/keeweb-native-modules": {
"version": "https://github.com/keeweb/keeweb-native-modules/releases/download/0.7.11/keeweb-native-modules.tgz", "version": "https://github.com/keeweb/keeweb-native-modules/releases/download/0.7.12/keeweb-native-modules.tgz",
"integrity": "sha512-EPK6HlxCPvkZJlHLknr8HIxvmJ9vXStI2H16lYdJAWX3GytlN6DIEnSLo25mo9uKCYhHjOyNwxkXfi0UppdZmg==" "integrity": "sha512-56LkWAQUeyTUQyLzy3cdtPPrhqZ5mfcLsyO53245hO1X4KBoHmec1gYNu9lvNQrFs/7okhMFHdjCHOcyBfeCkQ=="
}, },
"@polka/url": { "@polka/url": {
"version": "1.0.0-next.11", "version": "1.0.0-next.11",

View File

@ -16,7 +16,7 @@
"@babel/plugin-proposal-optional-chaining": "^7.12.7", "@babel/plugin-proposal-optional-chaining": "^7.12.7",
"@babel/preset-env": "^7.12.11", "@babel/preset-env": "^7.12.11",
"@fortawesome/fontawesome-free": "^5.15.2", "@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", "adm-zip": "^0.5.2",
"argon2-browser": "1.15.3", "argon2-browser": "1.15.3",
"autoprefixer": "^10.2.4", "autoprefixer": "^10.2.4",