vscode#QuickInputButtons TypeScript Examples
The following examples show how to use
vscode#QuickInputButtons.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: multiStepInput.ts From cloudmusic-vscode with MIT License | 5 votes |
showQuickPick<T extends QuickPickItem>({
title,
step,
totalSteps,
items,
// activeItems,
placeholder,
changeCallback,
canSelectMany,
previous,
next,
}: QuickPickParameters<T> & QuickPickOption): Promise<
readonly T[] | T | ButtonAction
> {
const disposables: Disposable[] = [];
return new Promise<readonly T[] | T | ButtonAction>((resolve, reject) => {
const input = window.createQuickPick<T>();
input.canSelectMany = !!canSelectMany;
input.matchOnDescription = true;
input.matchOnDetail = true;
input.ignoreFocusOut = true;
input.title = title;
input.step = step;
input.totalSteps = Math.max(
totalSteps || 1,
this._step,
this._steps.length
);
input.placeholder = placeholder;
input.items = items;
/* if (activeItems) {
input.activeItems = activeItems;
} */
const button: QuickInputButton[] = [];
if (previous) button.push(pickButtons.previous);
if (next) button.push(pickButtons.next);
input.buttons = [
...(this._step > 1 ? [QuickInputButtons.Back] : []),
...button,
...(this._step < this._steps.length ? [pickButtons.forward] : []),
pickButtons.close,
];
disposables.push(
input.onDidTriggerButton((item) => {
switch (item) {
case QuickInputButtons.Back:
reject(InputFlowAction.back);
break;
case pickButtons.forward:
reject(InputFlowAction.forward);
break;
case pickButtons.previous:
resolve(ButtonAction.previous);
break;
case pickButtons.next:
resolve(ButtonAction.next);
break;
default:
input.hide();
}
}),
input.onDidAccept(() =>
resolve(canSelectMany ? input.selectedItems : input.selectedItems[0])
),
input.onDidHide(() => reject(InputFlowAction.cancel))
);
if (changeCallback)
disposables.push(
input.onDidChangeValue((value) => changeCallback(input, value))
);
if (this._current) this._current.dispose();
this._current = input;
this._current.show();
}).finally(() => disposables.forEach((d) => void d.dispose()));
}
Example #2
Source File: multiStepInput.ts From cloudmusic-vscode with MIT License | 5 votes |
showInputBox({
title,
step,
totalSteps,
value,
prompt,
password,
changeCallback,
}: InputBoxParameters): Promise<string> {
const disposables: Disposable[] = [];
return new Promise<string>((resolve, reject) => {
const input = window.createInputBox();
input.ignoreFocusOut = true;
input.title = title;
input.step = step;
input.totalSteps = Math.max(
totalSteps || 1,
this._step,
this._steps.length
);
input.value = value || "";
input.prompt = prompt;
input.buttons = [
...(this._step > 1 ? [QuickInputButtons.Back] : []),
...(this._step < this._steps.length ? [pickButtons.forward] : []),
pickButtons.close,
];
input.password = password || false;
disposables.push(
input.onDidTriggerButton((item) => {
switch (item) {
case QuickInputButtons.Back:
reject(InputFlowAction.back);
break;
case pickButtons.forward:
reject(InputFlowAction.forward);
break;
default:
input.hide();
break;
}
}),
input.onDidAccept(() => {
const value = input.value;
resolve(value);
}),
input.onDidHide(() => reject(InputFlowAction.cancel))
);
if (changeCallback)
disposables.push(
input.onDidChangeValue((value) => changeCallback(input, value))
);
if (this._current) this._current.dispose();
this._current = input;
this._current.show();
}).finally(() => disposables.forEach((d) => void d.dispose()));
}