mirror of
https://github.com/Architeuthis-Flux/JumperlessV5.git
synced 2025-09-04 02:27:57 +00:00
140 lines
5.3 KiB
Markdown
140 lines
5.3 KiB
Markdown
# Jumperless Text Editor - JFS Syntax Highlighting Update
|
|
|
|
## Overview
|
|
|
|
The Jumperless text editor has been enhanced with dedicated syntax highlighting for JFS (Jumperless FileSystem) functions, making it easier to distinguish filesystem operations from hardware functions and standard Python code.
|
|
|
|
## New Features
|
|
|
|
### JFS Function Highlighting
|
|
|
|
All JFS filesystem functions now appear in **cyan-blue (color 45)** in the text editor:
|
|
|
|
#### JFS Module Functions
|
|
- `jfs.open()`, `jfs.read()`, `jfs.write()`, `jfs.close()`
|
|
- `jfs.seek()`, `jfs.tell()`, `jfs.size()`, `jfs.available()`
|
|
- `jfs.exists()`, `jfs.listdir()`, `jfs.mkdir()`, `jfs.rmdir()`
|
|
- `jfs.remove()`, `jfs.rename()`, `jfs.stat()`, `jfs.info()`
|
|
- `jfs.SEEK_SET`, `jfs.SEEK_CUR`, `jfs.SEEK_END`
|
|
|
|
#### Basic Filesystem Functions
|
|
- `fs_exists()`, `fs_listdir()`, `fs_read()`, `fs_write()`, `fs_cwd()`
|
|
|
|
### Complete Color Scheme
|
|
|
|
| Function Type | Color | Examples |
|
|
|---------------|-------|----------|
|
|
| **Python Keywords** | Orange (214) | `def`, `class`, `if`, `for`, `while` |
|
|
| **Python Built-ins** | Forest Green (79) | `print()`, `len()`, `range()`, `str()` |
|
|
| **Jumperless Hardware** | Magenta (207) | `gpio_set()`, `dac_set()`, `connect()` |
|
|
| **Jumperless Constants** | Purple (105) | `TOP_RAIL`, `GPIO_1`, `CONNECT_BUTTON` |
|
|
| **JFS Filesystem** | **Cyan-Blue (45)** | `jfs.open()`, `fs_exists()` |
|
|
| **Strings** | Bright Yellow (39) | `"text"`, `'string'` |
|
|
| **Numbers** | Pink (199) | `123`, `3.14`, `0xFF` |
|
|
| **Comments** | Green (34) | `# comment`, `"""docstring"""` |
|
|
|
|
## Benefits
|
|
|
|
### Visual Code Organization
|
|
The distinct colors help developers quickly identify different types of operations:
|
|
|
|
```python
|
|
import jfs # Standard import
|
|
import jumperless # Standard import
|
|
|
|
# Hardware operations (magenta)
|
|
gpio_set(13, "HIGH") # Hardware function
|
|
voltage = adc_get(0) # Hardware function
|
|
connect(D1, TOP_RAIL) # Hardware function
|
|
|
|
# Filesystem operations (cyan-blue)
|
|
jfs.write("config.txt", data) # Filesystem function
|
|
if jfs.exists("script.py"): # Filesystem function
|
|
content = jfs.read("script.py") # Filesystem function
|
|
|
|
# Mixed operations with clear visual distinction
|
|
for i in range(10): # Python built-in (green)
|
|
temp = adc_get(i) # Hardware (magenta)
|
|
jfs.write(f"temp_{i}.log", str(temp)) # Filesystem (cyan-blue)
|
|
```
|
|
|
|
### Improved Code Readability
|
|
- **Hardware operations** clearly stand out in magenta
|
|
- **File operations** are easily identified in cyan-blue
|
|
- **Standard Python** remains in familiar orange/green colors
|
|
|
|
### Better Debugging
|
|
When troubleshooting, developers can quickly:
|
|
- Spot filesystem operations that might cause I/O errors
|
|
- Identify hardware calls that interact with physical pins
|
|
- Distinguish between local variables and system functions
|
|
|
|
## Implementation Details
|
|
|
|
### Syntax Detection
|
|
The editor uses suffix-based detection for function categorization:
|
|
- `||||` suffix: JFS filesystem functions
|
|
- `|||` suffix: Jumperless constants/types
|
|
- `||` suffix: Jumperless hardware functions
|
|
- `|` suffix: Python built-in functions
|
|
|
|
### Performance
|
|
- Real-time syntax highlighting during editing
|
|
- Minimal performance impact with efficient string matching
|
|
- Cached highlighting for large files
|
|
|
|
## Examples
|
|
|
|
### Configuration File Manager
|
|
```python
|
|
import jfs
|
|
|
|
def load_config():
|
|
if jfs.exists("config.json"): # cyan-blue
|
|
content = jfs.read("config.json") # cyan-blue
|
|
return parse_json(content) # standard function
|
|
return {} # Python keyword (orange)
|
|
|
|
def save_config(config):
|
|
data = json.dumps(config) # standard function
|
|
jfs.write("config.json", data) # cyan-blue
|
|
print("Config saved") # built-in (green)
|
|
```
|
|
|
|
### Hardware Data Logger
|
|
```python
|
|
import jfs
|
|
import jumperless
|
|
|
|
def log_sensor_data():
|
|
# Hardware operations (magenta)
|
|
temp = adc_get(0) # magenta
|
|
voltage = dac_get(1) # magenta
|
|
|
|
# Filesystem operations (cyan-blue)
|
|
timestamp = time.time() # built-in (green)
|
|
log_line = f"{timestamp},{temp},{voltage}\n" # string (yellow)
|
|
|
|
with jfs.open("sensors.csv", "a") as file: # cyan-blue
|
|
file.write(log_line) # cyan-blue
|
|
|
|
print(f"Logged: temp={temp}V") # built-in (green)
|
|
```
|
|
|
|
## Migration Notes
|
|
|
|
### No Code Changes Required
|
|
Existing code continues to work without modification. The syntax highlighting is purely visual and doesn't affect functionality.
|
|
|
|
### Enhanced Development Experience
|
|
- More intuitive code organization
|
|
- Faster identification of function types
|
|
- Reduced cognitive load when reading complex scripts
|
|
|
|
## Documentation Updates
|
|
|
|
- **New**: [`CodeDocs/JFS_Module_Documentation.md`](JFS_Module_Documentation.md) - Complete JFS API reference
|
|
- **Updated**: [`CodeDocs/MicroPython_Native_Module.md`](MicroPython_Native_Module.md) - Includes JFS integration details
|
|
- **New**: [`examples/micropython_examples/jfs_demo.py`](../examples/micropython_examples/jfs_demo.py) - JFS demonstration script
|
|
|
|
The syntax highlighting update makes the Jumperless development experience more intuitive by providing clear visual distinction between filesystem, hardware, and standard Python operations. |