Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ body:
* This is actually a bug and not a feature.
* You are running the latest extension version.

If you have are trying to change or remove a background please refer to [#52](https://github.com/KatsuteDev/Background/issues/52).

If your VSCode is blank or stops working please check [here](https://github.com/KatsuteDev/Background#%EF%B8%8F-vscode-stopped-working) first.

- type: input
Expand Down
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ body:
* This feature does not already exist.
* You are running the latest version.

This extension already supports background path modification and removal, please refer to [#52](https://github.com/KatsuteDev/Background/issues/52).

- type: textarea
attributes:
label: Feature
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Add background images by file, folder, [glob](https://github.com/isaacs/node-glo
|`Background: Uninstall`|Uninstalls and disables the background.|
|`Background: Reload`|Randomizes the backgrounds. Background must already be installed.|
|`Background: Configuration`|Opens the configuration menu.|
|`Background: Changelog`|Opens changelog.|

## ⚙️ Configuration

Expand Down
Binary file modified assets/configuration.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/delete.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/glob.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"theme": "dark"
},
"publisher": "Katsute",
"version": "2.6.1",
"version": "2.7.0",
"private": true,
"engines": {
"vscode": "^1.81.0"
Expand Down Expand Up @@ -335,7 +335,7 @@
"tmp": "0.2.1"
},
"devDependencies": {
"@types/node": "20.4.5",
"@types/node": "20.4.9",
"@types/tmp": "0.2.3",
"@types/vscode": "1.81.0",
"@vscode/test-electron": "2.3.4",
Expand Down
12 changes: 9 additions & 3 deletions src/command/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ import * as glob from "../lib/glob";

const issues: vscode.Uri = vscode.Uri.parse(pkg.bugs.url);

export const config: vscode.Disposable = vscode.commands.registerCommand("background.config", () => {
export const command: vscode.Disposable = vscode.commands.registerCommand("background.config", () => config());

export const config: () => void = () => {
showQuickPick([
// background types
quickPickItem({
Expand Down Expand Up @@ -91,16 +93,19 @@ export const config: vscode.Disposable = vscode.commands.registerCommand("backgr
separator(),
// extension options
quickPickItem({
alwaysShow: true,
label: "$(check) Install",
description: "Install background",
handle: () => vscode.commands.executeCommand("background.install")
}),
quickPickItem({
alwaysShow: true,
label: "$(close) Uninstall",
description: "Uninstall background",
handle: () => vscode.commands.executeCommand("background.uninstall")
}),
quickPickItem({
alwaysShow: true,
label: "$(refresh) Reload Background",
description: "Randomizes current backgrounds",
handle: () => vscode.commands.executeCommand("background.reload")
Expand All @@ -116,7 +121,7 @@ export const config: vscode.Disposable = vscode.commands.registerCommand("backgr
handle: () => vscode.env.openExternal(issues)
})
], options);
});
}

// shared options

Expand Down Expand Up @@ -186,5 +191,6 @@ export const menu: (ui: UI) => void = (ui: UI) => {
{
...options,
title: `${str.capitalize(ui)} ${options.title}`,
});
},
config);
};
14 changes: 10 additions & 4 deletions src/command/config/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const addMultiple: (ui: UI, globs: string[], skipWarning?: boolean) => Pr
const files: string[] = get(`${ui}Backgrounds`) as string[];
files.push(...globs);
await update(`${ui}Backgrounds`, files.filter(unique), undefined, skipWarning);
skipWarning || cm(ui); // reopen menu
skipWarning || menu(ui); // reopen menu
}

export const replace: (ui: UI, old: string, glob: string, skipWarning?: boolean) => Promise<void> = async (ui: UI, old: string, glob: string, skipWarning: boolean = false) => {
Expand All @@ -51,7 +51,7 @@ export const replace: (ui: UI, old: string, glob: string, skipWarning?: boolean)
if(files[i] === old)
files[i] = glob;
await update(`${ui}Backgrounds`, files.filter(unique), undefined, skipWarning || old === glob);
skipWarning || cm(ui); // reopen menu
skipWarning || menu(ui); // reopen menu
};

export const remove: (ui: UI, glob: string, skipWarning?: boolean) => Promise<void> = async (ui: UI, glob: string, skipWarning: boolean = false) => {
Expand All @@ -60,7 +60,7 @@ export const remove: (ui: UI, glob: string, skipWarning?: boolean) => Promise<vo

export const removeMultiple: (ui: UI, globs: string[], skipWarning?: boolean) => Promise<void> = async (ui: UI, globs: string[], skipWarning: boolean = false) => {
await update(`${ui}Backgrounds`, (get(`${ui}Backgrounds`) as string[]).filter((f) => !globs.includes(f)).filter(unique), undefined, skipWarning);
skipWarning || cm(ui); // reopen menu
skipWarning || menu(ui); // reopen menu
}

// extensions https://github.com/microsoft/vscode/blob/main/src/vs/platform/protocol/electron-main/protocolMainService.ts#L27
Expand Down Expand Up @@ -113,6 +113,7 @@ export const menu: (ui: UI) => void = (ui: UI) => {
separator(),
// add
quickPickItem({
alwaysShow: true,
label: "$(file-add) Add a File",
ui,
handle: (item: CommandQuickPickItem) => {
Expand All @@ -129,6 +130,7 @@ export const menu: (ui: UI) => void = (ui: UI) => {
}
}),
quickPickItem({
alwaysShow: true,
label: "$(file-directory-create) Add a Folder",
ui: ui,
handle: (item: CommandQuickPickItem) => {
Expand All @@ -144,6 +146,7 @@ export const menu: (ui: UI) => void = (ui: UI) => {
}
}),
quickPickItem({
alwaysShow: true,
label: "$(kebab-horizontal) Add a Glob",
ui,
handle: (item: CommandQuickPickItem) => {
Expand All @@ -166,6 +169,7 @@ export const menu: (ui: UI) => void = (ui: UI) => {
}
}),
quickPickItem({
alwaysShow: true,
label: "$(ports-open-browser-icon) Add a URL",
ui,
handle: (item: CommandQuickPickItem) => {
Expand Down Expand Up @@ -193,6 +197,7 @@ export const menu: (ui: UI) => void = (ui: UI) => {
... items.length > 0 ? [
separator(),
quickPickItem({
alwaysShow: true,
label: "$(trash) Delete a background",
ui: ui,
handle: (item: CommandQuickPickItem) => {
Expand Down Expand Up @@ -225,5 +230,6 @@ export const menu: (ui: UI) => void = (ui: UI) => {
...options,
title: t("Files", ui),
placeHolder: "Files"
});
},
() => cm(ui));
};
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import * as crypto from "crypto";
import * as glob from "./lib/glob";
import { round } from "./lib/round";

import * as config from "./command/config";
import * as reload from "./command/reload";
import * as install from "./command/install";
import * as uninstall from "./command/uninstall";
import * as changelog from "./command/changelog";

import { config } from "./command/config";
import * as file from "./command/config/file";

import { statusbar } from "./statusbar";
Expand Down Expand Up @@ -106,7 +106,7 @@ export const activate: (context: vscode.ExtensionContext) => any = (context: vsc
context.subscriptions.push(uninstall.command);
context.subscriptions.push(changelog.command);

context.subscriptions.push(config);
context.subscriptions.push(config.command);

context.subscriptions.push(statusbar);
statusbar.show();
Expand Down
18 changes: 14 additions & 4 deletions src/vs/quickpick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,20 @@ export interface CommandQuickPickItem extends vscode.QuickPickItem {

// quick pick

export const showQuickPick: (items: CommandQuickPickItem[], options?: vscode.QuickPickOptions) => void = (items: CommandQuickPickItem[], options: vscode.QuickPickOptions = {}) => {
vscode.window.showQuickPick(items, options).then((item?: CommandQuickPickItem) => {
item && item.handle && new Promise(() => item.handle!(item)); // run then in a promise
});
export const showQuickPick: (items: CommandQuickPickItem[], options?: vscode.QuickPickOptions, menu?: () => void) => void = (items: CommandQuickPickItem[], options: vscode.QuickPickOptions = {}, menu?: () => void) => {
vscode.window.showQuickPick(
menu
// back button
? [quickPickItem({
alwaysShow: true,
label: "$(arrow-left) Back",
handle: () => menu()
}), separator(),...items]
: items, options)
.then((item?: CommandQuickPickItem) => {
item && item.handle && new Promise(() => item.handle!(item)); // run then in a promise
}
);
}

export const quickPickItem: (item: CommandQuickPickItem, current?: string) => CommandQuickPickItem = (item: CommandQuickPickItem, current?: string) => ({
Expand Down