diff --git a/images/icons/dark/globe.svg b/images/icons/dark/globe.svg new file mode 100644 index 000000000..1ff60a534 --- /dev/null +++ b/images/icons/dark/globe.svg @@ -0,0 +1,3 @@ + + + diff --git a/images/icons/dark/graph.svg b/images/icons/dark/graph.svg new file mode 100644 index 000000000..e07277064 --- /dev/null +++ b/images/icons/dark/graph.svg @@ -0,0 +1,3 @@ + + + diff --git a/images/icons/dark/help.svg b/images/icons/dark/help.svg new file mode 100644 index 000000000..a0a00f005 --- /dev/null +++ b/images/icons/dark/help.svg @@ -0,0 +1,3 @@ + + + diff --git a/images/icons/dark/open-preview.svg b/images/icons/dark/open-preview.svg new file mode 100644 index 000000000..b4ba465da --- /dev/null +++ b/images/icons/dark/open-preview.svg @@ -0,0 +1,3 @@ + + + diff --git a/images/icons/dark/preview.svg b/images/icons/dark/preview.svg new file mode 100644 index 000000000..6f3c492bc --- /dev/null +++ b/images/icons/dark/preview.svg @@ -0,0 +1,3 @@ + + + diff --git a/images/icons/light/globe.svg b/images/icons/light/globe.svg new file mode 100644 index 000000000..a7ad58fe5 --- /dev/null +++ b/images/icons/light/globe.svg @@ -0,0 +1,3 @@ + + + diff --git a/images/icons/light/graph.svg b/images/icons/light/graph.svg new file mode 100644 index 000000000..05facbc1f --- /dev/null +++ b/images/icons/light/graph.svg @@ -0,0 +1,3 @@ + + + diff --git a/images/icons/light/help.svg b/images/icons/light/help.svg new file mode 100644 index 000000000..a6977ef94 --- /dev/null +++ b/images/icons/light/help.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/images/icons/light/open-preview.svg b/images/icons/light/open-preview.svg new file mode 100644 index 000000000..0e0e63c62 --- /dev/null +++ b/images/icons/light/open-preview.svg @@ -0,0 +1,3 @@ + + + diff --git a/images/icons/light/preview.svg b/images/icons/light/preview.svg new file mode 100644 index 000000000..2263883c6 --- /dev/null +++ b/images/icons/light/preview.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/extension.ts b/src/extension.ts index 29d70673f..e68b6e246 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -52,6 +52,7 @@ export async function activate(context: vscode.ExtensionContext): Promise('sessionWatcher'); + // register commands specified in package.json const commands = { // create R terminal diff --git a/src/helpViewer/panel.ts b/src/helpViewer/panel.ts index 9821d5928..a345f035d 100644 --- a/src/helpViewer/panel.ts +++ b/src/helpViewer/panel.ts @@ -4,8 +4,7 @@ import * as vscode from 'vscode'; import * as cheerio from 'cheerio'; import { HelpFile, RHelp } from '.'; -import { setContext } from '../util'; - +import { setContext, UriIcon } from '../util'; //// Declaration of interfaces used/implemented by the Help Panel class // specified when creating a new help panel @@ -73,7 +72,6 @@ export class HelpPanel { preserveFocus: preserveFocus }; this.panel = vscode.window.createWebviewPanel('rhelp', 'R Help', showOptions, webViewOptions); - this.initializePanel(); } @@ -82,8 +80,9 @@ export class HelpPanel { return this.panel.webview; } - - private initializePanel(){ + + private initializePanel() { + this.panel.iconPath = new UriIcon('help'); // virtual uris used to access local files this.webviewScriptUri = this.panel.webview.asWebviewUri(this.webviewScriptFile); this.webviewStyleUri = this.panel.webview.asWebviewUri(this.webviewStyleFile); @@ -109,7 +108,7 @@ export class HelpPanel { void this.setContextValues(); }); } - + public async setContextValues(): Promise { await setContext('r.helpPanel.active', !!this.panel?.active); diff --git a/src/plotViewer/index.ts b/src/plotViewer/index.ts index 0b5c91f85..2e1199245 100644 --- a/src/plotViewer/index.ts +++ b/src/plotViewer/index.ts @@ -8,7 +8,7 @@ import * as path from 'path'; import * as fs from 'fs'; import * as ejs from 'ejs'; -import { config, setContext } from '../util'; +import { config, setContext, UriIcon } from '../util'; import { extensionContext } from '../extension'; @@ -272,7 +272,7 @@ export class HttpgdViewer implements IHttpgdViewer { readonly defaultPreviewPlotLayout: PreviewPlotLayout = 'multirow'; previewPlotLayout: PreviewPlotLayout; - + readonly defaultFullWindow: boolean = false; fullWindow: boolean; @@ -480,7 +480,7 @@ export class HttpgdViewer implements IHttpgdViewer { }; this.postWebviewMessage(msg); } - + public toggleFullWindow(force?: boolean): void { this.fullWindow = force ?? !this.fullWindow; const msg: ToggleFullWindowMessage = { @@ -745,6 +745,7 @@ export class HttpgdViewer implements IHttpgdViewer { showOptions || this.showOptions, this.webviewOptions ); + webviewPanel.iconPath = new UriIcon('graph'); webviewPanel.onDidDispose(() => this.webviewPanel = undefined); webviewPanel.onDidChangeViewState(() => { void this.setContextValues(); diff --git a/src/rmarkdown/preview.ts b/src/rmarkdown/preview.ts index 53932ad9c..f721667bf 100644 --- a/src/rmarkdown/preview.ts +++ b/src/rmarkdown/preview.ts @@ -8,7 +8,7 @@ import path = require('path'); import crypto = require('crypto'); -import { config, doWithProgress, getRpath, readContent, setContext, escapeHtml } from '../util'; +import { config, doWithProgress, getRpath, readContent, setContext, escapeHtml, UriIcon } from '../util'; import { extensionContext, tmpDir } from '../extension'; class RMarkdownPreview extends vscode.Disposable { @@ -377,6 +377,7 @@ export class RMarkdownPreviewManager { } private openPreview(outputUri: vscode.Uri, filePath: string, title: string, cp: cp.ChildProcessWithoutNullStreams, viewer: vscode.ViewColumn, resourceViewColumn: vscode.ViewColumn, autoRefresh: boolean): void { + const panel = vscode.window.createWebviewPanel( 'previewRmd', `Preview ${title}`, @@ -391,6 +392,8 @@ export class RMarkdownPreviewManager { localResourceRoots: [vscode.Uri.file(tmpDir())], }); + panel.iconPath = new UriIcon('preview'); + // Push the new rmd webview to the open proccesses array, // to keep track of running child processes // (primarily used in killing the child process, but also diff --git a/src/session.ts b/src/session.ts index 3fa108fed..6af47dbf6 100644 --- a/src/session.ts +++ b/src/session.ts @@ -11,7 +11,7 @@ import { commands, StatusBarItem, Uri, ViewColumn, Webview, window, workspace, e import { runTextInTerm } from './rTerminal'; import { FSWatcher } from 'fs-extra'; -import { config, readContent } from './util'; +import { config, readContent, UriIcon } from './util'; import { purgeAddinPickerItems, dispatchRStudioAPICall } from './rstudioapi'; import { homeExtDir, rWorkspace, globalRHelp, globalHttpgdManager, extensionContext } from './extension'; @@ -237,6 +237,7 @@ export async function showBrowser(url: string, title: string, viewer: string | b } void commands.executeCommand('setContext', 'r.browser.active', false); }); + panel.iconPath = new UriIcon('globe'); panel.webview.html = getBrowserHtml(externalUri); } console.info('[showBrowser] Done'); @@ -297,7 +298,7 @@ export async function showWebView(file: string, title: string, viewer: string | retainContextWhenHidden: true, localResourceRoots: [Uri.file(dir), Uri.file(webviewDir)], }); - + panel.iconPath = new UriIcon('globe'); panel.webview.html = await getWebviewHtml(panel.webview, file, title, dir, webviewDir); } console.info('[showWebView] Done'); @@ -323,6 +324,7 @@ export async function showDataView(source: string, type: string, title: string, localResourceRoots: [Uri.file(resDir)], }); const content = await getTableHtml(panel.webview, file); + panel.iconPath = new UriIcon('open-preview'); panel.webview.html = content; } else if (source === 'list') { const panel = window.createWebviewPanel('dataview', title, @@ -337,6 +339,7 @@ export async function showDataView(source: string, type: string, title: string, localResourceRoots: [Uri.file(resDir)], }); const content = await getListHtml(panel.webview, file); + panel.iconPath = new UriIcon('open-preview'); panel.webview.html = content; } else { if (isGuestSession) { diff --git a/src/util.ts b/src/util.ts index b961cf268..c392a8953 100644 --- a/src/util.ts +++ b/src/util.ts @@ -7,6 +7,7 @@ import * as path from 'path'; import * as vscode from 'vscode'; import * as cp from 'child_process'; import { rGuestService, isGuestSession } from './liveShare'; +import { extensionContext } from './extension'; export function config(): vscode.WorkspaceConfiguration { return vscode.workspace.getConfiguration('r'); @@ -361,3 +362,13 @@ export function getDir(dirPath: string): string { } return dirPath; } + +export class UriIcon { + dark: vscode.Uri; + light: vscode.Uri; + constructor(id: string) { + const extIconPath = extensionContext.asAbsolutePath('images/icons'); + this.dark = vscode.Uri.file(path.join(extIconPath, 'dark', id + '.svg')); + this.light = vscode.Uri.file(path.join(extIconPath, 'light', id + '.svg')); + } +}