Enhance status bar with new buttons for tree view and settings; refactor existing button setup
This commit is contained in:
@@ -60,26 +60,33 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
// Update formatting instructions button text if that setting changed
|
||||
if (item.settingKey === 'includeFormattingInstructions') {
|
||||
xmlEditsButton.text = prompterTreeProvider.isXmlEditsEnabled() ?
|
||||
"$(check) Formatting Instructions" : "$(diff-added) Formatting Instructions";
|
||||
"$(check) Formatting Instructions" : "$(diff-added) XML Edits";
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Create formatting instructions toggle button
|
||||
const xmlEditsButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
|
||||
xmlEditsButton.text = "$(diff-added) Formatting Instructions";
|
||||
const xmlEditsButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 1);
|
||||
xmlEditsButton.text = "$(diff-added) XML Edits";
|
||||
xmlEditsButton.tooltip = "Toggle formatting instructions mode";
|
||||
xmlEditsButton.command = 'prompter.toggleXmlEdits';
|
||||
xmlEditsButton.show();
|
||||
|
||||
// Create copy button
|
||||
const copyButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right);
|
||||
const copyButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 3);
|
||||
copyButton.text = "$(clippy) Copy";
|
||||
copyButton.tooltip = "Generate and copy prompt";
|
||||
copyButton.command = 'prompter.generatePrompt';
|
||||
copyButton.show();
|
||||
|
||||
// Create settings button
|
||||
const settingsButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 2);
|
||||
settingsButton.text = "$(settings-gear)";
|
||||
settingsButton.tooltip = "Prompter Settings";
|
||||
settingsButton.command = 'prompter.openSettings';
|
||||
settingsButton.show();
|
||||
|
||||
// Register command to toggle file selection
|
||||
let toggleSelectionCommand = vscode.commands.registerCommand('prompter.toggleSelection', (item: FileTreeItem) => {
|
||||
if (item.resourceUri) {
|
||||
@@ -95,13 +102,6 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
"$(check) XML Edits" : "$(diff-added) XML Edits";
|
||||
});
|
||||
|
||||
// Create settings button
|
||||
const settingsButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
|
||||
settingsButton.text = "$(settings-gear)";
|
||||
settingsButton.tooltip = "Prompter Settings";
|
||||
settingsButton.command = 'prompter.openSettings';
|
||||
settingsButton.show();
|
||||
|
||||
// Register command to open settings
|
||||
let openSettingsCommand = vscode.commands.registerCommand('prompter.openSettings', () => {
|
||||
prompterTreeProvider.toggleSettingsView();
|
||||
@@ -113,6 +113,11 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
"Show Files" : "Prompter Settings";
|
||||
});
|
||||
|
||||
// Register command to show the tree view
|
||||
let openTreeViewCommand = vscode.commands.registerCommand('prompter.openTreeView', () => {
|
||||
prompterTreeProvider.showFilesView();
|
||||
});
|
||||
|
||||
// Register command to generate prompt from selected files
|
||||
let generatePromptCommand = vscode.commands.registerCommand('prompter.generatePrompt', async () => {
|
||||
const selectedFiles = prompterTreeProvider.getSelectedFiles();
|
||||
@@ -155,7 +160,8 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
toggleSelectionCommand,
|
||||
toggleXmlEditsCommand,
|
||||
generatePromptCommand,
|
||||
openSettingsCommand
|
||||
openSettingsCommand,
|
||||
openTreeViewCommand
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,16 @@ export class PrompterTreeProvider implements vscode.TreeDataProvider<FileTreeIte
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
showSettingsView(): void {
|
||||
this.showingSettings = true;
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
showFilesView(): void {
|
||||
this.showingSettings = false;
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
getTreeItem(element: FileTreeItem | SettingTreeItem): vscode.TreeItem {
|
||||
// Return the element as is if it's a SettingTreeItem
|
||||
if (element instanceof SettingTreeItem) {
|
||||
|
||||
Reference in New Issue
Block a user