Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Remove Processing Filetype (.PDE extension) #868

Merged
merged 6 commits into from
Jul 26, 2019
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ This extension provides several commands in the Command Palette (<kbd>F1</kbd> o
| `arduino.commandPath` | Path to an executable (or script) relative to `arduino.path`. The default value is `arduino_debug.exe` for windows,`Contents/MacOS/Arduino` for Mac and `arduino` for Linux, You also can use a custom launch script to run Arduino by modifying this setting. (Requires a restart after change) Example: `run-arduino.bat` for Windows, `Contents/MacOS/run-arduino.sh` for Mac and `bin/run-arduino.sh` for Linux. |
| `arduino.additionalUrls` | Additional Boards Manager URLs for 3rd party packages. You can have multiple URLs in one string with a comma(`,`) as separator, or have a string array. The default value is empty. |
| `arduino.logLevel` | CLI output log level. Could be info or verbose. The default value is `"info"`. |
| `arduino.allowPDEFiletype` | Allow the VSCode Arduino extension to open .pde files from pre-1.0.0 versions of Ardiuno. Note that this will break Processing code. Default value is `false`. |
| `arduino.enableUSBDetection` | Enable/disable USB detection from the VSCode Arduino extension. The default value is `true`. When your device is plugged in to your computer, it will pop up a message "`Detected board ****, Would you like to switch to this board type`". After clicking the `Yes` button, it will automatically detect which serial port (COM) is connected a USB device. If your device does not support this feature, please provide us with the PID/VID of your device; the code format is defined in `misc/usbmapping.json`.To learn more about how to list the vid/pid, use the following tools: https://github.com/EmergingTechnologyAdvisors/node-serialport `npm install -g serialport` `serialport-list -f jsonline`|
| `arduino.disableTestingOpen` | Enable/disable automatic sending of a test message to the serial port for checking the open status. The default value is `false` (a test message will be sent). |
| `arduino.skipHeaderProvider` | Enable/disable the extension providing completion items for headers. This functionality is included in newer versions of the C++ extension. The default value is `false`.|
Expand All @@ -74,6 +75,7 @@ The following Visual Studio Code settings are available for the Arduino extensio
"arduino.path": "C:/Program Files (x86)/Arduino",
"arduino.commandPath": "arduino_debug.exe",
"arduino.logLevel": "info",
"arduino.allowPDEFiletype": false,
"arduino.enableUSBDetection": true,
"arduino.disableTestingOpen": false,
"arduino.skipHeaderProvider": false,
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,11 @@
"verbose"
]
},
"arduino.openPDEFiletype":{
"type":"boolean",
"default":false,
"description": "Allow VSCode Arduino to open PDE sketches, from pre-1.0.0 versions of Arduino"
},
"arduino.enableUSBDetection": {
"type": "boolean",
"default": true
Expand Down Expand Up @@ -505,8 +510,7 @@
{
"id": "cpp",
"extensions": [
".ino",
".pde"
".ino"
]
}
],
Expand Down
10 changes: 8 additions & 2 deletions src/arduino/vscodeSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const configKeys = {
ADDITIONAL_URLS: "arduino.additionalUrls",
LOG_LEVEL: "arduino.logLevel",
AUTO_UPDATE_INDEX_FILES: "arduino.autoUpdateIndexFiles",
ENABLE_USB_DETECTOIN: "arduino.enableUSBDetection",
ALLOW_PDE_FILETYPE: "arduino.allowPDEFiletype",
ENABLE_USB_DETECTION: "arduino.enableUSBDetection",
DISABLE_TESTING_OPEN: "arduino.disableTestingOpen",
IGNORE_BOARDS: "arduino.ignoreBoards",
SKIP_HEADER_PROVIDER: "arduino.skipHeaderProvider",
Expand All @@ -21,6 +22,7 @@ export interface IVscodeSettings {
commandPath: string;
additionalUrls: string | string[];
logLevel: string;
allowPDEFiletype: boolean;
enableUSBDetection: boolean;
disableTestingOpen: boolean;
ignoreBoards: string[];
Expand Down Expand Up @@ -57,8 +59,12 @@ export class VscodeSettings implements IVscodeSettings {
return this.getConfigValue<string>(configKeys.LOG_LEVEL) || "info";
}

public get allowPDEFiletype(): boolean {
return this.getConfigValue<boolean>(configKeys.ALLOW_PDE_FILETYPE);
}

public get enableUSBDetection(): boolean {
return this.getConfigValue<boolean>(configKeys.ENABLE_USB_DETECTOIN);
return this.getConfigValue<boolean>(configKeys.ENABLE_USB_DETECTION);
}

public get disableTestingOpen(): boolean {
Expand Down
47 changes: 25 additions & 22 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as constants from "./common/constants";

import { ArduinoContentProvider } from "./arduino/arduinoContentProvider";
import { IBoard } from "./arduino/package";
import { VscodeSettings } from "./arduino/vscodeSettings";
import ArduinoActivator from "./arduinoActivator";
import ArduinoContext from "./arduinoContext";
import {
Expand Down Expand Up @@ -43,7 +44,7 @@ export async function activate(context: vscode.ExtensionContext) {
"the arduino extension might not work appropriately.");
}
}

const vscodeSettings = VscodeSettings.getInstance();
const deviceContext = DeviceContext.getInstance();
deviceContext.extensionPath = context.extensionPath;
context.subscriptions.push(deviceContext);
Expand Down Expand Up @@ -329,29 +330,31 @@ export async function activate(context: vscode.ExtensionContext) {
}
});

vscode.workspace.onDidOpenTextDocument(async (document) => {
if (/\.pde$/.test(document.uri.fsPath)) {
const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino");
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
fs.renameSync(document.uri.fsPath, newFsName);
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName));
}
});
const allowPDEFiletype = vscodeSettings.allowPDEFiletype;

vscode.window.onDidChangeActiveTextEditor(async (editor) => {
if (!editor) {
return;
}

const document = editor.document;
if (/\.pde$/.test(document.uri.fsPath)) {
const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino");
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
fs.renameSync(document.uri.fsPath, newFsName);
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName));
}
});
if (allowPDEFiletype) {
vscode.workspace.onDidOpenTextDocument(async (document) => {
if (/\.pde$/.test(document.uri.fsPath)) {
const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino");
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
fs.renameSync(document.uri.fsPath, newFsName);
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName));
}
});

vscode.window.onDidChangeActiveTextEditor(async (editor) => {
if (!editor) {
return;
}
const document = editor.document;
if (/\.pde$/.test(document.uri.fsPath)) {
const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino");
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
fs.renameSync(document.uri.fsPath, newFsName);
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName));
}
});
}
Logger.traceUserData("end-activate-extension", { correlationId: activeGuid });
}

Expand Down