diff --git a/package.json b/package.json index bbfad5c..2e87eb0 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "Languages" ], "activationEvents": [ - "onLanguage:merlin32" + "onLanguage:merlin32", + "onCommand:extension.target.build" ], "main": "./out/extension", "contributes": { @@ -34,6 +35,51 @@ "scopeName": "source.asm.merlin32", "path": "./syntaxes/merlin32.tmLanguage.json" } + ], + "configuration": { + "type": "object", + "title": "Merlin32 configuration", + "properties": { + "Merlin32.platform": { + "type": "string", + "default": "Windows", + "description": "Possible values are Windows, Linux64, MaxOSX" + }, + "Merlin32.libs": { + "type": "string", + "default": "C:\\Users\\Olivier\\OneDrive\\Apple\\Merlin32_v1.0\\Library", + "description": "Path to the Merlin32 Library folder." + }, + "Merlin32.path": { + "type": "string", + "default": "C:\\Users\\Olivier\\OneDrive\\Apple\\Merlin32_v1.0\\", + "description": "Path to the Merlin32 toolset." + }, + "Merlin32.AppleII.emulator": { + "type": "string", + "default": "AppleWin.exe", + "description": "Apple II emulator." + } + } + }, + "menus": { + "editor/title": [{ + "when": "editorLangId == merlin32", + "command": "extension.target.build", + "group": "navigation" + }] + }, + "commands": [ + { + "command": "extension.target.build", + "title": "Build" + } + ], + "keybindings": [ + { + "command": "extension.target.build", + "key": "f10" + } ] }, "scripts": { diff --git a/src/extension.ts b/src/extension.ts index f865d12..b6850cd 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -4,6 +4,20 @@ import * as data from '../strings/resources.json'; // this method is called when vs code is activated export function activate(context: vscode.ExtensionContext) { + // Register the Build command (as defined in package.json) + var disposable = vscode.commands.registerCommand('extension.target.build', function () + { buildCommand(); }); + + activateHoverTooltips(context); +} + +//************************************************************** +// TODO: move this function to its own file +// TODO: checkout what is vscode.executeHoverProvider (https://code.visualstudio.com/docs/extensionAPI/vscode-api-commands) +function activateHoverTooltips(context: vscode.ExtensionContext) { + + console.log("Activating hover tooltips..."); + function initializeOpcodesRegex() { let r : string = "\\b("; for (var prop in data) { @@ -68,3 +82,24 @@ export function activate(context: vscode.ExtensionContext) { } } + +//************************************************************** +function buildCommand() { + + console.log("In buildCommand..."); + + var buildCommand = ""; + // Getting path to Merlin32 toolset + buildCommand += vscode.workspace.getConfiguration("Merlin32").get("path", "Name"); + // Adding platform (Windows, MaxOSX, Linux64) + buildCommand += vscode.workspace.getConfiguration("Merlin32").get("platform", "Name") + "\\"; + // Adding assembler executable name + buildCommand += "Merlin32"; + // Adding the libraries argument + buildCommand += " -V " + vscode.workspace.getConfiguration("Merlin32").get("libs", "Name"); + buildCommand += " HelloWorld.s"; + + console.log("buildCommand = " + buildCommand); + + // TODO: checkout if the integrated terminal can then be used: https://code.visualstudio.com/docs/editor/integrated-terminal +}