本文整理汇总了TypeScript中vscode.window.showInputBox方法的典型用法代码示例。如果您正苦于以下问题:TypeScript window.showInputBox方法的具体用法?TypeScript window.showInputBox怎么用?TypeScript window.showInputBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode.window
的用法示例。
在下文中一共展示了window.showInputBox方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: uploadToGist
function uploadToGist(filename: string, code: string, userName: string = null, userPass: string = null) {
vscode.window.showInputBox({
placeHolder: 'Description of your file'
}).then((desc: string) => {
let data = {
"description": desc,
"public": true,
"files": {}
}
data.files[filename] = {"content": code};
let opts = {
url: 'https://api.github.com/gists',
body: data,
json: true,
headers: {
'User-Agent': 'request'
}
}
if (userName != null && userPass != null) {
opts['auth'] = {
user: userName,
pass: userPass
}
}
request.post(opts, (err, httpResponse, body) => {
vscode.window.showInformationMessage("Your File is published here: " + body.html_url);
opn(body.html_url)
});
})
}
示例2: version
Window.showInformationMessage('This feature is experimental... (close this to continue)').then(() => {
return Window.showInputBox({
prompt: 'Optional version (enter to deprecate all versions)',
placeHolder: '< 0.2.3, 1.0.0, ...'
})
})
示例3: creatInputBox
function creatInputBox(param: string): Thenable<string | undefined> {
return vscode.window.showInputBox({
prompt: `Set ${param} of the png.`,
placeHolder: `${param}`,
validateInput: checkSizeInput
});
}
示例4: setInterval
window.showInputBox({ value: undefined, prompt: Strings.SendFeedbackPrompt, placeHolder: undefined, password: false }).then((value) => {
if (value === undefined) {
let disposable = window.setStatusBarMessage(Strings.NoFeedbackSent);
setInterval(() => disposable.dispose(), 1000 * 5);
return;
}
//User does not need to provide any feedback text
let providedEmail: string = "";
window.showInputBox({ value: undefined, prompt: Strings.SendEmailPrompt, placeHolder: undefined, password: false }).then((email) => {
if (email === undefined) {
let disposable = window.setStatusBarMessage(Strings.NoFeedbackSent);
setInterval(() => disposable.dispose(), 1000 * 5);
return;
}
if (email) {
providedEmail = email;
}
//This feedback will go no matter whether Application Insights is enabled or not.
self.ReportFeedback(choice.id, { "VSCode.Feedback.Comment" : value, "VSCode.Feedback.Email" : providedEmail} );
let disposable = window.setStatusBarMessage(Strings.ThanksForFeedback);
setInterval(() => disposable.dispose(), 1000 * 5);
});
});
示例5: runNgCommand
export var ngnew = vscode.commands.registerCommand('extension.ngNew', () => {
let project = vscode.window.showInputBox({ placeHolder: 'name of your project' }).then(
(data) => {
runNgCommand(['new', data], true);
}
)
});
示例6:
let disposable = vscode.commands.registerCommand('extension.openURL', () => {
let opts: vscode.InputBoxOptions = {
prompt: "URL",
value: "https://",
validateInput: (url) => {
if (urlIsValid(url)) {
return null;
}
return "Invalid URL.";
},
};
vscode.window.showInputBox(opts).then(
(url) => {
if (!urlIsValid(url)) {
return;
}
let uri = vscode.Uri.parse(url);
// Determine column to place browser in.
let col: vscode.ViewColumn;
let ae = vscode.window.activeTextEditor;
if (ae != undefined) {
col = ae.viewColumn || vscode.ViewColumn.One;
} else {
col = vscode.ViewColumn.One;
}
return vscode.commands.executeCommand('vscode.previewHtml', uri, col).then((success) => {
}, (reason) => {
vscode.window.showErrorMessage(reason);
}
);
});
});
示例7: showSearch
// Shows search box and searches
function showSearch() {
vscode.window.showInputBox({
placeHolder: "Type the package name or search term."
}).then(searchValue => {
vscode.window.setStatusBarMessage("Loading packages...");
axios.get(API_URL_SEARCH, {
params: {
q: searchValue,
prerelease: true,
take: 100
}
}).then(response => {
var packageList = response.data.data;
if (packageList.length < 1) {
Helpers.throwError("No results found. Please try again.");
} else {
vscode.window.showQuickPick(packageList)
.then(packageName => {
if (packageName) {
showVersionChooser(packageName);
}
});
}
vscode.window.setStatusBarMessage("");
}).catch(error => {
vscode.window.setStatusBarMessage("");
console.error(error);
Helpers.throwError("Could not connect to Nuget server.");
});
});
}
示例8: installBuildFileCommand
export async function installBuildFileCommand() {
// Check if there is an open folder in workspace
if (workspace.rootPath === undefined) {
window.showErrorMessage('You have not yet opened a folder.');
return;
}
var name = await window.showInputBox({
placeHolder: messages.PROMPT_SCRIPT_NAME,
value: DEFAULT_SCRIPT_NAME
});
if (!name) {
window.showWarningMessage('No script name provided! Try again and make sure to provide a file name.');
return;
}
var result = await installBuildFile(name);
if (result) {
window.showInformationMessage("Sample psake build file successfully created.");
} else {
window.showErrorMessage("Error creating sample psake buile file.");
}
}
示例9: pullFrom
@command('git.pullFrom')
async pullFrom(): Promise<void> {
const remotes = this.model.remotes;
if (remotes.length === 0) {
window.showWarningMessage(localize('no remotes to pull', "Your repository has no remotes configured to pull from."));
return;
}
const picks = remotes.map(r => ({ label: r.name, description: r.url }));
const placeHolder = localize('pick remote pull repo', "Pick a remote to pull the branch from");
const pick = await window.showQuickPick(picks, { placeHolder });
if (!pick) {
return;
}
const branchName = await window.showInputBox({
placeHolder: localize('branch name', "Branch name"),
prompt: localize('provide branch name', "Please provide a branch name"),
ignoreFocusOut: true
});
if (!branchName) {
return;
}
this.model.pull(false, pick.label, branchName);
}
示例10: searchFor
var disposable = vscode.commands.registerCommand(cInfo.command("search"), () => {
// The code you place here will be executed every time your command is executed
// Get the active editor
let editor = vscode.window.activeTextEditor;
let selectedText = "";
if (editor) {
// Get the selected text
let selection = editor.selection;
selectedText = editor.document.getText(selection);
}
// Get config settings
let config = vscode.workspace.getConfiguration(cInfo.group);
let useDefaultOnly = config.get<boolean>(cKeys.useDefaultProviderOnly)
let useDefaultForSelection = config.get<boolean>(cKeys.alwaysUseDefaultForSelection)
let skipInputForSelection = config.get<boolean>(cKeys.noInputBoxIfTextSelected)
if (!utils.isNullOrEmpty(selectedText) && skipInputForSelection) {
searchFor(selectedText, true);
} else {
if (!utils.isNullOrEmpty(selectedText) && useDefaultForSelection) {
useDefaultOnly = true
}
// In order to do so, setup some options.
let options: vscode.InputBoxOptions = {
prompt: "Enter provider code followed by query", // <- The text to display underneath the input box.
value: selectedText, // <- The value to prefill in the input box. Here we use the selected text.
placeHolder: "Query" // <- An optional string to show as place holder in the input box to guide the user what to type.
}
vscode.window.showInputBox(options).then((q) =>
searchFor(q, (useDefaultOnly || utils.startsWith(q, selectedText)))
);
}
});