Skip to content

Commit ccd60da

Browse files
authored
preparations for export/import commands (#102)
* update activation events * define commands * execute function on command
1 parent db41910 commit ccd60da

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

package.json

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "VBA",
44
"description": "VBA tooling, syntax highlighting and snippets for VS Code.",
55
"icon": "images/icon_256x256.png",
6-
"version": "0.9.4",
6+
"version": "0.9.5-dev",
77
"license": "MIT",
88
"repository": {
99
"type": "git",
@@ -22,7 +22,11 @@
2222
"VBA",
2323
"WWB"
2424
],
25-
"activationEvents": [],
25+
"activationEvents": [
26+
"onLanguage:vba",
27+
"onLanguage:wwb",
28+
"workspaceContains:**/*.{docm,xlsm,pptm}"
29+
],
2630
"main": "./out/extension.js",
2731
"capabilities": {
2832
"untrustedWorkspaces": {
@@ -65,7 +69,41 @@
6569
"scopeName": "source.wwb",
6670
"path": "./out/wwb.tmGrammar.json"
6771
}
68-
]
72+
],
73+
"commands": [
74+
{
75+
"command": "vba.extract_from_doc",
76+
"title": "VBA: Extract code from office document."
77+
},
78+
{
79+
"command": "vba.write_to_doc",
80+
"title": "VBA: Write code to office document."
81+
}
82+
],
83+
"menus": {
84+
"commandPalette": [
85+
{
86+
"command": "vba.extract_from_doc",
87+
"when": "false"
88+
},
89+
{
90+
"command": "vba.write_to_doc",
91+
"when": "false"
92+
}
93+
],
94+
"explorer/context": [
95+
{
96+
"command": "vba.extract_from_doc",
97+
"when": "resourceExtname in vba.ctx.docExts",
98+
"group": "2_workspace"
99+
},
100+
{
101+
"command": "vba.write_to_doc",
102+
"when": "resourceExtname in vba.ctx.docExts",
103+
"group": "2_workspace"
104+
}
105+
]
106+
}
69107
},
70108
"scripts": {
71109
"compile": "bait --library -o out/extension.js src",

src/extension.js.bt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,26 @@ package extension
55

66
import 'vscode' as #JS.vscode
77

8-
// TODO vscode.ExtensionContext
8+
// TODO lot's of JS interop improvements
9+
910
@export: 'activate'
1011
fun activate(context #JS.Any) {
12+
#JS.'JS.vscode.commands.executeCommand("setContext", "vba.ctx.docExts", [".docm", ".xlsm", ".pptm"])'
13+
14+
#JS.'context.subscriptions.push(JS.vscode.commands.registerCommand("vba.extract_from_doc", extension__extract_from_doc))'
15+
#JS.'context.subscriptions.push(JS.vscode.commands.registerCommand("vba.write_to_doc", extension__write_to_doc))'
16+
1117
println('vscode-vba activated')
1218
}
19+
20+
fun extract_from_doc() {
21+
show_notif_funding()
22+
}
23+
24+
fun write_to_doc() {
25+
show_notif_funding()
26+
}
27+
28+
fun show_notif_funding(){
29+
#JS.'JS.vscode.window.showInformationMessage("This feature is not yet complete.\nPlease consider a donation to support it\'s development.")'
30+
}

0 commit comments

Comments
 (0)