Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
629 changes: 629 additions & 0 deletions extension/media/codicon.css

Large diffs are not rendered by default.

Binary file added extension/media/codicon.ttf
Binary file not shown.
65 changes: 65 additions & 0 deletions extension/media/gnodev-browser.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
:root {
--container-paddding: 20px;
--input-padding-vertical: 2px;
--input-padding-horizontal: 4px;
--input-margin-vertical: 4px;
--input-margin-horizontal: 0;
}

html,
body {
height: 100%;
min-height: 100%;
padding: 0;
margin: 0;
}

body {
height: 100%;
position: relative;
}

button {
border: none;
padding: 3px;
text-align: center;
outline: 1px solid transparent;
color: var(--vscode-icon-foreground);
background: none;
border-radius: 5px;
}

button:hover:not(:disabled) {
cursor: pointer;
color: var(--vscode-toolbar-hoverForeground);
background: var(--vscode-toolbar-hoverBackground);
}

button:disabled {
opacity: 0.5;
}

.floating-controls {
position: fixed;
bottom: 20px;
right: 20px;
display: flex;
gap: 0.3em;
background: var(--vscode-editor-background);
padding: 8px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
border: 1px solid var(--vscode-widget-border);
z-index: 1000;
}

.floating-controls button {
display: flex;
}

iframe {
width: 100%;
height: 100%;
border: none;
background: white; /* Browsers default to a white background */
}
79 changes: 79 additions & 0 deletions extension/media/gnodev-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
function onceDocumentLoaded(f) {
if (document.readyState === 'loading' || document.readyState === 'uninitialized') {
document.addEventListener('DOMContentLoaded', f);
} else {
f();
}
}

const vscode = acquireVsCodeApi();

const iframe = document.getElementById('gnodev-iframe');
const floatingControls = document.querySelector('.floating-controls');
const forwardButton = floatingControls.querySelector('.forward-button');
const backButton = floatingControls.querySelector('.back-button');
const reloadButton = floatingControls.querySelector('.reload-button');
const resetButton = floatingControls.querySelector('.reset-button');
const openExternalButton = floatingControls.querySelector('.open-external-button');

let currentIframeLocation = iframe.src;

onceDocumentLoaded(() => {
// Listen for messages coming from the iframe.
window.addEventListener('message', (event) => {
switch (event.data.type) {
case 'keydown':
window.parent.dispatchEvent(new KeyboardEvent('keydown', this.data.event));
break;
case 'contextmenu':
iframe.dispatchEvent(
new MouseEvent('contextmenu', {
bubbles: true,
clientX: event.data.clientX,
clientY: event.data.clientY
})
);
break;
case 'location':
currentIframeLocation = event.data.url;
break;
}
});

// Forward cut, copy, paste events to the iframe
window.addEventListener('cut', () => {
iframe.contentWindow.postMessage({ type: 'cut' }, '*');
});

window.addEventListener('copy', () => {
iframe.contentWindow.postMessage({ type: 'copy' }, '*');
});

window.addEventListener('paste', () => {
iframe.contentWindow.postMessage({ type: 'paste' }, '*');
});

// Bind the buttons to their actions
forwardButton.addEventListener('click', () => {
history.forward();
});

backButton.addEventListener('click', () => {
history.back();
});

reloadButton.addEventListener('click', () => {
iframe.src = currentIframeLocation;
});

resetButton.addEventListener('click', () => {
vscode.postMessage({ type: 'reset' });
});

openExternalButton.addEventListener('click', () => {
vscode.postMessage({
type: 'openExternal',
url: currentIframeLocation
});
});
});
63 changes: 63 additions & 0 deletions extension/media/gnodev-iframe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// This script will be injected into the gnodev iframe to allow
// better interactions with vscode.

// Sending the current location of the iframe to the parent webview.
// Useful for tracking navigation within the iframe and be able to:
// - Reload the iframe
// - Open the current URL in the default browser
window.addEventListener('load', (event) => {
window.parent.postMessage(
{
type: 'location',
url: event.target.URL
},
'*'
);
});

// Binding keyboard shortcuts for common actions, like: copy, paste, undo, etc.
document.addEventListener('keydown', (event) => {
if ((event.ctrlKey || event.metaKey) && !event.altKey) {
const actionsMap = {
a: () => document.execCommand('selectAll'),
x: () => document.execCommand('cut'),
c: () => document.execCommand('copy'),
v: () => document.execCommand('paste'),
z: () => document.execCommand(event.shiftKey ? 'redo' : 'undo'),
y: () => document.execCommand('redo')
};

const action = actionsMap[event.key.toLowerCase()];
if (action) {
action();
event.preventDefault();
}
}
});

// Forwarding context menu events to the parent window.
document.addEventListener('contextmenu', (event) => {
window.parent.postMessage(
{
type: 'contextmenu',
clientX: event.clientX,
clientY: event.clientY
},
'*'
);
});

// Listening for messages from the parent window for context menu actions.
window.addEventListener('message', (event) => {
switch (event.data.type) {
case 'cut':
document.execCommand('cut');
break;
case 'copy':
document.execCommand('copy');
break;
case 'paste':
document.execCommand('paste');
break;
}
});
2 changes: 1 addition & 1 deletion extension/src/commands/getConfiguredGnoTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CommandFactory } from '.';
import { getGnoConfig, getGnoplsConfig } from '../config';
import { inspectGoToolVersion } from '../gnoInstallTools';
import { getConfiguredTools } from '../gnoTools';
import { getBinPath, getCurrentGoPath, getGoEnv, getGoVersion, getToolsGopath } from '../util';
import { getBinPath, getCurrentGoPath, getGoEnv, getGoVersion, getToolsGopath } from '../utils';
import { getEnvPath, initialEnvPath, getCurrentGoRoot } from '../utils/pathUtils';

export const getConfiguredGoTools: CommandFactory = () => {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/commands/getCurrentGnoPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as vscode from 'vscode';

import { CommandFactory } from '.';
import { getGnoConfig } from '../config';
import { getCurrentGoPath as utilGetCurrentGoPath, getWorkspaceFolderPath } from '../util';
import { getCurrentGoPath as utilGetCurrentGoPath, getWorkspaceFolderPath } from '../utils';

export const getCurrentGoPath: CommandFactory = () => {
return () => {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/commands/installTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { CommandFactory } from '.';
import { installAllTools, installTools as goInstallTools } from '../gnoInstallTools';
import { ToolAtVersion } from '../gnoTools';
import { getGoVersion } from '../util';
import { getGoVersion } from '../utils';

export const installTools: CommandFactory = () => {
return async (args: ToolAtVersion[]) => {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/commands/runBuilds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as vscode from 'vscode';

import { check } from '../gnoCheck';
import { CommandFactory } from '.';
import { handleDiagnosticErrors } from '../util';
import { handleDiagnosticErrors } from '../utils';

export const runBuilds: CommandFactory = (ctx, goCtx) => (
document: vscode.TextDocument,
Expand Down
2 changes: 1 addition & 1 deletion extension/src/commands/showCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as vscode from 'vscode';

import { CommandFactory } from '.';
import { getExtensionCommands } from '../util';
import { getExtensionCommands } from '../utils';

export const showCommands: CommandFactory = () => {
return () => {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/commands/startGnoDevServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const startGnoDevServer: CommandFactory = (ctx) => {
}

// Init the gnodev process.
currentGnoDevServer = { process: new GnodevProcess() };
currentGnoDevServer = { process: new GnodevProcess(ctx) };

// When the gnodev process is ready, open the webview if configured to do so.
currentGnoDevServer.process.onProcessReady((addr: GnodevAddress) => {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/extensionAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { Uri } from 'vscode';
import { CommandInvocation, ExtensionAPI } from './export';
import { getBinPathWithExplanation } from './util';
import { getBinPathWithExplanation } from './utils';

const api: ExtensionAPI = {
settings: {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoAddPkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import cp = require('child_process');
import { CommandFactory } from './commands';
import { getGnoConfig } from './config';
import { toolExecutionEnvironment } from './gnoEnv';
import { getBinPath } from './util';
import { getBinPath } from './utils';
import { diagnosticsStatusBarItem, outputChannel } from './gnoStatus';

// Constants
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { goLint } from './gnoLint';
import { isModSupported } from './gnoModules';
import { diagnosticsStatusBarItem, outputChannel } from './gnoStatus';
import { getTestFlags, goTest, TestConfig } from './testUtils';
import { ICheckResult } from './util';
import { ICheckResult } from './utils';
import { GoExtensionContext } from './context';

const STATUS_BAR_ITEM_NAME = 'Gno Test';
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import vscode = require('vscode');
import { getGnoConfig } from './config';
import { getCurrentGoPath, getToolsGopath, resolvePath, substituteEnv } from './util';
import { getCurrentGoPath, getToolsGopath, resolvePath, substituteEnv } from './utils';
import { dirExists } from './utils/pathUtils';
import { getFromGlobalState, updateGlobalState } from './stateUtils';
import { outputChannel } from './gnoStatus';
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoEnvironmentStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { getGnoConfig, extensionInfo } from './config';
import { toolInstallationEnvironment } from './gnoEnv';
import { addGoStatus, goEnvStatusbarItem, outputChannel, removeGoStatus } from './gnoStatus';
import { getFromGlobalState, getFromWorkspaceState, updateGlobalState, updateWorkspaceState } from './stateUtils';
import { getBinPath, getCheckForToolsUpdatesConfig, getGoVersion, GoVersion } from './util';
import { getBinPath, getCheckForToolsUpdatesConfig, getGoVersion, GoVersion } from './utils';
import {
correctBinname,
executableFileExists,
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import vscodeUri = require('vscode-uri');
import os = require('os');
import path = require('path');
import { getGnoConfig, getGnoplsConfig } from './config';
import { getBinPath } from './util';
import { getBinPath } from './utils';
import { getConfiguredTools } from './gnoTools';
import { inspectGoToolVersion } from './gnoInstallTools';
import { runGoEnv } from './gnoModules';
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoGenerateTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { toolExecutionEnvironment } from './gnoEnv';
import { promptForMissingTool } from './gnoInstallTools';
import { GoDocumentSymbolProvider } from './gnoDocumentSymbols';
import { outputChannel } from './gnoStatus';
import { getBinPath, resolvePath } from './util';
import { getBinPath, resolvePath } from './utils';
import { CommandFactory } from './commands';
import { GoExtensionContext } from './context';

Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import vscode = require('vscode');
import { ExecuteCommandRequest, ExecuteCommandParams } from 'vscode-languageserver-protocol';
import { toolExecutionEnvironment } from './gnoEnv';
import { promptForMissingTool } from './gnoInstallTools';
import { getBinPath, getImportPath, parseFilePrelude } from './util';
import { getBinPath, getImportPath, parseFilePrelude } from './utils';
import { getEnvPath, getCurrentGoRoot } from './utils/pathUtils';
import { GoExtensionContext } from './context';
import { CommandFactory } from './commands';
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getGnoConfig } from './config';
import { toolExecutionEnvironment } from './gnoEnv';
import { isModSupported } from './gnoModules';
import { outputChannel } from './gnoStatus';
import { getBinPath, getCurrentGoPath, getModuleCache } from './util';
import { getBinPath, getCurrentGoPath, getModuleCache } from './utils';
import { getEnvPath, getCurrentGoRoot, getCurrentGoWorkspaceFromGOPATH } from './utils/pathUtils';

export const installCurrentPackage: CommandFactory = () => async () => {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
getWorkspaceFolderPath,
GoVersion,
rmdirRecursive
} from './util';
} from './utils';
import { getEnvPath, getCurrentGoRoot, setCurrentGoRoot } from './utils/pathUtils';
import util = require('util');
import vscode = require('vscode');
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoLint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getGnoConfig, getGnoplsConfig } from './config';
import { toolExecutionEnvironment } from './gnoEnv';
import { diagnosticsStatusBarItem, outputChannel } from './gnoStatus';
import { goplsStaticcheckEnabled } from './gnoTools';
import { getWorkspaceFolderPath, handleDiagnosticErrors, ICheckResult, resolvePath, runTool } from './util';
import { getWorkspaceFolderPath, handleDiagnosticErrors, ICheckResult, resolvePath, runTool } from './utils';

/**
* Runs linter on the current file, package or workspace.
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
updateGlobalState
} from './stateUtils';
import { cancelRunningTests, showTestOutput } from './testUtils';
import { cleanupTempDir, getBinPath, getToolsGopath } from './util';
import { cleanupTempDir, getBinPath, getToolsGopath } from './utils';
import { clearCacheForTools } from './utils/pathUtils';
import { WelcomePanel } from './welcome';
import vscode = require('vscode');
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import vscode = require('vscode');
import vscodeUri = require('vscode-uri');
import { toolExecutionEnvironment } from './gnoEnv';
import { outputChannel } from './gnoStatus';
import { getBinPath, getGoVersion, getModuleCache, getWorkspaceFolderPath } from './util';
import { getBinPath, getGoVersion, getModuleCache, getWorkspaceFolderPath } from './utils';
import { getEnvPath, fixDriveCasingInWindows, getCurrentGoRoot } from './utils/pathUtils';
import { CommandFactory } from './commands';
export let GO111MODULE: string | undefined;
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { formatGoVersion, GoEnvironmentOption, terminalCreationListener } from '
import { GoDocumentSelector, isGoFile } from './gnoMode';
import { runGoEnv } from './gnoModules';
import { allToolsInformation } from './gnoToolsInformation';
import { getGnoVersion } from './util';
import { getGnoVersion } from './utils';
import { GoExtensionContext } from './context';
import { CommandFactory } from './commands';
import { LanguageClient, State } from 'vscode-languageclient/node';
Expand Down
2 changes: 1 addition & 1 deletion extension/src/gnoTaskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as vscode from 'vscode';
import { getGnoConfig } from './config';
import { toolExecutionEnvironment } from './gnoEnv';
import { getBinPath } from './util';
import { getBinPath } from './utils';

const TASK_TYPE = 'go';
type GoCommand = 'build' | 'test'; // TODO(hyangah): run, install?
Expand Down
Loading
Loading