rush-sync-server 0.2.6

Modern asynchronous TUI sync server with i18n, modular command system, and flexible configuration.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
# Rush Sync Server

![Rust](https://img.shields.io/badge/Rust-1.80+-orange)
![Build](https://img.shields.io/badge/build-passing-brightgreen)
![License](https://img.shields.io/badge/license-Dual--License-blue)
![Crates.io](https://img.shields.io/crates/v/rush-sync-server)

> ๐Ÿ›  **NOTE**: Version `0.2.2` on crates.io has a critical bug in language file loading (`*.json` not embedded correctly).
> Please use **version `0.2.6+`** for a stable release!

**Rush Sync Server** is a modern, modular terminal application written in **Rust**, featuring an interactive TUI, internationalized interface, color-coded logging, and flexible configuration.
Perfect for developers who need a **customizable, scriptable terminal UI**.

---

## ๐Ÿ†• What's New in v0.2.6

- โœ… **Fixed PIPE Cursor Rendering** - PIPE cursor now renders its own symbol instead of using terminal cursor, enabling **full color support** from TOML themes
- โœ… **Reorganized Configuration** - `.rss/rush.toml` has been completely restructured and sorted for better readability and organization
- โœ… **Zero Warnings & Errors** - All `cargo clippy` and `cargo check` warnings have been resolved - completely clean codebase!
- โœ… **Improved Cursor System** - Complete separation between terminal cursor and application cursor rendering for better control
- โœ… **Enhanced Theme Support** - All cursor colors and styles now work perfectly via TOML configuration

### Previous Features (v0.2.5)

- โœ… **Live Theme Switching** at runtime (without restart)
- โœ… **Advanced Cursor System** (PIPE, BLOCK, UNDERSCORE, DEFAULT)
- โœ… **Unified Cursor Architecture** (input/output cursor with blinking, positioning, color)
- โœ… **Centralized Viewport** for smooth layout handling and robust scrolling
- โœ… **Improved Restart Logic** with UI reinitialization and state restore
- โœ… **Theme-defined cursor styles and colors** via TOML
- โœ… **Full i18n coverage** for logs, errors, and commands

---

## ๐Ÿš€ Installation & Usage

### ๐Ÿ“ฆ **As Binary (End Users) - Version 0.2.6+**

```bash
# Install directly from crates.io
cargo install rush-sync-server

# Run the application
rush-sync
```

### ๐Ÿ“š **As Library (Developers) - Version 0.2.6+**

Add to your `Cargo.toml`:

```toml
[dependencies]
rush-sync-server = "0.2.6"
tokio = { version = "1.36", features = ["full"] }
```

#### **Quick Start Examples:**

```rust
use rush_sync_server::*;

#[tokio::main]
async fn main() -> Result<()> {
    // Option 1: Run with default configuration
    run().await?;
    Ok(())
}
```

```rust
use rush_sync_server::*;

#[tokio::main]
async fn main() -> Result<()> {
    // Option 2: Load config and run
    let config = load_config().await?;
    run_with_config(config).await?;
    Ok(())
}
```

```rust
use rush_sync_server::*;

#[tokio::main]
async fn main() -> Result<()> {
    // Option 3: Use as command handler only
    let handler = create_handler();

    let result = handler.handle_input("version");
    println!("Result: {}", result.message);

    let result = handler.handle_input("perf");
    println!("Performance: {}", result.message);

    Ok(())
}
```

#### **Advanced Library Usage:**

```rust
use rush_sync_server::*;

#[tokio::main]
async fn main() -> Result<()> {
    // Custom configuration
    let mut config = load_config().await?;
    config.poll_rate = std::time::Duration::from_millis(8); // 125 FPS
    config.typewriter_delay = std::time::Duration::from_millis(1); // Ultra-fast

    // Run with custom screen manager
    let mut screen = ScreenManager::new(&config).await?;
    screen.run().await?;

    Ok(())
}
```

### ๐Ÿ›  **From Source (Development)**

```bash
git clone https://github.com/LEVOGNE/rush.sync.server
cd rush.sync.server
cargo build --release

# Run as binary
cargo run --release

# Or install locally
cargo install --path .
rush-sync
```

---

## โœ… Features

- **Interactive terminal UI** with an asynchronous event loop (Tokio)
- **Color-coded logging** with level detection (`ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`)
- **Runtime log-level switching** with persistent config saving
- **Performance monitoring** with real-time FPS & config analysis
- **Advanced cursor system** with full color support via TOML themes
- **Internationalization (i18n):**
  - Multilingual markers are automatically mapped to standard colors (`[SPRACHE]`, `[IDIOMA]` โ†’ `lang` โ†’ Cyan)
  - Dynamic language switching at runtime (German/English)
  - Automatic language detection and config persistence
- **Typewriter effect** & **blinking cursor** (configurable/disableable)
- **Auto-scroll & scrollable message history**
- **Input history** & full cursor navigation
- **Modular command handler** with extensible plugin system
- **Configurable design & prompt** via TOML with performance optimization
- **Unicode support (grapheme-based)**
- **Restart function** without external process restart
- **Smart bounds checking** with automatic config correction
- **Zero warnings codebase** - completely clean `cargo clippy` and `cargo check`

---

## ๐Ÿ’ป Available Commands

| Command                | Description                                     | Examples                         |
| ---------------------- | ----------------------------------------------- | -------------------------------- |
| `version` / `ver`      | Show application version                        | `version`                        |
| `lang` / `language`    | Switch language (EN/DE) with config persistence | `lang de`, `lang en`             |
| `theme`                | Change themes live (from TOML configuration)    | `theme dark`, `theme light`      |
| `clear` / `cls`        | Clear all messages                              | `clear`                          |
| `exit` / `q`           | Exit with confirmation                          | `exit`                           |
| `restart`              | Internal restart (reloads config)               | `restart`, `restart --force`     |
| `history -c`           | Clear input history                             | `history -c`                     |
| `log-level`            | Change log level (runtime + persistent)         | `log-level 3`, `log-level debug` |
| `perf` / `performance` | Show performance & config status                | `perf`, `performance`            |

### Theme Command Details

```bash
theme                # Show available themes from TOML
theme dark           # Switch to dark theme
theme light          # Switch to light theme
theme blue           # Switch to blue theme
theme green          # Switch to green theme
theme preview <name> # Preview theme without switching
theme -h             # Show help
```

### Log-Level Command Details

```bash
log-level           # Show current level
log-level 3         # Set to INFO level
log-level DEBUG     # Set to DEBUG level
log-level -h        # Show help

# Available levels:
# 1 = ERROR   (Only critical errors)
# 2 = WARN    (Warnings and errors)
# 3 = INFO    (General information) [DEFAULT]
# 4 = DEBUG   (Debug information)
# 5 = TRACE   (Very detailed tracing)
```

### Performance Command Details

```bash
perf                # Show full performance report
performance         # Same as perf
stats               # Same as perf
perf -h             # Show help
```

**Performance Report includes:**

- Current FPS (based on poll_rate)
- Typewriter speed (chars/second)
- Config values & file location
- Performance recommendations
- Related commands

---

## โŒจ๏ธ Keyboard Shortcuts

| Key              | Function                     |
| ---------------- | ---------------------------- |
| `โ†‘ / โ†“`          | Navigate input history       |
| `โ† / โ†’`          | Move cursor in text          |
| `Home / End`     | Jump to start / end of input |
| `Shift + โ†‘ / โ†“`  | Scroll line by line          |
| `Page Up / Down` | Scroll page by page          |
| `Enter`          | Confirm input                |
| `ESC` (twice)    | Exit the program             |

---

## โš™๏ธ Configuration

The **`rush.toml`** file is automatically created in the `.rss` directory on first start.

### Complete Default Configuration (v0.2.6 - Reorganized & Sorted)

```toml
[general]
max_messages = 100
typewriter_delay = 5
input_max_length = 100
max_history = 30
poll_rate = 16
log_level = "info"
current_theme = "dark"

[language]
current = "en"

[theme.dark]
output_bg = "Black"
output_text = "White"
output_cursor = "PIPE"
output_cursor_color = "White"
input_bg = "White"
input_text = "Black"
input_cursor_prefix = "/// "
input_cursor = "PIPE"
input_cursor_color = "Black"

[theme.light]
output_bg = "White"
output_text = "Black"
output_cursor = "PIPE"
output_cursor_color = "Black"
input_bg = "Black"
input_text = "White"
input_cursor_prefix = "/// "
input_cursor = "PIPE"
input_cursor_color = "White"

[theme.green]
output_bg = "Black"
output_text = "Green"
output_cursor = "BLOCK"
output_cursor_color = "Green"
input_bg = "LightGreen"
input_text = "Black"
input_cursor_prefix = "$ "
input_cursor = "BLOCK"
input_cursor_color = "Black"

[theme.blue]
output_bg = "White"
output_text = "LightBlue"
output_cursor = "UNDERSCORE"
output_cursor_color = "Blue"
input_bg = "Blue"
input_text = "White"
input_cursor_prefix = "> "
input_cursor = "UNDERSCORE"
input_cursor_color = "White"
```

### ๐ŸŽจ Theme Configuration Details

**New in v0.2.6:**

- **Perfect cursor color support** - All cursor colors now work correctly via TOML
- **Clean theme structure** - Organized output-first, then input configuration
- **Multiple cursor types** - PIPE, BLOCK, UNDERSCORE all fully supported with colors

**Theme Structure:**

```toml
[theme.your_theme_name]
# Output area configuration
output_bg = "Background color for output area"
output_text = "Text color for output messages"
output_cursor = "PIPE|BLOCK|UNDERSCORE"
output_cursor_color = "Color for output cursor"

# Input area configuration
input_bg = "Background color for input area"
input_text = "Text color for input"
input_cursor_prefix = "Prompt text (e.g., '/// ')"
input_cursor = "PIPE|BLOCK|UNDERSCORE"
input_cursor_color = "Color for input cursor"
```

### Performance Optimization

**Recommended Values:**

- `poll_rate = 16` (60 FPS - optimal)
- `poll_rate = 33` (30 FPS - good for slower systems)
- `typewriter_delay = 0` (disabled) or `30-100` (enabled)

**Automatic Bounds Checking:**

- Invalid values are automatically corrected on startup
- Corrected values are saved back to config
- Performance warnings for critical settings

### Colors (COLOR_MAP)

Supported:
`Black`, `White`, `Gray`, `DarkGray`, `Red`, `Green`, `Blue`, `Yellow`,
`Magenta`, `Cyan`, `LightRed`, `LightGreen`, `LightBlue`, `LightYellow`,
`LightMagenta`, `LightCyan`

**Smart Color Categories:**

- `error` โ†’ Red
- `warning` / `warn` โ†’ Yellow
- `info` โ†’ Green
- `debug` โ†’ Blue
- `lang` / `language` โ†’ Cyan
- `version` โ†’ LightBlue

i18n translations are automatically mapped to standard keys
(e.g., `"Sprache"`, `"Idioma"`, `"ะฏะทั‹ะบ"` โ†’ `lang` โ†’ Cyan).

---

## ๐Ÿ—‚ Project Structure

```graphql
src/
โ”œโ”€โ”€ core/        # Core logic (Config, Error, Prelude, Constants)
โ”œโ”€โ”€ ui/          # Terminal UI (ScreenManager, TerminalManager, Widgets)
โ”œโ”€โ”€ input/       # Input handling (Keyboard, EventHandler)
โ”œโ”€โ”€ output/      # Logging, MessageManager, Color, Performance
โ”œโ”€โ”€ commands/    # Modular commands (exit, lang, history, restart, log-level, performance, theme)
โ”œโ”€โ”€ setup/       # Auto-configuration (TOML setup)
โ””โ”€โ”€ i18n/        # Internationalization (German/English)
    โ””โ”€โ”€ langs/   # Language files (de.json, en.json)
```

---

## ๐Ÿ›  Technical Details

- **Event loop:** Asynchronous (Tokio) โ†’ split into:
  - `handle_input_event`
  - `handle_tick_event`
  - `handle_resize_event`
- **Logging:**
  - Global `AppLogger` (intercepts all `log::*` calls)
  - Runtime log-level switching with config persistence
  - `LogMessage` stores level + text โ†’ color-coded output
- **Cursor System (v0.2.6):**
  - Complete separation between terminal cursor and application cursor
  - PIPE cursor renders its own symbol with full color support
  - BLOCK and UNDERSCORE cursors with configurable colors
  - Blinking animation and positioning independent of terminal
- **Performance Monitoring:**
  - Real-time FPS calculation based on poll_rate
  - Typewriter speed analysis (chars/second)
  - Config value validation with automatic correction
  - Performance recommendations based on system capabilities
- **Internationalization:**
  - `get_marker_color` automatically maps translated markers to standard categories
  - Smart fallback for unknown display categories
  - Persistent language switching with config save
- **Restart:** Internal, without external process restart
- **Memory Management:** Bounded message buffers with automatic cleanup
- **Code Quality:** Zero warnings from `cargo clippy` and `cargo check`

---

## ๐Ÿงช Testing

```bash
cargo test
RUST_LOG=debug cargo test

# Test specific components
cargo test command_system_tests
cargo test performance
cargo test config
cargo test theme_system

# Code quality checks (all pass with zero warnings!)
cargo clippy
cargo check
```

Available tests:
โœ” Commands (including theme, log-level & performance)
โœ” Event loop
โœ” Config setup & bounds checking
โœ” i18n translations (German/English)
โœ” Performance monitoring
โœ” Language switching
โœ” Theme system
โœ” Cursor rendering

---

## ๐ŸŽ› Advanced Usage

### Live Theme Switching

```bash
# Show available themes from TOML
theme

# Switch themes instantly (no restart required)
theme dark           # Professional dark theme
theme light          # Clean light theme
theme green          # Terminal green theme with BLOCK cursor
theme blue           # Modern blue theme with UNDERSCORE cursor

# Preview before switching
theme preview green  # See theme details without changing
```

### Performance Monitoring

```bash
# Show detailed performance report
perf

# Output example:
๐Ÿ“Š COMPREHENSIVE PERFORMANCE REPORT
==================================================

๐ŸŽฏ System Performance
   โ€ข Poll Rate: 16ms (60.0 FPS) โœ…
   โ€ข Typewriter Speed: 5ms (200.0 chars/sec)

๐Ÿ’พ Memory Usage
   โ€ข Total Estimated: 0.05 MB
   โ€ข Message Buffer: 0.01 MB
   โ€ข History Buffer: 0.00 MB
   โ€ข i18n Cache: 0.50 MB

๐Ÿ’ก Recommendations
   โ€ข โœ… All settings optimally configured

๐Ÿ”ง Related Commands
   โ€ข log-level debug - Enable debug logging
```

### Dynamic Log-Level Management

```bash
# Runtime log-level switching (saved to config)
log-level debug    # Switch to debug mode
log-level 1        # Switch to error-only
log-level info     # Back to default
```

### Language Switching

```bash
lang de            # Switch to German
lang en            # Switch to English
lang               # Show current language & available options
```

### **Library Integration Examples**

#### **Create Custom Commands**

```rust
use rush_sync_server::*;

// Define a custom command
#[derive(Debug)]
struct HelloCommand;

impl Command for HelloCommand {
    fn name(&self) -> &'static str { "hello" }
    fn description(&self) -> &'static str { "Say hello" }
    fn matches(&self, command: &str) -> bool { command == "hello" }

    fn execute_sync(&self, args: &[&str]) -> Result<String> {
        let name = args.first().unwrap_or(&"World");
        Ok(format!("Hello, {}!", name))
    }
}

#[tokio::main]
async fn main() -> Result<()> {
    // Add custom command to existing registry
    let mut handler = create_handler();
    handler.add_command(HelloCommand);

    let result = handler.handle_input("hello Rust");
    println!("{}", result.message); // "Hello, Rust!"

    Ok(())
}
```

#### **Use with Custom UI**

```rust
use rush_sync_server::*;

#[tokio::main]
async fn main() -> Result<()> {
    // Load config
    let config = load_config().await?;

    // Create handler for command processing
    let handler = create_handler();

    // Simple CLI loop (instead of full TUI)
    loop {
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();

        let result = handler.handle_input(&input.trim());
        println!("{}", result.message);

        if result.should_exit {
            break;
        }
    }

    Ok(())
}
```

---

## ๐Ÿ—บ Roadmap

- [ ] Mouse support (scroll & selection)
- [ ] Split-screen & tabs
- [ ] Syntax highlighting
- [x] ~~Plugin system for custom commands~~ โœ“ Implemented
- [x] ~~Live log-level configuration~~ โœ“ Implemented
- [x] ~~Performance monitoring~~ โœ“ Implemented
- [x] ~~Binary & Library distribution~~ โœ“ Implemented (v0.2.3+)
- [x] ~~Live theme switching~~ โœ“ Implemented (v0.2.5+)
- [x] ~~Advanced cursor system with colors~~ โœ“ Implemented (v0.2.6+)
- [ ] Config hot-reload without restart
- [ ] Custom color themes editor
- [ ] Command aliases & macros
- [ ] Plugin marketplace

---

## ๐Ÿ“Š **Version History**

### **v0.2.6 (Latest) - Cursor & Quality Update**

- โœ… **Fixed PIPE cursor rendering** with full color support from TOML
- โœ… **Reorganized `.rss/rush.toml`** configuration with sorted structure
- โœ… **Zero warnings codebase** - all `cargo clippy` and `cargo check` issues resolved
- โœ… **Enhanced cursor system** with complete terminal separation

### **v0.2.5 - Live Theme Update**

- โœ… **Live theme switching** at runtime without restart
- โœ… **Advanced cursor architecture** with unified input/output handling
- โœ… **Centralized viewport** with smooth scrolling

### **v0.2.3 - Library Release**

- โœ… **Binary distribution**: Install with `cargo install rush-sync-server`
- โœ… **Library API**: Use as dependency in your Rust projects
- โœ… **Convenience functions**: `run()`, `load_config()`, `create_handler()`
- โœ… **Public exports**: Access to `Config`, `CommandHandler`, `ScreenManager`
- โœ… **Custom command support**: Extend functionality with your own commands
- โœ… **Hybrid usage**: Use as standalone app OR integrate into your project

---

## ๐Ÿ“œ License

### **Dual-Licensing Model**

This project is distributed under a **dual license**:

1. **Community License (GPLv3)** โ€“ free for private and non-commercial use.
   See [LICENSE]LICENSE.
2. **Commercial License** โ€“ required for any commercial use.
   See [COMMERCIAL_LICENSE.md]COMMERCIAL_LICENSE.md.

**Contact for commercial licensing:**
๐Ÿ“ง [l.ersen@icloud.com](mailto:l.ersen@icloud.com)

---

## ๐Ÿค Contributing

1. Fork this repository
2. Create a feature branch
3. Commit changes + add tests
4. Submit a pull request

**Development Guidelines:**

- Follow performance recommendations (poll_rate >= 16ms)
- Add i18n support for new features (de.json + en.json)
- Include performance tests for new commands
- Update config bounds checking for new parameters
- Ensure zero warnings with `cargo clippy`
- Test theme configurations thoroughly

---

## ๐Ÿ† Code Quality

**Rush Sync Server v0.2.6** maintains the highest code quality standards:

- โœ… **Zero Clippy Warnings** - Complete compliance with Rust best practices
- โœ… **Zero Cargo Check Errors** - All code compiles cleanly
- โœ… **100% Functional** - All features work as documented
- โœ… **Comprehensive Tests** - Full test coverage for critical components
- โœ… **Clean Architecture** - Well-structured, modular codebase
- โœ… **Memory Safe** - No unsafe code, bounded buffers, proper cleanup