diff --git a/src/command/config.ts b/src/command/config.ts index 201c794b..287d8614 100644 --- a/src/command/config.ts +++ b/src/command/config.ts @@ -20,7 +20,7 @@ import * as vscode from "vscode"; import { get, UI } from "../vs/vsconfig"; import { pkg } from "../vs/package"; -import { CommandQuickPickItem, quickPickItem, separator, showQuickPick } from "../vs/quickpick"; +import { quickPickItem, separator, showQuickPick } from "../vs/quickpick"; import * as file from "./config/file"; import * as align from "./config/align"; @@ -50,7 +50,7 @@ export const config: vscode.Disposable = vscode.commands.registerCommand("backgr `${get("backgroundSize", "window")} Size` + ` • ` + `${get("backgroundChangeTime", "window")} second${get("backgroundChangeTime", "window") === 1 ? '' : 's'}`, ui: "window", - handle: menu + handle: () => menu("window") }), quickPickItem({ label: "$(multiple-windows) Editor", @@ -62,7 +62,7 @@ export const config: vscode.Disposable = vscode.commands.registerCommand("backgr `${get("backgroundSize", "editor")} Size` + ` • ` + `${get("backgroundChangeTime", "editor")} second${get("backgroundChangeTime", "editor") === 1 ? '' : 's'}`, ui: "editor", - handle: menu + handle: () => menu("editor") }), quickPickItem({ label: "$(layout-sidebar-left) Sidebar", @@ -74,7 +74,7 @@ export const config: vscode.Disposable = vscode.commands.registerCommand("backgr `${get("backgroundSize", "sidebar")} Size` + ` • ` + `${get("backgroundChangeTime", "sidebar")} second${get("backgroundChangeTime", "sidebar") === 1 ? '' : 's'}`, ui: "sidebar", - handle: menu + handle: () => menu("sidebar") }), quickPickItem({ label: "$(layout-panel) Panel", @@ -86,7 +86,7 @@ export const config: vscode.Disposable = vscode.commands.registerCommand("backgr `${get("backgroundSize", "panel")} Size` + ` • ` + `${get("backgroundChangeTime", "panel")} second${get("backgroundChangeTime", "panel") === 1 ? '' : 's'}`, ui: "panel", - handle: menu + handle: () => menu("panel") }), separator(), // extension options @@ -130,61 +130,61 @@ export const title: (s: string, ui?: UI) => string = (s: string, ui?: UI) => ui // menu -export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPickItem) => { +export const menu: (ui: UI) => void = (ui: UI) => { showQuickPick([ quickPickItem({ label: "$(file-media) File", - description: `${str.s(get(`${item.ui!}Backgrounds`), "Glob")} (${str.s(glob.count(get(`${item.ui!}Backgrounds`)), "Background")})`, + description: `${str.s(get(`${ui}Backgrounds`), "Glob")} (${str.s(glob.count(get(`${ui}Backgrounds`)), "Background")})`, detail: "Select background image files", - ui: item.ui!, - handle: file.menu + ui, + handle: () => file.menu(ui) }), separator(), quickPickItem({ label: "$(arrow-both) Alignment", - description: `${get("backgroundAlignment", item.ui!)}`, + description: `${get("backgroundAlignment", ui)}`, detail: "Background image alignment", - ui: item.ui!, - handle: align.menu + ui, + handle: () => align.menu(ui) }), quickPickItem({ label: "$(eye) Blur", - description: `${get("backgroundBlur", item.ui!)}`, + description: `${get("backgroundBlur", ui)}`, detail: "Background image blur", - ui: item.ui!, - handle: blur.menu + ui, + handle: () => blur.menu(ui) }), quickPickItem({ label: "$(color-mode) Opacity", - description: `${get("backgroundOpacity", item.ui!)}`, + description: `${get("backgroundOpacity", ui)}`, detail: "Background image opacity", - ui: item.ui!, - handle: opacity.menu + ui, + handle: () => opacity.menu(ui) }), quickPickItem({ label: "$(multiple-windows) Repeat", - description: `${get("backgroundRepeat", item.ui!)}`, + description: `${get("backgroundRepeat", ui)}`, detail: "Background image repeat", - ui: item.ui!, - handle: repeat.menu + ui, + handle: () => repeat.menu(ui) }), quickPickItem({ label: "$(screen-full) Size", - description: `${get("backgroundSize", item.ui!)}`, + description: `${get("backgroundSize", ui)}`, detail: "Background image size", - ui: item.ui!, - handle: size.menu + ui, + handle: () => size.menu(ui) }), quickPickItem({ label: "$(clock) Time", - description: `${get("backgroundChangeTime", item.ui!)} second${get("backgroundChangeTime", item.ui!) === 1 ? '' : 's'}`, + description: `${get("backgroundChangeTime", ui)} second${get("backgroundChangeTime", ui) === 1 ? '' : 's'}`, detail: "How often to change the background", - ui: item.ui!, - handle: time.menu + ui, + handle: () => time.menu(ui) }) ], { ...options, - title: `${str.capitalize(item.ui!)} ${options.title}`, + title: `${str.capitalize(ui)} ${options.title}`, }); }; \ No newline at end of file diff --git a/src/command/config/align.ts b/src/command/config/align.ts index 5577153a..e4b2eaba 100644 --- a/src/command/config/align.ts +++ b/src/command/config/align.ts @@ -18,7 +18,7 @@ import { config, Props } from "../../vs/package"; import { showInputBox } from "../../vs/inputbox"; -import { get, update, updateFromLabel } from "../../vs/vsconfig"; +import { get, UI, update, updateFromLabel } from "../../vs/vsconfig"; import { CommandQuickPickItem, quickPickItem, separator, showQuickPick } from "../../vs/quickpick"; import { menu as cm, options, title } from "../config"; @@ -31,46 +31,46 @@ const prop: Props = config("backgroundAlignment"); const handle: (item: CommandQuickPickItem) => void = (item: CommandQuickPickItem) => { updateFromLabel("backgroundAlignment", item, item.ui!) - .then(() => cm(item)); // reopen menu + .then(() => cm(item.ui!)); // reopen menu }; -export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPickItem) => { - const current: string = get("backgroundAlignment", item.ui!) as string; +export const menu: (ui: UI) => void = (ui: UI) => { + const current: string = get("backgroundAlignment", ui) as string; showQuickPick([ // top - quickPickItem({ label: prop.items!.enum![0], handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![1], handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![2], handle, ui: item.ui! }, current), + quickPickItem({ label: prop.items!.enum![0], handle, ui }, current), + quickPickItem({ label: prop.items!.enum![1], handle, ui }, current), + quickPickItem({ label: prop.items!.enum![2], handle, ui }, current), separator(), // center - quickPickItem({ label: prop.items!.enum![3], handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![4], handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![5], handle, ui: item.ui! }, current), + quickPickItem({ label: prop.items!.enum![3], handle, ui }, current), + quickPickItem({ label: prop.items!.enum![4], handle, ui }, current), + quickPickItem({ label: prop.items!.enum![5], handle, ui }, current), separator(), // bottom - quickPickItem({ label: prop.items!.enum![6], handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![7], handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![8], handle, ui: item.ui! }, current), + quickPickItem({ label: prop.items!.enum![6], handle, ui }, current), + quickPickItem({ label: prop.items!.enum![7], handle, ui }, current), + quickPickItem({ label: prop.items!.enum![8], handle, ui }, current), separator(), // manual - quickPickItem({ label: prop.items!.enum![9], description: "Manual position", ui: item.ui!, handle: (item: CommandQuickPickItem) => { - const currentValue: string = get("backgroundAlignmentValue", item.ui!); + quickPickItem({ label: prop.items!.enum![9], description: "Manual position", ui, handle: (item: CommandQuickPickItem) => { + const currentValue: string = get("backgroundAlignmentValue", ui); showInputBox({ - title: title("Alignment", item.ui!), + title: title("Alignment", ui), placeHolder: "Background position", value: currentValue, prompt: `Background position (${currentValue}). The literal value for the 'background-position' css property.`, validateInput: (value: string) => !validCSS(value) ? "Invalid CSS" : null, handle: (value: string) => { if(validCSS(value)){ - let changed: boolean = get("backgroundAlignment", item.ui!) !== prop.items!.enum![9] || currentValue !== value; + let changed: boolean = get("backgroundAlignment", ui) !== prop.items!.enum![9] || currentValue !== value; - update("backgroundAlignment", prop.items!.enum![9], item.ui!, true) - .then(() => update("backgroundAlignmentValue", value, item.ui!, true)) + update("backgroundAlignment", prop.items!.enum![9], ui, true) + .then(() => update("backgroundAlignmentValue", value, ui, true)) .then(() => { changed && notify(); - cm(item); // reopen menu + cm(ui); // reopen menu }); } } @@ -79,7 +79,7 @@ export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPic ], { ...options, - title: title("Alignment", item.ui!), + title: title("Alignment", ui), placeHolder: "Background alignment" }); }; \ No newline at end of file diff --git a/src/command/config/blur.ts b/src/command/config/blur.ts index 1a0fba2f..8888551b 100644 --- a/src/command/config/blur.ts +++ b/src/command/config/blur.ts @@ -17,27 +17,26 @@ */ import { showInputBox } from "../../vs/inputbox"; -import { get, update } from "../../vs/vsconfig"; -import { CommandQuickPickItem } from "../../vs/quickpick"; +import { UI, get, update } from "../../vs/vsconfig"; import { menu as cm, title } from "../config"; import { validCSS } from "../../lib/str"; // -export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPickItem) => { - const current: string = get("backgroundBlur", item.ui!) as string; +export const menu: (ui: UI) => void = (ui: UI) => { + const current: string = get("backgroundBlur", ui) as string; showInputBox({ - title: title("Blur", item.ui!), + title: title("Blur", ui), placeHolder: "Background blur", value: current, prompt: `Background blur (${current})`, validateInput: (value: string) => !validCSS(value) ? "Invalid CSS" : null, handle: (value: string) => { if(validCSS(value)) - update("backgroundBlur", value, item.ui!) - .then(() => cm(item)); // reopen menu + update("backgroundBlur", value, ui) + .then(() => cm(ui)); // reopen menu } }); }; \ No newline at end of file diff --git a/src/command/config/file.ts b/src/command/config/file.ts index cb4bda29..b6efe585 100644 --- a/src/command/config/file.ts +++ b/src/command/config/file.ts @@ -27,7 +27,6 @@ import * as glob from "../../lib/glob"; import { unique } from "../../lib/unique"; import { menu as cm, options, title as t } from "../config"; -import { notify } from "../install"; // config @@ -36,11 +35,15 @@ export const view: (ui: UI) => string[] = (ui: UI) => { } export const add: (ui: UI, glob: string, skipWarning?: boolean) => Promise = async (ui: UI, glob: string, skipWarning: boolean = false) => { + await addMultiple(ui, [glob], skipWarning); +} + +export const addMultiple: (ui: UI, globs: string[], skipWarning?: boolean) => Promise = async (ui: UI, globs: string[], skipWarning: boolean = false) => { const files: string[] = get(`${ui}Backgrounds`) as string[]; - files.push(glob); + files.push(...globs); await update(`${ui}Backgrounds`, files.filter(unique), undefined, skipWarning); - skipWarning || cm({label: '␀', ui}); // reopen menu -}; + skipWarning || cm(ui); // reopen menu +} export const replace: (ui: UI, old: string, glob: string, skipWarning?: boolean) => Promise = async (ui: UI, old: string, glob: string, skipWarning: boolean = false) => { const files: string[] = get(`${ui}Backgrounds`) as string[]; @@ -48,13 +51,17 @@ 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({label: '␀', ui}); // reopen menu + skipWarning || cm(ui); // reopen menu }; export const remove: (ui: UI, glob: string, skipWarning?: boolean) => Promise = async (ui: UI, glob: string, skipWarning: boolean = false) => { - await update(`${ui}Backgrounds`, (get(`${ui}Backgrounds`) as string[]).filter((f) => f !== glob).filter(unique), undefined, skipWarning); - skipWarning || cm({label: '␀', ui}); // reopen files -}; + await removeMultiple(ui, [glob], skipWarning); +} + +export const removeMultiple: (ui: UI, globs: string[], skipWarning?: boolean) => Promise = 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 +} // extensions https://github.com/microsoft/vscode/blob/main/src/vs/platform/protocol/electron-main/protocolMainService.ts#L27 @@ -87,16 +94,16 @@ const updateItem: (ui: UI, item: CommandQuickPickItem) => void = (ui: UI, item: // files -export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPickItem) => { +export const menu: (ui: UI) => void = (ui: UI) => { // existing items - const items: CommandQuickPickItem[] = (get(`${item.ui!}Backgrounds`) as string[]) + const items: CommandQuickPickItem[] = (get(`${ui}Backgrounds`) as string[]) .filter(unique) .map(file => quickPickItem({ label: file.replace(/(\${\w+})/g, "\\$1"), value: file, - ui: item.ui, + ui, description: `${str.s(glob.count(file), "matching file")}`, - handle: (item: CommandQuickPickItem) => updateItem(item.ui!, item) + handle: (item: CommandQuickPickItem) => updateItem(ui, item) })); // show menu @@ -107,7 +114,7 @@ export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPic // add quickPickItem({ label: "$(file-add) Add a File", - ui: item.ui!, + ui, handle: (item: CommandQuickPickItem) => { vscode.window.showOpenDialog({ canSelectFiles: true, @@ -116,20 +123,14 @@ export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPic openLabel: "Select Image", filters: {"Images": extensions()} }).then((files?: vscode.Uri[]) => { - if(files){ - let promise: Promise = Promise.resolve(); - for(const file of files) - promise = promise.then(() => add(item.ui!, file.fsPath.replace(/\\/g, '/'), true)); // append promise to chain - promise = promise - .then(() => files.length > 0 && notify()) - .then(() => cm({label: '␀', ui: item.ui!})) // reopen menu - } + if(files) + addMultiple(ui, files.map((f) => f.fsPath.replace(/\\/g, '/'))); }); } }), quickPickItem({ label: "$(file-directory-create) Add a Folder", - ui: item.ui!, + ui: ui, handle: (item: CommandQuickPickItem) => { vscode.window.showOpenDialog({ canSelectFiles: false, @@ -137,20 +138,14 @@ export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPic canSelectMany: true, openLabel: "Select Folder" }).then((files?: vscode.Uri[]) => { - if(files){ - let promise: Promise = Promise.resolve(); - for(const file of files) - promise = promise.then(() => add(item.ui!, `${file.fsPath.replace(/\\/g, '/')}/**`, true)); // append promise to chain - promise = promise - .then(() => files.length > 0 && notify()) - .then(() => cm({label: '␀', ui: item.ui!})) // reopen menu - } + if(files) + addMultiple(ui, files.map((f) => `${f.fsPath.replace(/\\/g, '/')}/**`)); }); } }), quickPickItem({ label: "$(kebab-horizontal) Add a Glob", - ui: item.ui!, + ui, handle: (item: CommandQuickPickItem) => { vscode.window.showInputBox({ title: "Add File", @@ -166,13 +161,13 @@ export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPic } }).then((glob?: string) => { if(glob) - add(item.ui!, glob); + add(ui, glob); }); } }), quickPickItem({ label: "$(ports-open-browser-icon) Add a URL", - ui: item.ui!, + ui, handle: (item: CommandQuickPickItem) => { vscode.window.showInputBox({ title: "Add URL", @@ -190,22 +185,45 @@ export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPic } }).then((url?: string) => { if(url) - add(item.ui!, url); + add(ui, url); }); } }), + // delete ... items.length > 0 ? [ separator(), quickPickItem({ - label: "$(lightbulb) To modify or remove an image, select the row and press enter", - ui: item.ui!, - handle: (item: CommandQuickPickItem) => menu(item) + label: "$(trash) Delete a background", + ui: ui, + handle: (item: CommandQuickPickItem) => { + const items: CommandQuickPickItem[] = (get(`${ui}Backgrounds`) as string[]) + .filter(unique) + .map(file => quickPickItem({ + label: file.replace(/(\${\w+})/g, "\\$1"), + value: file, + ui: item.ui, + description: `${str.s(glob.count(file), "matching file")}` + })); + + vscode.window.showQuickPick( + items, + { + ...options, + title: t("Delete", ui), + placeHolder: "Files", + canPickMany: true + } + ).then((selected?: CommandQuickPickItem[]) => { + if(selected) + removeMultiple(ui, selected.map((f) => f.value!)); + }); + } }) ] : [] ], { ...options, - title: t("Files", item.ui!), + title: t("Files", ui), placeHolder: "Files" }); }; \ No newline at end of file diff --git a/src/command/config/opacity.ts b/src/command/config/opacity.ts index 443ddc1d..99860939 100644 --- a/src/command/config/opacity.ts +++ b/src/command/config/opacity.ts @@ -19,19 +19,18 @@ import * as vscode from "vscode"; import { showInputBox } from "../../vs/inputbox"; -import { get, update } from "../../vs/vsconfig"; -import { CommandQuickPickItem } from "../../vs/quickpick"; +import { UI, get, update } from "../../vs/vsconfig"; import { round } from "../../lib/round"; import { menu as cm, title } from "../config"; // -export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPickItem) => { - const current: number = round(get("backgroundOpacity", item.ui!) as number, 2); +export const menu: (ui: UI) => void = (ui: UI) => { + const current: number = round(get("backgroundOpacity", ui) as number, 2); showInputBox({ - title: title("Opacity", item.ui!), + title: title("Opacity", ui), placeHolder: "Background opacity", value: current.toString(), prompt: `Background opacity (${current}). 0 is fully visible and 1 is invisible.`, @@ -47,8 +46,8 @@ export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPic if(!isNaN(+value)){ const o: number = Math.min(Math.max(round(+value, 2), 0), 1); if(o > .1){ - update("backgroundOpacity", o, item.ui!) - .then(() => cm(item)); // reopen menu + update("backgroundOpacity", o, ui) + .then(() => cm(ui)); // reopen menu }else{ vscode.window.showWarningMessage( "An opacity of " + o + " might make it difficult to see the UI, " + @@ -57,8 +56,8 @@ export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPic "Yes" ).then((c?: "Yes") => { if(c === "Yes") - update("backgroundOpacity", o, item.ui!) - .then(() => cm(item)); // reopen menu + update("backgroundOpacity", o, ui) + .then(() => cm(ui)); // reopen menu }); } } diff --git a/src/command/config/repeat.ts b/src/command/config/repeat.ts index d547e3a2..e6bd42e3 100644 --- a/src/command/config/repeat.ts +++ b/src/command/config/repeat.ts @@ -18,7 +18,7 @@ import { config, Props } from "../../vs/package"; -import { get, updateFromLabel } from "../../vs/vsconfig"; +import { get, UI, updateFromLabel } from "../../vs/vsconfig"; import { CommandQuickPickItem, quickPickItem, showQuickPick } from "../../vs/quickpick"; import { menu as cm, options, title } from "../config"; @@ -29,23 +29,23 @@ const prop: Props = config("backgroundRepeat"); const handle: (item: CommandQuickPickItem) => void = (item: CommandQuickPickItem) => { updateFromLabel("backgroundRepeat", item, item.ui!) - .then(() => cm(item)); // reopen menu + .then(() => cm(item.ui!)); // reopen menu }; -export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPickItem) => { - const current: string = get("backgroundRepeat", item.ui!) as string; +export const menu: (ui: UI) => void = (ui: UI) => { + const current: string = get("backgroundRepeat", ui) as string; showQuickPick([ - quickPickItem({ label: prop.items!.enum![0], description: prop.items!.enumDescriptions![0], handle: handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![1], description: prop.items!.enumDescriptions![1], handle: handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![2], description: prop.items!.enumDescriptions![2], handle: handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![3], description: prop.items!.enumDescriptions![3], handle: handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![4], description: prop.items!.enumDescriptions![4], handle: handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![5], description: prop.items!.enumDescriptions![5], handle: handle, ui: item.ui! }, current), + quickPickItem({ label: prop.items!.enum![0], description: prop.items!.enumDescriptions![0], handle: handle, ui }, current), + quickPickItem({ label: prop.items!.enum![1], description: prop.items!.enumDescriptions![1], handle: handle, ui }, current), + quickPickItem({ label: prop.items!.enum![2], description: prop.items!.enumDescriptions![2], handle: handle, ui }, current), + quickPickItem({ label: prop.items!.enum![3], description: prop.items!.enumDescriptions![3], handle: handle, ui }, current), + quickPickItem({ label: prop.items!.enum![4], description: prop.items!.enumDescriptions![4], handle: handle, ui }, current), + quickPickItem({ label: prop.items!.enum![5], description: prop.items!.enumDescriptions![5], handle: handle, ui }, current), ], { ...options, - title: title("Repeat", item.ui!), + title: title("Repeat", ui), placeHolder: "Background repeat", }); }; \ No newline at end of file diff --git a/src/command/config/size.ts b/src/command/config/size.ts index 50b85c9a..3031820a 100644 --- a/src/command/config/size.ts +++ b/src/command/config/size.ts @@ -18,7 +18,7 @@ import { config, Props } from "../../vs/package"; import { showInputBox } from "../../vs/inputbox"; -import { get, update, updateFromLabel } from "../../vs/vsconfig"; +import { get, UI, update, updateFromLabel } from "../../vs/vsconfig"; import { CommandQuickPickItem, quickPickItem, separator, showQuickPick } from "../../vs/quickpick"; import { menu as cm, options, title as t } from "../config"; @@ -31,23 +31,23 @@ const prop: Props = config("backgroundSize"); const handle: (item: CommandQuickPickItem) => void = (item: CommandQuickPickItem) => { updateFromLabel("backgroundSize", item, item.ui!) - .then(() => cm(item)); // reopen menu + .then(() => cm(item.ui!)); // reopen menu }; -export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPickItem) => { - const current: string = get("backgroundSize", item.ui!) as string; +export const menu: (ui: UI) => void = (ui: UI) => { + const current: string = get("backgroundSize", ui) as string; - const title: string = t("Size", item.ui!); + const title: string = t("Size", ui); showQuickPick([ // size - quickPickItem({ label: prop.items!.enum![0], description: prop.items!.enumDescriptions![0], handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![1], description: prop.items!.enumDescriptions![1], handle, ui: item.ui! }, current), - quickPickItem({ label: prop.items!.enum![2], description: prop.items!.enumDescriptions![2], handle, ui: item.ui! }, current), + quickPickItem({ label: prop.items!.enum![0], description: prop.items!.enumDescriptions![0], handle, ui }, current), + quickPickItem({ label: prop.items!.enum![1], description: prop.items!.enumDescriptions![1], handle, ui }, current), + quickPickItem({ label: prop.items!.enum![2], description: prop.items!.enumDescriptions![2], handle, ui }, current), separator(), // manual - quickPickItem({ label: prop.items!.enum![3], description: prop.items!.enumDescriptions![3], ui: item.ui!, handle: (item: CommandQuickPickItem) => { - const currentValue: string = get("backgroundSizeValue", item.ui!); + quickPickItem({ label: prop.items!.enum![3], description: prop.items!.enumDescriptions![3], ui: ui, handle: (item: CommandQuickPickItem) => { + const currentValue: string = get("backgroundSizeValue", ui); showInputBox({ title, placeHolder: "Background size", @@ -56,13 +56,13 @@ export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPic validateInput: (value: string) => !validCSS(value) ? "Invalid CSS" : null, handle: (value: string) => { if(validCSS(value)){ - let changed: boolean = get("backgroundSize", item.ui!) !== prop.items!.enum![3] || currentValue !== value; + let changed: boolean = get("backgroundSize", ui) !== prop.items!.enum![3] || currentValue !== value; - update("backgroundSize", prop.items!.enum![3], item.ui!, true) - .then(() => update("backgroundSizeValue", value, item.ui!, true)) + update("backgroundSize", prop.items!.enum![3], ui, true) + .then(() => update("backgroundSizeValue", value, ui, true)) .then(() => { changed && notify(); - cm(item); // reopen menu + cm(ui); // reopen menu }); } } diff --git a/src/command/config/time.ts b/src/command/config/time.ts index fc1d7cf0..a7ea5b22 100644 --- a/src/command/config/time.ts +++ b/src/command/config/time.ts @@ -17,19 +17,18 @@ */ import { showInputBox } from "../../vs/inputbox"; -import { get, update } from "../../vs/vsconfig"; -import { CommandQuickPickItem } from "../../vs/quickpick"; +import { UI, get, update } from "../../vs/vsconfig"; import { round } from "../../lib/round"; import { menu as cm, title } from "../config"; // -export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPickItem) => { - const current: number = round(get("backgroundChangeTime", item.ui!) as number, 2); +export const menu: (ui: UI) => void = (ui: UI) => { + const current: number = round(get("backgroundChangeTime", ui) as number, 2); showInputBox({ - title: title("Change Time", item.ui!), + title: title("Change Time", ui), placeHolder: "Background change time", value: current.toString(), prompt: `Background change time (${current}). How long in seconds before the background should automatically change. Set to 0 to always use the same image.`, @@ -44,8 +43,8 @@ export const menu: (item: CommandQuickPickItem) => void = (item: CommandQuickPic handle: (value: string) => { if(!isNaN(+value)){ const o: number = Math.max(round(+value, 2), 0); - update("backgroundChangeTime", o, item.ui!) - .then(() => cm(item)); // reopen menu + update("backgroundChangeTime", o, ui) + .then(() => cm(ui)); // reopen menu } } });