Skip to content

Latest commit

 

History

History
74 lines (59 loc) · 2.91 KB

File metadata and controls

74 lines (59 loc) · 2.91 KB

Rust Ratatui JSON Editor with Enhanced Features

This project was developed during my learning journey with Ratatui, building upon the original JSON Editor tutorial from the Ratatui documentation with more useful features to be used as a reference.

New Features

  • URL Fetching: Fetch JSON data from URLs and merge it into the current dataset (how to use async tasks)
  • File Operations: Save your JSON data to a file
  • Scrollable Interface: Navigate through large datasets with keyboard scrolling
  • Temporary Notifications: Non-intrusive status messages that appear and disappear automatically
  • Keyboard-Driven Interface: Full keyboard control for all operations

1. Separation of Concerns (SoC)

  • Core Module (src/core/)

    • Tasks: Contains all async operations (URL fetching, file writing)
    • Errors: Centralized error handling with custom error types
    • Types: Shared type definitions used across the application
  • App Module (src/app/)

    • State Management: Centralized application state
    • Enums: All application-specific enumerations
    • Handlers: UI-specific event handlers separated from core logic
  • UI Module (src/ui/)

    • Components: Reusable UI components
    • Screens: Different application screens
    • Notification System: Temporary notification display

2. Enhanced Notification System

  • Notifications appear in the top-right corner
  • Different types (Success, Error, Info) with distinct colors
  • Auto-dismiss after a configurable duration
  • Non-blocking UI updates

3. Improved Scrolling

  • Arrow keys for line-by-line navigation
  • Page Up/Down for larger jumps
  • Home/End for quick navigation
  • Visual highlighting of the selected item
  • Automatic scrolling to show newly added items

4. Better Error Handling

  • Custom error types with detailed information
  • Proper error propagation through the async chain
  • User-friendly error messages through notifications

Architecture Details

Module Structure

src/
├── app/
│   ├── enums.rs      # Application-specific enumerations
│   ├── handlers.rs   # UI event handlers
│   ├── mod.rs        # App state and core logic
│   ├── notif.rs      # Notification  
│   └── types.rs      # Type definitions
├── core/
│   ├── errors.rs     # Error handling
│   ├── mod.rs        # Core module exports
│   └── tasks.rs      # Async operations
├── ui/
│   ├── components/   # Reusable UI components
│   ├── screens/      # Application screens
│   └── mod.rs        # UI module exports
└── main.rs           # Application entry point

Acknowledgments