Flexible tab switching

This commit is contained in:
Mr. Stallion 2020-11-13 15:33:57 -06:00
parent 5a8a0927e6
commit e8c78079b1
4 changed files with 18 additions and 2 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## Canary
* Use `Ctrl+Tab`, `Ctrl+Shift+Tab`, `Ctrl+PgDown`, and `Ctrl+PgUp` to switch between character tabs
## 1.4.1
* Fixed some image previews showing up black

View File

@ -63,6 +63,7 @@ This repository contains a heavily customized version of the mainline F-Chat 3.0
* Conversation dialog can be opened by typing in a character name
* Message search matches character names
* PM list shows characters' online status as a colored icon
* Use `Ctrl+Tab`, `Ctrl+Shift+Tab`, `Ctrl+PgDown`, and `Ctrl+PgUp` to switch between character tabs
* Technical Details for Nerds
* Upgraded to Electron 10.x
* Replaced `node-spellchecker` with the built-in spellchecker that ships with Electron 8+

View File

@ -293,8 +293,15 @@
});
window.addEventListener('keydown', (e) => {
if(getKey(e) === Keys.Tab && e.ctrlKey && !e.altKey && !e.shiftKey)
parent.send('switch-tab', this.character);
const key = getKey(e);
if ((key === Keys.Tab) && (e.ctrlKey) && (!e.altKey)) {
parent.send(`${e.shiftKey ? 'previous' : 'switch'}-tab`, this.character);
}
if (((key === Keys.PageDown) || (key === Keys.PageUp)) && (e.ctrlKey) && (!e.altKey) && (!e.shiftKey)) {
parent.send(`${key === Keys.PageUp ? 'previous' : 'switch'}-tab`, this.character);
}
});
log.debug('init.chat.listeners.done');

View File

@ -162,6 +162,10 @@
const index = this.tabs.indexOf(this.activeTab!);
this.show(this.tabs[index + 1 === this.tabs.length ? 0 : index + 1]);
});
electron.ipcRenderer.on('previous-tab', (_e: Event) => {
const index = this.tabs.indexOf(this.activeTab!);
this.show(this.tabs[index - 1 < 0 ? this.tabs.length - 1 : index - 1]);
});
electron.ipcRenderer.on('show-tab', (_e: Event, id: number) => {
this.show(this.tabMap[id]);
});