mirror of
https://github.com/OlivierGuinart/Merlin32ForVSCode.git
synced 2024-12-22 10:30:44 +00:00
hover functionality final refactoring
This commit is contained in:
parent
6ef863618e
commit
367dd43955
@ -1,27 +1,8 @@
|
||||
import * as vscode from 'vscode';
|
||||
import * as data from '../strings/resources.json';
|
||||
import * as hover from './hover';
|
||||
|
||||
// this method is called when vs code is activated
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
hover.initializeOpcodesRegex();
|
||||
let activeEditor = vscode.window.activeTextEditor;
|
||||
if (activeEditor) {
|
||||
hover.triggerUpdateDecorations(activeEditor);
|
||||
}
|
||||
|
||||
vscode.window.onDidChangeActiveTextEditor(editor => {
|
||||
activeEditor = editor;
|
||||
if (editor) {
|
||||
hover.triggerUpdateDecorations(activeEditor);
|
||||
}
|
||||
}, null, context.subscriptions);
|
||||
|
||||
vscode.workspace.onDidChangeTextDocument(event => {
|
||||
if (activeEditor && event.document === activeEditor.document) {
|
||||
hover.triggerUpdateDecorations(activeEditor);
|
||||
}
|
||||
}, null, context.subscriptions);
|
||||
hover.activate(context);
|
||||
}
|
||||
|
||||
|
26
src/hover.ts
26
src/hover.ts
@ -5,8 +5,30 @@ import * as data from '../strings/resources.json';
|
||||
// this is just to enable hover.
|
||||
const opcodesDecorationType = vscode.window.createTextEditorDecorationType({ });
|
||||
|
||||
export function activate(context: vscode.ExtensionContext)
|
||||
{
|
||||
initializeOpcodesRegex();
|
||||
let activeEditor = vscode.window.activeTextEditor;
|
||||
if (activeEditor) {
|
||||
triggerUpdateDecorations(activeEditor);
|
||||
}
|
||||
|
||||
vscode.window.onDidChangeActiveTextEditor(editor => {
|
||||
activeEditor = editor;
|
||||
if (editor) {
|
||||
triggerUpdateDecorations(activeEditor);
|
||||
}
|
||||
}, null, context.subscriptions);
|
||||
|
||||
vscode.workspace.onDidChangeTextDocument(event => {
|
||||
if (activeEditor && event.document === activeEditor.document) {
|
||||
triggerUpdateDecorations(activeEditor);
|
||||
}
|
||||
}, null, context.subscriptions);
|
||||
}
|
||||
|
||||
var _regExp: RegExp;
|
||||
export function initializeOpcodesRegex() {
|
||||
function initializeOpcodesRegex() {
|
||||
let r : string = "\\b(";
|
||||
for (var prop in data) {
|
||||
if (prop != "--^") {
|
||||
@ -20,7 +42,7 @@ export function initializeOpcodesRegex() {
|
||||
|
||||
let _activeEditor: vscode.TextEditor;
|
||||
var _timeout = null;
|
||||
export function triggerUpdateDecorations(activeEditor: vscode.TextEditor) : NodeJS.Timer {
|
||||
function triggerUpdateDecorations(activeEditor: vscode.TextEditor) : NodeJS.Timer {
|
||||
_activeEditor = activeEditor;
|
||||
if (_timeout) {
|
||||
clearTimeout(_timeout);
|
||||
|
Loading…
Reference in New Issue
Block a user