Use VS Code mode

This commit is contained in:
brice.boisson
2025-10-22 23:24:27 +02:00
parent 0d91be6664
commit 8896c92d75
3 changed files with 123 additions and 118 deletions

View File

@@ -16,10 +16,10 @@
{ "command": "modelsim.toggleWaveMode", "title": "Toggle Wave Debug Mode" }
],
"keybindings": [
{ "command": "modelsim.addWaveUnderCursor", "key": "ctrl+w", "args": { "mode": "auto" } },
{ "command": "modelsim.addWaveUnderCursor", "key": "ctrl+e", "args": { "mode": "set" } },
{ "command": "modelsim.addWaveUnderCursor", "key": "ctrl+w", "when": "modelsim.mode", "args": { "mode": "auto" } },
{ "command": "modelsim.addWaveUnderCursor", "key": "ctrl+e", "when": "modelsim.mode", "args": { "mode": "set" } },
{ "command": "modelsim.toggleWaveMode", "key": "ctrl+alt+m" },
{ "command": "modelsim.zoomInWave", "key": "ctrl+alt+u" }
{ "command": "modelsim.zoomInWave", "key": "ctrl+alt+u", "when": "modelsim.mode" }
],
"viewsContainers": {
"panel": [

View File

@@ -10,6 +10,10 @@ import { requestModuleTree, addWave } from './wave_editor';
export const lastHoverByDoc = new Map<string, { pos: vscode.Position; at: number }>();
export const HOVER_FRESH_MS = 2000;
let statusItem: vscode.StatusBarItem;
const CTX = 'modelsim.mode';
export let waveMode = false;
// Hold MANY instance paths per module name, e.g. queue_slot -> ["/test/...[0]", "/test/...[1]", ...]
const svSelectors: vscode.DocumentSelector = [
@@ -17,20 +21,22 @@ const svSelectors: vscode.DocumentSelector = [
{ language: 'verilog', scheme: 'file' }
];
export let waveMode = false;
let statusItem: vscode.StatusBarItem;
function toggleWaveMode() {
async function toggleWaveMode() {
waveMode = !waveMode;
statusItem.text = waveMode ? '🌊 Wave Debug Mode' : '✏️ Edit Mode';
await vscode.commands.executeCommand('setContext', CTX, waveMode);
statusItem.tooltip = waveMode
? 'Wave Debug Mode — click to switch to Edit Mode'
: 'Edit Mode — click to switch to Wave Debug Mode';
}
export function activate(context: vscode.ExtensionContext) {
export async function activate(context: vscode.ExtensionContext) {
statusItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 1000);
statusItem.command = 'modelsim.toggleWaveMode'; // click to toggle
// statusItem.command = 'modelsim.toggleWaveMode'; // click to toggle
await vscode.commands.executeCommand('setContext', CTX, false);
const cmd_2 = vscode.commands.registerCommand('modelsim.toggleWaveMode', async () => {
toggleWaveMode();

View File

@@ -43,7 +43,10 @@ export async function requestModuleTree(
export async function addWave(
mode: String
) {
if (waveMode) {
if (!waveMode) {
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
return;
}
const editor = vscode.window.activeTextEditor;
if (!editor) return;
@@ -150,10 +153,6 @@ export async function addWave(
} else {
vscode.window.showWarningMessage('No response from ModelSim (timeout or error).');
}
} else {
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
}
}
async function looksLikeVariable(