Skip to content

Commit 24efef7

Browse files
committed
1
1 parent 34043a9 commit 24efef7

File tree

11 files changed

+72
-397
lines changed

11 files changed

+72
-397
lines changed

masm-tasm/src/ASM/main.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import * as vscode from "vscode";
22
import { nodejs_emu_list } from "../emulators/main-nodejs";
33
import { ActionType } from "../utils/configuration";
44
import { activateManager } from "./manager";
5-
import * as statusBar from './statusBar';
65

76
export async function activate(context: vscode.ExtensionContext) {
8-
statusBar.activate(context);
97

108
const execAction = activateManager(context, nodejs_emu_list);
119

masm-tasm/src/ASM/manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import * as vscode from 'vscode';
22

3-
import { API } from './vscode-dosbox';
43
import * as Diag from '../diagnose/main';
54
import * as conf from '../utils/configuration';
65
import { logger } from '../utils/logger';
76
import { uriUtils } from '../utils/util';
87

9-
export * from './vscode-dosbox';
8+
import * as statusbar from "../emulators/jsdos-ci";
109

1110
export interface AsmResult {
1211
message: string,
@@ -46,6 +45,7 @@ function actionMessage(act: conf.ActionType, file: string): string {
4645

4746
export function activateManager(context: vscode.ExtensionContext, actions: ExecAction[]) {
4847
const diag = Diag.activate(context);
48+
statusbar.activate(context)
4949

5050
return async function (actionType: conf.ActionType, _uri: vscode.Uri) {
5151
if(_uri===undefined && vscode.window.activeTextEditor){

masm-tasm/src/ASM/statusBar.ts

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as vscode from 'vscode';
2+
import * as conf from '../utils/configuration';
3+
4+
const bar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
5+
6+
function showStatus() {
7+
bar.command = 'masmtasm.updateEmuASM';
8+
bar.text = `${conf.extConf.emulator} ${conf.extConf.asmType}`;
9+
bar.show();
10+
}
11+
12+
async function statusBarCommand() {
13+
const _conf = vscode.workspace.getConfiguration('masmtasm.ASM');
14+
const items=["show jsdos view","show terminal"]
15+
16+
const placeHolder = 'manipulate emulator';
17+
const Selected = await vscode.window.showQuickPick(items, { placeHolder });
18+
if (Selected) {
19+
const [emu1, asm1] = Selected?.split('\t');
20+
const target = vscode.ConfigurationTarget.Global;
21+
await _conf.update('emulator', emu1, target);
22+
await _conf.update('assembler', asm1, target);
23+
showStatus();
24+
}
25+
}
26+
27+
export function activate(context: vscode.ExtensionContext): void {
28+
const disposable = vscode.commands.registerCommand('masmtasm.updateEmuASM', statusBarCommand);
29+
context.subscriptions.push(disposable);
30+
showStatus();
31+
}

masm-tasm/src/emulators/jsdos-webview.ts

Whitespace-only changes.

masm-tasm/src/language/Hover.ts

Lines changed: 38 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { MarkdownString, Uri } from "vscode";
55
import { Cppdoc } from './hoverFromCppdoc';
66
import { FELIX } from './hoverFelix';
77
import { HoverFromMarkdown } from './hoverFromMarkdown';
8-
import * as ast from "./ast/main";
98

109
export enum keywordType {
1110
other = 0,
@@ -48,64 +47,50 @@ export class AsmHoverProvider implements vscode.HoverProvider {
4847
const docinfo = DocInfo.getDocInfo(document); //scan the document
4948
const line = docinfo.lines[position.line];
5049

51-
const text = document.getText();
52-
const lexer = new ast.AssemblyLexer(text);
5350

54-
const tokens = lexer.tokenize();
51+
if (range) {
52+
const wordGet = document.getText(range);
53+
const wordLowCase = wordGet.toLowerCase();
5554

56-
for (const token of tokens) {
57-
if (token.line - 1 == position.line) {
58-
if (position.character+1 >= token.column && position.character+1 < token.column + token.value.length) {
59-
const str = `${token.value} ${token.column} ${position.character} ${token.type}`;
60-
return new vscode.Hover(str);
55+
if (line && line.operator?.includes(wordGet)) {
56+
const h = await this.getHover(wordGet, [keywordType.instruction]);
57+
if (h) { return h; }
58+
}
59+
60+
if (line && line.operand?.includes(wordGet)) {
61+
62+
const md = new MarkdownString();
63+
if (info.isNumberStr(wordLowCase)) {
64+
md.appendMarkdown(info.getNumMsg(wordLowCase));
65+
return new vscode.Hover(md);
66+
}
67+
68+
69+
//hover for char
70+
let wordGet2=wordGet;
71+
if(range.start.character>0 && range.end.character-range.start.character===1){
72+
const range2=new vscode.Range(range.start.line,range.start.character-1,range.end.line,range.end.character+1);
73+
wordGet2=document.getText(range2);
6174
}
75+
const char = /['"](.)['"]/.exec(wordGet2);
76+
if (char && line.operand?.includes(wordGet2)) {
77+
md.appendMarkdown(info.getcharMsg(char[1]));
78+
return new vscode.Hover(md);
79+
}
80+
81+
const h = await this.getHover(wordGet, [keywordType.operator, keywordType.register, keywordType.symbol]);
82+
if (h) { return h; }
6283
}
63-
}
6484

85+
const asmsymbol = docinfo.findSymbol(wordGet); //the word is a symbol?
86+
if (asmsymbol) {
87+
return new vscode.Hover(asmsymbol.markdown());
88+
}
6589

66-
// if (range) {
67-
// const wordGet = document.getText(range);
68-
// const wordLowCase = wordGet.toLowerCase();
69-
70-
// if (line && line.operator?.includes(wordGet)) {
71-
// const h = await this.getHover(wordGet, [keywordType.instruction]);
72-
// if (h) { return h; }
73-
// }
74-
75-
// if (line && line.operand?.includes(wordGet)) {
76-
77-
// const md = new MarkdownString();
78-
// if (info.isNumberStr(wordLowCase)) {
79-
// md.appendMarkdown(info.getNumMsg(wordLowCase));
80-
// return new vscode.Hover(md);
81-
// }
82-
83-
84-
// //hover for char
85-
// let wordGet2=wordGet;
86-
// if(range.start.character>0 && range.end.character-range.start.character===1){
87-
// const range2=new vscode.Range(range.start.line,range.start.character-1,range.end.line,range.end.character+1);
88-
// wordGet2=document.getText(range2);
89-
// }
90-
// const char = /['"](.)['"]/.exec(wordGet2);
91-
// if (char && line.operand?.includes(wordGet2)) {
92-
// md.appendMarkdown(info.getcharMsg(char[1]));
93-
// return new vscode.Hover(md);
94-
// }
95-
96-
// const h = await this.getHover(wordGet, [keywordType.operator, keywordType.register, keywordType.symbol]);
97-
// if (h) { return h; }
98-
// }
99-
100-
// const asmsymbol = docinfo.findSymbol(wordGet); //the word is a symbol?
101-
// if (asmsymbol) {
102-
// return new vscode.Hover(asmsymbol.markdown());
103-
// }
104-
105-
// const h = await this.getHover(wordGet, [keywordType.other, keywordType.directive, keywordType.register]);
106-
// if (h) { return h; }
107-
// }
108-
// return undefined;
90+
const h = await this.getHover(wordGet, [keywordType.other, keywordType.directive, keywordType.register]);
91+
if (h) { return h; }
92+
}
93+
return undefined;
10994
}
11095

11196
public async getHover(word: string, types: keywordType[]): Promise<vscode.Hover | undefined> {

masm-tasm/src/language/ast/ast.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)