Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Toggle IME when mode changed #47

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/neovim/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ export default class NeovimInput {
this.element.addEventListener('blur', this.onBlur.bind(this));
this.element.addEventListener('focus', this.onFocus.bind(this));
this.store.on('cursor', this.updateElementPos.bind(this));
this.store.on('mode', () => this.toggleIme(
['insert', 'replace', 'cmdline'].some(mode => mode === this.store.mode)));

this.focus();
}
Expand Down Expand Up @@ -390,4 +392,15 @@ export default class NeovimInput {
this.element.style.left = x + 'px';
this.element.style.top = y + 'px';
}

toggleIme(enable: boolean) {
if (enable) {
this.element.type = 'text';
} else {
// any of 'number', 'tel', 'email', 'url' works for Windows 10 but
// don't works for Linux
// 'password' (little hackey) works both for Windows 10 and Linux
this.element.type = 'password';
}
}
}