| Crates.io | ushell_input |
| lib.rs | ushell_input |
| version | 0.1.0 |
| created_at | 2025-12-05 20:27:33.503557+00 |
| updated_at | 2025-12-05 20:27:33.503557+00 |
| description | Core of the shell framework. |
| homepage | https://github.com/userx007/uRustShell |
| repository | https://github.com/userx007/uRustShell |
| max_upload_size | |
| id | 1969117 |
| size | 136,095 |
A high-performance, embedded-friendly input handling library for building interactive shell and REPL applications in Rust. Designed for both standard and no_std environments with configurable heap/stack allocation.
heapless data structures#, ##, #h, etc.)Add this to your Cargo.toml:
[dependencies]
shell_input = "0.1.0"
[dependencies.shell_input]
version = "0.1.0"
features = ["heap-history", "heap-input-buffer"]
heap-history - Allocate history on the heap (default: stack)
heap-input-buffer - Allocate input buffer on the heap (default: stack)
InputParser<NC, FNL, IML, HTC, HME>
NC: Number of autocomplete candidates (max commands to suggest)FNL: Function Name Length - max characters used for autocomplete matchingIML: Input Max Length - maximum characters in input bufferHTC: History Total Capacity - number of history entriesHME: History Max Entry - maximum characters per history entry| Key | Action |
|---|---|
Char |
Insert character at cursor |
Backspace |
Delete character before cursor |
Delete |
Delete character at cursor |
Ctrl+U |
Delete from cursor to line start |
Ctrl+K |
Delete from cursor to line end |
Ctrl+D |
Clear entire buffer |
| Key | Action |
|---|---|
Arrow Left/Right |
Move cursor |
Home |
Move to line start |
End |
Move to line end |
Arrow Up/Down |
Navigate command history |
PageUp/PageDown |
Jump to first/last history entry |
| Key | Action |
|---|---|
Tab |
Cycle autocomplete forward |
Shift+Tab |
Cycle autocomplete backward |
Enter |
Accept input |
The parser provides special hashtag-prefixed commands:
#q - Quit/exit (returns false from parse_input)# - List available commands## - Show full help (commands + shortcuts + arg types)#h - Display command history#c - Clear command history#N - Execute history entry at index N (e.g., #0, #5)shell_input/
├── input/
│ ├── buffer.rs - InputBuffer: Text editing with cursor management
│ │ • Insertion, deletion, cursor movement
│ │ • Clear, overwrite operations
│ │ • Bounded buffer with compile-time size
│ │
│ ├── key_reader.rs - Key: Platform-specific keyboard event capture
│ │ • Raw key reading (arrows, Ctrl, special keys)
│ │ • Cross-platform abstraction layer
│ │
│ ├── parser.rs - InputParser: Main orchestrator (primary API)
│ │ • Command autocompletion engine
│ │ • History navigation integration
│ │ • Key binding dispatch
│ │ • Built-in help system
│ │
│ └── renderer.rs - DisplayRenderer: Terminal output
│ • Prompt rendering with cursor positioning
│ • ANSI escape sequences
│ • Visual feedback (bell, boundary markers)
│
├── history/
│ └── mod.rs - History: Command history with circular buffer
│ • Up/Down navigation
│ • PageUp/PageDown for first/last entry
│ • Clear and indexed retrieval
│
├── autocomplete/
│ └── mod.rs - Autocomplete: Real-time suggestion engine
│ • Prefix matching with candidate cycling
│ • Tab/Shift+Tab for forward/backward
│ • Preserves text beyond match window
│
└── terminal/
└── mod.rs - Terminal: Low-level terminal control
• Raw mode management
• Terminal state restoration
• RAII-based cleanup
All data structures use compile-time sizing with heapless collections, making the library suitable for embedded systems and no_std environments. Optional heap allocation features provide flexibility for standard applications.
Const generics eliminate runtime configuration overhead and catch size mismatches at compile time:
// Compiler error if you try to store 128-char commands in 64-char history
let parser = InputParser::<10, 32, 64, 20, 128>::new(...);
The library uses Rust's type system to ensure optimal performance:
Currently supports:
Windows support is planned for future releases.
shell_input is designed as the core input layer and can be used standalone or as part of a larger shell framework. For complete shell applications with command dispatching, see the shell crate which provides a higher-level wrapper around InputParser.
Contributions are welcome! Areas of interest:
Please submit issues and PRs to the repository.
Licensed under either of:
at your option.
Built with:
heapless - Static data structures for embedded systems