From 2ac4ea5192111ebcca025885d1451c09ddfe25bd Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 6 May 2026 17:48:34 -0700 Subject: glide: Add tab group functions --- glide/.config/glide/glide.ts | 40 +++++++++++++++++++++++++++++++++++++ glide/.config/glide/tabbar.glide.ts | 8 +++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/glide/.config/glide/glide.ts b/glide/.config/glide/glide.ts index d508405..295c590 100644 --- a/glide/.config/glide/glide.ts +++ b/glide/.config/glide/glide.ts @@ -371,6 +371,46 @@ glide.keymaps.set('normal', '1', 'keep_window'); glide.keymaps.set('normal', '0', 'delete_window'); glide.keymaps.set('normal', '', 'other_window'); +// Groups + +const group_tab = glide.excmds.create({ + name: 'group_tab', + description: 'Add the current tab to a group.' +}, async ({ tab_id }) => { + const groups = await browser.tabGroups.query({}); + glide.commandline.show({ + title: "group", + options: groups.map((group) => ({ + label: group.title, + async execute({ input }) { + if (group.title.indexOf(input) >= 0) { + await browser.tabs.group({ + groupId: group.id, + tabIds: [tab_id], + }); + } else { + const groupId = await browser.tabs.group({ + tabIds: [tab_id], + }); + await browser.tabGroups.update(groupId, { + title: input, + }); + } + }, + })), + }); +}); + +const ungroup_tab = glide.excmds.create({ + name: 'ungroup_tab', + description: 'Remove the current tab from any group.' +}, async ({ tab_id }) => { + await browser.tabs.ungroup([ tab_id ]); +}); + +glide.keymaps.set('normal', 'ag', 'group_tab'); +glide.keymaps.set('normal', 'kg', 'ungroup_tab'); + glide.include('sitesearch.glide.ts'); glide.include('tabbar.glide.ts'); diff --git a/glide/.config/glide/tabbar.glide.ts b/glide/.config/glide/tabbar.glide.ts index dd4cf27..5cc6647 100644 --- a/glide/.config/glide/tabbar.glide.ts +++ b/glide/.config/glide/tabbar.glide.ts @@ -134,6 +134,12 @@ async function update_status_bar() { const url = active_tab.url; const title = active_tab.title || "Untitled"; + let groupDisplay = ""; + if (active_tab.groupId >= 0) { + const group = await browser.tabGroups.get(active_tab.groupId); + groupDisplay = `[${group.title}] | `; + } + let display_url = url || "about:blank"; if (display_url.length > 50) { @@ -141,7 +147,7 @@ async function update_status_bar() { } tabs_container.textContent = `${mode} [${tab_index + 1}/${tabs.length}]`; - right.textContent = `${title} | ${display_url}`; + right.textContent = `${groupDisplay}${title} | ${display_url}`; } catch (e) { tabs_container.textContent = e; right.textContent = "Error loading tabs" -- cgit v1.3-2-g0d8e