Skip to content

0.1.55a

Latest

Choose a tag to compare

@RobertCraigie RobertCraigie released this 30 Nov 23:57
00ecf62

Picker API

You can now use the commandline as a picker for arbitrary options.

For example, creating a basic version of :tab that only shows bookmarks:

glide.keymaps.set("normal", "<leader>o", async () => {
  const bookmarks = await browser.bookmarks.getRecent(10);

  glide.commandline.show({
    title: "bookmarks",
    options: bookmarks.map((bookmark) => ({
      label: bookmark.title,
      async execute() {
        const tab = await glide.tabs.get_first({
          url: bookmark.url,
        });
        if (tab) {
          await browser.tabs.update(tab.id, {
            active: true,
          });
        } else {
          await browser.tabs.create({
            active: true,
            url: bookmark.url,
          });
        }
      },
    })),
  });
}, { description: "Open the bookmarks picker" });

You can also customise how each option is displayed by providing a render() function on each option that returns a HTMLElement:

{
  label: bookmark.title,
  render() {
    return DOM.create_element("div", {
      style: {
        display: "flex",
        alignItems: "center",
        gap: "8px",
      },
      children: [
        DOM.create_element("span", [bookmark.title]),
        DOM.create_element("span", [bookmark.url], {
          style: { color: "#777", fontSize: "0.9em" },
        }),
      ],
    });
  },
};

See the full commandline docs for more information.

Split views API

Warning

This feature is very early in development in Firefox, there will be bugs.

Firefox has work in progress support for split views, so you can view multiple tabs at the same time.

split views example

You can now manage split views directly from the Glide config with glide.unstable.split_views, for example:

glide.keymaps.set(
  "normal",
  "<C-w>v",
  async ({ tab_id }) => {
    const all_tabs = await glide.tabs.query({});
    const current_index = all_tabs.findIndex((t) =>
      t.id === tab_id
    );
    const other = all_tabs[current_index + 1];
    if (!other) {
      throw new Error("No next tab");
    }
    glide.unstable.split_views.create([tab_id, other]);
  },
  {
    description:
      "Create a split view with the tab to the right",
  },
);

glide.keymaps.set(
  "normal",
  "<C-w>q",
  async ({ tab_id }) => {
    glide.unstable.split_views.separate(tab_id);
  },
  {
    description: "Close the split view for the current tab",
  },
);

Changes