Skip to content

Commit 07bb9c8

Browse files
committed
Added: Keybindings: Switching between tabs
- Switching to the N:th tab of panel - Switching to the last tab of panel - Switching to the parent tab (#182, #631, #213)
1 parent 286fa4c commit 07bb9c8

File tree

5 files changed

+128
-0
lines changed

5 files changed

+128
-0
lines changed

src/_locales/dict.browser.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,54 @@
265265
"ru": "Поиск",
266266
"zh_CN": "搜索"
267267
},
268+
"KbSwitchToParentTab": {
269+
"en": "Switch to parent tab",
270+
"ru": "Переключиться на родительскую вкладку"
271+
},
272+
"KbSwitchToTab0": {
273+
"en": "Switch to first tab of active panel",
274+
"ru": "Переключиться на первую вкладку активной панели"
275+
},
276+
"KbSwitchToTab1": {
277+
"en": "Switch to second tab of active panel",
278+
"ru": "Переключиться на вторую вкладку активной панели"
279+
},
280+
"KbSwitchToTab2": {
281+
"en": "Switch to third tab of active panel",
282+
"ru": "Переключиться на третью вкладку активной панели"
283+
},
284+
"KbSwitchToTab3": {
285+
"en": "Switch to fourth tab of active panel",
286+
"ru": "Переключиться на четвертую вкладку активной панели"
287+
},
288+
"KbSwitchToTab4": {
289+
"en": "Switch to fifth tab of active panel",
290+
"ru": "Переключиться на пятую вкладку активной панели"
291+
},
292+
"KbSwitchToTab5": {
293+
"en": "Switch to sixth tab of active panel",
294+
"ru": "Переключиться на шестую вкладку активной панели"
295+
},
296+
"KbSwitchToTab6": {
297+
"en": "Switch to seventh tab of active panel",
298+
"ru": "Переключиться на седьмую вкладку активной панели"
299+
},
300+
"KbSwitchToTab7": {
301+
"en": "Switch to eighth tab of active panel",
302+
"ru": "Переключиться на восьмую вкладку активной панели"
303+
},
304+
"KbSwitchToTab8": {
305+
"en": "Switch to ninth tab of active panel",
306+
"ru": "Переключиться на девятую вкладку активной панели"
307+
},
308+
"KbSwitchToTab9": {
309+
"en": "Switch to tenth tab of active panel",
310+
"ru": "Переключиться на десятую вкладку активной панели"
311+
},
312+
"KbSwitchToLastTab": {
313+
"en": "Switch to the last tab of active panel",
314+
"ru": "Переключиться на последнюю вкладку активной панели"
315+
},
268316

269317
"proxy_popup_title_prefix": {
270318
"en": "Proxy for \"",

src/_locales/dict.setup-page.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,6 +2127,10 @@ export const setupPageTranslations: Translations = {
21272127
en: 'Switching between panels',
21282128
ru: 'Переключение панелей',
21292129
},
2130+
'settings.kb_switching_tab': {
2131+
en: 'Switching between tabs',
2132+
ru: 'Переключение вкладок',
2133+
},
21302134
'settings.kb_create_remove_tabs': {
21312135
en: 'Creating / Removing tabs',
21322136
ru: 'Создание / Закрытие вкладок',

src/manifest.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,42 @@
247247
},
248248
"search": {
249249
"description": "__MSG_KbSearch__"
250+
},
251+
"switch_to_parent_tab": {
252+
"description": "__MSG_KbSwitchToParentTab__"
253+
},
254+
"switch_to_tab_0": {
255+
"description": "__MSG_KbSwitchToTab0__"
256+
},
257+
"switch_to_tab_1": {
258+
"description": "__MSG_KbSwitchToTab1__"
259+
},
260+
"switch_to_tab_2": {
261+
"description": "__MSG_KbSwitchToTab2__"
262+
},
263+
"switch_to_tab_3": {
264+
"description": "__MSG_KbSwitchToTab3__"
265+
},
266+
"switch_to_tab_4": {
267+
"description": "__MSG_KbSwitchToTab4__"
268+
},
269+
"switch_to_tab_5": {
270+
"description": "__MSG_KbSwitchToTab5__"
271+
},
272+
"switch_to_tab_6": {
273+
"description": "__MSG_KbSwitchToTab6__"
274+
},
275+
"switch_to_tab_7": {
276+
"description": "__MSG_KbSwitchToTab7__"
277+
},
278+
"switch_to_tab_8": {
279+
"description": "__MSG_KbSwitchToTab8__"
280+
},
281+
"switch_to_tab_9": {
282+
"description": "__MSG_KbSwitchToTab9__"
283+
},
284+
"switch_to_last_tab": {
285+
"description": "__MSG_KbSwitchToLastTab__"
250286
}
251287
},
252288

src/page.setup/components/keybindings.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ const layout = [
7373
'switch_to_panel_8',
7474
'switch_to_panel_9',
7575
76+
// Switching tabs
77+
'switching_tab',
78+
'switch_to_parent_tab',
79+
'switch_to_tab_0',
80+
'switch_to_tab_1',
81+
'switch_to_tab_2',
82+
'switch_to_tab_3',
83+
'switch_to_tab_4',
84+
'switch_to_tab_5',
85+
'switch_to_tab_6',
86+
'switch_to_tab_7',
87+
'switch_to_tab_8',
88+
'switch_to_tab_9',
89+
'switch_to_last_tab',
90+
7691
// Move tabs
7792
'move_tabs',
7893
'move_tab_to_active',

src/services/keybindings.actions.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,31 @@ function onCmd(name: string): void {
147147
} else if (name.startsWith('move_tabs_to_panel_')) onKeyMoveTabsToPanel(parseInt(name[19]))
148148
else if (name === 'search') {
149149
Search.start()
150+
} else if (name === 'switch_to_parent_tab') {
151+
Tabs.activateParent(Selection.get()[0])
152+
} else if (name === 'switch_to_last_tab') {
153+
onKeySwitchToTab()
154+
} else if (name.startsWith('switch_to_tab_')) {
155+
const index = parseInt(name.slice(-1))
156+
if (!isNaN(index)) onKeySwitchToTab(index)
157+
}
158+
}
159+
160+
function onKeySwitchToTab(targetIndex?: number): void {
161+
const activePanel = Sidebar.reactive.panelsById[Sidebar.reactive.activePanelId]
162+
if (!Utils.isTabsPanel(activePanel)) return
163+
164+
const tabsList = [...activePanel.pinnedTabs, ...activePanel.tabs]
165+
166+
let targetTab
167+
if (targetIndex === undefined) targetTab = tabsList[tabsList.length - 1]
168+
else targetTab = tabsList[targetIndex]
169+
170+
if (targetTab.id !== Tabs.activeId) browser.tabs.update(targetTab.id, { active: true })
171+
else if (Settings.reactive.tabsSecondClickActPrev) {
172+
const history = Tabs.getActiveTabsHistory()
173+
const prevTabId = history.actTabs[history.actTabs.length - 1]
174+
if (prevTabId !== undefined) browser.tabs.update(prevTabId, { active: true })
150175
}
151176
}
152177

0 commit comments

Comments
 (0)