diff options
author | StefanVukovic99 <stefanvukovic44@gmail.com> | 2024-04-22 22:24:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-22 20:24:50 +0000 |
commit | f0196aaf6beac57e17972c87153376bbbcdd7282 (patch) | |
tree | 225ed467e09f8d83c02a666d419fef044621c9dd /ext/js/display/display.js | |
parent | c6d93a965a5536979221fda856903356c10c1603 (diff) |
add profile switching keyboard shortcuts (#832)
* add profile switching
* add duplicate behavior dropdown (#853)
* duplicate behavior dropdown
* allow duplicate for existing users
* Update docs/anki-integration.md
Co-authored-by: James Maa <jmaa@berkeley.edu>
Signed-off-by: StefanVukovic99 <stefanvukovic44@gmail.com>
* Update docs/anki-integration.md
Co-authored-by: James Maa <jmaa@berkeley.edu>
Signed-off-by: StefanVukovic99 <stefanvukovic44@gmail.com>
* Update docs/anki-integration.md
Co-authored-by: James Maa <jmaa@berkeley.edu>
Signed-off-by: StefanVukovic99 <stefanvukovic44@gmail.com>
* remove suggestion comment
---------
Signed-off-by: StefanVukovic99 <stefanvukovic44@gmail.com>
Co-authored-by: James Maa <jmaa@berkeley.edu>
---------
Signed-off-by: StefanVukovic99 <stefanvukovic44@gmail.com>
Co-authored-by: James Maa <jmaa@berkeley.edu>
Diffstat (limited to 'ext/js/display/display.js')
-rw-r--r-- | ext/js/display/display.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js index 10c1545c..6b73f19b 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -196,6 +196,8 @@ export class Display extends EventDispatcher { ['firstEntry', () => { this._focusEntry(0, 0, true); }], ['historyBackward', () => { this._sourceTermView(); }], ['historyForward', () => { this._nextTermView(); }], + ['profilePrevious', async () => { await this._setProfile(-1); }], + ['profileNext', async () => { await this._setProfile(1); }], ['copyHostSelection', () => this._copyHostSelection()], ['nextEntryDifferentDictionary', () => { this._focusEntryWithDifferentDictionary(1, true); }], ['previousEntryDifferentDictionary', () => { this._focusEntryWithDifferentDictionary(-1, true); }] @@ -1996,6 +1998,26 @@ export class Display extends EventDispatcher { this._focusEntry(this._index + count * sign, 0, true); } + /** + * @param {number} direction + */ + async _setProfile(direction) { + const optionsFull = await this.application.api.optionsGetFull(); + + const profileCount = optionsFull.profiles.length; + const newProfile = (optionsFull.profileCurrent + direction + profileCount) % profileCount; + + /** @type {import('settings-modifications').ScopedModificationSet} */ + const modification = { + action: 'set', + path: 'profileCurrent', + value: newProfile, + scope: 'global', + optionsContext: null + }; + await this.application.api.modifySettings([modification], 'search'); + } + /** */ _closeAllPopupMenus() { for (const popupMenu of PopupMenu.openMenus) { |