-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
80 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,24 @@ | ||
# gearbar README | ||
# GearBar README | ||
|
||
This is the README for your extension "gearbar". After writing up a brief description, we recommend including the following sections. | ||
|
||
## Features | ||
|
||
Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. | ||
|
||
For example if there is an image subfolder under your extension project workspace: | ||
|
||
\!\[feature X\]\(images/feature-x.png\) | ||
|
||
> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. | ||
this extention give a gear button in the status bar for enable/disable vscode settings | ||
|
||
## Requirements | ||
|
||
If you have any requirements or dependencies, add a section describing those and how to install and configure them. | ||
|
||
## Extension Settings | ||
|
||
Include if your extension adds any VS Code settings through the `contributes.configuration` extension point. | ||
|
||
For example: | ||
|
||
This extension contributes the following settings: | ||
|
||
* `myExtension.enable`: Enable/disable this extension. | ||
* `myExtension.thing`: Set to `blah` to do something. | ||
|
||
## Known Issues | ||
|
||
Calling out known issues can help limit users opening duplicate issues against your extension. | ||
|
||
## Release Notes | ||
|
||
Users appreciate release notes as you update your extension. | ||
|
||
### 1.0.0 | ||
|
||
Initial release of ... | ||
|
||
### 1.0.1 | ||
|
||
Fixed issue #. | ||
|
||
### 1.1.0 | ||
|
||
Added features X, Y, and Z. | ||
|
||
--- | ||
|
||
## Following extension guidelines | ||
|
||
Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension. | ||
|
||
* [Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines) | ||
|
||
## Working with Markdown | ||
|
||
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts: | ||
|
||
* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux). | ||
* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux). | ||
* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets. | ||
|
||
## For more information | ||
|
||
* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) | ||
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/) | ||
you juste need to add your items in teh settings.json : | ||
|
||
```json | ||
"gearbar.items": [ | ||
{ | ||
"setting": "workbench.editor.enablePreview", | ||
"label": "Enable/Disable preview mode", | ||
"icon": "$(zap)", | ||
"tooltip": "Preview mode gives you a persistent file sheet on click" | ||
} | ||
] | ||
``` | ||
|
||
**Enjoy!** |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,58 @@ | ||
// The module 'vscode' contains the VS Code extensibility API | ||
// Import the module and reference it with the alias vscode in your code below | ||
import * as vscode from 'vscode'; | ||
|
||
// This method is called when your extension is activated | ||
// Your extension is activated the very first time the command is executed | ||
interface ItemConfig { | ||
setting: string; | ||
label: string; | ||
icon: string; | ||
tooltip: string; | ||
} | ||
|
||
export function activate(context: vscode.ExtensionContext) { | ||
const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 100); | ||
statusBarItem.text = "$(gear)"; | ||
statusBarItem.tooltip = "Click to toggle features"; | ||
statusBarItem.command = "gearbar.showMenu"; | ||
statusBarItem.show(); | ||
context.subscriptions.push(statusBarItem); | ||
|
||
const disposable = vscode.commands.registerCommand("gearbar.showMenu", async () => { | ||
const itemsConfig: ItemConfig[] = loadItemsConfig(); | ||
if (!itemsConfig || itemsConfig.length === 0) { | ||
vscode.window.showErrorMessage("No configuration items found in settings. Please configure 'gearbar.items' in your user/workspace settings."); | ||
return; | ||
} | ||
|
||
// Use the console to output diagnostic information (console.log) and errors (console.error) | ||
// This line of code will only be executed once when your extension is activated | ||
console.log('Congratulations, your extension "gearbar" is now active!'); | ||
const config = vscode.workspace.getConfiguration(); | ||
const quickPickItems: vscode.QuickPickItem[] = itemsConfig.map(item => { | ||
const currentValue = config.get<boolean>(item.setting, false); | ||
return { | ||
label: `${item.icon} ${item.label}`, | ||
description: currentValue ? "$(check)" : "", | ||
detail: item.tooltip | ||
}; | ||
}); | ||
|
||
// The command has been defined in the package.json file | ||
// Now provide the implementation of the command with registerCommand | ||
// The commandId parameter must match the command field in package.json | ||
const disposable = vscode.commands.registerCommand('gearbar.helloWorld', () => { | ||
// The code you place here will be executed every time your command is executed | ||
// Display a message box to the user | ||
vscode.window.showInformationMessage('Hello World from GearBar!'); | ||
}); | ||
const selection = await vscode.window.showQuickPick(quickPickItems, { | ||
placeHolder: "Select a feature to toggle" | ||
}); | ||
|
||
if (selection) { | ||
const selectedItem = itemsConfig.find(item => `${item.icon} ${item.label}` === selection.label); | ||
if (selectedItem) { | ||
const currentValue = config.get<boolean>(selectedItem.setting, false); | ||
await config.update(selectedItem.setting, !currentValue, vscode.ConfigurationTarget.Global); | ||
vscode.window.showInformationMessage(`${selectedItem.label} is now ${!currentValue ? 'enabled' : 'disabled'}.`); | ||
} | ||
} | ||
}); | ||
|
||
context.subscriptions.push(disposable); | ||
} | ||
|
||
context.subscriptions.push(disposable); | ||
function loadItemsConfig(): ItemConfig[] { | ||
const config = vscode.workspace.getConfiguration(); | ||
const items = config.get<ItemConfig[]>("gearbar.items", []); | ||
return items; | ||
} | ||
|
||
// This method is called when your extension is deactivated | ||
export function deactivate() {} |
This file was deleted.
Oops, something went wrong.