Skip to content

Commit ded4150

Browse files
committed
' ' view as a word
1 parent 9b16203 commit ded4150

File tree

5 files changed

+623
-2
lines changed

5 files changed

+623
-2
lines changed

language-configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
["\"", "\""],
2020
["'", "'"]
2121
],
22-
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\:\\;\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)|(\\;.+$)",
22+
"wordPattern": "('(.*?)')|(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\:\\;\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)|(\\;.+$)",
2323
"folding": {
2424
"markers": {
2525
"start": "proc|struct",

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as nls from 'vscode-nls'
33

44
const localize = nls.config({ messageFormat: nls.MessageFormat.both })();
55
import {runcode} from './runcode'
6-
import {hoveractivate} from "./language/lang"
6+
import {hoveractivate} from "./language/hover"
77
let asm:runcode
88
export function activate(context: vscode.ExtensionContext) {
99
console.log(localize("active.hello",'Congratulations, your extension "masm-tasm" is now active!'));

src/language/hover.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import * as vscode from 'vscode';
2+
import * as info from "./wordinfo";
3+
4+
class TasmHoverProvider implements vscode.HoverProvider {
5+
async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken) {
6+
let output:vscode.MarkdownString=new vscode.MarkdownString()
7+
let range = document.getWordRangeAtPosition(new vscode.Position(position.line, position.character));
8+
if(range){
9+
let word = document.getText(range).toLowerCase();
10+
let char=/'(.)'/.exec(word)
11+
if(char) output.appendMarkdown(info.getcharMsg(char[1]));
12+
let keyword = info.GetKeyword(word)
13+
// let proc = findProc(word)
14+
// let macro = findMacro(word),label=findLabel(word);
15+
if(info.isNumberStr(word)){
16+
output.appendMarkdown(info.getNumMsg(word));}
17+
// else if(proc !== undefined){
18+
// output.appendCodeblock("assembly","(Procedure) " + proc.name)
19+
// output.appendMarkdown( proc.description.des)
20+
// output.appendCodeblock("assembly", proc.description.paramsString())
21+
// output.appendCodeblock("assembly", proc.description.outputs())
22+
// }else if(macro !== undefined) {
23+
// if(macro.short){
24+
// output.appendCodeblock("assembly","(Macro) " + macro.name + " => " + macro.des.des)
25+
// }else{
26+
// output.appendCodeblock("assembly","(Macro) " + macro.name)
27+
// output.appendText(macro.des.des)
28+
// output.appendCodeblock("assembly",macro.des.paramsStringMac())
29+
// output.appendCodeblock("assembly",macro.des.outputs() )
30+
// }
31+
// }
32+
else if(keyword !== undefined){
33+
let md=info.getType(keyword.type)+" **"+keyword.name+"**\n\n"+keyword.def
34+
output.appendMarkdown(md)
35+
output.appendCodeblock("Syntax: " + keyword.data)
36+
}
37+
//else if(label !== undefined){
38+
// output.appendCodeblock('assembly','(Label) ' + label.name + " => " + label.value)
39+
// }
40+
}
41+
return new vscode.Hover(output);}
42+
}
43+
44+
export function hoveractivate(context: vscode.ExtensionContext) {
45+
if(vscode.workspace.getConfiguration('masmtasm.language').get('hover'))context.subscriptions.push(vscode.languages.registerHoverProvider('assembly',new TasmHoverProvider()));
46+
}
47+

src/language/scandoc.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)