-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
380 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
min-width: 4px; | ||
min-height: 4px; | ||
background-color: blueviolet; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
span.name | ||
{ | ||
color: var(--vscode-debugTokenExpression-name) | ||
} | ||
|
||
span.number | ||
{ | ||
color: var(--vscode-debugTokenExpression-number) | ||
} | ||
|
||
span.string | ||
{ | ||
color: var(--vscode-debugTokenExpression-string) | ||
} | ||
|
||
span.rawvalue | ||
{ | ||
color: var(--vscode-debugTokenExpression-string) | ||
} | ||
|
||
span.label | ||
{ | ||
color: var(--vscode-debugTokenExpression-value) | ||
} | ||
|
||
span.clickable | ||
{ | ||
cursor: pointer; | ||
} | ||
|
||
span.clickable:hover | ||
{ | ||
text-decoration: underline; | ||
} | ||
|
||
p.history | ||
{ | ||
margin: 0; | ||
font-family: var(--vscode-editor-font-family); | ||
font-weight: var(--vscode-editor-font-weight); | ||
font-size: var(--vscode-editor-font-size); | ||
white-space: pre; | ||
} | ||
|
||
p.label | ||
{ | ||
margin: 0 0 5px 0; | ||
font-family: var(--vscode-editor-font-family); | ||
font-weight: var(--vscode-editor-font-weight); | ||
font-size: var(--vscode-editor-font-size); | ||
white-space: pre; | ||
} | ||
|
||
#results | ||
{ | ||
margin-top: 10px; | ||
} | ||
|
||
.display_control | ||
{ | ||
margin-top: 10px; | ||
margin-bottom: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import { Disposable, ExtensionContext, Uri, window, ViewColumn, Webview, WebviewPanel, commands, debug, StatusBarAlignment, workspace, Position, Selection, Range, TextDocumentShowOptions } from "vscode"; | ||
import { getUri } from "../utilities/getUri"; | ||
import { getNonce } from "../utilities/getNonce"; | ||
import { messages } from "../memoryView/common"; | ||
|
||
export class HistoryView { | ||
public static currentPanel: HistoryView | undefined; | ||
|
||
public static activate(context: ExtensionContext) { | ||
const uri = context.extensionUri; | ||
|
||
context.subscriptions.push( | ||
commands.registerCommand('historyView.start', () => { | ||
const columnToShowIn = window.activeTextEditor | ||
? window.activeTextEditor.viewColumn | ||
: undefined; | ||
|
||
if (HistoryView.currentPanel) { | ||
HistoryView.currentPanel._panel.reveal(columnToShowIn); | ||
} | ||
else { | ||
const panel = window.createWebviewPanel( | ||
'historyView', | ||
'History View', | ||
columnToShowIn || ViewColumn.One, | ||
{ | ||
enableScripts: true, | ||
retainContextWhenHidden: true | ||
} | ||
); | ||
|
||
HistoryView.currentPanel = new HistoryView(panel, uri); | ||
} | ||
}) | ||
); | ||
} | ||
|
||
private readonly _panel: WebviewPanel; | ||
private _disposables: Disposable[] = []; | ||
|
||
private constructor(panel: WebviewPanel, extensionUri: Uri) { | ||
this._panel = panel; | ||
|
||
this._panel.onDidDispose(() => { this.dispose(), null, this, this._disposables }); | ||
|
||
this._panel.webview.html = this._getWebviewContent(this._panel.webview, extensionUri); | ||
|
||
this._setWebviewMessageListener(this._panel.webview); | ||
} | ||
|
||
private dispose() { | ||
HistoryView.currentPanel = undefined; | ||
|
||
this._panel.dispose(); | ||
|
||
while (this._disposables.length) { | ||
const disposable = this._disposables.pop(); | ||
if (disposable) { | ||
disposable.dispose(); | ||
} | ||
} | ||
} | ||
|
||
private _setWebviewMessageListener(webview: Webview) { | ||
webview.onDidReceiveMessage( | ||
(message: any) => { | ||
const command = message.command; | ||
|
||
switch (command) { | ||
case messages.getHistory: | ||
this._getHistory(webview); | ||
return; | ||
case messages.showFile: | ||
this._showFile(message.fileName, message.lineNumber); | ||
return; | ||
} | ||
}, | ||
undefined, | ||
this._disposables | ||
); | ||
} | ||
|
||
private _showFile(fileName: string, lineNumber: number) { | ||
const p = new Position(lineNumber - 1, 0); | ||
|
||
var o = new ShowOptions(); | ||
o.selection = new Selection(p, p); | ||
workspace.openTextDocument(Uri.file(fileName)).then(d => { | ||
window.showTextDocument(d, o); | ||
// .then(e => { | ||
// e.selections = [new Selection(p, p)]; | ||
// const r = new Range(p, p); | ||
// e.revealRange(r); | ||
// }); | ||
}); | ||
} | ||
|
||
private _getHistory(webview: Webview) { | ||
debug.activeDebugSession?.customRequest(messages.getHistory, {} | ||
).then(i => { | ||
webview.postMessage({ | ||
command: messages.updateHistory, payload: | ||
JSON.stringify(i) | ||
}); | ||
}); | ||
} | ||
|
||
private _getWebviewContent(webview: Webview, extensionUri: Uri) { | ||
const webviewUri = getUri(webview, extensionUri, ["out", "historyView.webview.js"]); | ||
const nonce = getNonce(); | ||
const styleUri = getUri(webview, extensionUri, ["out", "historyView.css"]); | ||
|
||
return /*html*/ `<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self' data:; style-src ${webview.cspSource}; script-src 'nonce-${nonce}';"> | ||
<title>Layer View</title> | ||
<link rel="stylesheet" href="${styleUri}"> | ||
</head> | ||
<body> | ||
<div class="display_control"> | ||
<div class="control_holder"> | ||
<vscode-button appearance="primary" id="update">Update</vscode-button> | ||
</div> | ||
</div> | ||
<div class="history_results_container"> | ||
<div id="results"></div> | ||
</div> | ||
<script type="module" nonce="${nonce}" src="${webviewUri}"></script> | ||
</body> | ||
</html>`; | ||
} | ||
} | ||
|
||
class ShowOptions implements TextDocumentShowOptions | ||
{ | ||
viewColumn?: ViewColumn; | ||
preserveFocus?: boolean; | ||
preview?: boolean; | ||
selection?: Range; | ||
} |
Oops, something went wrong.