From 477160fc81e5b5072030045d0d2fd41ccc8c73f0 Mon Sep 17 00:00:00 2001 From: Joseph Abbey Date: Sat, 24 Jun 2023 15:39:57 +0100 Subject: [PATCH] asm_compile gotos --- design/demos/asm/add.asm | 2 +- scratch-vhdl-vscode/src/extension.ts | 31 +++++++++++++++++----------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/design/demos/asm/add.asm b/design/demos/asm/add.asm index 3e52f9a..38e6eb6 100644 --- a/design/demos/asm/add.asm +++ b/design/demos/asm/add.asm @@ -16,7 +16,7 @@ r1 <- 0b0000 loop: leds <- r0 + btns - wincr 3 + wincri 3 leds <- btns and r1 wincr 1 goto loop diff --git a/scratch-vhdl-vscode/src/extension.ts b/scratch-vhdl-vscode/src/extension.ts index 4bf5e32..6e2a14e 100644 --- a/scratch-vhdl-vscode/src/extension.ts +++ b/scratch-vhdl-vscode/src/extension.ts @@ -35,17 +35,19 @@ export function activate(context: vscode.ExtensionContext) { output = output.replace( / --> ([a-zA-Z]:[\\\/](?:[^\\\/<>:"|?*\s]+[\\\/])*(?:[^\\\/<>:"|?*\s]+\.asm)):\x1b\[0m\x1b\[90m(\d+):(\d+)/g, (_, file, line, column) => - ` --> ${file}:` + ` --> ${file}:` ); output = output.replace( / --> ([a-zA-Z]:[\\\/](?:[^\\\/<>:"|?*\s]+[\\\/])*(?:[^\\\/<>:"|?*\s]+\.asm)):\x1b\[0m\x1b\[90m(\d+):(\d+)/g, (_, file, line, column) => - ` --> ${file}:` + ` --> ${file}:` ); output = output.replace( /\x1b\[90m/g, @@ -95,22 +97,27 @@ export function activate(context: vscode.ExtensionContext) { case 'goto': { const a = message.text.split(','); const f = a[0]; - const b = message.text.split(' '); + const b = a[1].split(' '); const l = parseInt(b[0]); const c = parseInt(b[1]); - const doc = await vscode.workspace.openTextDocument( - vscode.Uri.parse(f) + const e = await vscode.window.showTextDocument( + await vscode.workspace.openTextDocument(vscode.Uri.file(f)), + { + preview: true, + viewColumn: editor.viewColumn, + } ); - const e = await vscode.window.showTextDocument(doc); - e.revealRange( new vscode.Range( new vscode.Position(l, c), new vscode.Position(l, c) ) ); - e.selection = new vscode.Selection(l, 0, l, 999); + e.selection = new vscode.Selection( + new vscode.Position(l, c), + new vscode.Position(l, c) + ); break; } }