Skip to content

Commit 70b994a

Browse files
committed
FEAT: some improvement on Linux.
1 parent b033aef commit 70b994a

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,8 @@ An extension with rich support for the [Red Programming language](https://www.re
1111
## Quick Start
1212

1313
1. Install the extension
14-
2. Add [CLI Red](https://www.red-lang.org/p/download.html) binary into your system's $PATH or set the `red.redPath` in the `Settings`.
15-
16-
---
17-
**NOTE**
18-
19-
It doesn't work with the `red-view.exe`.
20-
21-
Please download the `red-xxx-xxxxxxx.exe`, rename it to `red.exe`, add it into the $PATH.
22-
23-
---
14+
2. Download [CLI Red](https://www.red-lang.org/p/download.html) and set the `red.redPath` in the `Settings`
15+
3. Restart VS Code
2416

2517
## Settings
2618

@@ -35,7 +27,12 @@ In order to compile Red source file, you need to configure the path to the Red t
3527
---
3628
**NOTE**
3729

38-
You can also set the paths for `red` and `red-view`. The plugin will use the one you specified instead of the one find in the system $PATH.
30+
You can also set the paths for `red` and `red-view`.
31+
32+
```
33+
"red.redPath": "/home/user1/tools/red"
34+
"red.redViewPath": "/home/user1/tools/red-view"
35+
```
3936

4037
---
4138

red.configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
["[", "]"],
88
["(", ")"]
99
],
10-
"wordPattern": "[\\w=~`\\-?!*+\\.&'^][\\w=~`\\-?!*+\\.&'^]*",
10+
"wordPattern": "([#:A-Za-z0-9\\+\\-\\*\\/\\@\\$\\%\\^\\&\\_\\=\\<\\>\\~\\!\\?\\[\\]\\{\\}\\.]+)",
1111
"autoClosingPairs": [
1212
["{", "}"],
1313
["[", "]"],

src/RedConfiguration.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ function findExecutable(exe: string) {
4848
}
4949

5050
function getRedConsole(gui: boolean) {
51-
let name = 'red';
52-
if (gui) {name = 'red-view';}
53-
let exe = findExecutable(name);
54-
if (exe !== '') {return exe;}
51+
if (process.platform === 'win32') {
52+
// There is a `red` program on Linux already
53+
let name = 'red';
54+
if (gui) {name = 'red-view';}
55+
let exe = findExecutable(name);
56+
if (exe !== '') {return exe;}
57+
}
5558

5659
let preBuiltPath: string;
5760
if (process.platform === 'win32') {
@@ -85,7 +88,8 @@ function getRedConsole(gui: boolean) {
8588
}
8689
}
8790
}
88-
return path.join(preBuiltPath, _console);
91+
let exe = path.join(preBuiltPath, _console);
92+
return checkFileExists(exe) ? exe : '';
8993
}
9094
catch (err) {
9195
return '';

src/commandsProvider.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ function redRunScript(gui: boolean, fileUri?: vscode.Uri) {
8181
filePath = "\"" + filePath + "\"";
8282

8383
let redTool = gui ? redConfigs.redGuiConsole : redConfigs.redConsole;
84+
if (redTool === '') {
85+
if (gui) {
86+
vscode.window.showErrorMessage('No Red View! Please set the `red.redViewPath` in `settings.json`');
87+
} else {
88+
vscode.window.showErrorMessage('No Red Interpreter! Please set the `red.redPath` in `settings.json`');
89+
}
90+
return;
91+
}
8492
let command = normalFile(redTool);
8593
execCommand(command, filePath);
8694
}
@@ -89,7 +97,7 @@ function redCompileScript(mode: string, fileUri?: vscode.Uri) {
8997
let redConfigs = RedConfiguration.getInstance();
9098
let redTool = redConfigs.redToolChain;
9199
if (redTool === '') {
92-
vscode.window.showErrorMessage('No Red compiler! Please configure the `red.redToolChainPath` in `settings.json`');
100+
vscode.window.showErrorMessage('No Red compiler! Please set the `red.redToolChainPath` in `settings.json`');
93101
return;
94102
}
95103
let filePath = getFileName(fileUri);

0 commit comments

Comments
 (0)