@duet3d/monacotokens 3.7.0-alpha.12 → 3.7.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -55
- package/dist/gcodes/gcodes.json +1331 -1938
- package/dist/gcodes/index.d.ts +0 -19
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/providers.js +17 -107
- package/package.json +1 -1
- package/dist/objectmodel/axes.d.ts +0 -12
- package/dist/objectmodel/axes.js +0 -18
package/README.md
CHANGED
|
@@ -1,65 +1,15 @@
|
|
|
1
1
|
# MonacoTokens
|
|
2
2
|
|
|
3
|
-
TypeScript
|
|
3
|
+
TypeScript library that holds syntax highlighting files for the Monaco editor
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Currently exported Monaco languages:
|
|
6
6
|
|
|
7
|
-
`
|
|
7
|
+
- `gcodeFDMLanguage` (RRF G-code to be used in FFF mode)
|
|
8
|
+
- `gcodeCNCLanguage` (RRF G-code to be used in CNC and Laser mode)
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
- `gcode-cnc` - RRF G-code in CNC and Laser mode
|
|
11
|
-
- `stm32` - `board.txt` hardware configuration (RRF on STM32/LPC)
|
|
12
|
-
- `menu` - PanelDue `menu` files
|
|
10
|
+
After importing the languages, you need to register them as following:
|
|
13
11
|
|
|
14
|
-
## Features
|
|
15
|
-
|
|
16
|
-
Since v3.6 the package has grown from plain tokenizers into a full editing experience:
|
|
17
|
-
|
|
18
|
-
- **One-call registration** - `registerDuetLanguages(monaco)` registers all languages with their bracket/comment configuration and theme colour overrides.
|
|
19
|
-
- **G-code autocompletion** - codes (G/M/T) and their parameters from a curated dictionary, including value enumerations where a parameter takes a fixed set of options.
|
|
20
|
-
- **Hover tooltips** - code summaries and per-parameter documentation.
|
|
21
|
-
- **Signature help** - a floating parameter list for the code being typed, with the active parameter highlighted.
|
|
22
|
-
- **Object-model awareness** - completion and hover for object-model expressions (e.g. `move.axes[0].letter`), enum values resolved from the model, and `var`/`global` local-variable completion inside meta G-code.
|
|
23
|
-
- **Meta G-code expressions** - functions, keywords and operators used in conditional G-code.
|
|
24
|
-
- **Machine-aware axis parameters** - per-axis parameters (positions, speeds, currents, ...) follow the connected machine: the suggestion list and parameter summary only offer the axes the machine actually has, while hovering or typing any supported axis still shows its documentation.
|
|
25
|
-
- **Deprecation hints** - deprecated codes, parameters and object-model paths are decorated in the editor and flagged in tooltips.
|
|
26
|
-
- **In-editor G-code search** plus a signature-help watcher that keeps the parameter popup in sync.
|
|
27
|
-
|
|
28
|
-
## Usage
|
|
29
|
-
|
|
30
|
-
Register the languages once per Monaco instance:
|
|
31
|
-
|
|
32
|
-
```ts
|
|
33
|
-
import { registerDuetLanguages } from "@duet3d/monacotokens";
|
|
34
|
-
|
|
35
|
-
registerDuetLanguages(monaco);
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Attach the per-editor G-code features (search action, signature-help watcher, deprecation decorations and the local-variable scanner) to each editor:
|
|
39
|
-
|
|
40
|
-
```ts
|
|
41
|
-
import { attachGcodeFeatures } from "@duet3d/monacotokens";
|
|
42
|
-
|
|
43
|
-
const features = attachGcodeFeatures(monaco, editor);
|
|
44
|
-
// later, when disposing the editor:
|
|
45
|
-
features.dispose();
|
|
46
12
|
```
|
|
47
|
-
|
|
48
|
-
### Machine context
|
|
49
|
-
|
|
50
|
-
For object-model and machine-aware completion (including the axis parameters above), provide the live object model. The providers read through the reference at completion time, so in-place model updates are picked up automatically. Pass a fresh reference whenever your store swaps the model (e.g. on reconnect), and `null` when no machine is connected:
|
|
51
|
-
|
|
52
|
-
```ts
|
|
53
|
-
import { setMachineContext } from "@duet3d/monacotokens";
|
|
54
|
-
|
|
55
|
-
setMachineContext({ model: machineModel });
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Without a machine context, axis parameters fall back to the standard letters (X, Y, Z, U, V, W, A, B, C, D), exported as `DEFAULT_AXIS_LETTERS`; the full set of valid axis identifiers is exported as `ALL_AXIS_LETTERS`.
|
|
59
|
-
|
|
60
|
-
The lower-level Monarch tokenizers (`gcodeFDMLanguage`, `gcodeCNCLanguage`, `stm32Language`, `menuLanguage`) and their language configurations remain exported for manual registration if you do not want the providers:
|
|
61
|
-
|
|
62
|
-
```ts
|
|
63
13
|
monaco.languages.register({ id: "gcode-fdm" });
|
|
64
14
|
monaco.languages.setMonarchTokensProvider("gcode-fdm", gcodeFDMLanguage);
|
|
65
15
|
|