mirror of
https://gitlab.com/aviortheking/code-stats-vscode.git
synced 2025-04-22 10:52:13 +00:00
HTML View for C::S Profile
This commit is contained in:
parent
01cd77e519
commit
982621c3a4
@ -3,6 +3,12 @@ import {
|
||||
Disposable,
|
||||
workspace,
|
||||
window,
|
||||
Uri,
|
||||
ViewColumn,
|
||||
commands,
|
||||
TextDocumentContentProvider,
|
||||
Event,
|
||||
CancellationToken,
|
||||
StatusBarItem,
|
||||
TextDocument,
|
||||
StatusBarAlignment,
|
||||
@ -13,6 +19,13 @@ import {
|
||||
import { Pulse } from "./pulse";
|
||||
import { CodeStatsAPI } from "./code-stats-api";
|
||||
|
||||
class HtmlProvider implements TextDocumentContentProvider {
|
||||
onDidChange?: Event<Uri>;
|
||||
provideTextDocumentContent(uri: Uri, token: CancellationToken): string | Thenable<string> {
|
||||
return "Nice HTML view of CS Stats for user";
|
||||
}
|
||||
}
|
||||
|
||||
export class XpCounter {
|
||||
private combinedDisposable: Disposable;
|
||||
private statusBarItem: StatusBarItem;
|
||||
@ -25,6 +38,7 @@ export class XpCounter {
|
||||
// wait 10s after each change in the document before sending an update
|
||||
private UPDATE_DELAY = 10000;
|
||||
|
||||
|
||||
constructor() {
|
||||
this.pulse = new Pulse();
|
||||
|
||||
@ -38,11 +52,24 @@ export class XpCounter {
|
||||
|
||||
this.initAPI();
|
||||
|
||||
let subscriptions: Disposable[] = [];
|
||||
|
||||
if (!this.statusBarItem) {
|
||||
this.statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left);
|
||||
this.statusBarItem.command = "code-stats.profile";
|
||||
}
|
||||
|
||||
let subscriptions: Disposable[] = [];
|
||||
let provider = new HtmlProvider();
|
||||
let registration = workspace.registerTextDocumentContentProvider('code-stats', provider);
|
||||
|
||||
subscriptions.push(registration);
|
||||
|
||||
let previewUri = Uri.parse('code-stats://profile')
|
||||
|
||||
subscriptions.push(commands.registerCommand("code-stats.profile", () => {
|
||||
commands.executeCommand('vscode.previewHtml', previewUri, ViewColumn.Two, 'Code::Stats Profile');
|
||||
} ) );
|
||||
|
||||
workspace.onDidChangeTextDocument(
|
||||
this.onTextDocumentChanged,
|
||||
this,
|
||||
|
Loading…
x
Reference in New Issue
Block a user