Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: improve input module #134

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct RegexError(
#[from] regex::Error,
);

/// Errors that can occur during setup
/// Errors that can occur during setup.
#[derive(Debug, thiserror::Error)]
#[allow(clippy::module_name_repetitions)]
pub enum SetupError {
Expand All @@ -54,7 +54,7 @@ pub enum SetupError {
TerminalSize(TermError),
}

/// Errors that can occur during clean up
/// Errors that can occur during clean up.
#[derive(Debug, thiserror::Error)]
#[allow(clippy::module_name_repetitions)]
pub enum CleanupError {
Expand All @@ -71,7 +71,7 @@ pub enum CleanupError {
LeaveAlternateScreen(TermError),
}

/// Errors that can happen while running
/// Errors that can happen during runtime.
#[derive(Debug, thiserror::Error)]
#[allow(clippy::module_name_repetitions)]
pub enum MinusError {
Expand Down
21 changes: 7 additions & 14 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
//! Working with user keyboard/mouse events
//! Manage keyboard/mouse-bindings while running `minus`.
//!
//! minus already has a sensible set of default key/mouse bindings so most people do not need to
//! care about this module. But if you want to add or remove certain key bindings then you need
//! to rely on this module..
//!
//! This module provides various items for defining registering keyboard/mouse event from the
//! user's terminal to a predefined action inside minus.
//!
//! For this document we will call any keyboard/mouse event from the terminal as a **binding**
//! > **Terminology in this module**: We will call any keyboard/mouse event from the terminal as a **binding**
//! and its associated predefined action as **callback**.
//!
//! There are two ways to define binding in minus
//! There are two ways to define binding in minus as you will see below.
//!
//! # Newer (Recommended) Method
//! ## Description
//! This method offers a much improved and ergonomic API for defining bindings and callbacks.
//! You use the [HashedEventRegister] for registering bindings and their associated callback.
//! It provides functions like [add_key_events](HashedEventRegister::add_key_events) and
Expand Down Expand Up @@ -99,7 +93,7 @@
//! manually copy the [default definitions](DefaultInputClassifier) and make the required
//! modifications yourself in this method. This lead to very messy and error-prone system for
//! defining bindings and also required application authors to bring in the the underlying
//! [crossterm](https://docs.rs/crossterm/latest) crate to define the innputs.
//! [crossterm](https://docs.rs/crossterm/latest) crate to define the inputs.
//!
TornaxO7 marked this conversation as resolved.
Show resolved Hide resolved
//! ## Example
//! ```
Expand Down Expand Up @@ -154,15 +148,14 @@
//! more data from a server but not necessarily sending it to minus. In these types of scenarios,
//! the [InputEvent::Ignore] is most likely your true friend. When this is returned by a callback
//! function, minus will execute your code but not do anything special for the event on its part.
//! ```text
//! ```no_test
//! input_register.add_key_events(&["f"], |_, ps| {
//! fetch_data_from_server(...);
//! InputEvent::Ignore
//! });
//!
//! ```
//! It can be used with the legacy method too.
//! ```text
//! ```no_test
//! struct CustomInputClassifier;
//! impl InputClassifier for CustomInputClassifier {
//! fn classify_input(
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! If you want to learn about its motivation and features, please take a look into it's [README].
//!
//! # Overview
//! When getting started with minus, the two most important concepts to get familier with are:-
//! When getting started with minus, the two most important concepts to get familier with are:
//! * The [Pager] type: which acts as a bridge between your application and minus. It is used
//! to pass data and configure minus before and after starting the pager.
//! * Initialization functions: This includes the [dynamic_paging] and [page_all] functions which
Expand Down Expand Up @@ -112,7 +112,7 @@
//! In static mode, `minus` doesn't start the pager and just prints the content if the current terminal size can
//! display all lines. You can of course change this behaviour.
//!
//! ## Standard actions
//! ## Default keybindings
//!
//! Here is the list of default key/mouse actions handled by `minus`.
//!
Expand Down
Loading