Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
aiekick committed Dec 8, 2024
1 parent aae5706 commit b695f8a
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 133 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
"typescript.tsc.autoDetect": "off",
"svn.ignoreMissingSvnWarning": true
}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ All notable changes to the "gearbar" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]
## [0.01]

- Initial release
75 changes: 14 additions & 61 deletions README.md
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!**
Binary file added images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@
"displayName": "GearBar",
"description": "a custom toolbar for modify settings",
"version": "0.0.1",
"publisher": "aiekick",
"engines": {
"vscode": "^1.95.0"
"vscode": "^1.25.0"
},
"categories": [
"Other"
],
"activationEvents": [],
"icon": "images/icon.png",
"galleryBanner": {
"color": "#008080",
"theme": "dark"
},
"activationEvents": [
"*"
],
"repository": {
"url": "https://github.com/aiekick/GearBar.git"
},
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "gearbar.helloWorld",
"title": "Hello World"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
Expand All @@ -28,7 +33,7 @@
"test": "vscode-test"
},
"devDependencies": {
"@types/vscode": "^1.95.0",
"@types/vscode": "^1.88.0",
"@types/mocha": "^10.0.9",
"@types/node": "20.x",
"@typescript-eslint/eslint-plugin": "^8.10.0",
Expand Down
66 changes: 49 additions & 17 deletions src/extension.ts
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() {}
44 changes: 0 additions & 44 deletions vsc-extension-quickstart.md

This file was deleted.

0 comments on commit b695f8a

Please sign in to comment.