Crate promkit

source ·
Expand description

§promkit

ci docs.rs

A toolkit for building your own interactive prompt in Rust.

§Getting Started

Put the package in your Cargo.toml.

[dependencies]
promkit = "0.3.1"

§Features

  • Support cross-platform both UNIX and Windows owing to crossterm
  • Various building methods
    • Preset; Support for quickly setting up a UI by providing simple parameters.
    • Combining various UI components.
      • They are provided with the same interface, allowing users to choose and assemble them according to their preferences.
    • (Upcoming) Stronger support to display yor own data structures.
  • Versatile customization capabilities
    • Theme for designing the appearance of the prompt.
      • e.g. cursor, text
    • Validation for user input and error message construction.
  • Mouse support (partially)
    • Allows scrolling through lists with the mouse wheel

§Examples/Demos

See here

§Why promkit?

Related libraries in this category include the following:

promkit offers several advantages over these libraries:

§Unified interface approach for UI components

promkit takes a unified approach by having all of its components inherit the same Renderer trait. This design choice enables users to seamlessly support their custom data structures for display, similar to the relationships seen in TUI projects like ratatui-org/ratatui and EdJoPaTo/tui-rs-tree-widget. In other words, it’s straightforward for anyone to display their own data structures using widgets within promkit.
In contrast, other libraries tend to treat each prompt as a mostly independent entity. If you want to display a new data structure, you often have to build the UI from scratch, which can be a time-consuming and less flexible process.

pub trait Renderer {
    fn create_panes(&self, width: u16) -> Vec<Pane>;
}

§Variety of Pre-built UI Preset Components

One of the compelling reasons to choose promkit is its extensive range of pre-built UI preset components. These presets allow developers to quickly implement various interactive prompts without the need to design and build each component from scratch. The availability of these presets not only speeds up the development process but also ensures consistency and reliability across different applications. Here are some of the preset components available, see Examples

§Resilience to terminal resizing

Performing operations that involve executing a command in one pane while simultaneously opening a new pane is a common occurrence. During such operations, if UI corruption is caused by resizing the terminal size, it may adversely affect the user experience.
Other libraries can struggle when the terminal is resized, making typing and interaction difficult or impossible. For example:

promkit introduces a step to align data with the screen size before rendering. This approach ensures consistency in UI elements even when the terminal size changes, providing a smoother user experience.

§License

This project is licensed under the MIT License. See the LICENSE file for details.

§Stargazers over time

Stargazers over time

Re-exports§

Modules§

Macros§

Structs§

  • Represents a customizable prompt that can handle user input and produce a result.

Enums§

  • Represents all possible errors that can occur within the application.
  • Represents the signal to control the flow of a prompt.

Traits§

  • A trait for casting objects to Any, allowing for dynamic typing.

Type Aliases§